diff -r c82943fb205f -r cce0af6351f0 printrun-src/printrun/gui/widgets.py --- a/printrun-src/printrun/gui/widgets.py Tue Jan 19 20:45:09 2021 +0100 +++ b/printrun-src/printrun/gui/widgets.py Wed Jan 20 10:15:13 2021 +0100 @@ -120,8 +120,7 @@ "UI": _("User interface"), "Viewer": _("Viewer"), "Colors": _("Colors"), - "External": _("External commands"), - "Laser": "Lasercut options"} + "External": _("External commands")} class PronterOptionsDialog(wx.Dialog): """Options editor""" @@ -131,11 +130,11 @@ panel = wx.Panel(self) header = wx.StaticBox(panel, label = _("Settings")) sbox = wx.StaticBoxSizer(header, wx.VERTICAL) - notebook = wx.Notebook(panel) + self.notebook = notebook = wx.Notebook(panel) all_settings = pronterface.settings._all_settings() group_list = [] groups = {} - for group in ["Printer", "UI", "Viewer", "Colors", "External", "Laser"]: + for group in ["Printer", "UI", "Viewer", "Colors", "External"]: group_list.append(group) groups[group] = [] for setting in all_settings: @@ -162,8 +161,9 @@ label.SetFont(font) grid.Add(label, pos = (current_row, 0), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT) + expand = 0 if isinstance(widget, (wx.SpinCtrlDouble, wx.Choice, wx.ComboBox)) else wx.EXPAND grid.Add(widget, pos = (current_row, 1), - flag = wx.ALIGN_CENTER_VERTICAL | wx.EXPAND) + flag = wx.ALIGN_CENTER_VERTICAL | expand) if hasattr(label, "set_default"): label.Bind(wx.EVT_MOUSE_EVENTS, label.set_default) if hasattr(widget, "Bind"): @@ -175,28 +175,25 @@ 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) + topsizer.Add(self.CreateButtonSizer(wx.OK | wx.CANCEL), 0, wx.ALIGN_CENTER) self.SetSizerAndFit(topsizer) self.SetMinSize(self.GetSize()) - self.notebook = notebook - self.group_list = group_list - - def setPage(self, name): - self.notebook.ChangeSelection(self.group_list.index(name)) - -def PronterOptions(pronterface, defaulttab = None): +notebookSelection = 0 +def PronterOptions(pronterface): dialog = PronterOptionsDialog(pronterface) - if defaulttab: - # set the active tab before open dialog - dialog.setPage(defaulttab) - + global notebookSelection + dialog.notebook.Selection = notebookSelection if dialog.ShowModal() == wx.ID_OK: + changed_settings = [] for setting in pronterface.settings._all_settings(): old_value = setting.value setting.update() if setting.value != old_value: pronterface.set(setting.name, setting.value) + changed_settings.append(setting) + pronterface.on_settings_change(changed_settings) + notebookSelection = dialog.notebook.Selection dialog.Destroy() class ButtonEdit(wx.Dialog): @@ -236,7 +233,7 @@ valid = True elif macro in self.pronterface.macros: valid = True - elif hasattr(self.pronterface.__class__, u"do_" + macro): + elif hasattr(self.pronterface.__class__, "do_" + macro): valid = False elif len([c for c in macro if not c.isalnum() and c != "_"]): valid = False @@ -268,7 +265,7 @@ self.Bind(wx.EVT_PAINT, self.paint) self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) self.bgcolor = wx.Colour() - self.bgcolor.SetFromName(bgcolor) + self.bgcolor.Set(bgcolor) self.width, self.height = size self.title = title self.max = maxval @@ -299,17 +296,17 @@ lo, hi, val, valhi = cmid, cmax, val - vmid, vmax - vmid vv = float(val) / valhi rgb = lo.Red() + (hi.Red() - lo.Red()) * vv, lo.Green() + (hi.Green() - lo.Green()) * vv, lo.Blue() + (hi.Blue() - lo.Blue()) * vv - rgb = map(lambda x: x * 0.8, rgb) - return wx.Colour(*map(int, rgb)) + rgb = (int(x * 0.8) for x in rgb) + return wx.Colour(*rgb) def paint(self, ev): - self.width, self.height = self.GetClientSizeTuple() + self.width, self.height = self.GetClientSize() self.recalc() x0, y0, x1, y1, xE, yE = 1, 1, self.ypt + 1, 1, self.width + 1 - 2, 20 dc = wx.PaintDC(self) dc.SetBackground(wx.Brush(self.bgcolor)) dc.Clear() - cold, medium, hot = wx.Colour(0, 167, 223), wx.Colour(239, 233, 119), wx.Colour(210, 50.100) + cold, medium, hot = wx.Colour(0, 167, 223), wx.Colour(239, 233, 119), wx.Colour(210, 50, 0) # gauge1, gauge2 = wx.Colour(255, 255, 210), (self.gaugeColour or wx.Colour(234, 82, 0)) gauge1 = wx.Colour(255, 255, 210) shadow1, shadow2 = wx.Colour(110, 110, 110), self.bgcolor @@ -361,7 +358,7 @@ setp_path.AddLineToPoint(setpoint, yE - 5) gc.DrawPath(setp_path) # draw readout - text = u"T\u00B0 %u/%u" % (self.value, self.setpoint) + text = "T\u00B0 %u/%u" % (self.value, self.setpoint) # gc.SetFont(gc.CreateFont(wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD), wx.WHITE)) # gc.DrawText(text, 29,-2) gc.SetFont(gc.CreateFont(wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD), wx.WHITE)) @@ -371,7 +368,7 @@ gc.DrawText(self.title, x0 + 18, y0 + 3) gc.DrawText(text, x0 + 118, y0 + 3) -class SpecialButton(object): +class SpecialButton: label = None command = None