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 ...
随机推荐
- App升级iOS7体会
本文转自App升级iOS7体会. xcode5 GM版已经发布,虽然还是pre-release版,但离最终版不远了.对于没有用到新特性的app面临的最大问题就是UI的变化.Apple提供了UI Tra ...
- Javascript Code Style Guide
本指南采用的Airbnb发布的基于ES5的JavaScript Code Style. ES5 英文版:https://github.com/airbnb/javascript/tree/es5-de ...
- LeetCode 中级 - 重新排序得到的幂(105)
从正整数 N 开始,我们按任何顺序(包括原始顺序)将数字重新排序,注意其前导数字不能为零. 如果我们可以通过上述方式得到 2 的幂,返回 true:否则,返回 false. 示例 1: 输入:1 输出 ...
- vscode调试html文件
1. vscode调试html文件 1.1. 使用Debugger for Chrome进行调试 1.1.1. 基于本地file配置方式调试 1.1.2. 基于服务端配置方式调试 1.1.2.1. 启 ...
- SQL Server 2012 - 开窗函数
-- 开窗函数:在结果集的基础上进一步处理(聚合操作) -- Over函数,添加一个字段显示最大年龄 SELECT * , MAX(StuAge) OVER ( ) MaxStuAge FROM db ...
- 【sql server常用操作{增删改查}】
use DB_x go drop database DB_y create database DB_y --创建数据库 on primary --指定主数据文件 ( name= ...
- Python提高篇
Python提高篇 1.模块 1)模块定义 模块就是py文件,可以是你自己写的,也可以是python当中自带的工具,当你在某个py文件下想要引用其他模块的功能,就需要你把你把该py文件导入. 2)导入 ...
- 树莓派驱动DHT22
树莓派-DHT22测量湿度 一般的温湿度传感器有dht11和dht22,dht11比较便宜,dht22比dht11贵好几倍,自然测量的准确度肯定是dht22高一些.追求更高精准度的可以使用SHT1x. ...
- UDP server Code
Code Example: The following programs demonstrate the use of getaddrinfo(), gai_strerror(), freeaddri ...
- Java设计模式(8)——结构型模式之组合模式(Composite)
一.概述 定义 将对象以树形结构组织起来,以达成“部分-整体” 的层次结构,使得客户端对单个对象和组合对象的使用具有一致性. 简图 角色——对应上图中顶点为Component,左边为Leaf,右边为C ...