skip to Main Content

I am creating a program called PythOS Pro, the successor to PythOS which I recently created. It is a package to add a graphical user interface to PythOS (which only uses a text shell) and it is in development. I had imported tkinter and decided to create a window that said ‘Welcome to PythOS Pro’ and the window worked. I then tried adding text in and, even after using pack, it did not show up!

This is the program’s code:

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!
    Main = tk.Tk
    WelcomeText = tk.Label(text="Welcome to PythOS Pro!")
    WelcomeText.pack

run() # This will be for dev testing because it is tested standalone.

I know questions like this have been asked but I have used tkinter before and it worked, so I am EXTREMLY CONFUSED!


I tried using online code but even that did not work. My version of Python is 3.10.2, released on January 13 2022 (yes, a year ago!) I also tried the latest Visual Studio Code but it has no tkinter support. 😢

I was expecting for the text to show up and then have a party sending it on to GitHub!!!

2

Answers


  1. 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.
    
    Login or Signup to reply.
  2. Edit: you’re missing brace bracket at the end of .pack.

    Change this:

    WelcomeText.pack 
    

    to:

    WelcomeText.pack()
    

    Screenshot:

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search