Commit 1a76a003 authored by Guillaume Seguin's avatar Guillaume Seguin

Cleanup custom button handling

parent d2085fd0
...@@ -972,15 +972,7 @@ Printrun. If not, see <http://www.gnu.org/licenses/>.""" ...@@ -972,15 +972,7 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
self.custombuttonbuttons = [] self.custombuttonbuttons = []
custombuttons = self.custombuttons[:] + [None] custombuttons = self.custombuttons[:] + [None]
for i, btndef in enumerate(custombuttons): for i, btndef in enumerate(custombuttons):
try: if btndef is None:
b = wx.Button(self.centerpanel, -1, btndef.label, style = wx.BU_EXACTFIT)
b.SetToolTip(wx.ToolTip(_("Execute command: ") + btndef.command))
if btndef.background:
b.SetBackgroundColour(btndef.background)
rr, gg, bb = b.GetBackgroundColour().Get()
if 0.3 * rr + 0.59 * gg + 0.11 * bb < 60:
b.SetForegroundColour("#ffffff")
except:
if i == len(custombuttons) - 1: if i == len(custombuttons) - 1:
self.newbuttonbutton = b = wx.Button(self.centerpanel, -1, "+", size = (19, 18), style = wx.BU_EXACTFIT) self.newbuttonbutton = b = wx.Button(self.centerpanel, -1, "+", size = (19, 18), style = wx.BU_EXACTFIT)
#b.SetFont(wx.Font(12, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD)) #b.SetFont(wx.Font(12, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD))
...@@ -988,10 +980,15 @@ Printrun. If not, see <http://www.gnu.org/licenses/>.""" ...@@ -988,10 +980,15 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
b.SetToolTip(wx.ToolTip(_("click to add new custom button"))) b.SetToolTip(wx.ToolTip(_("click to add new custom button")))
b.Bind(wx.EVT_BUTTON, self.cbutton_edit) b.Bind(wx.EVT_BUTTON, self.cbutton_edit)
else: else:
b = wx.Button(self.centerpanel, -1, ".", size = (1, 1)) b = wx.StaticText(self.panel, -1, "")
#b = wx.StaticText(self.panel,-1, "", size = (72, 22), style = wx.ALIGN_CENTRE+wx.ST_NO_AUTORESIZE) #+wx.SIMPLE_BORDER else:
b.Disable() b = wx.Button(self.centerpanel, -1, btndef.label, style = wx.BU_EXACTFIT)
#continue b.SetToolTip(wx.ToolTip(_("Execute command: ") + btndef.command))
if btndef.background:
b.SetBackgroundColour(btndef.background)
rr, gg, bb = b.GetBackgroundColour().Get()
if 0.3 * rr + 0.59 * gg + 0.11 * bb < 60:
b.SetForegroundColour("#ffffff")
b.custombutton = i b.custombutton = i
b.properties = btndef b.properties = btndef
if btndef is not None: if btndef is not None:
......
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