Commit e6438644 authored by Guillaume Seguin's avatar Guillaume Seguin

Minor rework of PronterOptions

parent 30549a77
...@@ -120,32 +120,40 @@ class MacroEditor(wx.Dialog): ...@@ -120,32 +120,40 @@ class MacroEditor(wx.Dialog):
reindented += self.indent_chars + line + "\n" reindented += self.indent_chars + line + "\n"
return reindented return reindented
class PronterOptions(wx.Dialog): class PronterOptionsDialog(wx.Dialog):
"""Options editor""" """Options editor"""
def __init__(self, pronterface): def __init__(self, pronterface):
wx.Dialog.__init__(self, None, title = _("Edit settings"), style = wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER) wx.Dialog.__init__(self, parent = None, title = _("Edit settings"), size = (400, 500), style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER | wx.DIALOG_NO_PARENT, pos = (100, 100))
topsizer = wx.BoxSizer(wx.VERTICAL) panel = wx.Panel(self)
vbox = wx.StaticBoxSizer(wx.StaticBox(self, label = _("Settings")) ,wx.VERTICAL) header = wx.StaticBox(panel, label = _("Settings"))
topsizer.Add(vbox, 1, wx.ALL+wx.EXPAND) sbox = wx.StaticBoxSizer(header, wx.VERTICAL)
panel2 = wx.Panel(panel)
grid = wx.FlexGridSizer(rows = 0, cols = 2, hgap = 8, vgap = 2) grid = wx.FlexGridSizer(rows = 0, cols = 2, hgap = 8, vgap = 2)
grid.SetFlexibleDirection( wx.BOTH ) grid.SetFlexibleDirection(wx.BOTH)
grid.AddGrowableCol( 1 ) grid.AddGrowableCol(1)
grid.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED ) grid.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED)
vbox.Add(grid, 0, wx.EXPAND)
for setting in pronterface.settings._all_settings(): for setting in pronterface.settings._all_settings():
grid.Add(setting.get_label(self), 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.ALIGN_RIGHT) grid.Add(setting.get_label(panel2), 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.ALIGN_RIGHT)
grid.Add(setting.get_widget(self), 1, wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND) grid.Add(setting.get_widget(panel2), 1, wx.ALIGN_CENTER_VERTICAL|wx.ALL)
topsizer.Add(self.CreateSeparatedButtonSizer(wx.OK+wx.CANCEL), 0, wx.EXPAND) panel2.SetSizer(grid)
self.SetSizer(topsizer) sbox.Add(panel2, 1, wx.EXPAND)
topsizer.Layout() panel.SetSizer(sbox)
topsizer.Fit(self) topsizer = wx.BoxSizer(wx.VERTICAL)
if self.ShowModal() == wx.ID_OK: topsizer.Add(panel, 1, wx.ALL | wx.EXPAND)
for setting in pronterface.settings._all_settings(): topsizer.Add(self.CreateButtonSizer(wx.OK | wx.CANCEL), 0, wx.ALIGN_RIGHT)
old_value = setting.value self.SetSizerAndFit(topsizer)
setting.update() self.SetMinSize(self.GetSize())
if setting.value != old_value: #self.CentreOnScreen()
pronterface.set(setting.name, setting.value)
self.Destroy() def PronterOptions(pronterface):
dialog = PronterOptionsDialog(pronterface)
if dialog.ShowModal() == wx.ID_OK:
for setting in pronterface.settings._all_settings():
old_value = setting.value
setting.update()
if setting.value != old_value:
pronterface.set(setting.name, setting.value)
dialog.Destroy()
class ButtonEdit(wx.Dialog): class ButtonEdit(wx.Dialog):
"""Custom button edit dialog""" """Custom button edit dialog"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment