[Python] i tried using pack() but it does not give me the result i wanted

Discussão em 'Python' iniciado por Stack, Março 3, 2025.

  1. Stack

    Stack Membro Participativo

    my code aims to move this purple square to the right but for some reason the square is in the middle. I put pack(side='right') but when i ran the code, it still puts the square in the middle.

    import tkinter as ttk
    import tkinter as tk
    from tkinter import*



    class WebsiteGUI:
    def __init__(self, root):
    self.root = root
    self.root.title('GUI')
    self.root.attributes('-fullscreen',False )

    main_screen = tk.Frame(root,height=1080, width= 1920,background = '#e4e4e4', )
    main_screen.pack()




    screen2 = tk.Frame(main_screen,height=100, width= 100, background = '#472882')
    screen2.pack(side= 'right', fill ='both', padx=10, pady=5, expand=True)


    root= ttk.Tk()
    WebsiteGUI(root)
    root.geometry('1920x1080')
    root.mainloop()

    Continue reading...

Compartilhe esta Página