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的更多相关文章

  1. python3+tkinter实现的黑白棋,代码完整 100%能运行

    今天分享给大家的是采用Python3+tkinter制作而成的小项目--黑白棋 tkinter是Python内置的图形化模块,简单易用,一般的小型UI程序可以快速用它实现,具体的tkinter相关知识 ...

  2. Python3 tkinter基础 Scrollbar pack 创建靠右、充满Y轴的垂直滚动条

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  3. Python3 tkinter基础 Radiobutton indicatoron 长条形 pack 充满一行

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  4. Python3 tkinter基础 Label pack 设置控件在窗体中的位置

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  5. 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 ...

  6. python3 tkinter模块

    一.tkinter 1.tkinter--tool kit interface工具包接口,用于GUI(Graphical User Interface)用户图形界面, 2.python3.x把Tkin ...

  7. Python3 tkinter基础 TK title 设置窗体的标题

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  8. Python3 tkinter基础 Tk quit 点击按钮退出窗体

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  9. Python3 tkinter基础 Text image 文本框中插入图片

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  10. Python3 tkinter基础 Text window 文本框中插入按钮

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

随机推荐

  1. hdu Hat's Fibonacci(用了kuangbin模板)

    大数的位数设置很坑,设成700会越界,设成800会超空间,最后设成了750居然就过了.... #include <iostream> #include <cstdio> #in ...

  2. Redis Sentinel 介绍

    Redis Sentinel   sentinel的功能: 监控:sentinel节点定期检测redis数据节点,其余sentinel节点是否可达. 通知:sentinel 节点会将故障转移结果通知给 ...

  3. 关于Django中JsonResponse返回中文字典编码错误的解决方案

    解决方案:JsonResponse(data, json_dumps_params={'ensure_ascii':False}) ! data是需要渲染的字典 def master(request) ...

  4. 【补】英语对IT工作者的重要性

    浅谈程序员的英语学习   作为在中国工作的程序员,不懂得英语似乎也不妨碍找到好工作,升职加薪.但程序员这个工种则稍有不同,因为程序,尤其是高级语言,基本上都是由英语和数字表达式构成的.英语对于程序员十 ...

  5. ffmreg thinkphp 控制器 获取音频视频详细信息(获取时长)

    FFmpeg下载:http://ffmpeg.zeranoe.com/builds/ 下载并解压FFmpeg文件夹: 打开你想安装的任意磁盘,例如:d盘.新建一个名为“ffmpeg”的文件夹,将第二步 ...

  6. PHP读取excel

    $file = '';//文件名称 $file_ext = explode('.',$file);$file_ext = $file_ext[1];$data['file_ext'] = $file_ ...

  7. socketpair通信

    1.线程间通信(参考安卓源码InputTransport.cpp) #include <pthread.h> #include <sys/types.h> /* See NOT ...

  8. (转载)PHP环境搭建-记录

    PHP环境搭建-记录   转于 http://jingyan.baidu.com/article/fcb5aff797ec41edaa4a71c4.html php5.5 做了大量的更新,在与apac ...

  9. python--函数汇总

    函数: 定义和特性: 定义:函数是指将一组语句的集合通过一个名字(函数名)封装起来,要想执行这个函数,只需调用其函数名()即可 特性:1,代码重用2,保持一致性3,可扩展性 函数的创建: 一,格式:p ...

  10. ECMAScript 5 compatibility shims for legacy JavaScript engines

    ECMAScript 5 compatibility shims for legacy JavaScript engines https://github.com/es-shims/es5-shim