Python tkinter布局与按钮间距设置方式

作者:小兜全糖(Cx) 时间:2023-09-28 23:43:27 

新建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() #进入消息循环机制

来源:https://blog.csdn.net/weixin_43632687/article/details/90228681

标签:Python,tkinter,布局,间距
0
投稿

猜你喜欢

  • 使用Java实现先查询缓存再查询数据库

    2024-01-14 02:18:05
  • 菜鸟课堂:MySQL权限的详细解答

    2009-09-03 11:43:00
  • Python中的map()函数和reduce()函数的用法

    2021-10-19 01:04:34
  • Python中Collection的使用小技巧

    2022-04-14 01:42:57
  • numpy之sum()的使用及说明

    2023-12-12 00:31:16
  • ASP操作XML文件的完整实例

    2007-09-26 12:05:00
  • 使用symfony命令创建项目的方法

    2023-11-15 10:07:45
  • go-cache的基本使用场景示例解析

    2023-08-06 00:52:02
  • python之数字图像处理方式

    2023-02-02 18:27:09
  • vue.js使用v-if实现显示与隐藏功能示例

    2024-05-02 16:59:50
  • python语音识别的转换方法

    2023-12-06 20:56:57
  • python批量导出导入MySQL用户的方法

    2024-01-29 02:58:42
  • Python流行ORM框架sqlalchemy安装与使用教程

    2022-10-20 06:12:20
  • Node.js中Bootstrap-table的两种分页的实现方法

    2024-05-11 10:58:21
  • Pytorch dataloader在加载最后一个batch时卡死的解决

    2022-09-15 06:50:34
  • Go 并发编程协程及调度机制详情

    2024-01-31 03:22:55
  • Python中的两个内置模块介绍

    2023-03-29 08:10:00
  • Python3 读、写Excel文件的操作方法

    2023-05-21 15:14:32
  • python3 lambda表达式详解

    2021-03-01 20:28:20
  • pandas把dataframe转成Series,改变列中值的类型方法

    2023-07-04 11:41:58
  • asp之家 网络编程 m.aspxhome.com