1 #MessageBox: Message Bullet box2 #constantly click the button to toggle various pop-up windows3 ImportTkinter as TK4 fromTkinterImportMessageBox5 fromTk_center_winImportSet_win_center6 7Root =tk. Tk ()8Root.title ('message Box')9Root.geometry ('190x80+300+300')#Setting the window size and positionTen #Set_win_center (Root, 190, 80) # Set the window size and center the display Onen =0 AStr_var =tk. Stringvar () -Str_var.set ('Askokcancel') - the - defcmd (): - " "Bullet Box Tips" " - GlobalN + GlobalStr_var -n + = 1 + ifn = = 1: AR = Messagebox.askokcancel ('message Box','Askokcancel') at Print('Askokcancel:', R) -Str_var.set ('askquestion') - elifn = = 2: -R = Messagebox.askquestion ('message Box','askquestion') - Print('askquestion:', R) -Str_var.set ('AskYesNo') in elifn = = 3: -R = Messagebox.askyesno ('message Box','AskYesNo') to Print('AskYesNo:', R) +Str_var.set ('Askretrycancel') - elifn = = 4: theR = Messagebox.askretrycancel ('message Box','Askretrycancel') * Print('Askretrycancel:', R) $Str_var.set ('ShowError')Panax Notoginseng elifn = = 5: -R = Messagebox.showerror ('message Box','ShowError') the Print('ShowError:', R) +Str_var.set ('Showinfo') A elifn = = 6: theR = Messagebox.showinfo ('message Box','Showinfo') + Print('Showinfo:', R) -Str_var.set ('showwarning') $ Else: $R = messagebox.showwarning ('message Box','showwarning') - Print('showwarning:', R) -Str_var.set ('Askokcancel') then =0 - Wuyi thelabel = Tk. Label (Root, text='constantly click the button to toggle various pop-up windows', font='Song Body -14', pady=8) - Label.grid () Wubtn = Tk. Button (Root, width=' the', Textvariable=str_var, command=cmd) - Btn.grid () About $Root.mainloop ()
:
Python's tkinter Use-message bullet box