I am having trouble with Python and would like to have some help.
I am making a apt GUI 'front-end' with a nice UI.
def on_textbox_changed(self): self.instvar = self.installapps.get_text() def on_button1_clicked(self, widget): print "Preparing to run 'sudo apt-get install (package selected)" command2 = 'xterm -e sudo apt-get install ' and self.instvar cmd2 = commands.getoutput(command2)
Would you know how to take a textbox entry and make it a variable? I looked around the web and this is what I came up with. And every time I'm trying this it gives me this error:
Traceback (most recent call last): File "/home/rareshn/Documents/Zintori/Applets/aptfe/aptfe/AptfeWindow.py", line 49, in on_button1_clicked command2 = 'xterm -e sudo apt-get install ' and self.instvar AttributeError: 'AptfeWindow' object has no attribute 'instvar'
If you could help me, that would be useful. Thanks!
Best Answer
You are clicking the button before
self.instvar
is set. Theon_textbox_changed
handler is probably never called. Startup Glade and select your text entry. In the property editor on the right select thesignals
tab and connect theGtkEditable
changed
signal to the correct handler.You should also put a print statement inside
on_textbox_changed
to see if it really is called.Alse, this line doesn't do what you think it does:
See this interactive session: