How am I able to do this? I am new to this so if it is possible to not use OOP, that would be great :)
I’m trying to do that part myself.
Asked
Active
Viewed 1,706 times
-1

martineau
- 119,623
- 25
- 170
- 301

KhalaMan2000
- 11
- 2
-
Possible duplicate of https://stackoverflow.com/questions/7546050/switch-between-two-frames-in-tkinter – Hass786123 Sep 08 '19 at 17:26
-
2Change the screen in what way? What have your tried? Please update your question and supply more details and code you have, even if it's not working. – martineau Sep 08 '19 at 17:32
-
1What does "change the screen" mean? You can delete and add widgets to the main window whenever you want. – Bryan Oakley Sep 08 '19 at 18:09
1 Answers
1
Since Python is an OOP language, and the Tkinter interface is inherently object based you will not be getting away from any OOP.
That being said. To my thinking the best method, would be to keep track of all created elements place them and then remove them were necessary. This method is a lot of effort but perhaps a good learning project.
As example pack an object in the Tkinter window and pack_forget the object when you need to remove it. (Label and Button in the example below).
from tkinter import Tk, Label, Button
class QBox:
""" Class that is an object"""
def __init__(self, master):
""" Class init Method"""
self.master = master
master.title("Question Box")
self.label = Label(master, text="Welcome to the Question Box")
self.button = Button(master, command=self.change, text="Clickme", fg='Black')
self.label.pack()
self.button.pack()
def change(self):
self.label.pack_forget()
def main():
root = Tk()
QBox(root)
root.mainloop()
if __name__ == '__main__':
main()
This is the basic concept of the pack and pack_forget functions Tkinter has to offer. Hope this helps.

Kevin Smith
- 581
- 2
- 6
- 13
-
A link to some docs that might help.(https://www.geeksforgeeks.org/python-gui-tkinter/) – Kevin Smith Sep 08 '19 at 17:36