[wxPython] Setting size of sashes in wxSplitterWindow

Might be something trivial again, but I'm puzzled why my calls to
SetSashPosition in the code below don't seem to have any effect.

#!/bin/env python
from wxPython.wx import *

class MainWindow(wxFrame):
    def __init__(self,parent,id,title):
        wxFrame.__init__(self,parent,-4, title, size = (800, 600),
  
                                        style=wxDEFAULT_FRAME_STYLE|
                                        wxNO_FULL_REPAINT_ON_RESIZE)

        self.leftrightsplitter = wxSplitterWindow(self, -1)
        self.folderwin = wxWindow(self.leftrightsplitter, -1)
        self.emailsplitter = wxSplitterWindow(self.leftrightsplitter, -1)
        self.headerwin = wxWindow(self.emailsplitter, -1)
        self.messagewin = wxWindow(self.emailsplitter, -1)
        self.leftrightsplitter.SplitVertically(self.folderwin, self.emailsplitter)
        self.emailsplitter.SplitHorizontally(self.headerwin, self.messagewin)
        self.emailsplitter.SetMinimumPaneSize(20)
        self.leftrightsplitter.SetMinimumPaneSize(20)

        # These don't seem to have any effect :frowning:
        self.leftrightsplitter.SetSashPosition(100, true)
        self.emailsplitter.SetSashPosition(100, true)

        wxStaticText(self.folderwin, -1, "Folders", wxPoint(5,5)).SetBackgroundColour(wxRED)
        wxStaticText(self.headerwin, -1, "Headers", wxPoint(5,5)).SetBackgroundColour(wxRED)
        wxStaticText(self.messagewin, -1, "Message", wxPoint(5,5)).SetBackgroundColour(wxRED)
                
        self.Show(true)

    def OnExit(self,e):
        self.Close(true) # Close the frame.

def main():
    wxInitAllImageHandlers()
    app = wxPySimpleApp()
    frame = MainWindow(None, -1, "mymua")
    frame.Show(1)
    app.MainLoop()

if __name__ == "__main__":
    main()

···

--
mail: gerhard <at> bigfoot <dot> de registered Linux user #64239
web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id AD24C930
public key fingerprint: 3FCC 8700 3012 0A9E B0C9 3667 814B 9CAA AD24 C930
reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b')))

* Gerhard Häring <haering_linux@gmx.de> [2002-07-09 09:53 +0200]:

Might be something trivial again, but I'm puzzled why my calls to
SetSashPosition in the code below don't seem to have any effect. [...]

This is wxWindows-020624 and the wxPython therein. It does work with
wxWindows/Python 2.3.2.1. This is on wxGTK. Does anybody know by chance
if is fixed in the current version or should I report it as a wxWindows
bug?

ciao,

Gerhard

···

--
mail: gerhard <at> bigfoot <dot> de registered Linux user #64239
web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id AD24C930
public key fingerprint: 3FCC 8700 3012 0A9E B0C9 3667 814B 9CAA AD24 C930
reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b')))

Gerhard =?iso-8859-15?Q?H=E4ring?= wrote:

* Gerhard Hring <haering_linux@gmx.de> [2002-07-09 09:53 +0200]:

Might be something trivial again, but I'm puzzled why my calls to
SetSashPosition in the code below don't seem to have any effect.
[...]

This is wxWindows-020624 and the wxPython therein. It does work
with wxWindows/Python 2.3.2.1. This is on wxGTK. Does anybody know
by chance if is fixed in the current version or should I report it
as a wxWindows bug?

Trying to set the sash position from within the __init__() method
indeed doesn't work, but it's not a bug: SetSashPosition() does some
checking on the validity of the position, where it didn't do so before.
The fix is trivial, though. Replace:

   self.leftrightsplitter.SplitVertically(self.folderwin,
      self.emailsplitter)
   self.emailsplitter.SplitHorizontally(self.headerwin,
      self.messagewin)

with:

   self.leftrightsplitter.SplitVertically(self.folderwin,
      self.emailsplitter, 100)
   self.emailsplitter.SplitHorizontally(self.headerwin,
      self.messagewin, 100)

and lose the SetSashPosition() calls. That's all.

Robert Amesz

Trying to set the sash position from within the __init__() method
indeed doesn't work, but it's not a bug: SetSashPosition() does some
checking on the validity of the position, where it didn't do so before.

