python GUI寫圖書館管理系統

'''
GUI圖書館管理系統
@author:Arsenal_Ramsey
@time:2019/5/31
@進度:。。。
'''
import wx
studentDatabase=dict()  
bookDatabase=dict()   
borrowDatabase=dict()    

class STUDENTADD(wx.Frame):
    def __init__(self,superion):
        wx.Frame.__init__(self,parent=superion,title="添加學生",size=(400,400))
        panel=wx.Panel(self)
        image_file = 'image.jpg'
        to_bmp_image = wx.Image(image_file, wx.BITMAP_TYPE_ANY).ConvertToBitmap() 
        self.bitmap = wx.StaticBitmap(self, -1, to_bmp_image, (0, 0))  
        wx.StaticText(self.bitmap,-1,"學號",pos=(10,50),style=wx.ALIGN_RIGHT)
        wx.StaticText(self.bitmap,-1,"姓名",pos=(10,100),style=wx.ALIGN_RIGHT)
        self.SID=wx.TextCtrl(self.bitmap,-1,pos=(100,50),size=(160,20))
        self.SNAM=wx.TextCtrl(self.bitmap,pos=(100,100),size=(160,20))
        self.buttonOK=wx.Button(parent=self.bitmap,label='OK',pos=(150,150))
        self.Bind(wx.EVT_BUTTON,self.OnbuttonOK,self.buttonOK)
        self.buttonQuit=wx.Button(parent=self.bitmap,label='退出',pos=(150,200))
        self.Bind(wx.EVT_BUTTON,self.OnbuttonQuit,self.buttonQuit)
    def OnbuttonOK(self,event):
        '''OK'''
        StudentId=self.SID.GetValue()
        StudentName=self.SNAM.GetValue()
        studentDatabase.update({StudentId:StudentName})

    def OnbuttonQuit(self,event):
        '''退出事件'''
        self.Close(True)

class STUDENTDEL(wx.Frame):
    def __init__(self,superion):
        wx.Frame.__init__(self,parent=superion,title="刪除學生",size=(400,400))
        panel=wx.Panel(self)
        image_file = 'image.jpg'
        to_bmp_image = wx.Image(image_file, wx.BITMAP_TYPE_ANY).ConvertToBitmap() 
        self.bitmap = wx.StaticBitmap(self, -1, to_bmp_image, (0, 0)) 
        label1=wx.StaticText(self.bitmap,-1,"學號",pos=(10,50),style=wx.ALIGN_RIGHT)
        self.SID=wx.TextCtrl(self.bitmap,-1,pos=(100,50),size=(160,20))
        self.buttonOK=wx.Button(parent=self.bitmap,label='OK',pos=(150,150))
        self.Bind(wx.EVT_BUTTON,self.OnbuttonOK,self.buttonOK)
        self.buttonQuit=wx.Button(parent=self.bitmap,label='退出',pos=(150,200))
        self.Bind(wx.EVT_BUTTON,self.OnbuttonQuit,self.buttonQuit)
    def OnbuttonOK(self,event):
        '''OK'''
        StudentId=self.SID.GetValue()
        studentDatabase.pop(StudentId)

    def OnbuttonQuit(self,event):
        '''退出事件'''
        self.Close(True)

class STUDENTSER(wx.Frame):
    def __init__(self,superion):
        wx.Frame.__init__(self,parent=superion,title="學生數據庫",size=(400,400))
        panel=wx.Panel(self)
        image_file = 'image.jpg'
        to_bmp_image = wx.Image(image_file, wx.BITMAP_TYPE_ANY).ConvertToBitmap() 
        self.bitmap = wx.StaticBitmap(self, -1, to_bmp_image, (0, 0)) 
        self.result=wx.StaticText(self.bitmap,-1,'查詢到的信息',pos=(150,120))
        self.buttonOK=wx.Button(parent=self.bitmap,label='OK',pos=(150,150))
        self.Bind(wx.EVT_BUTTON,self.OnbuttonOK,self.buttonOK)
        self.buttonQuit=wx.Button(parent=self.bitmap,label='退出',pos=(150,200))
        self.Bind(wx.EVT_BUTTON,self.OnbuttonQuit,self.buttonQuit)
        
    def OnbuttonOK(self,event):
        '''OK'''
        a="{學號:姓名}:"+str(studentDatabase)
        self.result.SetLabel(a)
        

    def OnbuttonQuit(self,event):
        '''退出事件'''
        self.Close(True)

