[Python] how to set fixed frame sizes in python tkinter

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

  1. Stack

    Stack Membro Participativo

    say i have a tkinter window with two separate frames that i want to fill with info, my only problem is that the frame size sets itself dynamcally. my windows size is 500 by 500 and i want the top frame to go from 0,0 to 250,250. and the bottom from 0,250 to 500,500. I think you might get the idea at this point

    here is my code so far:

    def main_game(username,password,new_u,old_u):
    Tk_window_center(500,500)
    root.resizable(width=False, height=False)
    ##
    if new_u =="":
    pass
    else:
    new_u.pack_forget()
    if old_u =="":
    pass
    else:
    old_u.pack_forget()
    ##
    output_window_frame=Frame(root, bg="black")
    user_terminal_frame=Frame(root)
    ##
    usr_output=Label(output_window_frame)
    user_inp=Entry(user_terminal_frame)
    user_term=Label(user_terminal_frame)
    ##
    output_window_frame.grid(row=0,column=0,rowspan=3,columnspan=3, sticky="NSEW")

    user_terminal_frame.grid(row=4,column=0,rowspan=3,columnspan=3, sticky="NSEW")
    user_inp.pack(side="top", fill="x")
    user_term.pack(side="bottom", fill="x")


    p.s. new_u and old_u are previous frames that activate on startup

    Continue reading...

Compartilhe esta Página