Python tkinter布局与按钮间距设置方式
2020-03-11 17:52
197 查看
新建label与button,并设置位置(grid)
import tkinter as tk root = tk.Tk() label = tk.Label(root, text = ‘Label') label.grid(column = 3, row = 8) button = tk.Button(root, text = ‘Button') button.grid(column = 5, row = 1)
按钮间距设置
col_count, row_count = root.grid_size() for col in xrange(col_count): root.grid_columnconfigure(col, minsize=20) for row in xrange(row_count): root.grid_rowconfigure(row, minsize=20)
补充知识:Python 窗体(tkinter)按钮 位置
我就废话不多说了,还是直接看代码吧
import tkinter def go(): #函数 print("go函数") win=tkinter.Tk() #构造窗体 win.title("hello zhaolin")#标题 win.geometry("800x800+300+0")#800宽度,800高度,x,y坐标,左上角 button=tkinter.Button(win,text="有种点我",command=go) #收到消息执行go函数 button.pack()#加载到窗体, button1=tkinter.Button(win,text="有种点",command= lambda :print("hello world"),width=20,height=10) button1.pack()#加载到窗体, #button.place(10,10) win.mainloop() #进入消息循环机制
以上这篇Python tkinter布局与按钮间距设置方式就是小编分享给大家的全部内容了,希望能给大家一个参考
您可能感兴趣的文章:
相关文章推荐
- Python tkinter布局与按钮间距设置
- Python3 Tkinter基础 Button text,fg在窗体中添加一个按钮,在按钮上显示文字 并 设置文字的颜色
- Python3 Tkinter基础 Menubutton 设置一个按钮 点击按钮出现下拉菜单
- Python3 Tkinter基础 Button bg 设置按钮的背景颜色
- Python3 Tkinter基础 Radiobutton 设置indicatoron=False 改变按钮的外观 从圆形变为button的形状
- togglebutton的使用(开关按钮)改变布局的方式
- VS2008下设置绝对定位的布局方式
- python tkinter界面中添加按钮的方法
- python tkinter学习——布局
- Python tkinter三种布局实例详解
- Python3 Tkinter基础 点击按钮退出窗体 root.quit
- Python模块学习系列(6)----Tkinter(几何布局管理)
- python tkinter 布局方法
- RecyclerView onItemClick 按钮和布局都有单击事件时的处理方式
- Python3 Tkinter基础 创建显示一行文字的窗体并设置窗体的标题 Label,title
- ExpandableListView group和child的item间距设置以及多种布局等问题的解决
- Python3 Tkinter基础 Button Entry 点击按钮将输入框中文字打印到控制台中
- 布局管理(tkinter,Python3.x)
- Python GUI之tkinter布局管理
- [python]tkinter布局中的fill、expand与anchor