Nub needs help withTkinter
Agency
image9n at hotmail.com
Tue Dec 9 14:29:04 EST 2003
O.K.
So, I'm stuck again. I tried putting the code into a class, might not
be
smart given what I know, but I did it. I'm thinking that the beat,
time, and bpm would each have their own class and display/label. I
know that the pack() determines if something shows up. So, I'm
guessing that somewhere along the line pack() is not be referenced
right. My problem is that I have a window,
with no label showing up. I also just noticed that there is no linkage
between the beatContainer/frame and the beatNum/label. Here is the
newbie code:
from Tkinter import *
class beatX:
def _init_(self, parent):
self.beatContainer = Frame(parent)
self.beatContainer.pack()
self.beatNum = Label(self, text = "Beat Counter : ")
self.beatNum.config(text = "Beat Counter : %d" %beats)
self.beatNum.pack()
self.beatNum.bind("<space>", self.beatCounter)
self.beatNum.bind("<Return>", self.beatReset)
def beatCounter(event):
print "increment counter"
beats = beats + 1
def beatReset(event):
print "reset counter"
beats = 0
root = Tk()
root.mainloop()
More information about the Python-list
mailing list