class STUDENT(wx.Frame):
    def __init__(self,superion):
        wx.Frame.__init__(self,parent=superion,title="學生信息管理",size=(400,400))
        panel=wx.Panel(self)
        image_file = 'image.jpg'
        to_bmp_image = wx.Image(image_file, wx.BITMAP_TYPE_ANY).ConvertToBitmap() 
        self.bitmap = wx.StaticBitmap(self, -1, to_bmp_image, (0, 0)) 
        self.buttonAdd=wx.Button(parent=self.bitmap,label='添加',pos=(150,50))
        self.Bind(wx.EVT_BUTTON,self.OnbuttonAdd,self.buttonAdd)
        self.buttonDel=wx.Button(parent=self.bitmap,label='刪除',pos=(150,100))
        self.Bind(wx.EVT_BUTTON,self.OnbuttonDel,self.buttonDel)
        self.buttonSer=wx.Button(parent=self.bitmap,label='查詢',pos=(150,150))
        self.Bind(wx.EVT_BUTTON,self.OnbuttonSer,self.buttonSer)
        self.buttonQuit=wx.Button(parent=self.bitmap,label='退出',pos=(150,200))
        self.Bind(wx.EVT_BUTTON,self.OnbuttonQuit,self.buttonQuit)
    def OnbuttonAdd(self,event):
        '''添加學生事件'''
        app=wx.App()
        frame=STUDENTADD(None)
        frame.Show()
        app.MainLoop()
    def OnbuttonDel(self,event):
        '''刪除學生事件'''
        app=wx.App()
        frame=STUDENTDEL(None)
        frame.Show()
        app.MainLoop()
    def OnbuttonSer(self,event):
        app=wx.App()
        frame=STUDENTSER(None)
        frame.Show()
        app.MainLoop()
    def OnbuttonQuit(self,event):
        '''退出事件'''
        self.Close(True)

class BOOKADD(wx.Frame):
    def __init__(self,superion):
        wx.Frame.__init__(self,parent=superion,title="添加圖書",size=(400,400))
        panel=wx.Panel(self)
        image_file = 'image.jpg'
        to_bmp_image = wx.Image(image_file, wx.BITMAP_TYPE_ANY).ConvertToBitmap() 
        self.bitmap = wx.StaticBitmap(self, -1, to_bmp_image, (0, 0)) 
        wx.StaticText(self.bitmap,-1,"ISDN",pos=(10,50),style=wx.ALIGN_RIGHT)
        wx.StaticText(self.bitmap,-1,"書名",pos=(10,100),style=wx.ALIGN_RIGHT)
        self.BID=wx.TextCtrl(self.bitmap,-1,pos=(100,50),size=(160,20))
        self.BNAM=wx.TextCtrl(self.bitmap,pos=(100,100),size=(160,20))
        self.buttonOK=wx.Button(parent=self.bitmap,label='OK',pos=(150,150))
        self.Bind(wx.EVT_BUTTON,self.OnbuttonOK,self.buttonOK)
        self.buttonQuit=wx.Button(parent=self.bitmap,label='退出',pos=(150,200))
        self.Bind(wx.EVT_BUTTON,self.OnbuttonQuit,self.buttonQuit)
    def OnbuttonOK(self,event):
        '''OK'''
        BookId=self.BID.GetValue()
        BookName=self.BNAM.GetValue()
        bookDatabase.update({BookId:BookName})

    def OnbuttonQuit(self,event):
        '''退出事件'''
        self.Close(True)

