Hi all,
wx.lib.agw.aui.AuiManager fails to restore a previously saved perspective.
I’ve installed wxPython-Phoenix on my Ubuntu 16.04 64bit machine using pip
sudo pip3 install --upgrade --trusted-host wxpython.org --pre -f Index of /Phoenix/snapshot-builds wxPython_Phoenix
I can successfully import wx:
Python 3.5.2 (default, Sep 10 2016, 08:21:44)
[GCC 5.4.0 20160609] on linux
Type “help”, “copyright”, “credits” or “license” for more information.import wx
wx.version
‘3.0.3.dev2562+33fadd8’
However when I try to save/load perspectives nothing happens. Here’s an example:
The following code creates one panel with a toggle button. Clicking repeatedly on the button should show/hide a second panel on the right by switching between different saved perspectives.
import wx
import wx.lib.agw.aui as aui
class MyFrame(wx.Frame):
def __init__(self, parent, id=-1, title="AUI Test"):
wx.Frame.__init__(self, parent, id, title)
self._mgr = aui.AuiManager()
self._mgr.SetManagedWindow(self)
# Create panels
self.panel0 = MySidePanel(self)
self._mgr.AddPane(self.panel0,
aui.AuiPaneInfo().
Caption("Panel0").
Name("Panel0").
Left())
self.panel1 = MyDummyPanel(self)
self._mgr.AddPane(self.panel1,
aui.AuiPaneInfo().
Caption("Panel1").
Name("Panel1").
CenterPane())
self.createPerspectives()
self._mgr.Update()
def createPerspectives(self):
self.perspectives = []
# all panels
perspective_all = self._mgr.SavePerspective()
# side panel only
self._mgr.GetPane("Panel1").Hide()
perspective_side = self._mgr.SavePerspective()
self.perspectives.append(perspective_all)
self.perspectives.append(perspective_side)
class MySidePanel(wx.Panel):
def __init__(self, parent):
self.frame = parent
wx.Panel.__init__(self, parent, -1)
self.button = wx.ToggleButton(self, label="Show")
self.button.Bind(wx.EVT_TOGGLEBUTTON, self.on_button)
self.Fit()
def on_button(self, event):
if self.button.GetValue():
self.frame._mgr.LoadPerspective(self.frame.perspectives[0])
self.button.SetLabel("Hide")
else:
self.frame._mgr.LoadPerspective(self.frame.perspectives[1])
self.button.SetLabel("Show")
class MyDummyPanel(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent, -1)
wx.StaticText(self, -1, "foo foo foo")
self.Fit()
app = wx.App(False)
frame = MyFrame(None, wx.ID_ANY, “Perspectives Test”)
frame.Show(True)
app.MainLoop()
``
The button changes label, but the panel on the right is never shown. No error message either.
I’ve tried with both python 2.7 and python 3.5 on Ubuntu 16:04 64bit with wxpython (phoenix) 3.0.3.dev2562+33fadd8, but none worked.
I’ve also tried to download the tarball and manually compile, but it didn’t make any difference.
On Windows 10 64bit and python 3.5 it works. On OSX El Capitan and python 3.5 it works. So looks like it’s linux related.
Any ideas?
Thanks!