| 
 Python Tkinter 框架(Frame)控件在屏幕上顯示一個矩形區域,多用來作為容器。 語法語法格式如下: - w = Frame ( master, option, ... )
 
  複製代碼 
序號  | 可選項& 描述  |  | 1 | bg 框架背景顏色  |  | 2 | d 框架的大小,默認為2 個像素  |  | 3 | 光標 鼠標移動到框架時,光標的形狀,可以設置為arrow, circle, cross, plus 等。  |  | 4 | 高度 框架的高度,默認值是0。  |  | 5 | 高亮背景 框架沒有獲得焦點時,高亮邊框的顏色,默認由系統指定。  |  | 6 | 高光色 框架獲得焦點時,高亮邊框的顏色  |  | 7 | 高光厚度 指定高亮邊框的寬度,默認值為0不帶高亮邊框)  |  | 8 | 救濟 邊框樣式,可選的有:FLAT、SUNKEN、RAISED、GROOVE、RIDGE。默認為FLAT。  |  | 9 | 寬度 設置框架寬度,默認值是0。  |  | 10 | 聚焦 指定該組件是否接受輸入焦點(用戶可以通過tab 鍵將焦點轉移上來),默認為false。  |   實例 
- #!/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()
 
  複製代碼 
 
 
測試輸出結果如下: 
Python Tkinter 框架 Frame  
 
 
 
文章出處 
 |