[Tutor] yet more Tkinter+class problems

Thomi Richards thomi@thomi.imail.net.nz
Tue Nov 19 17:53:02 2002


hmmm... for some reason, anything in "statusframe" doesn't show up.
heres the source, is there something i am doing really wrong? Do frames
have to be nested inside each other?? surely not...

(sorry about the indenting, sylpheed cuts the lines short...)
--<snip>--
from Tkinter import *

class convertapp:
        def __init__(self,):
                self.parent = Tk()

                self.mainframe = Frame(self.parent)
                self.mainframe.pack()

                self.buttonframe = Frame(self.mainframe)
                self.buttonframe.pack(side='top')

                self.statusframe = Frame(self.mainframe)
                self.buttonframe.pack(side='bottom')

                #buttons:
                self.gobutton =
Button(self.buttonframe,text="Go!",command=self.testbar)
                self.gobutton.pack(side='left')

                self.quitbutton =
Button(self.buttonframe,text="Quit",command=self.mainframe.quit)
                self.quitbutton.pack(side='left')

                #percent bar, and status text:
                self.statustext =
Label(self.statusframe,text="Initialising")
                self.statustext.pack(side='top')

                self.percentbar =
Canvas(self.statustext,height=20,width=200,bg='black')
                self.percentbar.create_line(0,6,0,6, fill='red',
width=6, tag='bar')
                self.percentbar.pack(side='bottom')

        def testbar(self,x=10):
                if (x > 0) and (x < 200):
                        self.percentbar.coords('bar', 0, 6, x, 6)
                else:
                        self.percentbar.coords('bar', 0, 6, 50, 6)


        def start(self):
                self.mainframe.mainloop()


app = convertapp()
app.start()
--</snip>--

thanks

-- 
Lord, what fools these mortals be!
 -- midsummer nights dream.
Thomi Richards,
thomi@imail.net.nz