wxpython实现界面,读取excel配置文件并查询道具信息

来源:互联网 发布:淘宝上怎么开店流程图 编辑:程序博客网 时间:2024/05/16 09:16
# coding=gbkimport sysimport xlrdimport wxreload(sys)sys.setdefaultencoding('utf-8')book = xlrd.open_workbook(r'C:\Users\Administrator\Desktop\510\123.xls')sheet = book.sheet_by_index(0)rowName=sheet.row_values(0)Name_index = rowName.index(u'"道具名称"')Big_index = rowName.index(u'道具大类')Small_index = rowName.index(u'道具小类')ID_index = rowName.index(u'道具ID')Max_index =rowName.index(u'叠加上限')countRow = sheet.nrowsglobal datadata=[]for i in range(1,countRow):    temp=[]    listRow = sheet.row(i)    getName = listRow[Name_index].value    getBigID = listRow[Big_index].value    getSmallID = listRow[Small_index].value    getID = listRow[ID_index].value    getMax = listRow[Max_index].value    temp.append(getName)    temp.append('%d %d %d' % (getBigID,getSmallID,getID))    temp.append(getMax)    data.append(temp)def check(event):    inp = editline.GetValue().strip()    for x in data:        if inp in x and inp==x[0]:            ss = '物品ID为: %s \n物品最大叠加数量为:%d' % (x[1],x[2])            break        elif inp in x and inp==x[1]:            ss = '物品名称为: %s \n物品最大叠加数量为:%d' % (x[0].encode('gbk'),x[2])            break        else:            ss ='查找物品不存在,请重新输入'    detailline.SetValue(ss)app = wx.App()win = wx.Frame(None,title='道具信息查询',size=(400,200))checkButton = wx.Button(win,label='查询',pos=(310,10),size=(70,25))checkButton.Bind(wx.EVT_BUTTON, check)editline = wx.TextCtrl(win,pos=(10,10),size=(290,25))detailline = wx.TextCtrl(win,pos=(10,43),size=(365,110),style=wx.TE_MULTILINE)win.Show()app.MainLoop()

0 0
原创粉丝点击