messages (message)
Message controls provide a way to display multiple lines of text, and you can set the font and background colors
Example:
From tkinter Import *
root=tk ()
root.title ("top") message
(root,text= ' Your can record your wonderful-thing, Can record your wonderful thing ', \
bg= ' Blue ', fg= ' ivory ', Relief=groove). Pack (padx=10,pady=10)
Root.mainloop ()
Results:
list (ListBox)
A list box component is a list of options from which a user can select an option
Example:
From tkinter Import *
root=tk ()
root.title ()
l=listbox (root,width=15)
l.pack () for
item in [' Apple ', ' orange ', ' peach ', ' banana ', ' melon ':
l.insert (End,item)
Root.mainloop ()
Results:
scroll bar (Scrollbar)
The scrollbar component can be added to any one component, and some components will automatically add scrollbars when the interface is not displayed, but you can use the ScrollBar component to control the scroll bar
Example:
From tkinter Import *
root=tk ()
root.title (' top ')
L=listbox (root,height=6,width=15)
scroll= Scrollbar (Root,command=l.yview)
l.configure (yscrollcommand=scroll.set)
l.pack (side=left)
Scroll.pack (side=right,fill=y) for
item in range:
l.insert (End,item)
Root.mainloop ()
Results:
message box (MessageBox)
The message window is used to pop-up the alert box like a user warning, or to let the user choose what to do next, the message box includes many types, long with info, warning, error, Yesno, Okcancel, and so on, including different icons, buttons, and pop-up prompts.
Example:
Import Tkinter as TK import Tkmessagebox as MsgBox def btn1_clicked (): Msgbox.showinfo ("info", "Showinfo test.")
Def btn2_clicked (): msgbox.showwarning ("Warning", "showwarning test.")
Def btn3_clicked (): Msgbox.showerror ("Error", "ShowError test.")
Def btn4_clicked (): Msgbox.askquestion ("question", "askquestion test.")
Def btn5_clicked (): Msgbox.askyesno ("Yesno", "AskYesNo test.")
Def btn6_clicked (): Msgbox.askokcancel ("Okcancel", "Askcancel test.")
Def btn7_clicked (): Msgbox.askretrycancel ("Retry", "Askretrycancel test.") Root=tk. Tk () root.title ("Msgbox test") btn1=tk. Button (root,text= "Showinfo", command=btn1_clicked) Btn1.pack (FILL=TK. X) btn2=tk. Button (root,text= "showwarning", command=btn2_clicked) Btn2.pack (FILL=TK. X) btn3=tk. Button (root,text= "ShowError", command=btn3_clicked) Btn3.pack (FILL=TK. X) btn4=tk. Button (root,text= "Showaskquestion", command=btn4_clicked) Btn4.pack (FILL=TK. X) btn5=tk. Button (root,text= "AskYesNo", command=btn5_clicked) Btn5.pack (FILL=TK. X) btn6=tk. Button (root,text= "Showokcancel", command=btn6_clicked) Btn6.pack (FILL=TK. X) btn7=tk. Button (root,text= "Showretrycancel", command=btn7_clicked) Btn7.pack (FILL=TK.
X) Root.mainloop ()
Result:
Click Related action:
Continue:
Continue: