Skip to content
Advertisement

Update ttk.ProgressBar defined in other class Python

I have a main class for my GUI, where i create a ttk.ProgressBar:

JavaScript

I have a class for each page of my Notebook and i want update my progressbar when i run a function in my page2, I tried:

JavaScript

But I get the error message :

JavaScript

I simplified the code for be the most generalist possible.

How can I do that then?

Advertisement

Answer

You have progressbar in MainApplication so Page2 would need some access to MainApplication.

Normally we send parent object as first argument in widgets i.e. Button(root,...) and later widget can use self.master to access parent object.

But you don’t assign parent object in super().__init__() so it automatically set tk.Tk as parent. And if you use self.master then you should have access to MainApplication

JavaScript
JavaScript

EDIT:

If you would assign Notebook (container) as master/parent for Page2

JavaScript

then you would need

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement