Извините за мою глупость sh ... поэтому я загружаю полный код
, пожалуйста, научите меня правильному пути ....
в комбинированном ящике я выбираю одно содержимое, и оно привязывается к функция «def OnSelectComboBox (self, event):» и я хочу получить выбранное содержимое в выпадающем списке в ***** «Я хочу получить выбранное содержимое в выпадающем списке здесь» *****, но я не могу
поэтому, пожалуйста, научите меня, это невозможно или иным образом
спасибо
# -*- coding:utf-8 -*-
import wx
import sqlite3
from PIL import Image # for image processing
from wx.adv import Animation, AnimationCtrl # for gif Animation
conn = sqlite3.connect('reference_file.rre')
cur = conn.cursor()
class MyApp(wx.App):
def OnInit(self):
self.frame = errorCode_SAC(None, title ="Guide")
self.SetTopWindow(self.frame)
self.frame.Show()
return True
class errorCode_SAC(wx.Frame):
def __init__(self, parent, id=wx.ID_ANY, title="Search", pos=wx.DefaultPosition, size=(1500,650), style=wx.DEFAULT_FRAME_STYLE, name=""):
super(errorCode_SAC, self).__init__(parent, id, title, pos, size, style, name="")
self.Panel_err_sac = wx.Panel(self,wx.ID_ANY, pos=(0,0), size=(774, 608))
self.Panel_dd = wx.Panel(self, wx.ID_ANY, pos=(777,0), size=(1,608))
self.Panel_err_sac_result = wx.Panel(self,wx.ID_ANY, pos=(778,0), size=(706, 308))
self.Panel_err_image = wx.Panel(self,wx.ID_ANY, pos=(778,309), size=(706,300))
self.explBox_err_sac = wx.StaticBox(self.Panel_err_sac, wx.ID_ANY, "[ Instruction ]", pos = (8,10), size=(756, 200))
self.lbname1 = wx.StaticText(self.explBox_err_sac, label="1.input name.",pos=(10,20))
self.sa_ra_code_box = wx.StaticBox(self.Panel_err_sac, wx.ID_ANY, "[ input model ]", pos=(8,230), size=(340,80))
self.sa_err_code_CeNa = wx.TextCtrl(self.sa_ra_code_box, wx.ID_ANY, pos=(8,30), size=(260,22))
self.button = wx.Button(self.sa_ra_code_box, wx.ID_OK, label="search", size=(50,23), pos = (280,30))
self.button.SetDefault()
self.sa_er_Box = wx.StaticBox(self.Panel_err_sac, wx.ID_ANY, "[ Search by input name ]", pos = (8,320), size = (340,280))
self.sa_er_inputkw = wx.StaticText(self.sa_er_Box, label="",pos=(8,15), size=(10,40), style=wx.ALIGN_LEFT)
self.sa_er_middle = wx.StaticText(self.sa_er_Box, label=" by", pos=(50,15))
self.sa_er_middle = wx.StaticText(self.sa_er_Box, label="", pos=(8,30))
self.sa_er_footer = wx.StaticText(self.sa_er_Box, label=" searched",pos=(50,30))
self.sa_er_svlist = wx.ListCtrl(self.sa_er_Box, -1, pos = (8,60), size = (330,200), style = wx.LC_REPORT | wx.SUNKEN_BORDER)
self.sa_er_svlist.InsertColumn(0,"model")
self.sa_er_svlist.InsertColumn(1,"spec")
self.sa_er_svlist.SetColumnWidth(0,100)
self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.sa_err_catelist_OnClick, self.sa_er_svlist)
self.button.Bind(wx.EVT_BUTTON, self.sa_err_search_OnButton)
self.sa_er_result_Box = wx.StaticBox(self.Panel_err_sac, wx.ID_ANY, "[ check list ]", pos=(360,230), size =(405,370))
self.sa_er_question_ti = wx.StaticText(self.sa_er_result_Box, label="", pos=(50,20), size = (130,-1))
self.sa_er_question_text = wx.StaticText(self.sa_er_result_Box, label="point", pos = (10,50), size = (130,-1))
self.sa_er_question_te = wx.StaticText(self.sa_er_result_Box, label="", pos=(50,50), size = (130,-1))
self.P_err_sac_case1 = wx.StaticBox(self.Panel_err_sac_result, wx.ID_ANY, "[ check list below ]", pos = (8,10), size=(690,60))
self.P_err_sac_case2 = wx.StaticBox(self.Panel_err_sac_result, wx.ID_ANY, "[ symptom ]", pos=(8,90), size =(690,200))
self.cas2_symp = wx.StaticText(self.P_err_sac_case2, label="selected symptom is..", pos=(10,20))
self.cas2_symp_text = wx.StaticText(self.P_err_sac_case2, label="", pos=(10,40))
self.cas2_descrip = wx.StaticText(self.P_err_sac_case2, label="cause....", pos=(10,70))
self.cas2_descrip_text = wx.StaticText(self.P_err_sac_case2, label="", pos=(10,90))
# -- Combo box
items=[] # Dummy list
self.cb = wx.ComboBox(self.P_err_sac_case1, pos=(10,30),size=(500,20), choices=items, style=wx.CB_READONLY)
self.Bind(wx.EVT_COMBOBOX, self.OnSelectComboBox)
*****"I want get the selected combobox contents here"*****
# -- search query
def sa_err_search_OnButton(self, e):
self.sa_er_inputkw.SetLabel(self.sa_err_code_CeNa.GetValue())
searchResult = "%"+self.sa_err_code_CeNa.GetValue()+"%"
self.sa_er_svlist.DeleteAllItems()
sa_err_code_CeNa = cur.execute("Select * from sa_er_cate where cate like '"+searchResult+"'")
count = 0
for i in sa_err_code_CeNa:
self.sa_er_svlist.Append(i[1:3])
count = count +1
self.sa_er_middle.SetLabel(str(count))
self.Bind(wx.EVT_CLOSE, self.on_close)
def on_close(self,e):
self.Destroy()
def sa_err_catelist_OnClick(self, event):
sa_idx = event.GetIndex()
sa_err_check = self.sa_er_svlist.GetItem(sa_idx, 0).GetText()
sa_err_check_Comment = cur.execute("select cate,chek_comment from sa_er_cate where cate ='%s'" %sa_err_check)
for row in sa_err_check_Comment:
self.sa_er_question_ti.SetLabel(row[0])
self.sa_er_question_te.SetLabel(row[1])
model_name_string = row[0]
result_query_1 = cur.execute("Select symp from sac_er_ramp where cate='%s'" % model_name_string)
list=[]
for row_test in result_query_1:
list.append(row_test[0])
self.cb.SetItems(list)
def OnSelectComboBox(self,event):
item = event.GetString()
result_query_2 = cur.execute("Select symp, descrip, judgement,image from sac_er_ramp where symp='%s'" % item)
for row in result_query_2:
self.cas2_symp_text.SetLabel(row[0])
self.cas2_descrip_text.SetLabel(row[1])
imageno = row[3]
# -- image box -> this is problem
"""
erim = Image.open('./image/image_error_ramp/%s.webp' % imageno)
erim.info.pop('background',None)
erim.save('./image/image_error_ramp/%s.gif' % imageno,save_all=True, loop=0)
anim = Animation('./image/image_error_ramp/%s.gif' % imageno)
ctrl = AnimationCtrl(self.Panel_err_image, -1,anim, pos=(35,40))
ctrl.Play()
os.remove('./image/image_error_ramp/%s.gif' % imageno)
"""
if __name__=="__main__":
app = MyApp(False)
app.MainLoop()