我发布了一个有关调整大小的问题,但是我在此代码中使用了网格,但是我想知道如何均匀地调整其大小,因此这两个框架均会均匀地调整大小,而不是第一个调整大小要大于第二帧
from tkinter import *
from tkinter import ttk
class CustomFrame(Frame):
def __init__(self,main,name,bg,**options):
Frame.__init__(self,main)
self.name = name
self.bg = bg
self.lbl = Label(self,text=name)
self.lbl.grid(sticky='NEWS')
self.text = Text(self,width=50)
self.text.grid(sticky='NEWS')
self.config(bg=bg)
self.lbl.config(bg=bg)
self.rowconfigure(0,weight=1)
self.columnconfigure(0,weight=1)
self.rowconfigure(0,weight=1)
self.columnconfigure(0,weight=1)
class Main:
def __init__(self,master):
self.master = master
self.container = Frame(self.master)
self.container.grid(sticky='NSEW')
self.frame = CustomFrame(self.container,'Frame 1','skyblue')
self.frame.grid(row=0,column=0,sticky='NSEW')
self.frame2 = CustomFrame(self.container,'FRAME 2','green')
self.frame2.grid(row=0,column=1,sticky='NSEW')
self.container.rowconfigure(0,weight=1)
self.container.columnconfigure(0,weight=1)
self.master.columnconfigure(0,weight=1)
self.master.rowconfigure(0,weight=1)
if __name__ == '__main__':
root = Tk()
Main(root)
root.mainloop()