Specifically, at this moment in time the splitter window is it's default
minimum size (something like 20,20) so setting a sash at 100 is not valid.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Hi,

Is there a pre-made widget to support "wizards" (to use the MS Windows term)? I thought I saw a reference to something somewhere...

Thanks,
Robb

Is there a pre-made widget to support "wizards" (to use the MS Windows
term)? I thought I saw a reference to something somewhere...

There is, but it's not in wxPython yet.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

I wanted that too. But it was pretty easy writing our own wizard interface.

Just make each page be a normal python object, but in the show create a wxPanel on top of 'parent'. Make the wizard be two panels, a large top one and a lower one with back, next, and cancel buttons. Then as each page shows, create it's controls as children of the large top panel. When it hides, just destroy the panel that it created in the show method.

Then make pages class that handles order and all that.

wizard.pages[0].show()
wizard.pages.showNext()
wizard.pages['person'].show()

It's a quick and easy exercise in python and wxPython.

GBU
Matthew Sherborne

This would be a really nice one to add to the demos...as a new wxPython
user I ended up spending some time trying to replicate this. :>

-dave

···

On Tue, 2002-07-09 at 16:32, Matthew Sherborne wrote:

I wanted that too. But it was pretty easy writing our own wizard interface.

Just make each page be a normal python object, but in the show create a
wxPanel on top of 'parent'. Make the wizard be two panels, a large top
one and a lower one with back, next, and cancel buttons. Then as each
page shows, create it's controls as children of the large top panel.
When it hides, just destroy the panel that it created in the show method.

Then make pages class that handles order and all that.

wizard.pages[0].show()
wizard.pages.showNext()
wizard.pages['person'].show()

It's a quick and easy exercise in python and wxPython.

GBU
Matthew Sherborne

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users

I agree - this should be easy (and even fun) to roll onesself. But the algorithm you described:

Matthew Sherborne wrote:

  Then as each page shows, create it's controls as children of the large top panel. When it hides, just destroy the panel that it created in the show method.

...seems difficult. And, how would you handle "previous"/"next" movement if you're creating and tearing down the UI after every frame?

I'm imagining the following:

* A subclass of wxPanel that acts like the Java CardLayout LayoutManager. Basically, it's a tab panel without the visible tabs, and the panels are changed programmatically.
* This panel is contained in a dialog window with "Previous...", "Next..." and "Finish" buttons.
* The wizard class has methods for adding new wxPanels and for displaying the modal dialog.

Just brainstorming here...
Robb

Dave Aitel wrote:

This would be a really nice one to add to the demos...as a new wxPython
user I ended up spending some time trying to replicate this. :>

Yes, unfortunately I did it at work so if I release it my boss would fry me :frowning:

And of course it would need some more genercization.

I could re-write it at home, but I'm quite busy at the moment, learning Numeric and Zope and stuff

Sorry all.
Matthew

* Robin Dunn <robin@alldunn.com> [2002-07-09 11:41 -0700]:

> Trying to set the sash position from within the __init__() method
> indeed doesn't work, but it's not a bug: SetSashPosition() does some
> checking on the validity of the position, where it didn't do so
> before.

Specifically, at this moment in time the splitter window is it's
default minimum size (something like 20,20) so setting a sash at 100
is not valid.

Thanks, Robert and Robin, it works much better now.

Gerhard

···

--
mail: gerhard <at> bigfoot <dot> de registered Linux user #64239
web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id AD24C930
public key fingerprint: 3FCC 8700 3012 0A9E B0C9 3667 814B 9CAA AD24 C930
reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b')))

>This would be a really nice one to add to the demos...as a new wxPython
>user I ended up spending some time trying to replicate this. :>
>

It should be fairly easy to duplicate the C++ wxWizard in Python. There's
nothing too tricky going on there. See these files (rejoin broken URLs):

http://cvs.wxwindows.org/cgi-bin/viewcvs.cgi/wxWindows/include/wx/wizard.h?r
ev=1.20&content-type=text/vnd.viewcvs-markup

http://cvs.wxwindows.org/cgi-bin/viewcvs.cgi/wxWindows/include/wx/generic/wi
zard.h?rev=1.9&content-type=text/vnd.viewcvs-markup

http://cvs.wxwindows.org/cgi-bin/viewcvs.cgi/wxWindows/src/generic/wizard.cp
p?rev=1.31&content-type=text/vnd.viewcvs-markup

Otherwise, it's on my list and I'll get to it eventually.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!