class BOOKDEL(wx.Frame):
    def __init__(self,superion):
        wx.Frame.__init__(self,parent=superion,title="刪除圖書",size=(400,400))
        panel=wx.Panel(self)
        image_file = 'image.jpg'
        to_bmp_image = wx.Image(image_file, wx.BITMAP_TYPE_ANY).ConvertToBitmap() 
        self.bitmap = wx.StaticBitmap(self, -1, to_bmp_image, (0, 0))
        wx.StaticText(self.bitmap,-1,"ISDN",pos=(10,50),style=wx.ALIGN_RIGHT)
        self.BID=wx.TextCtrl(self.bitmap,-1,pos=(100,50),size=(160,20))
        self.buttonOK=wx.Button(parent=self.bitmap,label='OK',pos=(150,150))
        self.Bind(wx.EVT_BUTTON,self.OnbuttonOK,self.buttonOK)
        self.buttonQuit=wx.Button(parent=self.bitmap,label='退出',pos=(150,200))
        self.Bind(wx.EVT_BUTTON,self.OnbuttonQuit,self.buttonQuit)
    def OnbuttonOK(self,event):
        '''OK'''
        BookId=self.BID.GetValue()
        bookDatabase.pop(BookId)
    def OnbuttonQuit(self,event):
        '''退出事件'''
        self.Close(True)

class BOOKSER(wx.Frame):
    def __init__(self,superion):
        wx.Frame.__init__(self,parent=superion,title="圖書數據庫",size=(400,400))
        panel=wx.Panel(self)
        image_file = 'image.jpg'
        to_bmp_image = wx.Image(image_file, wx.BITMAP_TYPE_ANY).ConvertToBitmap() 
        self.bitmap = wx.StaticBitmap(self, -1, to_bmp_image, (0, 0)) 
        self.result=wx.StaticText(self.bitmap,-1,'查詢到的信息',pos=(150,120))
        self.buttonOK=wx.Button(parent=self.bitmap,label='OK',pos=(150,150))
        self.Bind(wx.EVT_BUTTON,self.OnbuttonOK,self.buttonOK)
        self.buttonQuit=wx.Button(parent=self.bitmap,label='退出',pos=(150,200))
        self.Bind(wx.EVT_BUTTON,self.OnbuttonQuit,self.buttonQuit)
        
    def OnbuttonOK(self,event):
        '''OK'''
        a="{ISDN:書名}:"+str(bookDatabase)
        self.result.SetLabel(a)
    def OnbuttonQuit(self,event):
        self.Close(True)

class BOOK(wx.Frame):
    def __init__(self,superion):
        wx.Frame.__init__(self,parent=superion,title="圖書信息管理",size=(400,400))
        panel=wx.Panel(self)
        image_file = 'image.jpg'
        to_bmp_image = wx.Image(image_file, wx.BITMAP_TYPE_ANY).ConvertToBitmap() 
        self.bitmap = wx.StaticBitmap(self, -1, to_bmp_image, (0, 0))
        self.buttonAdd=wx.Button(parent=self.bitmap,label='添加',pos=(150,50))
        self.Bind(wx.EVT_BUTTON,self.OnbookAdd,self.buttonAdd)
        self.buttonDel=wx.Button(parent=self.bitmap,label='刪除',pos=(150,100))
        self.Bind(wx.EVT_BUTTON,self.OnbookDel,self.buttonDel)
        self.buttonSer=wx.Button(parent=self.bitmap,label='查詢',pos=(150,150))
        self.Bind(wx.EVT_BUTTON,self.OnbuttonSer,self.buttonSer)
        self.buttonQuit=wx.Button(parent=self.bitmap,label='退出',pos=(150,200))
        self.Bind(wx.EVT_BUTTON,self.OnbuttonQuit,self.buttonQuit)
    def OnbookAdd(self,event):
        '''添加圖書事件'''
        app=wx.App()
        frame=BOOKADD(None)
        frame.Show()
        app.MainLoop()
    def OnbookDel(self,event):
        '''刪除圖書事件'''
        app=wx.App()
        frame=BOOKDEL(None)
        frame.Show()
        app.MainLoop()
    def OnbuttonSer(self,event):
        app=wx.App()
        frame=BOOKSER(None)
        frame.Show()
        app.MainLoop()
    def OnbuttonQuit(self,event):
        '''退出事件'''
        self.Close(True)

