Home > front end >  Tkinter window items (widgets) not showing up even after using pack. (Python
Tkinter window items (widgets) not showing up even after using pack. (Python

Time:01-27

I am creating a program called PythOS Pro, the successor to enter image description here

CodePudding user response:

mainloop will keep the window open, also () must be included in Tk()

import tkinter as tk
def run():
    print("Importing packages. Please wait...")
    import time
    import random
    time.sleep(2)
    print("PythOS Pro is being deployed. Please wait...")
    time.sleep(1)
    StartSuccsess = random.randint(0, 100)
    if StartSuccsess == 0:
        print("""An error has occured. The system has halted. Please refer to the 
PythOS Pro error page on GitHub.
发生错误。系统已停止。请参考 GitHub 上的 PythOS Pro 错误页面。
Произошла ошибка. Система остановилась. Пожалуйста, обратитесь к странице 
ошибок PythOS Pro на GitHub.
Ein Fehler ist aufgetreten. Das System wurde angehalten. Weitere 
Informationen finden Sie auf der Fehlerseite von PythOS Pro auf GitHub.

Error Code / 错误代码 / Код ошибки / Fehlercode: E0006""")
    else:
        time.sleep(4)
        main()

def main():
    print("SUCCESS") # This is a placeholder. When finished, the core of PythOS Pro will be here!
    mainwindow = tk.Tk()
    mainwindow.title('Welcome Text')
    button = tk.Label(text='Welcome to PythOS Pro!')
    button.pack()
    mainwindow.mainloop()

run() # This

will be for dev testing because it is tested standalone.

  • Related