Hi All,
I have just started playing with the agw version of aui (most recent
svn version) - and must say that it is very nice, however, I seem to
be having issues using perspectives.
While testing my test app (code below), I have found 2 situations,
both related to perspective restoration, that I had not expected.
I'm using besides the
python2.5.4
wxpthon2.8.10.1 (msw-unicode)
My test app has 4 panes and if I
1 minimize a pane
2 save a perspective
3 close my app
4 restart my app
5 load the perspective
I find the minimized pane is hidden (as one would expect) but the
minimized icon created when it was minimized is not restored.
I've been poking about a bit and the problem seem to be that while
loading the perspective the AuiManager code checks to see if a window
exists for each pane entry in the perspective file and there is none
for the minimized icon because my code only made windows for the
components it knows about. The code then just ignores the information
about the minimized icon stuff and carries on.
I have found another issue that is probably related. It occurs using
the same test application. if I
1 drag a pane over to another pane and dock it so a notebook is
spontaneously created with the panes as pages
2 save the perspective
3 close the app
4 restart app
5 reload perspective
I find that the pane that was dragged is missing
Is this behavior expected and if so is, there a standard way to do
things correctly so that I don't lose panes?
If the behavior is aberrant, is there a design strategy that would
dictate who, when and where the missing frames should be created? I
ask so that if I do any patching I can do it more or less correctly.
Dominic
···
################################################################################
import wx
#import wx.aui
import sys
sys.path.append(r'D:\temp\agw')
from agw import aui
import pickle
id_paramsPanel = wx.NewId()
class TopFrame(wx.Frame):
def __init__(self, *args, **kargs):
wx.Frame.__init__(self, *args, **kargs)
self.lastProspective =None
self.subPanels =[]
self.setup()
self.setupEvents()
self.setLayout()
self.layoutDetails = self.getLayoutDetails()
self.Update()
def setup(self):
self.manager = aui.AuiManager()
self.manager.SetDockSizeConstraint(0.5, 0.5)
self.manager.SetManagedWindow(self)
self.prospectives =[]
#make panel1
self.paramsPanel = paramsPanel = self.makeParamsPanel()
paramsPanelInfo = aui.AuiPaneInfo()
paramsPanelInfo.Name('params')
paramsPanelInfo.Caption('params report')
paramsPanelInfo.CenterPane()
paramsPanelInfo.CloseButton(False)
self.manager.AddPane(paramsPanel, paramsPanelInfo)
self.infoPanel1 = infoPanel1 = self.makeInfoPanel1()
self.subPanels.append(infoPanel1)
infoPanel1Info = aui.AuiPaneInfo()
infoPanel1Info.Name('info')
infoPanel1Info.Caption('info report')
infoPanel1Info.Top()
infoPanel1Info.Layer(0)
infoPanel1Info.Position(0)
infoPanel1Info.CloseButton(False)
infoPanel1Info.MaximizeButton(True)
infoPanel1Info.MinimizeButton(True)
self.manager.AddPane(infoPanel1, infoPanel1Info)
self.infoPanel2 = infoPanel2 = self.makeInfoPanel2()
self.subPanels.append(infoPanel2)
infoPanel2Info = aui.AuiPaneInfo()
infoPanel2Info.Name('info2')
infoPanel2Info.Caption('info report 2')
infoPanel2Info.Left()
infoPanel2Info.Layer(1)
infoPanel2Info.Position(0)
infoPanel2Info.CloseButton(False)
infoPanel2Info.MaximizeButton(True)
infoPanel2Info.MinimizeButton(True)
self.manager.AddPane(infoPanel2, infoPanel2Info)
self.infoPanel3 = infoPanel3 = self.makeInfoPanel3()
self.subPanels.append(self.infoPanel3)
infoPanel3Info = aui.AuiPaneInfo()
infoPanel3Info.Name('info3')
infoPanel3Info.Caption('info report 3')
infoPanel3Info.Left()
infoPanel3Info.Position(1)
infoPanel3Info.Layer(1)
infoPanel3Info.CloseButton(False)
infoPanel3Info.MaximizeButton(True)
infoPanel3Info.MinimizeButton(True)
self.manager.AddPane(infoPanel3, infoPanel3Info)
def setupEvents(self):
self.Bind(wx.EVT_CLOSE, self.onClose)
def getLayoutDetails(self):
screenCount = wx.Display.GetCount()
screenId = wx.Display.GetFromWindow(self)
dimensionRect = self.GetScreenRect()
frameMaxed = self.IsMaximized()
save=True
for aPane in self.manager.GetAllPanes():
if aPane.IsMaximized() and aPane.name != 'params':
save =False
if save:
closingLayout = self.manager.SavePerspective()
else:
closingLayout = self.lastProspective
screenDetails = {"screenCount" : screenCount,
"screenId" : screenId,
"frameRect" : dimensionRect,
'frameMaximized' : frameMaxed,
'layout' : closingLayout
}
return screenDetails
def storeLayout(self, details):
# details = self.panel.getLayOutDetails()
try:
fh = open('layout', 'w')
pickle.dump( details, fh)
fh.close()
except:
pass # should log problem
def retrieveLayout(self):
details ={}
try:
fh = open('layout', 'r')
details = pickle.load(fh)
fh.close()
except:
pass # should log problem
return details
def setLayoutDetails(self, details):
priorLocation =False
oldPositionX = -1
oldPositionY = -1
oldWidth = -1
oldHeight = -1
if 'frameRect' in details.keys():
priorLocation =True
dimensionRect = details['frameRect']
oldPositionX = dimensionRect.x
oldPositionY = dimensionRect.Y
oldWidth = dimensionRect.width
oldHeight = dimensionRect.height
oldMaximized =False
if 'frameMaximized' in details.keys():
oldMaximized = details['frameMaximized']
screens =[]
screenCount = wx.Display.GetCount()
done =False
if oldMaximized:
if 'screenId' in details.keys():
screenId = details['screenId']
if screenId >=0 and screenId <screenCount:
aDisplay = wx.Display(screenId)
dimensions = aDisplay.GetClientArea()
frameWidth = int(dimensions.width * 0.7)
dx = int(dimensions.width * 0.2/2)
frameHeight = int(dimensions.height * 0.7)
dy= int( dimensions.height * 0.2/2)
self.Maximize()
self.SetDimensions(dimensions.x+dx,dimensions.y
+dx,frameWidth, frameHeight)
done =True
elif oldPositionX ==-3200 and oldPositionY ==-3200:
pass
else:
for i in range(screenCount):
aDisplay = wx.Display(i)
clientDimension = aDisplay.GetClientArea()
totalDimension = aDisplay.GetGeometry()
screens.append([clientDimension, totalDimension])
if oldPositionX >= clientDimension.x and \
oldPositionX < clientDimension.x
+clientDimension.width and \
oldPositionY >= clientDimension.y and \
oldPositionY < clientDimension.y
+clientDimension.height:
self.SetDimensions(oldPositionX ,oldPositionY,oldWidth , oldHeight)
done = True
minWidth = minHeight =50
if not done:
width = height = None
if oldHeight >= minHeight and oldWidth >= minWidth:
height =int(oldHeight)
width = oldWidth
self.defaultLayout(width, height)
if 'layout' in details.keys():
priorLayout = details['layout']
if priorLayout !=None:
self.manager.LoadPerspective(priorLayout)
self.manager.Update()
def onClose(self, evt):
if self.IsIconized():
details = self.layoutDetails
else:
details = self.getLayoutDetails()
self.storeLayout(details)
self.manager.UnInit()
del self.manager
self.Destroy()
def defaultLayout(self, frameWidth =None,frameHeight =None):
displayCount = wx.Display.GetCount()
dimensions =wx.Rect(0, 0, 600,800)
if displayCount >0: # what should we do if we don't have a
monitor?
for i in range(displayCount):
aDisplay = wx.Display(i)
dims = aDisplay.GetClientArea()
if dims.x ==0 and dims.y ==0:
principleDisplay = i
dimensions = dims
break
if frameWidth==None:
frameWidth = int(dimensions.width * 0.7)
dx = int(dimensions.width * 0.2/2)
if frameHeight ==None:
frameHeight = int(dimensions.height * 0.7)
dy= int( dimensions.height * 0.2/2)
self.SetDimensions(dimensions.x+dx,dimensions.y+dy,frameWidth,
frameHeight)
self.manager.Update()
def setLayout(self):
details = self.retrieveLayout()
if details =={}:
self.defaultLayout()
else:
self.setLayoutDetails(details)
def makeParamsPanel(self):
notebook = wx.Notebook(self, -1,size=(400,400))
page1 = wx.TextCtrl(notebook,-1, "params_page1" )
notebook.AddPage(page1,"Look here")
page2 = wx.TextCtrl(notebook,-1, "params_test2")
notebook.AddPage(page2,"Look there")
return notebook
def makeInfoPanel1(self):
notebook = wx.Notebook(self, -1,size= (400,200))
page1 = wx.TextCtrl(notebook,-1, "info1_page1")
notebook.AddPage(page1,"Go ")
page2 = wx.TextCtrl(notebook,-1, "info1_page2")
notebook.AddPage(page2,"Away")
return notebook
def makeInfoPanel2(self):
notebook = wx.Notebook(self, -1,size= (400,400))
page1 = wx.TextCtrl(notebook,-1, "info2_page1")
notebook.AddPage(page1,"Be")
page2 = wx.TextCtrl(notebook,-1, "info2_page2")
notebook.AddPage(page2,"Gone")
return notebook
def makeInfoPanel3(self):
notebook = wx.Notebook(self, -1,size= (400,400))
page1 = wx.TextCtrl(notebook,-1, "info3_page1")
notebook.AddPage(page1,"Fat")
page2 = wx.TextCtrl(notebook,-1, "info3_page2")
notebook.AddPage(page2,"Cat")
return notebook
def main():
theApp = wx.App()
topFrame =TopFrame(None, -1, size= wx.Size(800, 600))
topFrame.Show()
theApp.MainLoop()
if __name__=="__main__":
main()
--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en