如下所示:
#coding=utf-8 #布局自定义尺寸 from tkinter import * class App: def __init__(self,master): frame=Frame(master) frame.pack(fill=BOTH,expand=1) listbox=Listbox(frame) #listbox=Listbox(frame,height=3,selectmode=BROWSE) #curselection() for item in ['red','green','blue','yellow','pink']: listbox.insert(END,item) listbox.grid(row=0,column=0,sticky=W+E+N+S) # sticky 适配 text=Text(frame,relief=SUNKEN) text.grid(row=0,column=1,sticky=W+E+N+S) text.insert(END,'word'*1000) frame.columnconfigure(1,weight=1) #尺寸适配 frame.rowconfigure(0,weight=1) #尺寸适配 #Spinbox(frame,values=('a','b','c')).grid(row=3) #get() root=Tk() root.wm_title('尺寸适配') app=App(root) root.geometry("400x300+0+0") #尺寸适配 root.mainloop()
当前文章:PythonGUI布局尺寸适配方法-创新互联
转载来源:https://www.cdcxhl.com/article38/copcpp.html
成都网站建设公司_创新互联,为您提供建站公司、云服务器、定制网站、企业网站制作、手机网站建设、外贸网站建设
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联