Join us at IRC!
I'd prefer to die standing, than to live on my knees - Che Guevara
Friday, May 25, 2012
Navigation
Members Online
Total Online: 31
Web Spiders: 15
Guests Online: 30
Members Online: 1

Registered Members: 70209
Newest Member: KalareShou
Latest Articles
View Thread

HellBound Hackers | Computer General | Programming

Author

Python Tkinter Help

x_5631
Member

Posts: 156
Location: Uk
Joined: 22.06.07
Rank:
Mad User
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.

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
class Application(Frame):


Any help? :]


Author

RE: Python Tkinter Help

Demons Halo
Member



Posts: 261
Location: Sweden
Joined: 26.03.09
Rank:
Hacker Level 1
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:


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.daniweb.com/forums/thread39404.html#




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

RE: Python Tkinter Help

S1L3NTKn1GhT
Member



Posts: 468
Location: XXXX
Joined: 03.06.06
Rank:
God
Warn Level: 10
Posted on 20-06-09 19:30
+1 i believe demon is correct must be within.


root@wtf.org#su - dumbass

Dude you're AWESOME!
-SystemMeltdown(MSN)
http://isexu.com
Author

RE: Python Tkinter Help

x_5631
Member

Posts: 156
Location: Uk
Joined: 22.06.07
Rank:
Mad User
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

Rapt0r
Member

Posts: 28
Location:
Joined: 28.12.08
Rank:
Hacker Level 2
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

x_5631
Member

Posts: 156
Location: Uk
Joined: 22.06.07
Rank:
Mad User
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 :)


Author

RE: Python Tkinter Help

Rapt0r
Member

Posts: 28
Location:
Joined: 28.12.08
Rank:
Hacker Level 2
Posted on 20-06-09 19:53
x_5631 wrote:
Thanks. That was just what I needed :]
Works fine now :)


No problem.
Guest
Username

Password

Remember Me


Bookmark This Page
Affiliates
Adverts

 

 

Links

Anime Wallpaper Site

Error processing request
By using, viewing or obtaining any information contained on this site, you agree to the disclaimer.

© HellBound Hackers 2008- 2009. Since 3rd December 2004.