Forum Moderators: Staff
Poser Python Scripting F.A.Q (Last Updated: 2024 Sep 18 2:50 am)
userDir = os.path.join(poser.PrefsLocation(),"My Script") iniFile = os.path.join(userDir,"MyScript.ini") scene = poser.Scene() man = poser.WxAuiManager() root = man.GetManagedWindow()
class MyClass(wx.ScrolledWindow):
def __init__(self, parent):
etc
def MyFunction(self):
etc
win = MyClass(root)
def readINIFile(filepath):
# dock value of one or zero read from ini file
def main():
readINIFile(iniFile)
win.MyFunction()
man.AddPane(win, wx.aui.AuiPaneInfo().
Caption("Create Prop").CaptionVisible(True).GripperTop(True).
Floatable(True).Resizable(True).DestroyOnClose(True).Dockable(dock).
FloatingSize(wx.Size(330, 895)).CloseButton(True).MaxSize(wx.Size(330, 895)).
MinSize(wx.Size(330, 250)))
info = man.GetPane(win)
info.Show()
man.Update()
main()
I've used the format above to create a dockable window. The option to dock or not is set by the value read from the ini file on start up. Trouble is that once I docked it, it would always start up docked. I could never again get it to start up un-docked. I've looked for a possible setting in the Poser.ini file but not found one. Not exactly an answer to your problem but may shed some light on it. How are you creating the dockable window for your script?
You don't by any chance have an example do you? (...not the write/read from file, I get that...its the Read Position and Write Position of the pane) I've been toying with it all day, and using this, but all I've managed to do is mess it up.
In exasperation, I've all but decided to just force it to float, which is not ideal.
With Poser 9+, this is working if you use the new 'addons' system.
If you don't use the addons system, I was able to make it work to something similar to what PhilC did.
Saving dock info:
Read the pane settings.
Save it in a .ini file.
Restoring dock info:
Read the .ini file.
Create the pane with the settings from the .ini file.
There are some strange things happening... And the position must be adjusted...
When I load a new pange, I'm using a function that read the ini file, the the position (xp, yp), the size (xs, ys), the dock/float status (DOCK), the various docking information (D - Direction, L - layer, P - position and R - row) and the dockable/floatable status.
Getting the docking information:
pane.dock_direction,pane.dock_layer,pane.dock_pos,pane.dock_row
Then to restore the settings, I read the ini file and get the informations:
(xp,yp,xs,ys,DOCK, D, L, P, R, DOCKABLE) =
SWPC_SizeAndPosInstances()
Finally, I'm loading all using this:
if DOCK:<br></br>
pane.Dock()<br></br>
else:<br></br>
pane.Float()<br></br>
pane.Dockable(DOCKABLE)<br></br>
pane.Floatable(DOCKABLE)<br></br>
pane.Caption(name).CaptionVisible()<br></br>
pane.Resizable()<br></br>
pane.Direction(D).Layer(L).Position(P-1).Row(R)<br></br>
pane.FloatingSize(wx.Size(xs-16, ys-34))<br></br>
pane.FloatingPosition(wx.Point(xp+8, yp+26))<br></br>
pane.BestSize(wx.Size(100,100))<br></br>
pane.MinSize(wx.Size(100,100))<br></br>
pane.CloseButton(True)<br></br>
pane.MinimizeButton(True)<br></br>
pane.DestroyOnClose(True)
Notice the Position(P-1) which adjust the docking position - don't know why it's necessary but this was working for me.
Now... this is an old code and certainly might be better :) Last thing, don't forget the addons if you're developing for the latest version of Poser. It's much better and offers other nice uses :)
I attached it in case anyone has time to take a look. I stripped it down to the bare docking and setup stuff, so it is pretty small. It just loads and has a single file->save command, which create an INI file in c:temp.
You'll have to change it to a .py of course...
(feel free to critique...I am trying to improve)
This site uses cookies to deliver the best experience. Our own cookies make user accounts and other features possible. Third-party cookies are used to display relevant ads and to analyze how Renderosity is used. By using our site, you acknowledge that you have read and understood our Terms of Service, including our Cookie Policy and our Privacy Policy.
For wxPython windows, how do you set it to remember the location of the docked window on the next launch of Poser? I can get it docking, and I found and understand how to make it non-docking....
What I don't understand is how to get it to remember the dock settings? When I restart, my script always starts undocked again?
Thanks!