简体   繁体   English

Tkinter主框架上的框架布局

[英]frame layout on main frame in tkinter

I am trying to adjust the subframes layout on the mainframe. 我正在尝试调整大型机上的子帧布局。 As a beginner and as understand I have tried to sort out, but it is not giving the expected result. 作为一个初学者,据我了解,我试图进行梳理,但是并没有得到预期的结果。

Code: 码:

from tkinter import *

root = Tk()

root.geometry("1390x700+0+0")
root.title("Top Frame")
root.configure(background = "white")
# layout all of the main containers
root.grid_rowconfigure(1, weight=1)
root.grid_columnconfigure(0, weight=1)
#################################################################################
#Frames
#################################################################################
Header_F = Frame(root, bd = 10, pady = 5)
Header_F.grid(row =0, column =0, sticky = W+E)


Components_F = Frame(root,  bd = 10, width =500, height = 400)
Components_F.grid(row= 1, column = 0, sticky = NW, pady = 10)
Components_F.grid_propagate(False)

Communication_F = Frame(root, width = 100, height = 100)
Communication_F.grid(column = 1 , row = 1 , sticky = W )
Communication_F.grid_propagate(False)

Actual Result: This is the image of actually result 实际结果: 这是实际结果的图像

Expected Result: 预期结果:

This is the Expected Result image 这是预期结果图像

try this: 尝试这个:

from tkinter import *

root = Tk()

root.geometry("1390x700+0+0")
root.title("Top Frame")
root.configure(background = "white")
# layout all of the main containers
#root.grid_rowconfigure(1, weight=1)
#root.grid_columnconfigure(0, weight=1)
#################################################################################
#Frames
#################################################################################
Header_F = Frame(root, bd = 10,  height = 40)
Header_F.grid(row =0, column =0, sticky = W+E)


Components_F = Frame(root,  bd = 10, width =500, height = 400)
Components_F.grid(row= 1, column = 0, sticky = NW, pady = 10,padx = 10)
Components_F.grid_propagate(False)

Communication_F = Frame(root, width = 100, height = 100)
Communication_F.grid(column = 1 , row = 1, sticky = NW, pady = 10 )
Communication_F.grid_propagate(False)

root.mainloop()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM