Python implements vehicle Management (GUI) __python

Source: Internet
Author: User
Rethinking

This assignment I am the object-oriented programming, therefore did not consider very comprehensively, causes the programming process to appear a series of coding error, function variable name repetition and so on, this object-oriented programming benefit in the summer vacation completes the PHP+H5+CSS to complete the message board webpage, therefore the plan relatively quickly, The finished is also very timely.
In the future, when object-oriented programming to take into account the Split function function, the function is separated, otherwise it is only a false object-oriented.

Back

#-*-coding:utf-8-*-import OS import Os.path class Back (object): Def __init__ (self,num): self.result1= ' Self.rootdir= "/home/wangxinshuo/car" for Parent,dirnames,filenames in Os.walk (self.rootdir): fo R Num1 in Filenames:file=open ("/home/wangxinshuo/car/%s"%num1, "R") Line=file.readline (). s Plit () if (Len (line) >0): if (line[3]== "leased out"): self.result1+= (L Ine[0] + "" + line[1] + "" + line[2] + "" + line[3] + "" + line[4]+ ' \ n ') #print Li Ne[0] File.close () flag=0 line=[] self.result2= ' for Parent,dirnames,fil Enames in Os.walk (self.rootdir): For Num2 in Filenames:file=open ("/home/wangxinshuo/car/%s"%N
                    UM2, "R") Line=file.readline (). Split () if (Line[0]==num.encode (' Utf-8 ')):
               Flag=1     LINE[3] = "Not leased out" file.close () File = open ("/home/wangxinshuo/car/%s"% Num2, "
                W ") File.write (Line[0] +" "+ line[1] +" "+ line[2] +" "+ line[3] +" "+ line[4]
        File.close () if (Flag): self.result2+= "return success!" else:self.result2+= "Please check the license number" Def RETURN_RESULT1 (self): return self.result1 def RETURN_RESULT2 (self): return SELF.RESULT2

Back_window

#-*-Coding:utf-8-*-########################################################################### # # Python Code
Generated with Wxformbuilder (version Feb 2016) # # http://www.wxformbuilder.org/# # Please do ' not ' EDIT this file! ########################################################################### Import WX Import wx.xrc from back Import Back ########################################################################### # # Class MyFrame4 ################ ########################################################### class MyFrame5 (WX. Frame): Def __init__ (self, parent): WX. Frame.__init__ (self, parent, Id=wx.id_any, Title=wx. Emptystring, Pos=wx. Defaultposition, Size=wx. Size (618, 462), style=wx. Default_frame_style | Wx. Tab_traversal) self. Setsizehintssz (WX. DefaultSize, WX. defaultsize) bSizer16 = wx. Boxsizer (WX. VERTICAL) BSizer17 = wx. Boxsizer (WX. VERTICAL) Self.m_textctrl10 = wx. Textctrl (self, wx.id_any,Wx. Emptystring, WX. Defaultposition, WX. Size (MB), Style=wx.te_multiline | wx.te_readonly) Bsizer17.add (self.m_textctrl10, 0, WX. All, 5) bsizer16.add (bSizer17, 0, WX. EXPAND, 5) bSizer18 = WX. Boxsizer (WX. Horizontal) self.m_statictext11 = wx. Statictext (self, wx.id_any, u "Please enter the license plate number you want to return", WX. Defaultposition, WX. Size (0) self.m_staticText11.Wrap ( -1) bsizer18.add (self.m_statictext11, 0, WX. All, 5) Self.m_textctrl11 = WX. Textctrl (self, Wx.id_any, WX.) Emptystring, WX. Defaultposition, WX. Size (0) bsizer18.add (self.m_textctrl11, 0, WX. All, 5) bsizer16.add (bSizer18, 0, WX. EXPAND, 5) bSizer19 = WX. Boxsizer (WX. Horizontal) self.m_statictext12 = wx. Statictext (self, Wx.id_any, WX.) Emptystring, WX. Defaultposition, WX. Size (0), Self.m_staticText12.Wrap ( -1) bsizer19.add (self.m_statictext12, 0, WX. All, 5) Self.m_button4 = WX. button (self, wx.id_any, u "OK", wx. DefAultposition, WX. Size (m), 0 bsizer19.add (self.m_button4, 0, WX.) All, 5) Bsizer16.add (BSIZER19, 1, WX. EXPAND, 5) self. Setsizer (bSizer16) self. Layout () self. Centre (WX. BOTH) # Connect Events Self.m_button4. Bind (WX.
        Evt_button, Self.m_button4onbuttonclick) ################################################################ Back=back (' 0000 ') Self.m_textCtrl10.SetValue (BACK.RETURN_RESULT1 ()) def __del__ (self): Pass # Vi Rtual event handlers, overide them in your derived class Def m_button4onbuttonclick (Self, event): Result1=self . M_textctrl11.getvalue () back=back (RESULT1) result2=back.return_result2 () Self.m_textCtrl10.SetVal UE (RESULT2)

Scrap

#-*-Coding:utf-8-*-
import os
import Os.path
class Scrap (object):
    def __init__ (self,num):
        self.result= '
        self.rootdir= "/home/wangxinshuo/car" for
        parent,dirnames,filenames in Os.walk (self.rootdir ):
            for Num2 in filenames:
                file=open ("/home/wangxinshuo/car/%s"%num2, "r+")
                Line=file.readline (). Split (
                if (len (line) >0):
                    if (Line[0]==num.encode (' Utf-8 ')):
                        self.result+= "Scrap success!"
                        File.close ()
                        File = open ("/home/wangxinshuo/car/%s"% Num2, "W")
                        os.remove ("/home/wangxinshuo/car/%s"% NUM2)
                        File.close ()

    def return_result (self): return
        Self.result

Scrap_window

#-*-Coding:utf-8-*-########################################################################### # # Python Code
Generated with Wxformbuilder (version Feb 2016) # # http://www.wxformbuilder.org/# # Please do ' not ' EDIT this file! ########################################################################### Import WX Import WX.XRC from Scrap Import Scrap from check import Check ########################################################################### # # Class MyFrame3 ########################################################################### class MyFrame4 (WX. Frame): Def __init__ (self, parent): WX. Frame.__init__ (self, parent, Id=wx.id_any, Title=wx. Emptystring, Pos=wx. Defaultposition, Size=wx. Size (599, 380), style=wx. Default_frame_style | Wx. Tab_traversal) self. Setsizehintssz (WX. DefaultSize, WX. defaultsize) BSizer12 = wx. Boxsizer (WX. VERTICAL) BSizer13 = wx. Boxsizer (WX. Horizontal) Self.m_textctrl7 = wx.Textctrl (self, Wx.id_any, WX.) Emptystring, WX. Defaultposition, WX. Size (MB), Style=wx.te_multiline | wx.te_readonly) Bsizer13.add (self.m_textctrl7, 0, WX. All, 5) bsizer12.add (bSizer13, 0, WX. EXPAND, 5) BSizer14 = WX. Boxsizer (WX. Horizontal) Self.m_statictext9 = wx. Statictext (self, wx.id_any, u "Please enter the license plate of the car you want to scrap", WX. Defaultposition, WX. Size (0), Self.m_staticText9.Wrap ( -1) bsizer14.add (self.m_statictext9, 0, WX. All, 5) Self.m_textctrl8 = WX. Textctrl (self, Wx.id_any, WX.) Emptystring, WX. Defaultposition, WX. Size (0) bsizer14.add (self.m_textctrl8, 0, WX. All, 5) bsizer12.add (bSizer14, 0, WX. EXPAND, 5) BSizer15 = WX. Boxsizer (WX. Horizontal) self.m_statictext10 = wx. Statictext (self, Wx.id_any, WX.) Emptystring, WX. Defaultposition, WX. Size (0), Self.m_staticText10.Wrap ( -1) bsizer15.add (self.m_statictext10, 0, WX. All, 5) Self.m_button3 = WX. Button (self, wx.Id_any, U "OK", wx. Defaultposition, WX. Size (m), 0 bsizer15.add (self.m_button3, 0, WX.) All, 5) Bsizer12.add (BSIZER15, 1, WX. EXPAND, 5) self. Setsizer (BSizer12) self. Layout () self. Centre (WX. BOTH) # Connect Events Self.m_button3. Bind (WX.
        Evt_button, Self.m_button3onbuttonclick) ############################################# Check=Check () Self.m_textCtrl7.SetValue (Check.return_value ()) def __del__ (self): Pass # Virtual event handlers, ove Ride them in your derived class Def m_button3onbuttonclick (Self, event): Scrap=scrap (Self.m_textCtrl8.GetValue ()) Self.m_textCtrl7.SetValue (Scrap.return_result ())

Rent

#-*-coding:utf-8-*-import OS import Os.path class Rent (object): Def __init__ (self,num): self.rootdir= "/hom E/wangxinshuo/car "self.result1= '" self.result1+= "license plate number car name color status rent \ n" For Parent,dirnames, Filenames in Os.walk (Self.rootdir): For NUM1 in Filenames:file=open ("/home/wangxinshuo/car/%s "%num1, R") Words=file.readline (). Split () if (Len (Words) >=4): if (Wor ds[3]== "not leased out"): self.result1+= (words[0]+ "T" +words[1]+ ' \ t ' +words[2]+ ' \ t ' +words[3]+ ' \ t ') +word s[4]+ ' \ n ') file.close () ############################################ flag=0 line= [] self.result2= ' for parent,dirnames,filenames in Os.walk (self.rootdir): for Num2 in Filenam
                Es:file=open ("/home/wangxinshuo/car/%s"%num2, "R") Line=list (File.readline (). Split ()) if (Len (line)>=1): if (Line[0]==num.encode (' Utf-8 ')): Flag=1 Line
                        [3]= "Rent Out" File.close () File=open ("/home/wangxinshuo/car/%s"%num2, "W")
                        File.write (line[0]+ "+line[1]+" "+line[2]+" "+line[3]+" "+line[4")
        #print str (line[3]) else:self.result2+= "No car to Borrow" file.close ()
        if (Flag): self.result2+= "borrow the car success!" else:self.result2+= "Please check the entered license plate number" Def return_result1 (self): return self.result1 def return_resu LT2 (self): return SELF.RESULT2

