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:

python GUI写图书馆管理系统_第1张图片

学生信息管理:

python GUI写图书馆管理系统_第2张图片

 

python GUI写图书馆管理系统_第3张图片

python GUI写图书馆管理系统_第4张图片

图书信息管理系统:

python GUI写图书馆管理系统_第5张图片

python GUI写图书馆管理系统_第6张图片

python GUI写图书馆管理系统_第7张图片

python GUI写图书馆管理系统_第8张图片

借阅信息管理系统:

python GUI写图书馆管理系统_第9张图片

python GUI写图书馆管理系统_第10张图片

python GUI写图书馆管理系统_第11张图片

python GUI写图书馆管理系统_第12张图片

你可能感兴趣的:(python程序设计)