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)
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 theclass MAIN(object):withclass 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.