class BORROW(wx.Frame):
    def __init__(self,superion):
        wx.Frame.__init__(self,parent=superion,title="借閱圖書",size=(400,400))
        panel=wx.Panel(self)
        image_file = 'image.jpg'
        to_bmp_image = wx.Image(image_file, wx.BITMAP_TYPE_ANY).ConvertToBitmap() 
        self.bitmap = wx.StaticBitmap(self, -1, to_bmp_image, (0, 0))
        wx.StaticText(self.bitmap,-1,'學號',pos=(30,20),style=wx.ALIGN_RIGHT)
        wx.StaticText(self.bitmap,-1,'ISDN',pos=(30,50),style=wx.ALIGN_RIGHT)
        wx.StaticText(self.bitmap,-1,'書名',pos=(30,80),style=wx.ALIGN_RIGHT)
        wx.StaticText(self.bitmap,-1,'天數',pos=(30,120),style=wx.ALIGN_RIGHT)
        self.SID=wx.TextCtrl(self.bitmap,-1,pos=(90,20),size=(160,20))
        self.ISDN=wx.TextCtrl(self.bitmap,pos=(90,50),size=(160,20))
        self.BNAME=wx.TextCtrl(self.bitmap,pos=(90,80),size=(160,20))
        self.DAYS=wx.TextCtrl(self.bitmap,pos=(90,120),size=(160,20))
        self.buttonOK=wx.Button(parent=self.bitmap,label='OK',pos=(150,150))
        self.Bind(wx.EVT_BUTTON,self.OnbookOK,self.buttonOK)
        self.buttonQuit=wx.Button(parent=self.bitmap,label='退出',pos=(150,200))
        self.Bind(wx.EVT_BUTTON,self.OnbuttonQuit,self.buttonQuit)
    def OnbookOK(self,event):
        StudentId=self.SID.GetValue()
        Isdn=self.ISDN.GetValue()
        BookName=self.BNAME.GetValue()
        Days=self.DAYS.GetValue()
        borrowDatabase.update({StudentId:(Isdn,BookName,Days)})
    def OnbuttonQuit(self,event):
        '''退出事件'''
        self.Close(True)

class RETURN(wx.Frame):
    def __init__(self,superion):
        wx.Frame.__init__(self,parent=superion,title="歸還圖書",size=(400,400))
        panel=wx.Panel(self)
        image_file = 'image.jpg'
        to_bmp_image = wx.Image(image_file, wx.BITMAP_TYPE_ANY).ConvertToBitmap() 
        self.bitmap = wx.StaticBitmap(self, -1, to_bmp_image, (0, 0))
        wx.StaticText(self.bitmap,-1,'學號',pos=(30,20),style=wx.ALIGN_RIGHT)
        wx.StaticText(self.bitmap,-1,'ISDN',pos=(30,50),style=wx.ALIGN_RIGHT)
        wx.StaticText(self.bitmap,-1,'書名',pos=(30,80),style=wx.ALIGN_RIGHT)
        self.SID=wx.TextCtrl(self.bitmap,-1,pos=(90,20),size=(160,20))
        self.ISDN=wx.TextCtrl(self.bitmap,pos=(90,50),size=(160,20))
        self.BNAME=wx.TextCtrl(self.bitmap,pos=(90,80),size=(160,20))
        self.buttonOK=wx.Button(parent=self.bitmap,label='OK',pos=(150,150))
        self.Bind(wx.EVT_BUTTON,self.OnbookOK,self.buttonOK)
        self.buttonQuit=wx.Button(parent=self.bitmap,label='退出',pos=(150,200))
        self.Bind(wx.EVT_BUTTON,self.OnbuttonQuit,self.buttonQuit)
    def OnbookOK(self,event):
        StudentId=self.SID.GetValue()
        Isdn=self.ISDN.GetValue()
        BookName=self.BNAME.GetValue()
        borrowDatabase.pop(StudentId)
    def OnbuttonQuit(self,event):
        '''退出事件'''
        self.Close(True)

