Follow us on Twitter!
Hacking isn't just Computers & Exploits. It's a Philosophy. - Mr_Cheese
Sunday, April 20, 2014
Navigation
Home
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
Learn
Communicate
Submit
Shop
Challenges
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Other
Members Online
Total Online: 24
Guests Online: 24
Members Online: 0

Registered Members: 82843
Newest Member: hx47
Latest Articles
View Thread

HellBound Hackers | Computer General | Programming

Author

Python Tkinter Help


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 20-06-09 18:53
I'm trying to bind a key to a command, but it doesn't seem to be working. As far as I know, I need to bind it to the dialogue, which is what I'm doing, and nothing happens.
I don't get any errors, the program runs fine, but when I press the key nothing happens.

Code
def createWidgets(self):
        #self.rowconfigure(0, weight=1)
        #self.columnconfigure(0, weight=1)
       
        self.quitButton = Button(self, text="Exit", command=self.closer)
        self.okButton = Button(self, text="Ok", command=self.check)
        self.urlField = Entry(self)
        self.urlLabel = Label(self, text="URL:")

        self.urlField.bind("<Return>", self.check)
        self.bind("<F6>", self.worked)

        self.urlLabel.grid(row=0, sticky=W, padx=5, pady=10)
        self.urlField.grid(row=0, column=1, padx=5)
        self.okButton.grid(row=0, column=2, padx=5, pady=20)
        self.quitButton.grid(row=1)




Which is part of the class
Code
class Application(Frame):




Any help? :]


Author

RE: Python Tkinter Help

Demons Halo
Member



Posts: 261
Location: Sweden
Joined: 26.03.09
Rank:
Apprentice
Posted on 20-06-09 19:22
I've not used classes before but as far as I know your widgets must be included in the "master" window like this:

Code

master = Tk()

quitbutton=Button(master, text="Quit", command=master.destroy)




I'm a GUI beginner like you are so I might be wrong about this :P

also, check this link:

http://www.daniwe. . .9404.html#




Edited by Demons Halo on 20-06-09 19:33
base_dropper@hotmail.com www.demonshalo.com
Author

RE: Python Tkinter Help


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 20-06-09 19:30
+1 i believe demon is correct must be within.


Author

RE: Python Tkinter Help


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 20-06-09 19:34
Sorry, I should have pointed out... the buttons and everything all work.. I just posted such a big chunk of code so people could get an idea where the bit that doesn't work is.

It's just the "self.bind(blahblahblah)" that doesn't work.
Even the "self.urlField.bind(blahblahblah)" works.


Author

RE: Python Tkinter Help


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 20-06-09 19:40
x_5631 wrote:
It's just the "self.bind(blahblahblah)" that doesn't work.
Even the "self.urlField.bind(blahblahblah)" works.


If your trying to bind a key event to a parent widget like a frame, you have to use bind_all() instead of bind().
Author

RE: Python Tkinter Help


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 20-06-09 19:43
Rapt0r wrote:
x_5631 wrote:
It's just the "self.bind(blahblahblah)" that doesn't work.
Even the "self.urlField.bind(blahblahblah)" works.


If your trying to bind a key event to a parent widget like a frame, you have to use bind_all() instead of bind().


Thanks. That was just what I needed :]
Works fine now Smile


Author

RE: Python Tkinter Help


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 20-06-09 19:53
x_5631 wrote:
Thanks. That was just what I needed :]
Works fine now Smile


No problem.