1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] How can I make the layout of the interface fit other screen resolutions,?

Discussão em 'Python' iniciado por Stack, Setembro 30, 2024 às 22:32.

  1. Stack

    Stack Membro Participativo

    How to make the layout of the interface in the program on other computers with a different screen size (resolution) was the same as on my computer. For example: I run the program on my computer and everything is fine with the interface, but as soon as I run it on another (smaller or bigger) computer, the interface is not the same as mine. How can I make the interface on other computers be the same as mine? import tkinter as tk

    from PIL import Image, ImageTk


    def open_second_window():
    second_window = tk.Toplevel(root)
    second_window.title("window")
    second_window.state('zoomed')

    image_path = "1.jpg"
    image = Image.open(image_path)
    photo = ImageTk.PhotoImage(image)

    label = tk.Label(second_window, image=photo)
    label.image = photo
    label.pack(fill=tk.BOTH, expand=True)
    label.place(x=770, y=0)

    button = tk.Button(second_window,height=4, width=12, font='Times 31', text="ONE", command=lambda: open_four_window(second_window))

    button.place(x=308, y=82, anchor='ne')
    button1 = tk.Button(second_window,height=4, width=12, font='Times 31', wraplength=289, text="TWO", command=open_five_window)
    button1.place(x=688, y=82, anchor='ne')
    button = tk.Button(second_window,height=4, width=12, font='Times 31', text="THREE", command=open_threee_window)
    button.place(x=308, y=352, anchor='ne')
    button1 = tk.Button(second_window,height=4, width=12, font='Times 31', text="FOUR", command=open_threetenfive_window)
    button1.place(x=688, y=352, anchor='ne')


    tk.Label(second_window, font='Times 30', text="text", fg="red").place(x=150, y=30)


    third_window.grab_set()
    def open_four_window(second_window):
    second_window.destroy()

    four_window = tk.Toplevel(root)
    four_window.title("win")
    four_window.state('zoomed')

    image_path = "2.jpg"
    image = Image.open(image_path)
    photo = ImageTk.PhotoImage(image)

    label = tk.Label(four_window, image=photo)
    label.image = photo
    label.pack(fill=tk.BOTH, expand=True)
    label.place(x=0, y=0)


    button = tk.Button(four_window,height=1, width=33, font='Times 31', text="Start", command=lambda: open_second_window())
    button.place(x=768, y=720, anchor='ne')
    button1 = tk.Button(four_window,height=1, width=33, font='Times 31', text="Exit", command=Close)
    button1.place(x=1536, y=720, anchor='ne')



    third_window.grab_set()


    ///

    root = tk.Tk()
    root.title("menu")
    root.state('zoomed')


    image_path = "40.jpg"
    image = Image.open(image_path)
    photo = ImageTk.PhotoImage(image)
    image.thumbnail((1, 1))

    label = tk.Label(root, image=photo)
    label.pack(fill=tk.BOTH, expand=True)
    label.place(x=-3, y=0)

    def Close():
    root.destroy()

    button = tk.Button(root,height=1, width=33, font='Times 31', text="Start", command=lambda: open_second_window())
    button.place(x=768, y=720, anchor='ne')
    button1 = tk.Button(root,height=1, width=33, font='Times 31', text="Exit", command=Close)
    button1.place(x=1536, y=720, anchor='ne')


    tk.Label(root, font='Times 30', text="text", fg="red").place(x=150, y=30)
    tk.Label(root, font='Times 30 italic', text="description").place(x=600, y=77)

    root.mainloop()

    Continue reading...

Compartilhe esta Página