summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaalleen <36401965+kaalleen@users.noreply.github.com>2024-08-04 18:34:50 +0200
committerGitHub <noreply@github.com>2024-08-04 18:34:50 +0200
commit17b88ce2c14a0802e18e90d8dd142224013dfb15 (patch)
tree688d78c639698345bb692f09c74328873571dc8d
parent1a0bb1b8fff89b22ea1cbe53bc6a59ed95de691b (diff)
Simulator: toggle info and preferences dialog (#3115)
Co-authored-by: Lex Neva
-rw-r--r--lib/gui/simulator/simulator_preferences.py4
-rw-r--r--lib/gui/simulator/view_panel.py34
2 files changed, 28 insertions, 10 deletions
diff --git a/lib/gui/simulator/simulator_preferences.py b/lib/gui/simulator/simulator_preferences.py
index 9954c8f2..d42de4f0 100644
--- a/lib/gui/simulator/simulator_preferences.py
+++ b/lib/gui/simulator/simulator_preferences.py
@@ -61,7 +61,7 @@ class SimulatorPreferenceDialog(wx.Dialog):
def on_apply(self, event):
global_settings['simulator_line_width'] = self.line_width.GetValue()
global_settings['simulator_npp_size'] = self.npp_size.GetValue()
- self.Destroy()
+ self.Close()
def on_cancel(self, event):
global_settings['simulator_line_width'] = self.line_width_value
@@ -69,4 +69,4 @@ class SimulatorPreferenceDialog(wx.Dialog):
if self.drawing_panel.loaded:
self.drawing_panel.update_pen_size()
self.drawing_panel.Refresh()
- self.Destroy()
+ self.Close()
diff --git a/lib/gui/simulator/view_panel.py b/lib/gui/simulator/view_panel.py
index 90d4fe9c..9cfe3331 100644
--- a/lib/gui/simulator/view_panel.py
+++ b/lib/gui/simulator/view_panel.py
@@ -47,19 +47,19 @@ class ViewPanel(ScrolledPanel):
self.btnColorChange.SetBitmap(self.control_panel.load_icon('color_change'))
self.btnColorChange.Bind(wx.EVT_TOGGLEBUTTON, lambda event: self.on_marker_button('color_change', event))
- self.btnInfo = wx.BitmapButton(self, -1, style=self.button_style)
+ self.btnInfo = wx.BitmapToggleButton(self, -1, style=self.button_style)
self.btnInfo.SetToolTip(_('Open info dialog'))
self.btnInfo.SetBitmap(self.control_panel.load_icon('info'))
- self.btnInfo.Bind(wx.EVT_BUTTON, self.on_info_button)
+ self.btnInfo.Bind(wx.EVT_TOGGLEBUTTON, self.on_info_button)
self.btnBackgroundColor = wx.ColourPickerCtrl(self, -1, colour='white', size=((40, -1)))
self.btnBackgroundColor.SetToolTip(_("Change background color"))
self.btnBackgroundColor.Bind(wx.EVT_COLOURPICKER_CHANGED, self.on_update_background_color)
- self.btnSettings = wx.BitmapButton(self, -1, style=self.button_style)
+ self.btnSettings = wx.BitmapToggleButton(self, -1, style=self.button_style)
self.btnSettings.SetToolTip(_('Open settings dialog'))
self.btnSettings.SetBitmap(self.control_panel.load_icon('settings'))
- self.btnSettings.Bind(wx.EVT_BUTTON, self.on_settings_button)
+ self.btnSettings.Bind(wx.EVT_TOGGLEBUTTON, self.on_settings_button)
if self.detach_callback:
self.btnDetachSimulator = wx.BitmapButton(self, -1, style=self.button_style)
@@ -128,9 +128,27 @@ class ViewPanel(ScrolledPanel):
self.drawing_panel.Refresh()
def on_settings_button(self, event):
- settings_panel = SimulatorPreferenceDialog(self, title=_('Simulator Preferences'))
- settings_panel.Show()
+ if event.GetEventObject().GetValue():
+ self.settings_panel = SimulatorPreferenceDialog(self, title=_('Simulator Preferences'))
+ self.settings_panel.Bind(wx.EVT_CLOSE, self.settings_panel_closed)
+ self.settings_panel.Show()
+ else:
+ self.settings_panel.Close()
def on_info_button(self, event):
- self.info_panel = DesignInfoDialog(self, title=_('Design Info'))
- self.info_panel.Show()
+ if event.GetEventObject().GetValue():
+ self.info_panel = DesignInfoDialog(self, title=_('Design Info'))
+ self.info_panel.Bind(wx.EVT_CLOSE, self.info_panel_closed)
+ self.info_panel.Show()
+ else:
+ self.info_panel.Close()
+
+ def info_panel_closed(self, event):
+ self.info_panel.Destroy()
+ self.info_panel = None
+ self.btnInfo.SetValue(False)
+
+ def settings_panel_closed(self, event):
+ self.settings_panel.Destroy()
+ self.settings_panel = None
+ self.btnSettings.SetValue(False)