Python tkinter grid manager not working, columns

前端 未结 2 412
Happy的楠姐
Happy的楠姐 2021-01-29 03:02

Python version 2.7 (I know it\'s dated) I have searched throught several answers and haven\'t found a solution. I\'m trying to get this label :

w = Label(root,          


        
2条回答
  •  一生所求
    2021-01-29 03:26

    You can use grid_columnconfigure to show empty columns. This shows column 2

    from Tkinter import *
    
    root = Tk()
    root.wm_title("Title:D")
    
    root.geometry('{}x{}'.format(500, 300))
    
    ##photo = PhotoImage(file="spaz.gif")
    label = Label(root, text="Label 1")
    label.grid(row=1, column=1)
    
    root.grid_columnconfigure(2, weight=1)
    
    w = Label(root, text="This label", fg="red", font=("Helvetica", 16))
    w.grid(row=5, column=20)
    
    root.mainloop()
    

提交回复
热议问题