Pārlūkot izejas kodu

wxGUI/gui_core: fix trigger 'wx.EVT_CHOICE' event if you set widget selection programatically (#1580)

Tomas Zigo 3 gadi atpakaļ
vecāks
revīzija
d6ad4a227b

+ 4 - 2
gui/wxpython/gmodeler/dialogs.py

@@ -214,9 +214,11 @@ class ModelSearchDialog(wx.Dialog):
             parent=self.panel, model=menuModel.GetModel(), showTip=True
         )
         self.search.moduleSelected.connect(
-            lambda name: self.cmd_prompt.SetTextAndFocus(name + " ")
+            lambda name: (
+                self.cmd_prompt.SetText(name + " "),
+                self.label.SetValue(name),
+            )
         )
-        wx.CallAfter(self.cmd_prompt.SetFocus)
 
         self.label = TextCtrl(parent=self.panel, id=wx.ID_ANY)
         self.comment = TextCtrl(parent=self.panel, id=wx.ID_ANY, style=wx.TE_MULTILINE)

+ 2 - 1
gui/wxpython/gui_core/widgets.py

@@ -1281,6 +1281,7 @@ class SearchModuleWidget(wx.Panel):
             self._searchChoice.SetItems(commands)
             if commands:
                 self._searchChoice.SetSelection(0)
+                self.OnSelectModule()
 
         label = _("%d modules match") % len(commands)
         if self._showTip:
@@ -1310,7 +1311,7 @@ class SearchModuleWidget(wx.Panel):
 
         return commands
 
-    def OnSelectModule(self, event):
+    def OnSelectModule(self, event=None):
         """Module selected from choice, update command prompt"""
         cmd = self._searchChoice.GetStringSelection()
         self.moduleSelected.emit(name=cmd)