Python3 tkinter Desktop Software Tutorial

Source: Internet
Author: User

"""the Brid layout""" fromTkinterImport*ImportTkinter.filedialog fromTkinterImportScrolledtext#importing modules for scrolling text boxes fromTkinter.messageboxImport*Import Timeclasstkmain (): Xin=Tk () path=Stringvar ()#Path Assignment    defSelectpath (self): Path_=tkinter.filedialog.askopenfilename () self.path.set (path_)#Desktop    defViews (Self): Self.xin.geometry ('400x400')#Specify the main frame body sizeSelf.xin.title (' name')#Title nameLabel (Self.xin, text="numbering"). Grid (Row=1, column=0, sticky=E) self.number_id=Tkinter. Stringvar () Self.number_id_entry=Tkinter. Entry (self.xin) self.number_id_entry["textvariable"] =self.number_id self.number_id_entry.grid (Row=1, Column=1, sticky=E) Label (self.xin, Text="file"). Grid (Row=3, column=0, sticky=E)#Entry (self.xin, stat= "ReadOnly", Textvariable=self.path). Grid (Row=3, Column=1, sticky=e)Self.xls_path =Tkinter. Stringvar () Self.xls_path_entry= Tkinter. Entry (self.xin,stat="ReadOnly") self.xls_path_entry["textvariable"] =Self.path self.xls_path_entry.grid (Row=3, Column=1, sticky=E) Button (self.xin, Text="Select", Command=self.selectpath). Grid (Row=3, column=2, sticky=E)#Occupy positionLabel (Self.xin, text=""). Grid (Row=5, column=0) Button (self.xin, Text="Run", command=self.validate). Grid (Row=6, Column=1, sticky=E) Button (self.xin, Text="Stop"). Grid (Row=6, column=2, sticky=E)#Occupy positionLabel (Self.xin, text=""). Grid (Row=7, column=0)#Scrolling text BoxSCROLW = 50#set the length of a text boxSCROLH = 18#set the height of a text boxSelf.text = Scrolledtext. Scrolledtext (Self.xin, WIDTH=SCROLW, Height=scrolh, wrap=Tkinter. WORD) Self.text.grid (Row=10, Columnspan=8, sticky=Tkinter. E)Pass    #Verifying Events    defValidate (self): Is_validata=True; Try: Number_id_val=Int (self.number_id.get ()); Xls_path_val=Self.path.get ()ifXls_path_val = ="": Is_validata=FALSEifNumber_id_val < 1: Is_validata=FALSEexcept: Is_validata=FALSEifIs_validata = =FALSE: forIinchRange (0,100): Self.text.see (END)#always see the last position of text ~Time.sleep (0.5) Self.text.insert ('End',"verification does not pass, please check!"+ STR (i) +"\ r \ n") self.text.update () #一直更新输出ifi = = 50 :                     Break            Print("verification does not pass!")        Pass    defapp (self): Self.views () Mainloop ()defMain (): Tkmain (). App (); Pass;if __name__=="__main__": Main ()

Python3 tkinter Desktop Software Tutorial

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.