Commit d46b470d authored by Guillaume Seguin's avatar Guillaume Seguin

Cleanup custom buttons positionning

parent 895c14e4
...@@ -390,7 +390,8 @@ class MainWindow(wx.Frame): ...@@ -390,7 +390,8 @@ class MainWindow(wx.Frame):
rightsizer = wx.BoxSizer(wx.VERTICAL) rightsizer = wx.BoxSizer(wx.VERTICAL)
extracontrols = wx.GridBagSizer() extracontrols = wx.GridBagSizer()
add_extra_controls(extracontrols, self, page1panel2, left_pane.extra_buttons) add_extra_controls(extracontrols, self, page1panel2, left_pane.extra_buttons)
rightsizer.Add(extracontrols, 1, wx.ALIGN_CENTER) rightsizer.AddStretchSpacer()
rightsizer.Add(extracontrols, 0, wx.ALIGN_CENTER)
self.lowersizer.Add(leftsizer, 1, wx.ALIGN_CENTER) self.lowersizer.Add(leftsizer, 1, wx.ALIGN_CENTER)
self.lowersizer.Add(rightsizer, 1, wx.ALIGN_CENTER) self.lowersizer.Add(rightsizer, 1, wx.ALIGN_CENTER)
self.mainsizer_page1.Add(page1panel2, 1, wx.EXPAND) self.mainsizer_page1.Add(page1panel2, 1, wx.EXPAND)
...@@ -420,7 +421,8 @@ class MainWindow(wx.Frame): ...@@ -420,7 +421,8 @@ class MainWindow(wx.Frame):
self.Bind(wx.EVT_CLOSE, self.kill) self.Bind(wx.EVT_CLOSE, self.kill)
vizpane.Detach(self.centersizer) vizpane.Detach(self.centersizer)
rightsizer.Add(self.centersizer, 0, wx.EXPAND) rightsizer.Add(self.centersizer, 0, wx.ALIGN_CENTER)
rightsizer.AddStretchSpacer()
self.panel.SetSizerAndFit(self.notesizer) self.panel.SetSizerAndFit(self.notesizer)
...@@ -431,7 +433,7 @@ class MainWindow(wx.Frame): ...@@ -431,7 +433,7 @@ class MainWindow(wx.Frame):
i.Disable() i.Disable()
#self.panel.Fit() #self.panel.Fit()
self.cbuttons_panel = page1panel self.cbuttons_panel = page1panel2
self.cbuttons_reload() self.cbuttons_reload()
def createGui(self): def createGui(self):
......
...@@ -723,26 +723,15 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -723,26 +723,15 @@ class PronterWindow(MainWindow, pronsole.pronsole):
pass pass
def cbuttons_reload(self): def cbuttons_reload(self):
allcbs = [] allcbs = getattr(self, "custombuttonbuttons", [])
ubs = self.uppersizer
cs = self.centersizer cs = self.centersizer
#for item in ubs.GetChildren(): for button in allcbs:
# if hasattr(item.GetWindow(),"custombutton"): cs.Detach(button)
# allcbs += [(ubs, item.GetWindow())]
for item in cs.GetChildren():
if hasattr(item.GetWindow(),"custombutton"):
allcbs += [(cs, item.GetWindow())]
for sizer, button in allcbs:
#sizer.Remove(button)
button.Destroy()
self.custombuttonbuttons = [] self.custombuttonbuttons = []
newbuttonbuttonindex = len(self.custombuttons) newbuttonbuttonindex = len(self.custombuttons)
while newbuttonbuttonindex>0 and self.custombuttons[newbuttonbuttonindex-1] is None: while newbuttonbuttonindex>0 and self.custombuttons[newbuttonbuttonindex-1] is None:
newbuttonbuttonindex -= 1 newbuttonbuttonindex -= 1
while len(self.custombuttons) < 13: for i, btndef in enumerate(self.custombuttons):
self.custombuttons.append(None)
for i in xrange(len(self.custombuttons)):
btndef = self.custombuttons[i]
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))
...@@ -768,14 +757,8 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -768,14 +757,8 @@ class PronterWindow(MainWindow, pronsole.pronsole):
if btndef is not None: if btndef is not None:
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)
#else:
# b.Bind(wx.EVT_BUTTON, lambda e:e.Skip())
self.custombuttonbuttons.append(b) self.custombuttonbuttons.append(b)
#if i<4: cs.Add(b, pos = (i // 4, i % 4))
# ubs.Add(b)
#else:
cs.Add(b, pos = ((i)/4, (i)%4))
self.mainsizer.Layout()
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