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 ...
随机推荐
- Context initialization failed org.springframework.beans.factory.BeanCreationException
严重: Context initialization failed org.springframework.beans.factory.BeanCreationException: Error cre ...
- OCR
谷歌OCR光学字符识别窥探 - 简书 Tesseract OCR初探 利用Tesseract图片文字识别初探 _ TonyDeng's Blog Tesseract OCR(光学字符识别)教程 - C ...
- vue移动端项目vw适配运行项目时出现"advanced"报错解决办法。
Module build failed: Error: Cannot load preset "advanced". Please check your configuration ...
- Tomcat问题之 启动 Cannot find /usr/local/tomcat/bin/setclasspath.sh
在linux启动startup命令报Cannot find /usr/local/tomcat/bin/setclasspath.sh 使用: unset CATALINA_HOME命令得以解决 ...
- Ansible实现主备模式的高可用(Keepalived)
前言 Ansible是一款极其简单的IT自动化运维工具,基于Python开发,集合了众多运维工具(puppet.cfengine.chef.func.fabric)的优点,实现了批量系统配置.批量程序 ...
- TinyMCE插件:RESPONSIVE filemanager 9 文件名统一格式化
上传图片方法(filemanager/UploadHandler.php) 在上传图片的函数中查看,发现$file->name是一个完整的[文件名.后缀名],所以使用explode(),文件名和 ...
- 线上服务内存OOM问题定位三板斧
相信大家都有感触,线上服务内存OOM的问题,是最难定位的问题,不过归根结底,最常见的原因: 本身资源不够 申请的太多 资源耗尽 58到家架构部,运维部,58速运技术部联合进行了一次线上服务内存OOM问 ...
- jdk11新特性
JDK 11主要特性一览 jdk11即将在9月25号发布正式版.确定的新特性包括以下17个 181 嵌套类可见性控制 309 动态文件常量 315 改进 Aarch64 Intrinsics 318 ...
- Git简单配置ssh秘钥
执行以下命令: git config --global user.name "demo" git config --global user.email "demo@dem ...
- ruby 正则表达式Regexp
ruby正则表达式在线编辑器:rubular 一般规则: /a/匹配字符a. /\?/匹配特殊字符?.特殊字符包括^, $, ? , ., /, \, [, ], {, }, (, ), + ...