当前位置:网站首页>Tkinter study notes (IV)
Tkinter study notes (IV)
2022-06-11 22:07:00 【Chrn morning】
tix and ttk Control
Introduce
tix The library provides tk Common gizmos missing from the library , Such as hlist Control ,combobox Control ,control Control and various scrollable gizmos , With the help of tix Super controls can design more beautiful applications .
ttk Provides a platform independent window toolkit
ttk.NoteBook Control
import tkinter as tk
from tkinter import ttk
root=tk.Tk()
root.title(' main window ')
root.geometry('400x300+200+200')
frame=ttk.LabelFrame(root,text='ttk.labelframe',width=200,height=100)
frame.pack(expand=1,fill='both')
# establish notebook
tab=ttk.Notebook(frame)
# Add new tab
tab1=ttk.Frame(tab)
tab.add(tab1,text=' section in a publication or regular feature on radio or television dedicated to disseminating various types of information ')# Add a new tab to notebook
tab2=ttk.Frame(tab)
tab.add(tab2,text=' Comprehensive analysis of ')# Add a new tab to notebook
tab3=ttk.Frame(tab)
tab.add(tab3,text=' Technical analysis ')# Add a new tab to notebook
tab4=ttk.Frame(tab)
tab.add(tab4,text=' Write code ')# Add a new tab to notebook
tab5=ttk.Frame(tab)
tab.add(tab5,text=' Simulation back test ')# Add a new tab to notebook
tab6=ttk.Frame(tab)
tab.add(tab6,text=' Bicolor ')# Add a new tab to notebook
tab7=ttk.Frame(tab)
tab.add(tab7,text=' Big lotto ')# Add a new tab to notebook
tab.pack(expand=1,fill='both')
tab.select(tab4)# choice tab4
root.mainloop()

ttk.Treeview Control
import tkinter as tk
from tkinter import ttk
root=tk.Tk()
root.title('ttk.TreeView demonstration ')
root.geometry('600x500+200+200')
tree=ttk.Treeview(root,height=10)
#"" Represents the root node ,text Show text ,values Is a hidden value
a=tree.insert("",0," indicators ",text=" indicators ",values=("1"),open=True)
a1=tree.insert(a,0," Technical indicators ",text=" Technical indicators ",values=("2"))
a2=tree.insert(a,1," trading system ",text=" trading system ",values=("3"))
a3=tree.insert(a,2," Conditional stock selection ",text=" Conditional stock selection ",values=("4"))
a4=tree.insert(a,3,"K Line ",text="K Line ",values=("5"))
b=tree.insert("",1," Tools ",text=' Tools ',values=("6"),open=True)
b1=tree.insert(b,0," System settings ",text=' System settings ',values=("7"))
b2=tree.insert(b,0," Index ranking ",text=' Index ranking ',values=("8"))
tree.pack(fill=tk.X)
tree.selection_set(" indicators ")
#show Specifies the display of those element trees
tree2=ttk.Treeview(root,columns=('col1','col2','col3'),show="headings")
# Modify the options to make
tree2.column('col1',width=100,anchor='center')
tree2.column('col2',width=100,anchor='center')
tree2.column('col3',width=100,anchor='center')
# Modify the title option to specify the column
tree2.heading('col1',text=' Stock code ')
tree2.heading('col2',text=' date ')
tree2.heading('col3',text=' Time ')
def click(event):
item=tree2.selection()[0]
print('you click on',tree2.item(item,"values"))
for i in range(10):
tree2.insert("",i,values=('60007','2021 year 1 month 8 Japan ','11:1'+str(i)))
# Double click the left button to trigger the event
tree2.bind("<Double-1>",click)
tree2.pack(fill=tk.X)
root.mainloop()
#9,10


form Table geometry Manager
import tkinter as tk
from tkinter import ttk
from tkinter import tix
# Import tkinter Constant ,w
from tkinter.constants import *
root=tix.Tk()
width=300
height=200
x=150
y=150
root.geometry('{}x{}+{}+{}'.format(width,height,x,y))
root.title('tix Of form Layout ')
a=tk.Label(root,text='aaa',relief=tix.SUNKEN,bd=1)
# When right,bottom by none when , Control w Is the automatic width
a.form(top=50,left=50,right=None,bottom=None)
b=ttk.Label(root,text='bbb')
b.place(x=50,y=100)
c=tix.Label(root,text='ccc',relief=tix.SUNKEN,bd=1)
c.form(top='%30',left='%50')
# When right=-1 It means w To the right border of the parent control
d=tix.Label(root,text='ddd',relief=tix.SUNKEN,bd=1)
d.form(left='%50',top=c,bottom=-1)
root.mainloop()
#11

