Python3 Tkinter-Pack
1.创建
from tkinter import *
root=Tk()
print(root.pack_slaves())
Label(root,text='pack').pack()
print(root.pack_slaves())
root.mainloop()

2.改变大小
from tkinter import *
root=Tk()
root.geometry('80x80+0+0')
print(root.pack_slaves())
Label(root,text='pack').pack()
print(root.pack_slaves())
root.mainloop()

3.添加多个组件
from tkinter import *
root=Tk()
root.geometry('80x80+0+0')
print(root.pack_slaves())
for i in range(5):
Label(root,text='pack'+str(i)).pack()
print(root.pack_slaves())
root.mainloop()

4.子组件布局
from tkinter import *
root=Tk()
root.geometry('80x80+0+0')
print(root.pack_slaves())
Label(root,text='pack1',bg='red').pack(fill=Y)
Label(root,text='pack2',bg='blue').pack(fill=BOTH)
Label(root,text='pack3',bg='green').pack(fill=X)
print(root.pack_slaves())
root.mainloop()

5.组件布局
from tkinter import *
root=Tk()
root.geometry('80x80+0+0')
print(root.pack_slaves())
Label(root,text='pack1',bg='red').pack(fill=Y,expand=1)
Label(root,text='pack2',bg='blue').pack(fill=BOTH,expand=1)
Label(root,text='pack3',bg='green').pack(fill=X,expand=1)
print(root.pack_slaves())
root.mainloop()

6.改变组件布局
from tkinter import *
root=Tk()
root.geometry('80x80+0+0')
print(root.pack_slaves())
Label(root,text='pack1',bg='red').pack(fill=Y,expand=1,side=LEFT)
Label(root,text='pack2',bg='blue').pack(fill=BOTH,expand=1,side=RIGHT)
Label(root,text='pack3',bg='green').pack(fill=X,expand=1,side=LEFT)
print(root.pack_slaves())
root.mainloop()

7.组件间距
from tkinter import *
root=Tk()
root.geometry('80x80+0+0')
print(root.pack_slaves())
Label(root,text='pack1',bg='red').pack(fill=Y,expand=1,side=LEFT)
Label(root,text='pack2',bg='blue').pack(fill=BOTH,expand=1,side=RIGHT,padx=10)
Label(root,text='pack3',bg='green').pack(fill=X,expand=1,side=LEFT,pady=10)
print(root.pack_slaves())
root.mainloop()

Python3 Tkinter-Pack的更多相关文章
- python3+tkinter实现的黑白棋,代码完整 100%能运行
今天分享给大家的是采用Python3+tkinter制作而成的小项目--黑白棋 tkinter是Python内置的图形化模块,简单易用,一般的小型UI程序可以快速用它实现,具体的tkinter相关知识 ...
- Python3 tkinter基础 Scrollbar pack 创建靠右、充满Y轴的垂直滚动条
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- Python3 tkinter基础 Radiobutton indicatoron 长条形 pack 充满一行
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- Python3 tkinter基础 Label pack 设置控件在窗体中的位置
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- python3 tkinter报错:_tkinter.TclError: cannot use geometry manager pack inside . which already has slaves managed by grid
报错: _tkinter.TclError: cannot use geometry manager pack inside . which already has slaves managed by ...
- python3 tkinter模块
一.tkinter 1.tkinter--tool kit interface工具包接口,用于GUI(Graphical User Interface)用户图形界面, 2.python3.x把Tkin ...
- Python3 tkinter基础 TK title 设置窗体的标题
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- Python3 tkinter基础 Tk quit 点击按钮退出窗体
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- Python3 tkinter基础 Text image 文本框中插入图片
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- Python3 tkinter基础 Text window 文本框中插入按钮
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
随机推荐
- Spark集群新增节点方法
Spark集群处理能力不足需要扩容,如何在现有spark集群中新增新节点?本文以一个实例介绍如何给Spark集群新增一个节点. 1. 集群环境 现有Spark集群包括3台机器,用户名都是cdahdp, ...
- SQLite 如何取出特定部分数据
如果我要取11-20的Students表的数据,则为: Select * From Students Limit 9 Offset 10; 表示从Students 表获取数据,跳过10行,取9行 ...
- mpvue开发美团外卖点餐小程序
mpvue-meituan mpvue-meituan 是一款使用mpvue开发的实战小程序项目,完全仿制美团官方外卖点餐小程序开发而成,项目的框架结构完全按照企业开发架构搭建而成.结合了原生小程序的 ...
- python类的使用(类定义,构造器,类属性,方法)
注:这里只描述使用方法,具体类的概念长篇大论就不要为难我这个懒人了. 总之一句话编程语言只是一个工具,会用就行,好用就行.打破砂锅问到底,我觉得有必要研究一下C,汇编,电子链路等. class clt ...
- C++ 内存、new与malloc分配内存区别?
一关于内存 1.内存分配方式 内存分配方式有三种: (1)从静态存储区域分配.内存在程序编译的时候就已经分配好,这块内存在程序的整个运行期间都存在.例如全局变量,static变量. (2)在栈上创建. ...
- C++笔记005:用面向过程和面向对象方法求解圆形面积
原创笔记,转载请注明出处! 点击[关注],关注也是一种美德~ 结束了第一个hello world程序后,我们来用面向过程和面向对象两个方法来求解圆的面积这个问题,以能够更清晰的体会面向对象和面向过程. ...
- STL笔记
STL的基本概念: 1-容器:是可容纳各种类型的数据结构,是 类模板. 2-迭代器:是用于依次存放容器中的元素,类似指针. 3-算法: 是用于操作容器中元素的 函数模板. sort() 用来对 vec ...
- 浅析MySQL 5.7组复制技术(Group Replication)
Group Replication is know as an up to date HA(High Availablity) solution which is supported in ...
- centos7安装ftp
1.服务器初始化检查 检查selinux,firewall,iptables是否开启 1.查看selinux的运行状态 [root@zeq ~] getenforce Disabled 我的现在是关闭 ...
- 【读书笔记 - Effective Java】03. 用私有构造器或者枚举类型强化Singleton属性
实现Singleton(代表本质上唯一的系统组件)的三种方法: 1. 保持私有构造器,导出公有的静态成员,客户端访问该类的唯一实例. 2. 保持私有构造器,公有的成员是静态工厂方法. 3. 单元素的枚 ...