Rent_window

#-*-Coding:utf-8-*-########################################################################### # # Python Code
Generated with Wxformbuilder (version Feb 2016) # # http://www.wxformbuilder.org/# # Please do ' not ' EDIT this file! ########################################################################### Import WX Import WX.XRC from Rent Import Rent ########################################################################### # # Class MyFrame2 ################ ########################################################### class MyFrame3 (WX. Frame): Def __init__ (self, parent): WX. Frame.__init__ (self, parent, Id=wx.id_any, Title=wx. Emptystring, Pos=wx. Defaultposition, Size=wx. Size (604, 341), style=wx. Default_frame_style | Wx. Tab_traversal) self. Setsizehintssz (WX. DefaultSize, WX. defaultsize) BSizer7 = wx. Boxsizer (WX. VERTICAL) BSizer10 = wx. Boxsizer (WX. VERTICAL) self.m_textctrl6 = wx. Textctrl (self, wx.id_any, WX. Emptystring, WX. Defaultposition, WX. Size (MB), Style=wx.te_multiline | wx.te_readonly) Bsizer10.add (self.m_textctrl6, 0, WX. All, 5) bsizer7.add (bSizer10, 0, WX. EXPAND, 5) BSizer8 = WX. Boxsizer (WX. Horizontal) Self.m_statictext6 = wx. Statictext (self, wx.id_any, u "Please enter the license plate of the car you want to rent", WX. Defaultposition, WX. Size (0) self.m_staticText6.Wrap ( -1) bsizer8.add (self.m_statictext6, 0, WX. All, 5) Self.m_textctrl5 = WX. Textctrl (self, Wx.id_any, WX.) Emptystring, WX. Defaultposition, WX. Size (0) bsizer8.add (self.m_textctrl5, 0, WX. All, 5) bsizer7.add (BSizer8, 0, WX. EXPAND, 5) BSizer9 = WX. Boxsizer (WX. Horizontal) Self.m_statictext7 = wx. Statictext (self, Wx.id_any, WX.) Emptystring, WX. Defaultposition, WX. Size (230, 0) self.m_staticText7.Wrap ( -1) bsizer9.add (self.m_statictext7, 0, WX. All, 5) Self.m_button2 = WX. button (self, wx.id_any, u "OK", wx. Defaultposition, WX. SIze (M), 0) bsizer9.add (self.m_button2, 0, WX. All, 5) bsizer7.add (BSizer9, 0, WX. EXPAND, 5) self. Setsizer (BSizer7) self. Layout () self. Centre (WX. BOTH) # Connect Events Self.m_button2. Bind (WX. Evt_button, Self.m_button2onbuttonclick) ############################################################## R Ent=rent (' 0000 ') Self.m_textCtrl6.SetValue (RENT.RETURN_RESULT1 ()) def __del__ (self): Pass # Virt UAL event handlers, overide them in your derived class Def m_button2onbuttonclick (Self, event): Result=self.m_ Textctrl5.getvalue () rent=rent (Result) Self.m_textCtrl6.SetValue (RENT.RETURN_RESULT2 ())

Check

#-*-Coding:utf-8-*-
import os
import Os.path
class Check (object):
    def __init__ (self):
        Self.rootdir= "/home/wangxinshuo/car"
        self.result= '
        self.result+= "license plate    name    color    status    rent \ n" For
        Parent,dirnames,filenames in Os.walk (self.rootdir): for
            Num in filenames:
                file=open ("/home/ wangxinshuo/car/%s "%num, RB")
                self.result+= (file.readline () + ' \ n ')
                File.close ()
    def return_value ( Self): return
        self.result
#check =check ()

Save

#-*-Coding:utf-8-*-class Save (object): Def __init__ (Self,num,type,colour,money): #Money =str (Money) File=open ("/home/wangxinshuo/car/%s"%num, "WB") File.write ((Num + ""). Encode (' Utf-8 ') ) File.write ((Type + ""). Encode (' Utf-8 ')) File.write ((Colour + ""). Encode (' Utf-8 ')) FILE.W Rite (U "not leased" + U "). Encode (' Utf-8 ')) File.write ((Money +" "). Encode (' Utf-8 ')) File.close () 

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.