Python tkinter分隔控件(Seperator)的使用
分隔控件的作用就是把控件分隔為幾個部分。分隔控件有2兩種:水平(HORIZONTAL )或者垂直(VERTICAL )。如果是使用grid布局管理器,需要使用sticky來拉伸分隔控件,否則可能只是窄窄的一條線。如果是使用pack布局管理器,使用使用fill來拉伸控件。
分隔控件的屬性有:
(1)class_分隔控件的名字。
(2)Orient分隔控件的方向。有水平和垂直兩個方向。
import tkinter as tkfrom tkinter import ttk root = tk.Tk()root.geometry(’320x240’)b=ttk.Separator(root,orient=’horizontal’)a=ttk.Button(root,text=’Button’)a.pack()b.pack(fill=tk.X)root.mainloop()
結(jié)果:
(3)Style分隔控件的外觀。分隔控件的外觀只能改變背景顏色。其他的都不能改變。
import tkinter as tkfrom tkinter import ttk root = tk.Tk()root.geometry(’320x240’)s=ttk.Style()s.configure(’red.TSeparator’,background=’red’)b=ttk.Separator(root,orient=’horizontal’,style=’red.TSeparator’)a=ttk.Button(root,text=’Button’)a.pack()b.pack(fill=tk.X)root.mainloop()
結(jié)果:
分隔控件的功能非常簡單,沒有任何的方法。
到此這篇關(guān)于Python tkinter分隔控件(Seperator)的使用的文章就介紹到這了,更多相關(guān)Python tkinter分隔控件內(nèi)容請搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!
相關(guān)文章:
1. PHP正則表達式函數(shù)preg_replace用法實例分析2. 一個 2 年 Android 開發(fā)者的 18 條忠告3. vue使用moment如何將時間戳轉(zhuǎn)為標準日期時間格式4. js select支持手動輸入功能實現(xiàn)代碼5. Android 實現(xiàn)徹底退出自己APP 并殺掉所有相關(guān)的進程6. Android studio 解決logcat無過濾工具欄的操作7. 什么是Python變量作用域8. vue-drag-chart 拖動/縮放圖表組件的實例代碼9. Spring的異常重試框架Spring Retry簡單配置操作10. Vue實現(xiàn)仿iPhone懸浮球的示例代碼
