1

I was trying to add a progress bar to my Tkinter gui, and I have been stymied by a problem that I am not 100% sure how to define. My program is setup in this fassion.

class MAIN(object):
    def __init__(self, *args, **kwargs)
        tkinter stuff...

root = tk.Tk()
app = MAIN(root)
app.mainloop()

And then I tried to add a progress using this example (that works on its own). And this code is set up like this.

class MAIN(tk.Tk):
    def __init__(self, *args, **kwargs)
        tk.Tk.__init(self, *args, **kwargs)
        tkinter stuff....

app = MAIN()
app.mainloop()

If I change either of these programs to have the other's format they throw errors. I would ideally like to be able to keep my format (the first one) and be able to run the example in my format, so that way I don't have to update a lot of legacy code.

Help/explanations will be greatly appreciated.

Edit: Here is the error.

TypeError: unbound method __init__() must be called with Tk instance as first argument (got SampleApp instance instead)
Community
  • 1
  • 1
deadstump
  • 955
  • 2
  • 11
  • 23
  • Well... what error? I don't even know what's wrong. You're not providing enough information for anybody to be able to answer this. I *do* see you may be getting an `AttributeError` on line 3 of the second one. – Tyler Crompton Jun 29 '12 at 19:09
  • @TylerCrompton Sorry, the error is added to the post. – deadstump Jun 29 '12 at 19:16
  • @deadstump It's good etiquette to answer your own question in an answer rather than an edit. Write an answer, and then after some time has passed, accept it, so that it's clear this question has been resolved. – Wilduck Jun 29 '12 at 19:50

1 Answers1

0

My issue was that I did not understand inheritance in classes, and where as my program prior to trying to use the progress bar did not need any modifications to the tk.Tk.__init__. So the resolution to the issue was to replace the class MAIN(object): with class MAIN(tk.Tk): as in the working example. My progress bar still does not work right and now there is another window, but the program runs.

deadstump
  • 955
  • 2
  • 11
  • 23