Commit 8e697fac authored by Guillaume Seguin's avatar Guillaume Seguin

Fix custom buttons for real

parent d46b470d
...@@ -724,14 +724,11 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -724,14 +724,11 @@ class PronterWindow(MainWindow, pronsole.pronsole):
def cbuttons_reload(self): def cbuttons_reload(self):
allcbs = getattr(self, "custombuttonbuttons", []) allcbs = getattr(self, "custombuttonbuttons", [])
cs = self.centersizer
for button in allcbs: for button in allcbs:
cs.Detach(button) self.centersizer.Detach(button)
self.custombuttonbuttons = [] self.custombuttonbuttons = []
newbuttonbuttonindex = len(self.custombuttons) custombuttons = self.custombuttons[:] + [None]
while newbuttonbuttonindex>0 and self.custombuttons[newbuttonbuttonindex-1] is None: for i, btndef in enumerate(custombuttons):
newbuttonbuttonindex -= 1
for i, btndef in enumerate(self.custombuttons):
try: try:
b = wx.Button(self.cbuttons_panel, -1, btndef.label, style = wx.BU_EXACTFIT) b = wx.Button(self.cbuttons_panel, -1, btndef.label, style = wx.BU_EXACTFIT)
b.SetToolTip(wx.ToolTip(_("Execute command: ")+btndef.command)) b.SetToolTip(wx.ToolTip(_("Execute command: ")+btndef.command))
...@@ -741,7 +738,7 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -741,7 +738,7 @@ class PronterWindow(MainWindow, pronsole.pronsole):
if 0.3*rr+0.59*gg+0.11*bb < 60: if 0.3*rr+0.59*gg+0.11*bb < 60:
b.SetForegroundColour("#ffffff") b.SetForegroundColour("#ffffff")
except: except:
if i == newbuttonbuttonindex: if i == len(custombuttons) - 1:
self.newbuttonbutton = b = wx.Button(self.cbuttons_panel, -1, "+", size = (19, 18), style = wx.BU_EXACTFIT) self.newbuttonbutton = b = wx.Button(self.cbuttons_panel, -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))
b.SetForegroundColour("#4444ff") b.SetForegroundColour("#4444ff")
...@@ -758,7 +755,7 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -758,7 +755,7 @@ class PronterWindow(MainWindow, pronsole.pronsole):
b.Bind(wx.EVT_BUTTON, self.procbutton) b.Bind(wx.EVT_BUTTON, self.procbutton)
b.Bind(wx.EVT_MOUSE_EVENTS, self.editbutton) b.Bind(wx.EVT_MOUSE_EVENTS, self.editbutton)
self.custombuttonbuttons.append(b) self.custombuttonbuttons.append(b)
cs.Add(b, pos = (i // 4, i % 4)) self.centersizer.Add(b, pos = (i // 4, i % 4))
def help_button(self): def help_button(self):
print _('Defines custom button. Usage: button <num> "title" [/c "colour"] command') print _('Defines custom button. Usage: button <num> "title" [/c "colour"] command')
......
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