class SEARCH(wx.Frame):
    def __init__(self,superion):
        wx.Frame.__init__(self,parent=superion,title='查詢',size=(400,400))
        panel=wx.Panel(self)
        image_file = 'image.jpg'
        to_bmp_image = wx.Image(image_file, wx.BITMAP_TYPE_ANY).ConvertToBitmap() 
        self.bitmap = wx.StaticBitmap(self, -1, to_bmp_image, (0, 0))
        wx.StaticText(self.bitmap,-1,'請輸入你要查詢的學生的學號:',pos=(50,50))
        self.SID=wx.TextCtrl(self.bitmap,-1,pos=(60,80),size=(160,20))
        self.result=wx.StaticText(self.bitmap,-1,'查詢到的借閱信息',pos=(50,120))
        self.buttonOk=wx.Button(parent=self.bitmap,label='確定',pos=(150,150))
        self.Bind(wx.EVT_BUTTON,self.OnbuttonOK,self.buttonOk)
        self.buttonQuit=wx.Button(parent=self.bitmap,label='退出',pos=(150,200))
        self.Bind(wx.EVT_BUTTON,self.OnbuttonQuit,self.buttonQuit)
    def OnbuttonOK(self,event):
        StudentId=self.SID.GetValue()
        for key in borrowDatabase.keys():
            if StudentId in key:
                a=str(borrowDatabase.get(StudentId))
                self.result.SetLabel(a)
            else:
                self.result.SetLabel('Not Found!!!')

    def OnbuttonQuit(self,event):
        self.Close(True)

class BORROW_RETURN(wx.Frame):
    def __init__(self,superion):
        wx.Frame.__init__(self,parent=superion,title="借閱信息管理",size=(400,400))
        panel=wx.Panel(self)
        image_file = 'image.jpg'
        to_bmp_image = wx.Image(image_file, wx.BITMAP_TYPE_ANY).ConvertToBitmap() 
        self.bitmap = wx.StaticBitmap(self, -1, to_bmp_image, (0, 0))
        self.buttonBookBorrow=wx.Button(parent=self.bitmap,label='借書',pos=(150,50))
        self.Bind(wx.EVT_BUTTON,self.OnbuttonBookBorrow,self.buttonBookBorrow)
        self.buttonBookReturn=wx.Button(parent=self.bitmap,label='還書',pos=(150,100))
        self.Bind(wx.EVT_BUTTON,self.OnbuttonBookReturn,self.buttonBookReturn)
        self.buttonSearch=wx.Button(parent=self.bitmap,label='查詢',pos=(150,150))
        self.Bind(wx.EVT_BUTTON,self.OnbuttonSearh,self.buttonSearch)
        self.buttonQuit=wx.Button(parent=self.bitmap,label='退出',pos=(150,200))
        self.Bind(wx.EVT_BUTTON,self.OnbuttonQuit,self.buttonQuit)
    def OnbuttonBookBorrow(self,event):
        '''借書事件'''
        app=wx.App()
        frame=BORROW(None)
        frame.Show()
        app.MainLoop()
    def OnbuttonBookReturn(self,event):
        '''還書事件'''
        app=wx.App()
        frame=RETURN(None)
        frame.Show()
        app.MainLoop()
    def OnbuttonSearh(self,event):
        '''查詢事件'''
        app=wx.App()
        frame=SEARCH(None)
        frame.Show()
        app.MainLoop()
    def OnbuttonQuit(self,event):
        '''退出事件'''
        self.Close(True)

