zoukankan      html  css  js  c++  java
  • TKinter布局之pack

    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()
    

      效果图:

      

  • 相关阅读:
    I.MX6 sdio 设备注册及识别
    linux串口查看命令
    连词
    相形-声似词汇
    replace A with B是用A代替B还是用B代替A?
    无监督、弱监督、半监督、强化、多示例学习是什么
    JS散度(Jensen-Shannon)
    embedding是什么
    httpclient: 设置请求的超时时间,连接超时时间等
    httpclient工具使用(org.apache.httpcomponents.httpclient)
  • 原文地址:https://www.cnblogs.com/kongzhagen/p/6144588.html
Copyright © 2011-2022 走看看