Browse Source

Fix wxGUI Vector Network Analysis Tool ComboBox widget deprecation warning (#418)

* wxGUI Vector Network Analysis Tool: add ComboBox widget wrapper class

* wxGUI Vector Network Analysis Tool: fix ComboBox widget tooltip text
Tomas Zigo 5 years ago
parent
commit
ca6471d6dd
2 changed files with 19 additions and 4 deletions
  1. 16 2
      gui/wxpython/gui_core/wrap.py
  2. 3 2
      gui/wxpython/vnet/toolbars.py

+ 16 - 2
gui/wxpython/gui_core/wrap.py

@@ -1,7 +1,7 @@
 """
 @package gui_core.wrap
 
-@brief Core wrapped wxpython widgets 
+@brief Core wrapped wxpython widgets
 
 Classes:
  - wrap::GSpinCtrl
@@ -619,7 +619,7 @@ class ListBox(wx.ListBox):
     over the widget on different platforms/wxpython versions"""
 
     def __init__(self, *args, **kwargs):
-        wx.ListBox.__init__(self, *args, **kwargs) 
+        wx.ListBox.__init__(self, *args, **kwargs)
 
     def SetToolTip(self, tip):
         if wxPythonPhoenix:
@@ -642,3 +642,17 @@ class HyperlinkCtrl(HyperlinkCtrl_):
             HyperlinkCtrl_.SetToolTip(self, tipString=tip)
         else:
             HyperlinkCtrl_.SetToolTipString(self, tip)
+
+
+class ComboBox(wx.ComboBox):
+    """Wrapper around wx.ComboBox to have more control
+    over the widget on different platforms/wxpython versions"""
+
+    def __init__(self, *args, **kwargs):
+        wx.ComboBox.__init__(self, *args, **kwargs)
+
+    def SetToolTip(self, tip):
+        if wxPythonPhoenix:
+            wx.ComboBox.SetToolTip(self, tipString=tip)
+        else:
+            wx.ComboBox.SetToolTipString(self, tip)

+ 3 - 2
gui/wxpython/vnet/toolbars.py

@@ -21,6 +21,7 @@ import wx
 
 from icons.icon import MetaIcon
 from gui_core.toolbars import BaseToolbar, BaseIcons
+from gui_core.wrap import ComboBox
 from core.gcmd import RunCommand
 
 
@@ -193,7 +194,7 @@ class AnalysisToolbar(BaseToolbar):
             choices.append(
                 self.vnet_mgr.GetAnalysisProperties(moduleName)['label'])
 
-        self.anChoice = wx.ComboBox(
+        self.anChoice = ComboBox(
             parent=self,
             id=wx.ID_ANY,
             choices=choices,
@@ -201,7 +202,7 @@ class AnalysisToolbar(BaseToolbar):
             size=(
                 350,
                 30))  # FIXME
-        self.anChoice.SetToolTipString(_('Availiable analyses'))
+        self.anChoice.SetToolTip(_('Available analyses'))
         self.anChoice.SetSelection(0)
 
         self.anChoiceId = self.AddControl(self.anChoice)