tix.Balloon Balloon window control
tix.Ballon Balloon controls can help other controls , When the user moves the cursor
To the window that is bound to the control , The screen displays a small pop-up window with a descriptive message .
import tkinter.tix as tix
from tkinter.constants import *
event=0
def Run(root):
balloon=DemoBalloon(root)
balloon.mainloop()
balloon.destroy()
class DemoBalloon:
def __init__(self,w):
self.root=w
self.exit=-1
# Bind system level events
z=w.winfo_toplevel()
z.wm_protocol("WM_DELETE_WINDOW",lambda self=self: self.quitcmd())
z.title('tix.balloon demonstration ')
status=tix.Label(w,width=40,relief=tix.SUNKEN,bd=1)
status.pack(side=tix.BOTTOM,fill=tix.Y,padx=1,pady=1)
# Set up two tix Button
button1=tix.Button(w,text=' close window ',command=self.quitcmd)
button2=tix.Button(w,text=' Destroy button ',command=w.destroy)
button1.pack(side=tix.TOP,expand=1)
button2.pack(side=tix.TOP,expand=1)
# establish tixballon
b=tix.Balloon(w,statusbar=status)
b.bind_widget(button1,balloonmsg=' close ',statusmsg=' Press this button , close window ')
b.bind_widget(button2,balloonmsg=' Delete ',statusmsg=' Press this button , Delete button ')
def quitcmd(self):
self.exit=0
def mainloop(self):
a=1
while self.exit<0 and a>0:
a=self.root.tk.dooneevent(event)
def destroy(self):
self.root.destroy()
if __name__=='__main__':
root=tix.Tk()
Run(root)
#12

tix.ButtonBox Button box control
tix.ButtonBox The button box control can add a button , Such as “OK”,“cancel” etc.
tix.combobox Combo box control
The user can select an option by chaining in the item sub component or selecting from the list box sub component .
tix.control Control window components
The user can adjust the value by pressing the up and down arrow buttons or directly entering the value , The new value will be checked against the user-defined upper and lower limits .
边栏推荐
- Latex combat notes 3- macro package and control commands
- C语言实现八种排序 - 归并排序
- 超标量处理器设计 姚永斌 第2章 Cache --2.3 小节摘录
- Uncover the secret of the popular app. Why is it so black
- Popular science | what are the types of NFT (Part 1)
- Top - K problem
- On the night of the joint commissioning, I beat up my colleagues
- 【学术相关】申请审核制下,到双一流大学读博的难度有多大?
- R language book learning 03 "in simple terms R language data analysis" - Chapter 7 linear regression model
- SVN本地部署server和cleint 并用阿里云盘自动备份
猜你喜欢

Add anti debugging function to game or code (application level)

5.学城项目 支付宝支付

Glory earbud 3 Pro with three global first strong breakdowns flagship earphone Market

R语言书籍学习03 《深入浅出R语言数据分析》-第十章 关联规则 第十一章 随机森林

Classes and objects (3)

206.反转链表

学习位段(1)

How to view the installation date of the win system

Collection of articles and literatures related to R language (continuously updated)

Matlab: solution of folder locking problem
随机推荐
C language to achieve eight sorts (2)
Matlab: solution of folder locking problem
189. rotation array
One question per day -- verifying palindrome string
Matplotlib和tkinter学习笔记(一)
机器学习之线性回归简单实例
Two methods to judge the storage of large and small end
实现栈和队列
[Yu Yue education] General English of Shenyang Institute of Engineering (4) reference materials
Huawei equipment configuration h-vpn
Latex combat notes 3- macro package and control commands
自定义实现offsetof
Static PVC with CEPH CSI
Players must read starfish NFT advanced introduction
使用VBScript读取网络的日志数据进行处理
科普 | NFT的类型有哪些(上)
Classes and objects (2)
Tkinter学习笔记(三)
快速排序的三种方法
Conception du Processeur superscalaire Yao yongbin chapitre 2 cache - - sous - section 2.4 extrait