class MANGER(wx.Frame):
    def __init__(self,superion):
        wx.Frame.__init__(self,parent=superion,title="圖書館管理系統",size=(400,400))
        panel=wx.Panel(self)
        image_file = 'image.jpg'
        to_bmp_image = wx.Image(image_file, wx.BITMAP_TYPE_ANY).ConvertToBitmap() 
        self.bitmap = wx.StaticBitmap(self, -1, to_bmp_image, (0, 0))
        self.buttonStudent = wx.Button(parent=self.bitmap, label='學生信息管理',pos=(150,50))
        self.Bind(wx.EVT_BUTTON, self.OnButtonStudent, self.buttonStudent)
        self.buttonBook = wx.Button(parent=self.bitmap, label='圖書信息管理',pos=(150,100))
        self.Bind(wx.EVT_BUTTON, self.OnButtonBook, self.buttonBook)
        self.buttonBorrow = wx.Button(parent=self.bitmap, label='借閱信息管理',pos=(150,150))
        self.Bind(wx.EVT_BUTTON, self.OnButtonBorrow, self.buttonBorrow)
        self.buttonQuit=wx.Button(parent=self.bitmap,label='退出',pos=(150,200))
        self.Bind(wx.EVT_BUTTON,self.OnbuttonQuit,self.buttonQuit)

    def OnButtonStudent(self,event):
        '''學生信息管理事件'''
        app=wx.App()
        frame=STUDENT(None)
        frame.Show()
        app.MainLoop()

    def OnButtonBook(self,event):
        '''圖書信息管理事件'''
        app=wx.App()
        frame=BOOK(None)
        frame.Show()
        app.MainLoop()
        pass
    def OnButtonBorrow(self,event):
        app=wx.App()
        frame=BORROW_RETURN(None)
        frame.Show()
        app.MainLoop()
        '''借閱關係事件'''
        pass
    def OnbuttonQuit(self,event):
        '''退出事件'''
        self.Close(True)

class LOGIN(wx.Frame):
    def __init__(self,superion):
            wx.Frame.__init__(self,parent=superion,title="登錄",size=(400,400))
            panel=wx.Panel(self)
            image_file = 'image.jpg'
            to_bmp_image = wx.Image(image_file, wx.BITMAP_TYPE_ANY).ConvertToBitmap() 
            self.bitmap = wx.StaticBitmap(self, -1, to_bmp_image, (0, 0)) 
            image_width = to_bmp_image.GetWidth() 
            image_height = to_bmp_image.GetHeight()
            wx.StaticText(self.bitmap,-1,'賬號:',pos=(20,50),style=wx.ALIGN_RIGHT)
            wx.StaticText(self.bitmap,-1,'密碼:',pos=(20,100),style=wx.ALIGN_RIGHT)
            self.username=wx.TextCtrl(self.bitmap,-1,pos=(70,50),size=(200,20))
            self.password=wx.TextCtrl(self.bitmap,pos=(70,100),size=(200,20),style=wx.TE_PASSWORD)
            self.buttonOK = wx.Button(parent=self.bitmap, label='登錄', pos=(150,150))
            self.Bind(wx.EVT_BUTTON, self.OnButtonCheck, self.buttonOK)
            self.buttonRes = wx.Button(parent=self.bitmap, label='註冊', pos=(150,200))
            self.Bind(wx.EVT_BUTTON, self.OnButtonRes, self.buttonRes)

    def OnButtonCheck(self, event):
            user=self.username.GetValue()
            psw=self.password.GetValue()
            if user == '20177710746' and psw == '20177710746':
                app=wx.App()
                fram=MANGER(None)
                fram.Show()
                app.MainLoop()
            else:
                wx.MessageBox('你輸入的賬號或密碼有誤!')
    def OnButtonRes(self,event):
            wx.MessageBox("嘿嘿告訴你個祕密---賬號:20177710746 密碼:20177710746")

if __name__ == '__main__':
    app=wx.App()
    fram=LOGIN(None)
    fram.Show()
    app.MainLoop()

登陸界面 賬號20177710746,密碼20177710746:

學生信息管理:

 

圖書信息管理系統:

借閱信息管理系統:

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章