Commit 3930fe4b authored by Guillaume Seguin's avatar Guillaume Seguin

Fix custom buttons placement under wx2.9

parent 06954dd2
...@@ -293,8 +293,6 @@ class VizPane(wx.BoxSizer): ...@@ -293,8 +293,6 @@ class VizPane(wx.BoxSizer):
root.gwindow.Bind(wx.EVT_CLOSE, lambda x: root.gwindow.Hide()) root.gwindow.Bind(wx.EVT_CLOSE, lambda x: root.gwindow.Hide())
if not isinstance(root.gviz, NoViz): if not isinstance(root.gviz, NoViz):
self.Add(root.gviz.widget, 1, flag = wx.SHAPED | wx.ALIGN_CENTER_HORIZONTAL) self.Add(root.gviz.widget, 1, flag = wx.SHAPED | wx.ALIGN_CENTER_HORIZONTAL)
root.centersizer = wx.GridBagSizer()
self.Add(root.centersizer, 0, flag = wx.ALIGN_CENTER)
class LogPane(wx.BoxSizer): class LogPane(wx.BoxSizer):
...@@ -420,8 +418,11 @@ class MainWindow(wx.Frame): ...@@ -420,8 +418,11 @@ class MainWindow(wx.Frame):
self.panel.Bind(wx.EVT_MOUSE_EVENTS, self.editbutton) self.panel.Bind(wx.EVT_MOUSE_EVENTS, self.editbutton)
self.Bind(wx.EVT_CLOSE, self.kill) self.Bind(wx.EVT_CLOSE, self.kill)
vizpane.Detach(self.centersizer) # Custom buttons
rightsizer.Add(self.centersizer, 0, wx.ALIGN_CENTER) self.centersizer = wx.GridBagSizer()
self.centerpanel = self.newPanel(page1panel2)
self.centerpanel.SetSizer(self.centersizer)
rightsizer.Add(self.centerpanel, 0, wx.ALIGN_CENTER)
rightsizer.AddStretchSpacer() rightsizer.AddStretchSpacer()
self.panel.SetSizerAndFit(self.notesizer) self.panel.SetSizerAndFit(self.notesizer)
...@@ -432,8 +433,6 @@ class MainWindow(wx.Frame): ...@@ -432,8 +433,6 @@ class MainWindow(wx.Frame):
for i in self.printerControls: for i in self.printerControls:
i.Disable() i.Disable()
#self.panel.Fit()
self.cbuttons_panel = page1panel2
self.cbuttons_reload() self.cbuttons_reload()
def createGui(self, compact = False): def createGui(self, compact = False):
...@@ -449,7 +448,15 @@ class MainWindow(wx.Frame): ...@@ -449,7 +448,15 @@ class MainWindow(wx.Frame):
left_sizer = wx.BoxSizer(wx.VERTICAL) left_sizer = wx.BoxSizer(wx.VERTICAL)
left_sizer.Add(left_pane, 0) left_sizer.Add(left_pane, 0)
self.lowersizer.Add(left_sizer, 0, wx.EXPAND) self.lowersizer.Add(left_sizer, 0, wx.EXPAND)
self.lowersizer.Add(VizPane(self, lowerpanel), 1, wx.EXPAND | wx.ALIGN_CENTER) vizpanel = self.newPanel(lowerpanel)
viz_pane = VizPane(self, vizpanel)
# Custom buttons
self.centersizer = wx.GridBagSizer()
self.centerpanel = self.newPanel(vizpanel)
self.centerpanel.SetSizer(self.centersizer)
viz_pane.Add(self.centerpanel, 0, flag = wx.ALIGN_CENTER)
vizpanel.SetSizer(viz_pane)
self.lowersizer.Add(vizpanel, 1, wx.EXPAND | wx.ALIGN_CENTER)
logpanel = self.newPanel(lowerpanel) logpanel = self.newPanel(lowerpanel)
log_pane = LogPane(self, logpanel) log_pane = LogPane(self, logpanel)
logpanel.SetSizer(log_pane) logpanel.SetSizer(log_pane)
...@@ -480,6 +487,4 @@ class MainWindow(wx.Frame): ...@@ -480,6 +487,4 @@ class MainWindow(wx.Frame):
for i in self.printerControls: for i in self.printerControls:
i.Disable() i.Disable()
#self.panel.Fit()
self.cbuttons_panel = lowerpanel
self.cbuttons_reload() self.cbuttons_reload()
...@@ -736,7 +736,7 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -736,7 +736,7 @@ class PronterWindow(MainWindow, pronsole.pronsole):
custombuttons = self.custombuttons[:] + [None] custombuttons = self.custombuttons[:] + [None]
for i, btndef in enumerate(custombuttons): for i, btndef in enumerate(custombuttons):
try: try:
b = wx.Button(self.cbuttons_panel, -1, btndef.label, style = wx.BU_EXACTFIT) b = wx.Button(self.centerpanel, -1, btndef.label, style = wx.BU_EXACTFIT)
b.SetToolTip(wx.ToolTip(_("Execute command: ")+btndef.command)) b.SetToolTip(wx.ToolTip(_("Execute command: ")+btndef.command))
if btndef.background: if btndef.background:
b.SetBackgroundColour(btndef.background) b.SetBackgroundColour(btndef.background)
...@@ -745,13 +745,13 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -745,13 +745,13 @@ class PronterWindow(MainWindow, pronsole.pronsole):
b.SetForegroundColour("#ffffff") b.SetForegroundColour("#ffffff")
except: except:
if i == len(custombuttons) - 1: 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.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))
b.SetForegroundColour("#4444ff") b.SetForegroundColour("#4444ff")
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.cbuttons_panel,-1, ".", size = (1, 1)) b = wx.Button(self.centerpanel,-1, ".", size = (1, 1))
#b = wx.StaticText(self.panel,-1, "", size = (72, 22), style = wx.ALIGN_CENTRE+wx.ST_NO_AUTORESIZE) #+wx.SIMPLE_BORDER #b = wx.StaticText(self.panel,-1, "", size = (72, 22), style = wx.ALIGN_CENTRE+wx.ST_NO_AUTORESIZE) #+wx.SIMPLE_BORDER
b.Disable() b.Disable()
#continue #continue
...@@ -762,7 +762,7 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -762,7 +762,7 @@ class PronterWindow(MainWindow, pronsole.pronsole):
b.Bind(wx.EVT_MOUSE_EVENTS, self.editbutton) b.Bind(wx.EVT_MOUSE_EVENTS, self.editbutton)
self.custombuttonbuttons.append(b) self.custombuttonbuttons.append(b)
self.centersizer.Add(b, pos = (i // 4, i % 4)) self.centersizer.Add(b, pos = (i // 4, i % 4))
self.centersizer.Layout() self.panel.GetSizer().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