import wx
from python实验2 import classinformation
class 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=(100, 70))
self.text_id = wx.TextCtrl(pl, pos=(100, 100), size=(235, 25), style=wx.TE_LEFT)
self.bt_bc = wx.Button(pl, label="查询", pos=(100, 140))
self.bt_bc.Bind(wx.EVT_BUTTON, self.Chaxun)
self.bt_qx = wx.Button(pl, label="取消", pos=(200, 140))
self.bt_qx.Bind(wx.EVT_BUTTON, self.Cancel)
def Chaxun(self,event):
id = self.text_id.GetValue()
if id =='':
message = '输入为空!'
else:
(a,b,c) = classinformation.chaxuninformation(id)
message = """
该同学姓名为: {:s}
班级为:{:s}
""".format(c,b)
wx.MessageBox(message)
pass
def Cancel(self, event):
self.text_id.SetValue('')
wx.MessageBox('取消成功!')
if __name__ == '__main__':
app = wx.App()
frame = MyFrame(parent=None,id=-1)
frame.Show()
app.MainLoop()