亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Python Tkinter簡單布局實(shí)例教程

 更新時間:2014年09月03日 15:13:23   投稿:shichen2014  
這篇文章主要介紹了Python Tkinter簡單布局實(shí)例教程,包括了填充、左右布局、絕對布局、網(wǎng)格布局等,需要的朋友可以參考下

本文實(shí)例展示了Python Tkinter實(shí)現(xiàn)簡單布局的方法,示例中備有較為詳盡的注釋,便于讀者理解。分享給大家供大家參考之用。具體如下:

# -*- coding: utf-8 -*-
from Tkinter import *

root = Tk()
# 80x80代表了初始化時主窗口的大小,0,0代表了初始化時窗口所在的位置
root.geometry('80x80+10+10')

# 填充方向
'''
Label(root, text = 'l1', bg = 'red').pack(fill = Y)
Label(root, text = 'l2', bg = 'green').pack(fill = BOTH)
Label(root, text = 'l3', bg = 'blue').pack(fill = X)


# 左右布局
Label(root, text = 'l1', bg = 'red').pack(fill = Y, side = LEFT)
Label(root, text = 'l2', bg = 'green').pack(fill = BOTH, side = RIGHT)
Label(root, text = 'l3', bg = 'blue').pack(fill = X, side = LEFT)

# 絕對布局
l4 = Label(root, text = 'l4')
l4.place(x = 3, y = 3, anchor = NW)
'''

# Grid 網(wǎng)格布局
l1 = Label(root, text = 'l1', bg = 'red')
l2 = Label(root, text = 'l2', bg = 'blue')
l3 = Label(root, text = 'l3', bg = 'green')
l4 = Label(root, text = 'l4', bg = 'yellow')
l5 = Label(root, text = 'l5', bg = 'purple')

l1.grid(row = 0, column = 0)
l2.grid(row = 1, column = 0)
l3.grid(row = 1, column = 1)
l4.grid(row = 2 )
l5.grid(row = 0, column = 3)

root.mainloop()

Grid 網(wǎng)格布局運(yùn)行效果如下圖所示:

感興趣的讀者可以測試一下本文實(shí)例運(yùn)行效果,相信對大家的Python程序設(shè)計有一定的借鑒價值。

相關(guān)文章

最新評論