Tkinter--GUI布局
来源:互联网 发布:观人于微而知其著 编辑:程序博客网 时间:2024/06/06 00:53
http://blog.csdn.net/xxb2008
#-*- coding: utf-8 -*-"""Tkconstants.py -- 常量类Tkinter布局pack 参数说明fill -- x 横向填充(默认,各组件自上而下), y竖向填充(各组件自左往右),both都填充expand -- 1 父外框大小改变时,自动扩充大小,0为falseside -- left right top bottom 停靠在父组件的哪一边上anchor -- 对齐方式grid 参数说明row -- 行号rowspan -- 合并行column -- 列号columnspan -- 合并列sticky -- 组件紧靠所在单元格的某一边角grid填充(自动缩放)--同 pack的 expand属性root.columnconfigure(0, weight=1)root.rowconfigure(0, weight=1)frame.grid(row=0, column=0, sticky="nsew")下面是程序融合了 pack填充(自动缩放)和 grid填充(自动缩放)与及 多组件整合布局http://blog.csdn.net/xxb2008"""import Tkinterclass MainFrame(Tkinter.Frame): def __init__(self, master=None): Tkinter.Frame.__init__(self, master) self.grid(row=0, column=0, sticky="nsew") self.createFrame() def createFrame(self): self.frameTop = Tkinter.Frame(self) self.frameTop.pack(fill="x") self.labelFilePaths = Tkinter.Label(self.frameTop, text="文件路径:", width=10) self.labelFilePaths.pack(fill="y", expand=0, side=Tkinter.LEFT) self.textFilePaths = Tkinter.Text(self.frameTop, height=10) self.textFilePaths.pack(fill="both", expand=1, side=Tkinter.LEFT) self.frameCenter = Tkinter.Frame(self) self.frameCenter.pack(fill="x") self.frameBottom = Tkinter.Frame(self) self.frameBottom.pack(fill="x") #self.labelFilePaths = Tkinter.Label(self, text="文件路径:", width=10) #self.labelFilePaths.grid(row=0, column=0, sticky="w") #self.textFilePaths = Tkinter.Text(self.frame, height=10) #self.textFilePaths.pack(fill="both") #self.textFilePaths.grid(row=1, column=0, sticky="nsew")def main(): root = Tkinter.Tk() root.columnconfigure(0, weight=1) root.rowconfigure(0, weight=1) root.geometry('640x360') #设置了主窗口的初始大小960x540 app = MainFrame(root) app.mainloop()if __name__ == "__main__": main()
0 0
- Tkinter--GUI布局
- Tkinter--GUI布局
- Python GUI之tkinter布局管理
- python图形界面GUI编程之tkinter布局
- Python GUI (Tkinter)
- Python Tkinter制作GUI
- python GUI Tkinter 模块
- Python GUI编程(Tkinter)
- Python GUI编程(Tkinter)
- GUI Programming Using Tkinter
- Python GUI编程(Tkinter)
- Python GUI编程(Tkinter)
- Python GUI编程(Tkinter)
- Python Gui 学习 Tkinter
- python GUI编程(Tkinter)
- Python Gui 学习 Tkinter
- Python GUI Programming (Tkinter)
- python GUI编程(Tkinter)
- 谷歌搜索技巧
- Tkinter--HelloWorld
- Tkinter--Button和Scale样例
- 数据、类型常规操作
- JS--刷新当前页面
- Tkinter--GUI布局
- Tkinter--Text文本框样例
- wxPython--基础组件-文本框样例
- wxPython--基础组件-Frame框架样例
- wxPython--基础组件-Menu菜单样例
- wxPython--基础组件-窗体拆分布局
- Python--线程样式
- Python--Socket样例
- 应用安全工作的那些事儿