Commit e6438644 authored by Guillaume Seguin's avatar Guillaume Seguin

Minor rework of PronterOptions

parent 30549a77
......@@ -120,32 +120,40 @@ class MacroEditor(wx.Dialog):
reindented += self.indent_chars + line + "\n"
return reindented
class PronterOptions(wx.Dialog):
class PronterOptionsDialog(wx.Dialog):
"""Options editor"""
def __init__(self, pronterface):
wx.Dialog.__init__(self, None, title = _("Edit settings"), style = wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
topsizer = wx.BoxSizer(wx.VERTICAL)
vbox = wx.StaticBoxSizer(wx.StaticBox(self, label = _("Settings")) ,wx.VERTICAL)
topsizer.Add(vbox, 1, wx.ALL+wx.EXPAND)
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))
panel = wx.Panel(self)
header = wx.StaticBox(panel, label = _("Settings"))
sbox = wx.StaticBoxSizer(header, wx.VERTICAL)
panel2 = wx.Panel(panel)
grid = wx.FlexGridSizer(rows = 0, cols = 2, hgap = 8, vgap = 2)
grid.SetFlexibleDirection( wx.BOTH )
grid.AddGrowableCol( 1 )
grid.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
vbox.Add(grid, 0, wx.EXPAND)
grid.SetFlexibleDirection(wx.BOTH)
grid.AddGrowableCol(1)
grid.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED)
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_widget(self), 1, wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND)
topsizer.Add(self.CreateSeparatedButtonSizer(wx.OK+wx.CANCEL), 0, wx.EXPAND)
self.SetSizer(topsizer)
topsizer.Layout()
topsizer.Fit(self)
if self.ShowModal() == wx.ID_OK:
grid.Add(setting.get_label(panel2), 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.ALIGN_RIGHT)
grid.Add(setting.get_widget(panel2), 1, wx.ALIGN_CENTER_VERTICAL|wx.ALL)
panel2.SetSizer(grid)
sbox.Add(panel2, 1, wx.EXPAND)
panel.SetSizer(sbox)
topsizer = wx.BoxSizer(wx.VERTICAL)
topsizer.Add(panel, 1, wx.ALL | wx.EXPAND)
topsizer.Add(self.CreateButtonSizer(wx.OK | wx.CANCEL), 0, wx.ALIGN_RIGHT)
self.SetSizerAndFit(topsizer)
self.SetMinSize(self.GetSize())
#self.CentreOnScreen()
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)
self.Destroy()
dialog.Destroy()
class ButtonEdit(wx.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