Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #6844
| From | Tracubik <affdfsdfdsfsd@b.com> |
|---|---|
| Subject | help me reviewing and organizing my code =) |
| Newsgroups | comp.lang.python |
| Date | 2011-06-02 07:31 +0000 |
| Message-ID | <4de73c5d$0$38638$4fafbaef@reader1.news.tin.it> (permalink) |
| Organization | TIN.IT (http://www.tin.it) |
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
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
help me reviewing and organizing my code =) Tracubik <affdfsdfdsfsd@b.com> - 2011-06-02 07:31 +0000 Re: help me reviewing and organizing my code =) Chris Angelico <rosuav@gmail.com> - 2011-06-02 18:04 +1000 Re: help me reviewing and organizing my code =) Peter Otten <__peter__@web.de> - 2011-06-02 12:41 +0200
csiph-web