-
python tkinter pack_TKinter布局之pack
2020-12-01 23:44:38pack布局非常简单,不用做过多的设置,直接使用一个 pack 函数就可以了。1、我们使用 pack 函数的时候,默认先使用的放到上面,然 后 依次向下排,它会给我们的组件一个自认为合适的位置 和大小,这是默认方式。2、...pack布局非常简单,不用做过多的设置,直接使用一个 pack 函数就可以了。
1、我们使用 pack 函数的时候,默认先使用的放到上面,然 后 依次向下排,它会给我们的组件一个自认为合适的位置 和大小,这是默认方式。
2、可接受的参数:
side:按扭停靠在窗口的哪个位置
left: 左
top: 上
right: 右
botton: 下
fill:填充
x:水平方向填充
y:竖直方向填充
both:水平和竖直方向填充
none:不填充
expand:
yes:扩展整个空白区
no:不扩展
anchor:
N:北 下
E:东 右
S:南 下
W:西 左
CENTER:中间
padx:x方向的外边距
pady:y方向的外边距
ipadx:x方向的内边距
ipady:y方向的内边距
示例代码:
#!/usr/bin/env python
# _*_ coding:utf-8 _*_
from Tkinter import *
root = Tk()
Button(root,text='A').pack(side=LEFT,expand=YES,fill=Y)
Button(root,text='B').pack(side=TOP,expand=YES,fill=BOTH)
Button(root,text='C').pack(side=RIGHT,expand=YES,fill=NONE)
Button(root,text='D').pack(side=LEFT,expand=NO,fill=Y)
Button(root,text='E').pack(side=TOP,expand=YES,fill=BOTH)
Button(root,text='F').pack(side=BOTTOM,expand=YES)
Button(root,text='G').pack(anchor=SE)
root.mainloop()
效果图:
-
python tkinter pack_Python Tkinter Pack布局管理器
2020-12-01 23:44:37GUI 编程就相当于小孩子搭积木,每个积木块应该放在哪里,每个积木块显示为多大,也就是对大小和位置都需要进行管理,...如果使用 Pack 布局,那么当程序向容器中添加组件时,这些组件会依次向后排列,排列方向既可...GUI 编程就相当于小孩子搭积木,每个积木块应该放在哪里,每个积木块显示为多大,也就是对大小和位置都需要进行管理,而布局管理器正是负责管理各组件的大小和位置的。此外,当用户调整了窗口的大小之后,布局管理器还会自动调整窗口中各组件的大小和位置。python学习网,大量的免费python视频教程,欢迎在线学习!
如果使用 Pack 布局,那么当程序向容器中添加组件时,这些组件会依次向后排列,排列方向既可是水平的,也可是垂直的。
下面程序简单示范了 Pack 布局的用法,该程序向窗口中添加了三个 Label 组件:# Python 2.x使用这行
#from Tkinter import *
# Python 3.x使用这行
from tkinter import *
# 创建窗口并设置窗口标题
root = Tk()
# 设置窗口标题
root.title('Pack布局')
for i in range(3):
lab = Label(root, text="第%d个Label" % (i + 1), bg='#eeeeee')
# 调用pack进行布局
lab.pack()
# 启动主窗口的消息循环
root.mainloop()
上面程序创建了一个窗口,然后使用循环创建了三个 Label,并对这三个 Label 使用了 pack() 方法进行默认的 Pack 布局。运行该程序看到如图所示的界面:
上图图使用的是默认的 Pack 布局,实际上程序在调用 pack() 方法时可传入多个选项。例如,通过 help(tkinter.Label.pack) 命令来查看 pack() 方法支持的选项,可以看到如下输出结果:
>>> help(tkinter.Label.pack)
Help on function pack_configure in module tkinter:
pack_configure(self, cnf={}, **kw)
Pack a widget in the parent widget. Use as options:
after=widget - pack it after you have packed widget
anchor=NSEW (or subset) - position widget according to
given direction
before=widget - pack it before you will pack widget
expand=bool - expand widget if parent size grows
fill=NONE or X or Y or BOTH - fill widget if widget grows
in=master - use master to contain this widget
in_=master - see 'in' option description
ipadx=amount - add internal padding in x direction
ipady=amount - add internal padding in y direction
padx=amount - add padding in x direction
pady=amount - add padding in y direction
side=TOP or BOTTOM or LEFT or RIGHT - where to add this widget.
从上面的显示信息可以看出,pack() 方法通常可支持如下选项:
anchor:当可用空间大于组件所需求的大小时,该选项决定组件被放置在容器的何处。该选项支持 N(北,代表上)、E(东,代表右)、S(南,代表下)、W(西,代表左)、NW(西北,代表左上)、NE(东北,代表右上)、SW(西南,代表左下)、SE(东南,代表右下)、CENTER(中,默认值)这些值。
expand:该 bool 值指定当父容器增大时才是否拉伸组件。
fill:设置组件是否沿水平或垂直方向填充。该选项支持 NONE、X、Y、BOTH 四个值,其中 NONE 表示不填充,BOTH 表示沿着两个方向填充。
ipadx:指定组件在 x 方向(水平)上的内部留白(padding)。
ipady:指定组件在 y 方向(水平)上的内部留白(padding)。
padx:指定组件在 x 方向(水平)上与其他组件的间距。
pady:指定组件在 y 方向(水平)上与其他组件的间距。
side:设置组件的添加位置,可以设置为 TOP、BOTTOM、LEFT 或 RIGHT 这四个值的其中之一。
当程序界面比较复杂时,就需要使用多个容器(Frame)分开布局,然后再将 Frame 添加到窗口中。例如如下程序:# Python 2.x使用这行
#from Tkinter import *
# Python 3.x使用这行
from tkinter import *
class App:
def __init__(self, master):
self.master = master
self.initWidgets()
def initWidgets(self):
# 创建第一个容器
fm1 = Frame(self.master)
# 该容器放在左边排列
fm1.pack(side=LEFT, fill=BOTH, expand=YES)
# 向fm1中添加3个按钮
# 设置按钮从顶部开始排列,且按钮只能在垂直(X)方向填充
Button(fm1, text='第一个').pack(side=TOP, fill=X, expand=YES)
Button(fm1, text='第二个').pack(side=TOP, fill=X, expand=YES)
Button(fm1, text='第三个').pack(side=TOP, fill=X, expand=YES)
# 创建第二个容器
fm2 = Frame(self.master)
# 该容器放在左边排列,就会挨着fm1
fm2.pack(side=LEFT, padx=10, expand=YES)
fm2.pack(side=LEFT, padx=10, fill=BOTH, expand=YES)
# 向fm2中添加3个按钮
# 设置按钮从右边开始排列
Button(fm2, text='第一个').pack(side=RIGHT, fill=Y, expand=YES)
Button(fm2, text='第二个').pack(side=RIGHT, fill=Y, expand=YES)
Button(fm2, text='第三个').pack(side=RIGHT, fill=Y, expand=YES)
# 创建第三个容器
fm3 = Frame(self.master)
# 该容器放在右边排列,就会挨着fm1
fm3.pack(side=RIGHT, padx=10, fill=BOTH, expand=YES)
# 向fm3中添加3个按钮
# 设置按钮从底部开始排列,且按钮只能在垂直(Y)方向填充
Button(fm3, text='第一个').pack(side=BOTTOM, fill=Y, expand=YES)
Button(fm3, text='第二个').pack(side=BOTTOM, fill=Y, expand=YES)
Button(fm3, text='第三个').pack(side=BOTTOM, fill=Y, expand=YES)
root = Tk()
root.title("Pack布局")
display = App(root)
root.mainloop()
上面程序创建了三个 Frame 容器,其中第一个 Frame 容器内包含三个从顶部(TOP)开始排列的按钮,这意味着这三个按钮会从上到下依次排列,且这三个按钮能在水平(X)方向上填充;第二个 Frame 容器内包含三个从右边(RIGHT)开始排列的按钮,这意味着这三个按钮会从右向左依次排列;第三个 Frame 容器内包含三个从底部(BOTTOM)开始排列的按钮,这意味着这三个按钮会从下到上依次排列,且这三个按钮能在垂直(Y)方向上填充。
运行上面程序,将看到如下图所示的界面。
从上图中可以看到,为运行效果添加了三个框,分别代表 fm1、fm2、fm3(实际上容器是看不到的),此时可以看到 fm1 内的三个按钮从上到下排列,并且可以在水平方向上填充;fm3 内的三个按钮从下到上排列,并且可以在垂直方向上填充。
可能有读者会有疑问,fm2 内的三个按钮也都设置了 fill=Y,expand=YES,这说明它们也能在垂直方向上填充,为啥舍看不到呢?仔细看 fm2.pack(side=LEFT, padx=10, expand= YES)这行代码,它说明 fm2 本身不在任何方向上填充,因此 fm2 内的三个按钮都不能填充。
-
python3 tkinter教程pack_Python tkinter之pack
2020-12-23 03:11:461、默认居中,从上而下#-*- encoding=utf-8 -*-importtkinterfrom tkinter import *if __name__ == '__main__':passwin= tkinter.Tk() #窗口win.title('南风丶轻语') #标题screenwidth = win.winfo_screenwidth() #...1、默认居中,从上而下
#-*- encoding=utf-8 -*-
importtkinterfrom tkinter import *
if __name__ == '__main__':passwin= tkinter.Tk() #窗口
win.title('南风丶轻语') #标题
screenwidth = win.winfo_screenwidth() #屏幕宽度
screenheight = win.winfo_screenheight() #屏幕高度
width = 300height= 100x= int((screenwidth - width) / 2)
y= int((screenheight - height) / 2)
win.geometry('{}x{}+{}+{}'.format(width, height, x, y)) #大小以及位置
Button(win, text='按钮1', bg='red').pack() #默认居中,从上而下
Button(win, text='按钮2', bg='yellow').pack()
Button(win, text='按钮3', bg='blue').pack()
win.mainloop()
2、填充X,Y轴
2.1、填充X轴(fill=X)
#-*- encoding=utf-8 -*-
importtkinterfrom tkinter import *
if __name__ == '__main__':passwin= tkinter.Tk() #窗口
win.title('南风丶轻语') #标题
screenwidth = win.winfo_screenwidth() #屏幕宽度
screenheight = win.winfo_screenheight() #屏幕高度
width = 300height= 100x= int((screenwidth - width) / 2)
y= int((screenheight - height) / 2)
win.geometry('{}x{}+{}+{}'.format(width, height, x, y)) #大小以及位置
Button(win, text='按钮1', bg='red').pack(
fill=X, #填充横坐标
)
Button(win, text='按钮2', bg='yellow').pack()
Button(win, text='按钮3', bg='blue').pack()
win.mainloop()
2.2、填充Y轴(fill=Y)
#-*- encoding=utf-8 -*-
importtkinterfrom tkinter import *
if __name__ == '__main__':passwin= tkinter.Tk() #窗口
win.title('南风丶轻语') #标题
screenwidth = win.winfo_screenwidth() #屏幕宽度
screenheight = win.winfo_screenheight() #屏幕高度
width = 300height= 100x= int((screenwidth - width) / 2)
y= int((screenheight - height) / 2)
win.geometry('{}x{}+{}+{}'.format(width, height, x, y)) #大小以及位置
Button(win, text='按钮1', bg='red').pack(
side=LEFT, #放置在左边
fill=Y, #填充纵坐标
)
Button(win, text='按钮2', bg='yellow').pack()
Button(win, text='按钮3', bg='blue').pack()
win.mainloop()
2.3、填充XY轴(fill=BOTH,expand=True)
#-*- encoding=utf-8 -*-
importtkinterfrom tkinter import *
if __name__ == '__main__':passwin= tkinter.Tk() #窗口
win.title('南风丶轻语') #标题
screenwidth = win.winfo_screenwidth() #屏幕宽度
screenheight = win.winfo_screenheight() #屏幕高度
width = 300height= 100x= int((screenwidth - width) / 2)
y= int((screenheight - height) / 2)
win.geometry('{}x{}+{}+{}'.format(width, height, x, y)) #大小以及位置
Button(win, text='按钮1', bg='red').pack(
side=LEFT, #放置在左边
fill=BOTH, #填充
expand=True, #如果父组件大小增长,则展开小部件
)
Button(win, text='按钮2', bg='yellow').pack()
Button(win, text='按钮3', bg='blue').pack()
win.mainloop()
3、内外间距
#-*- encoding=utf-8 -*-
importtkinterfrom tkinter import *
if __name__ == '__main__':passwin= tkinter.Tk() #窗口
win.title('南风丶轻语') #标题
screenwidth = win.winfo_screenwidth() #屏幕宽度
screenheight = win.winfo_screenheight() #屏幕高度
width = 300height= 300x= int((screenwidth - width) / 2)
y= int((screenheight - height) / 2)
win.geometry('{}x{}+{}+{}'.format(width, height, x, y)) #大小以及位置
Button(win, text='按钮1', bg='red', width=20).pack(
ipadx=10, #内间距x
ipady=10, #内间距y
padx=10, #外间距x
pady=10 #外间距y
)
Button(win, text='按钮2', bg='yellow', width=20).pack()
Button(win, text='按钮3', bg='blue').pack()
win.mainloop()
备注:
①按钮1和按钮2的宽度一致,但是按钮1的ipadx=10,可以看出按钮1比按钮二长10
②按钮1设置了X和Y的外间距,因此可以看出组件间的间隔
4、side布局
4.1、上下左右布局
# -*- encoding=utf-8 -*-
import tkinter
from tkinter import *
if __name__ == '__main__':
pass
win = tkinter.Tk() # 窗口
win.title('南风丶轻语') # 标题
screenwidth = win.winfo_screenwidth() # 屏幕宽度
screenheight = win.winfo_screenheight() # 屏幕高度
width = 300
height = 100
x = int((screenwidth - width) / 2)
y = int((screenheight - height) / 2)
win.geometry('{}x{}+{}+{}'.format(width, height, x, y)) # 大小以及位置
Button(win, text='按钮1', bg='red').pack(side=RIGHT)
Button(win, text='按钮2', bg='yellow').pack(side=LEFT)
Button(win, text='按钮3', bg='blue').pack(side=BOTTOM)
Button(win, text='按钮4', bg='green').pack(side=TOP)
win.mainloop()
4.2、从左(右)向右(左)
#-*- encoding=utf-8 -*-
importtkinterfrom tkinter import *
if __name__ == '__main__':passwin= tkinter.Tk() #窗口
win.title('南风丶轻语') #标题
screenwidth = win.winfo_screenwidth() #屏幕宽度
screenheight = win.winfo_screenheight() #屏幕高度
width = 300height= 100x= int((screenwidth - width) / 2)
y= int((screenheight - height) / 2)
win.geometry('{}x{}+{}+{}'.format(width, height, x, y)) #大小以及位置
Button(win, text='按钮1', bg='red').pack(side=LEFT)
Button(win, text='按钮2', bg='yellow').pack(side=LEFT)
Button(win, text='按钮3', bg='blue').pack(side=LEFT)
Button(win, text='按钮4', bg='green').pack(side=LEFT)
Button(win, text='按钮5', bg='red').pack(side=RIGHT)
Button(win, text='按钮6', bg='yellow').pack(side=RIGHT)
Button(win, text='按钮7', bg='blue').pack(side=RIGHT)
Button(win, text='按钮8', bg='green').pack(side=RIGHT)
win.mainloop()
4.3、自动填充满父元素
#-*- encoding=utf-8 -*-
importtkinterfrom tkinter import *
if __name__ == '__main__':passwin= tkinter.Tk() #窗口
win.title('南风丶轻语') #标题
screenwidth = win.winfo_screenwidth() #屏幕宽度
screenheight = win.winfo_screenheight() #屏幕高度
width = 400height= 500x= int((screenwidth - width) / 2)
y= int((screenheight - height) / 2)
win.geometry('{}x{}+{}+{}'.format(width, height, x, y)) #大小以及位置
all_count= 20line_count= 4color= ['red', 'blue', 'yellow', 'pink', 'green']
color_index=0for j in range(int(all_count /line_count)):
f=Frame()
f.pack(fill=BOTH, expand=True)for i inrange(line_count):
Button(f, text='排列按钮', bg=color[color_index]).pack(side='left', expand='true',
fill=BOTH)
color_index+= 1
if color_index >=len(color):
color_index=0
win.mainloop()
-
python中tkinter模块pack_python tkinter pack参数_tkinter模块常用参数(python3)
2021-02-03 10:04:56#生成root主窗口 label=tkinter.Label(root,text='Hello,GUI') #生成标签 label.pack() #将标签添加到主窗口 button1=tkinter.Button(root,text='Button1') #生成button1 button1.pack(side=tkinter.LEFT) ...root.title('标题名') 修改框体的名字,也可在创建时使用className参数来命名;
root.resizable(0,0) 框体大小可调性,分别表示x,y方向的可变性;
root.geometry('250x150') 指定主框体大小;
root.quit() 退出;
root.update_idletasks()
root.update() 刷新页面;
2、初级样例
import tkinter
root=tkinter.Tk() #生成root主窗口
label=tkinter.Label(root,text='Hello,GUI') #生成标签
label.pack() #将标签添加到主窗口
button1=tkinter.Button(root,text='Button1') #生成button1
button1.pack(side=tkinter.LEFT) #将button1添加到root主窗口
button2=tkinter.Button(root,text='Button2')
button2.pack(side=tkinter.RIGHT)
root.mainloop() #进入消息循环(必需组件)
3、tkinter中的15种核心组件
Button 按钮;
Canvas 绘图形组件,可以在其中绘制图形;
Checkbutton 复选框;
Entry 文本框(单行);
Text 文本框(多行);
Frame 框架,将几个组件组成一组
Label 标签,可以显示文字或图片;
Listbox 列表框;
Menu 菜单;
Menubutton 它的功能完全可以使用Menu替代;
Message 与Label组件类似,但是可以根据自身大小将文本换行;
Radiobutton 单选框;
Scale 滑块;允许通过滑块来设置一数字值
Scrollbar 滚动条;配合使用canvas, entry, listbox, and text窗口部件的标准滚动条;
Toplevel 用来创建子窗口窗口组件。
(在Tkinter中窗口部件类没有分级;所有的窗口部件类在树中都是兄弟。)
推荐学习视频:Python Tkinter 数字时钟小项目 - 网易云课堂study.163.com
-
python tkinter pack_tk/Tkinter中的pack布局
2020-12-06 21:41:11tk是一款轻量级的GUI框架,它能够快速编写GUI程序,python自带的GUI包Tkinter也是基于tk的。在诸如一些工程软件二次开发或者python创建图形界面时,应用都比较广泛。使用tk的常规步骤是:先创建widgets,然后利用... -
python tkinter pack_Python Tkinter pack.forget()问题
2021-02-03 00:53:52importtkinterastkclassWindow(tk.Frame):def__init__(self,master):tk.Frame.__init__(self,master)# first screenself.screen_01=tk.Frame(master)self.screen_01.pack(fill=tk.BOTH,expand=1)self.screen_01.conf... -
python中tkinter模块pack_Python tkinter模块和参数
2021-02-03 10:05:00转自:https://www.cnblogs.com/aland-1415/p/6849193.html1、使用tkinter.Tk() 生成主窗口(root=tkinter.Tk());root.title('标题名') 修改框体的名字,也可在创建时使用className参数来命名;root.resizable(0,0) ... -
tkinter pack and place
2019-01-09 14:49:52pack and place 放置位置 需求: import tkinter as tk import tkinter.messagebox window = tk.Tk() window.title('my window') window.geometry('200x200') # 1. # tk.Label(window,text=1).pack(side='... -
python pack布局_Tkinter 布局管理器:pack
2020-12-10 17:16:39"""This recipe describes how to handle asynchronous I/O in an environment whereyou are running Tkinter as the graphical user interface. Tkinter is safeto use as long as all the graphics commands are h... -
python tkinter pack实例_python Tkinter的图片刷新实例
2021-02-03 00:54:13调用python自带的GUI制作库一开始想用Tkinter制作GUI的,网上说是python自带的,结果输入:import tkinter后,显示:_ImportError: No module named tkinter_以为是没有安装,还利用apt-get install 命令安装了一堆... -
tkinter-pack布局
2021-01-29 12:50:15from tkinter import * root = Tk() Button(root,text = "a").pack(side = LEFT,expand = YES,fill = Y) Button(root,text = "b").pack(side = TOP,expand = YES , fill = BOTH) Button(root,text= "c") .pack(side ... -
-
The Tkinter Pack Geometry Manager
2020-07-14 09:13:38The Tkinter Pack Geometry Manager [pack] pack 常见用法 将部件放到一个框架内, 并且充满整个框架 部件自动摆放, on top of each other 部件依次摆放, side by side 不要和 grid 混用 实例 Patterns 1. 充满... -
-
Tkinter之Pack篇
2017-09-05 15:22:51''' Created on 2017年9月5日 ...'''Tkinter教程之Pack篇''' #_*_coding:utf-8_*_ import tkinter as tk from tkinter import * if __name__ == '__main__': root = tk.Tk() root.wm_title('P -
tkinter-pack布局详解
2020-07-04 08:17:11tkinter中控件的布局可以有三个类来控制,分别是Pack,Place,Grid.本系列文章将这三个类统称为布局类. 布局类与控件类的类间关系如下: 由上图可以看出,tkinter总共有17个控件类,三个布局类都是控 -
python的pack方法_Tkinter-pack方法混乱
2020-12-16 04:58:29bd=2) C.pack(side=tk.LEFT,fill=tk.BOTH, expand=tk.TRUE) D.pack(side=tk.RIGHT,fill=tk.BOTH, expand=tk.TRUE) A.pack(fill=tk.BOTH, expand=tk.TRUE) B.pack(fill=tk.BOTH, expand=tk.TRUE) CD.pack(fill=tk.... -
TKinter之pack()
2020-01-29 13:10:59pack() 首先介绍最基本的框架,下面我们用三个简单的步骤来绘制一个最简单的窗口 1.导入tkinter库 2.创建主窗口对象 3.加入消息循环 # 1.导入tkinter库 import tkinter # 2.创建主窗口对象 root = tkinter.Tk() ... -
python tkinter pack参数_tkinter模块常用参数(python3)
2020-12-18 05:30:52#生成root主窗口 label=tkinter.Label(root,text='Hello,GUI') #生成标签 label.pack() #将标签添加到主窗口 button1=tkinter.Button(root,text='Button1') #生成button1 button1.pack(side=tkinter.LEFT) ... -
python tkinter pack参数_关于python tkinter库中组件摆放方法 pack方法中 形参anchor 赋值问题...
2020-12-18 05:30:52本人在使用python tkinter库时,查看其组件的摆放方法pack使用方式时,发现pack的形参赋值方式特别奇怪,例子如下:导入tkinter库from tkinter import *创建一个顶层窗口window=Tk()采用tkinter库中的pack方法在窗口... -
用tkinter.pack设计复杂界面布局
2018-11-04 12:41:59tkinter是python语言中常用的界面实现模块,其中pack()方法,可创建浮动,自动伸缩扩展的软件界面,如以下界面。 如果你对以上用tkinter.pack实现的界面布局有兴趣,觉得有些实现效果可以参考借鉴,请继续阅读... -
python tkinter pack 同一行_如何使用tkinter pack()方法将小部件放在下一行?
2021-01-11 22:24:58how can i put widget next row using tkinter pack() method?? i usedpack(side= LEFT) but i can't make like my upload picture . pack(side=LEFT) is only left... i can't put next row widget. iw... -
tkinter布局之pack
2020-04-09 20:01:07pack默认方式为从上到下依次排列 pack参数 side:按扭停靠在窗口的哪个位置 left: 左 top: 上 right: 右 botton: 下 fill:填充 x:水平方向填充 y:竖直方向填充 both:水平和竖直方向填充 none:不... -
python tkinter pack实例_Python Tkinter图形工具使用方法及实例解析
2020-12-18 05:27:53Tkinter 常用组件按钮Button 按钮组件RadioButton 单选框组件CheckButton 选择按钮组件Listbox 列表框组件文本输组件Entry 单行文本框组件Text 多行文本框组件标签组件Label 标签组件,可以显示图片和文字Message ... -
Tkinter教程之Pack篇
2019-09-24 17:23:16本文转载自:... '''Tkinter教程之Pack篇'''#Pack为一布局管理器,可将它视为一个弹性的容器'''1.一个空的widget'''#不使用pack#-*-coding:cp936-*-fromTkinterimport*root=Tk()#查看当前ro... -
TKinter布局之pack
2018-03-24 16:03:01pack布局非常简单,不用做过多的设置,直接使用一个 pack 函数就可以了。 1、我们使用 pack 函数的时候,默认先使用的放到上面,然 后 依次向下排,它会给我们的组件一个自认为合适的位置 和大小,这是默认方式。 ... -
python tkinter库 pack布局方法调用
2021-03-24 23:51:11python的tkinter库pack布局方法调用 这个布局边角简单 tkinter.Label(window,text='今晚去庆祝',bg="back",fg='white').pack() #等同于 label = tkinter.Label(window,text="今晚去庆祝",bg='back',fg='white') ... -
Tkinter之pack所有属性详解
2019-12-04 14:36:20Tkinter的pack()方法记录 我理解的pack方法就是需要将容器如何放置在你的窗口上面,主要是相对位置的一个概念,而且最重要的是pack方法是按照代码执行顺序一行一行放置的,先后顺序对结果有很大影响。 首先pack()方法...