[Python] Tkinter blank in windows 11. Works in VS

Discussão em 'Python' iniciado por Stack, Fevereiro 27, 2025.

  1. Stack

    Stack Membro Participativo

    I've got a project in python 3.7. It worked perfectly in windows 10, but since the forced windows 11 update I cannot get it to display. The Tkinter GUI window will display, but be blank, none of my buttons or pages visibile. As the title says, it works when ran through visual studio. I get no errors or messages of any type.

    Here's the code that I think is relevant. It should open up multiple pages with buttons

    #! /usr/bin/python3
    import sys
    import os
    from tkinter import *
    from tkinter.ttk import *
    from tkinter import simpledialog

    style = Style()
    style.configure('W.TButton', font =('calibri', 45, 'bold'), foreground = 'black',background='orange')
    style.configure('Z.TButton', font =('calibri', 30, 'bold'), foreground = 'black',background='orange')
    style.configure('S.TButton', font =('calibri', 45, 'bold'), foreground = 'white',background='red')
    style.theme_settings("default",{"TNotebook.Tab": {"configure":{"padding": [30, 30]}}})
    style.configure('Tnotebook.Tab', font =('calibri', 50, 'bold'))
    root.geometry("1200x600+40+100")
    root.title("Program name here")
    nbook = Notebook(root)
    page1 = Frame(nbook, style='')
    nbook.pack(fill=BOTH, expand=1)
    # handles closing
    root.protocol("WM_DELETE_WINDOW", on_closing)
    root.mainloop()


    What it should look like

    I have tried changing locations of root.mainloop() to various places as other threads discuss. I don't know what else to try, mainly because it worked on windows 10 and works when ran from Visual Studio.

    Continue reading...

Compartilhe esta Página