中文字幕一区二区人妻电影,亚洲av无码一区二区乱子伦as ,亚洲精品无码永久在线观看,亚洲成aⅴ人片久青草影院按摩,亚洲黑人巨大videos

Python Tkinter 框架控件(Frame)

Python GUI編程 Python GUI編程

Python Tkinter 框架(Frame)控件在屏幕上顯示一個(gè)矩形區(qū)域,多用來作為容器。

語法

語法格式如下:

w = Frame ( master, option, ... )
  • master: 框架的父容器。

  • options: 可選項(xiàng),即該框架的可設(shè)置的屬性。這些選項(xiàng)可以用鍵-值的形式設(shè)置,并以逗號(hào)分隔。

序號(hào) 可選項(xiàng) & 描述
1

bg

框架背景顏色

2

bd

框架的大小,默認(rèn)為 2 個(gè)像素

3

cursor

鼠標(biāo)移動(dòng)到框架時(shí),光標(biāo)的形狀,可以設(shè)置為 arrow, circle, cross, plus 等。

4

height

框架的高度,默認(rèn)值是 0。

5

highlightbackground

框架沒有獲得焦點(diǎn)時(shí),高亮邊框的顏色,默認(rèn)由系統(tǒng)指定。

6

highlightcolor

框架獲得焦點(diǎn)時(shí),高亮邊框的顏色

7

highlightthickness

指定高亮邊框的寬度,默認(rèn)值為 0不帶高亮邊框)

8

relief

邊框樣式,可選的有:FLAT、SUNKEN、RAISED、GROOVE、RIDGE。默認(rèn)為 FLAT。

9

width

設(shè)置框架寬度,默認(rèn)值是 0。

10

takefocus

指定該組件是否接受輸入焦點(diǎn)(用戶可以通過 tab 鍵將焦點(diǎn)轉(zhuǎn)移上來),默認(rèn)為 false。

實(shí)例

#!/usr/bin/python # -*- coding: UTF-8 -*- # python2 使用 Tkinter from Tkinter import * # python3 使用 tkinter #from tkinter import * def say_hi(): print("hello ~ !") root = Tk() frame1 = Frame(root) frame2 = Frame(root) root.title("tkinter frame") label= Label(frame1,text="Label",justify=LEFT) label.pack(side=LEFT) hi_there = Button(frame2,text="say hi~",command=say_hi) hi_there.pack() frame1.pack(padx=1,pady=1) frame2.pack(padx=10,pady=10) root.mainloop()

測(cè)試輸出結(jié)果如下:

Python GUI編程 Python GUI編程

其他擴(kuò)展