help me reviewing and organizing my code =)
Tracubik
affdfsdfdsfsd at b.com
Thu Jun 2 03:31:41 EDT 2011
if you like, off course :)
I'm making a port in python of a program made of bash commands + zenity
for the GUI.
so, i've to re-create a GUI in pyGTK and associate the right bash commands
to the buttons.
Instead of executing the bash script i simply print they in the console.
so, here's my code
import gtk
class myProgram:
def __init__(self):
...
self.btnUname = gtk.Button("uname")
self.btnLs = gtk.Button("ls")
self.btnUname.connect("clicked", self.print_associated_command, "uname")
self.btnLs.connect("clicked", self.print_associated_command, "ls")
...
def print_associated_command(self, widget, data=None):
UNAME_CODE = ['uname']
LS_CODE = ['cd /home/myUserId/Images/SashaGray',
'ls *.jpg']
command_list = {
"uname" : UNAME_CODE,
"ls" : LS_CODE
}
for item in command_list[data]:
print 'COMMAND: ' + item
print '-----------------------------------------------------'
do you like it?
considering i'll have about 40+ buttons, do you suggest me to move some
part of code outside in a different module?
help for your thanks
thanks for your help
Nico
More information about the Python-list
mailing list