Python教程

pythonGUI班级信息

本文主要是介绍pythonGUI班级信息,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
import wxclass MyFrame(wx.Frame):
    def __init__(self,parent,id):
        wx.Frame.__init__(self,parent,id,title="班级信息收集程序",size=(600,400))
        pl = wx.Panel(self)
        self.title = wx.StaticText(pl,label="请输入要收集的班级、姓名、学号",pos=(200,20))
        self.label_id = wx.StaticText(pl,label="学号:",pos=(50,50))
        self.text_id = wx.TextCtrl(pl,pos=(100,50),size=(235,25),style=wx.TE_LEFT)
        self.label_bj = wx.StaticText(pl,label="班级:",pos=(50,90))
        self.text_bj = wx.TextCtrl(pl, pos=(100, 90), size=(235, 25), style=wx.TE_LEFT)
        self.label_xm = wx.StaticText(pl, label="姓名:", pos=(50, 130))
        self.text_xm = wx.TextCtrl(pl, pos=(100, 130), size=(235, 25), style=wx.TE_LEFT)
        self.bt_bc = wx.Button(pl,label="保存",pos=(100,170))
        self.bt_bc.Bind(wx.EVT_BUTTON,self.Baochun)
        self.bt_qx = wx.Button(pl,label="取消",pos=(200,170))
        self.bt_qx.Bind(wx.EVT_BUTTON, self.Cancel)

    def Baochun(self,event):
        id = self.text_id.GetValue()
        bj = self.text_bj.GetValue()
        xm = self.text_xm.GetValue()
        if id =='' or bj == '' or xm == '':
            message = '输入为空!'
        else:
            classinformation.baochuninformation(id,bj,xm)
            message = '保存成功!'
        wx.MessageBox(message)


    def Cancel(self,event):
        self.text_xm.SetValue('')
        self.text_bj.SetValue('')
        self.text_id.SetValue('')
        wx.MessageBox('取消成功!')


if __name__ == '__main__':
    app = wx.App()
    frame = MyFrame(parent=None,id=-1)
    frame.Show()
    app.MainLoop()

 

 

这篇关于pythonGUI班级信息的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!