Python Tkinter Help
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.
#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
```markupclass Application(Frame):```
Any help? :]
I've not used classes before but as far as I know your widgets must be included in the "master" window like this:
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:
Rapt0r wrote: [quote]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().[/quote]
Thanks. That was just what I needed :] Works fine now :)