Tkinter Have Code For Pages In Separate Files
I have code that opens up a window and has three buttons for page 1, page 2, and page 3. However I also have four .py files (Dashboard, PageOne, PageTwo. PageThree). Dashboard will
Solution 1:
The error messages tell you everything you need to know in order to fix the problem. This is a simple problem that has nothing to do with tkinter, and everything to do with properly organizing and using your code.
For example, what is Page is not defined
telling you? It's telling you, quite literally, that Page
is not defined. You defined it in your main file, but you're using it in another file. The solution is to move the definition of Page
to a separate file that can be imported into the files that use it.
Modify your files and imports to look like this:
page.py
class Page(tk.Frame):
...
pageOne.py
from page import Page
class PageOne(Page):
...
pageTwo.py
from page import Page
class PageTwo(Page):
...
pageThree.py
from page import Page
class PageThree(Page):
...
Dashboard.py
from pageOne import PageOne
from pageTwo import PageTwo
from pageThree import PageThree
...
Post a Comment for "Tkinter Have Code For Pages In Separate Files"