Re: wxPython Phoenix fails to LoadPerspective on Linux
Riccardo Borgani <[email protected]>
| Newsgroups | gmane.comp.python.wxpython.devel |
|---|---|
| Message-ID | <[email protected]> |
I've been trying different combinations, and it looks to me that the issue
is in the _mgr.Update() method.
Even getting rid of perspectives and directly showing/hiding the pane
doesn't solve the problem:
import wx
import wx.lib.agw.aui as aui
class MyFrame(wx.Frame):
def __init__(self, parent, id, title):
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().
Name("Panel0").
Left())
self.panel1 = MyDummyPanel(self)
self._mgr.AddPane(self.panel1,
aui.AuiPaneInfo().
Name("Panel1").
CenterPane())
# start with side panel only
self._mgr.GetPane("Panel1").Hide()
self._mgr.Update()
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.GetPane("Panel1").Show()
self.frame._mgr.Update()
self.button.SetLabel("Hide")
else:
self.frame._mgr.GetPane("Panel1").Hide()
self.frame._mgr.Update()
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, "Aui Manager Test")
frame.Show(True)
app.MainLoop()
It's as if the Update call didn't actually draw the new layout on Linux.
On Monday, October 3, 2016 at 7:09:30 PM UTC+2, Mario Lacunza wrote:
>
> Just to say in Ubuntu 16.04 LTS 64bits with wx 3.0.2.. installed from
> repos works fine.
>
I know, but I need to use it with Python 3, so using wx 3.0.2 (classic) is
not an option.
> 2016-10-03 10:42 GMT-05:00 Riccardo Borgani <[email protected]
> <javascript:>>:
>
>> 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
>>> http://wxpython.org/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!
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "wxPython-dev" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
--
You received this message because you are subscribed to the Google Groups "wxPython-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.