If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
Anonymous
-
2020-12-08
I see your code and notice that I hadn't called the toplevel. So I change in main_support.py (restrito and restrito_support are files of secondary window):
And works now. But, can you please explain why I need to call Toplevel1 to avoid "w is not defined"? Just starting with PAGE and I'm really enjoying it
Thanks
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The reason is pretty simple, actually. If you take a look at the function that is in the child.py file (or in your case the restrito.py file) you will see the following...
def create_Toplevel1(rt, *args, kwargs):
'''Starting point when module is imported by another module.
Correct form of call: 'create_Toplevel1(root, *args, kwargs)' .'''
Notice the comment. "Starting point when the module is imported by another module".
Now look at the function above it in the same python file...
def vp_start_gui():
'''Starting point when module is the main routine.'''
Again, the comment says it all. When the module is the main routine.
When you are instantiating a new form, you have to use the create_Toplevel1 function. The name of this can change, if you set the alias for the toplevel widget (the design form that you put all the widgets on) to something else. So assuming that you alias the toplevel form to "MyPrettyForm", the function would be called "create_MyPrettyForm()".
I hope this helps.
Greg
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm have the main window and secondary one. I'm trying to call the second one and change it's label, but i'm not getting
main_support.py
restrito_support.py
Error: NameError: name 'w' is not defined
I'm doing like documentation says as example:
w.Button1.configure(color='red')
Since you did not provide your source project, I threw together this demo for you.
Hopefully, it works for you as it does for me.
Greg
I see your code and notice that I hadn't called the toplevel. So I change in main_support.py (restrito and restrito_support are files of secondary window):
to:
And works now. But, can you please explain why I need to call Toplevel1 to avoid "w is not defined"? Just starting with PAGE and I'm really enjoying it
Thanks
The reason is pretty simple, actually. If you take a look at the function that is in the child.py file (or in your case the restrito.py file) you will see the following...
def create_Toplevel1(rt, *args, kwargs):
'''Starting point when module is imported by another module.
Correct form of call: 'create_Toplevel1(root, *args, kwargs)' .'''
Notice the comment. "Starting point when the module is imported by another module".
Now look at the function above it in the same python file...
def vp_start_gui():
'''Starting point when module is the main routine.'''
Again, the comment says it all. When the module is the main routine.
When you are instantiating a new form, you have to use the create_Toplevel1 function. The name of this can change, if you set the alias for the toplevel widget (the design form that you put all the widgets on) to something else. So assuming that you alias the toplevel form to "MyPrettyForm", the function would be called "create_MyPrettyForm()".
I hope this helps.
Greg