Problem split splitterwindow again

Hello, following code:

#!/usr/bin/env python

import wx
import wx.stc

class MySplitter(wx.SplitterWindow):
    def __init__(self, parent, ID):
        wx.SplitterWindow.__init__(self, parent, ID,
                                   style = wx.SP_LIVE_UPDATE
                                   )

class StcHistory(wx.stc.StyledTextCtrl):
    def __init__(self, parent):
        wx.stc.StyledTextCtrl.__init__(self, parent, -1)

class StcMemory(wx.stc.StyledTextCtrl):
    def __init__(self, parent):
        wx.stc.StyledTextCtrl.__init__(self, parent, -1)

class ExtFrame(wx.Frame):
    def __init__(self, *args, **kwargs):
        wx.Frame.__init__(self, *args, **kwargs)
        self.splitter = MySplitter(self, -1)

        self.stcmemory = StcMemory(self.splitter)
        self.panel = wx.Panel(self.splitter)
        self.splitter.SetMinimumPaneSize(20)
        self.splitter.SplitHorizontally(self.stcmemory, self.panel,
-100)

        self.subsplitter = MySplitter(self.panel, -1)
        self.stchistory = StcHistory(self.subsplitter)
        self.subpanel = wx.Panel(self.subsplitter)
        self.subsplitter.SetMinimumPaneSize(20)
        self.subsplitter.SplitVertically(self.stchistory,
self.subpanel, -100)

def main():
    app = wx.App(0)
    frame = ExtFrame(None, -1, "wxExt")
    frame.Show(True)
    app.MainLoop()

if __name__ == "__main__":
    main()

I only see some compressed graphics on the left upper part. What is
wrong in this code? Thank you in advnance!

wxgtk, 2.8.10.1

Hi Franz,

franzSplitter.py (2.24 KB)

···

On 03/09/2010 12:08, franz steinhaeusler wrote:

Hello, following code:

#!/usr/bin/env python

import wx
import wx.stc

class MySplitter(wx.SplitterWindow):
     def __init__(self, parent, ID):
         wx.SplitterWindow.__init__(self, parent, ID,
                                    style = wx.SP_LIVE_UPDATE
                                    )

class StcHistory(wx.stc.StyledTextCtrl):
     def __init__(self, parent):
         wx.stc.StyledTextCtrl.__init__(self, parent, -1)

class StcMemory(wx.stc.StyledTextCtrl):
     def __init__(self, parent):
         wx.stc.StyledTextCtrl.__init__(self, parent, -1)

class ExtFrame(wx.Frame):
     def __init__(self, *args, **kwargs):
         wx.Frame.__init__(self, *args, **kwargs)
         self.splitter = MySplitter(self, -1)

         self.stcmemory = StcMemory(self.splitter)
         self.panel = wx.Panel(self.splitter)
         self.splitter.SetMinimumPaneSize(20)
         self.splitter.SplitHorizontally(self.stcmemory, self.panel,
-100)

         self.subsplitter = MySplitter(self.panel, -1)
         self.stchistory = StcHistory(self.subsplitter)
         self.subpanel = wx.Panel(self.subsplitter)
         self.subsplitter.SetMinimumPaneSize(20)
         self.subsplitter.SplitVertically(self.stchistory,
self.subpanel, -100)

def main():
     app = wx.App(0)
     frame = ExtFrame(None, -1, "wxExt")
     frame.Show(True)
     app.MainLoop()

if __name__ == "__main__":
     main()

I only see some compressed graphics on the left upper part. What is
wrong in this code? Thank you in advnance!

wxgtk, 2.8.10.1

Don't know on wxGtk, but on Windows I see the same problem.

I would recommend using sizers to make splitters etc work better, see attached one way of doing it.

Werner

Thank you Werner, both for your reply and code, it works, but
if I resize the whole window, the splitterwindows don't resize with the
frame.

FranzSt wrote:

Thank you Werner, both for your reply and code, it works, but
if I resize the whole window, the splitterwindows don't resize with the
frame.

More accurate, it resizes horizontally, but not vertically.

Hi Franz,

···

On 03/09/2010 13:54, FranzSt wrote:

FranzSt wrote:

Thank you Werner, both for your reply and code, it works, but
if I resize the whole window, the splitterwindows don't resize with the
frame.

More accurate, it resizes horizontally, but not vertically.

Haven't looked, but probably some AddGrowablexxx missing or .sizer.Add not defined correctly.

Will try and have a look later this afternoon.

Werner

werner wrote:

  Hi Franz,

FranzSt wrote:

Thank you Werner, both for your reply and code, it works, but
if I resize the whole window, the splitterwindows don't resize with the
frame.

More accurate, it resizes horizontally, but not vertically.

Haven't looked, but probably some AddGrowablexxx missing or .sizer.Add
not defined correctly.

Will try and have a look later this afternoon.

Werner

That would be cool. And To "resize" the splitterwindows
("proportionally") when resizing the frame, there must be a size event
directly on the splitterwindow(?)

···

On 03/09/2010 13:54, FranzSt wrote:

FranzSt wrote:

werner wrote:

  Hi Franz,

FranzSt wrote:

Thank you Werner, both for your reply and code, it works, but
if I resize the whole window, the splitterwindows don't resize with the
frame.

More accurate, it resizes horizontally, but not vertically.

Haven't looked, but probably some AddGrowablexxx missing or .sizer.Add
not defined correctly.

Will try and have a look later this afternoon.

Werner

That would be cool. And To "resize" the splitterwindows
("proportionally") when resizing the frame, there must be a size event
directly on the splitterwindow(?)

        panelSizer = wx.FlexGridSizer(rows=0, cols=1)
        panelSizer.AddGrowableCol(0)
=> panelSizer.AddGrowableRow(0)

That did the trick. Thank you again for your example, resizing
proportioally, that i think, should find I out myself.

···

On 03/09/2010 13:54, FranzSt wrote:

        panelSizer = wx.FlexGridSizer(rows=0, cols=1)
        panelSizer.AddGrowableCol(0)
=> panelSizer.AddGrowableRow(0)

That did the trick. Thank you again for your example, resizing
proportioally, that i think, should find I out myself.

This is it
http://wiki.wxpython.org/ProportionalSplitterWindow
I have even edited myself a little bit some years ago! What one forget
over the time passing by... :wink:

Still one problem: The stc Window is so big (in the horizontal
direction). That can be seen because of the horizontal scrollbars. How
can I fit the stc window into the reserved space of the splitterwindow?

The whole code (gtk)

http://pastebin.com/AkmatVU0

The STC always assumes that there is potentially a very long line of text, so it sets the scrollbar to accommodate that.

···

On 9/6/10 8:41 AM, franz steinhaeusler wrote:

Still one problem: The stc Window is so big (in the horizontal
direction). That can be seen because of the horizontal scrollbars. How
can I fit the stc window into the reserved space of the splitterwindow?

--
Robin Dunn
Software Craftsman

Robin Dunn wrote:

···

On 9/6/10 8:41 AM, franz steinhaeusler wrote:

Still one problem: The stc Window is so big (in the horizontal
direction). That can be seen because of the horizontal scrollbars. How
can I fit the stc window into the reserved space of the splitterwindow?

The STC always assumes that there is potentially a very long line of
text, so it sets the scrollbar to accommodate that.

Is there a possibility to set the scrollbar in a way, which orients on
the longest line. If scroll is not needed, to hide the scrollbar?

FranzSt wrote:

Robin Dunn wrote:

Still one problem: The stc Window is so big (in the horizontal
direction). That can be seen because of the horizontal scrollbars. How
can I fit the stc window into the reserved space of the splitterwindow?

The STC always assumes that there is potentially a very long line of
text, so it sets the scrollbar to accommodate that.

Is there a possibility to set the scrollbar in a way, which orients on
the longest line. If scroll is not needed, to hide the scrollbar?

I think, basically I would have to discover the longest line, calc with
the character width the width of that line and call
SetScrollWidth(that width) sometimes (for example, when the modified
event happens)

···

On 9/6/10 8:41 AM, franz steinhaeusler wrote:

You can use your own scrollbar instead of the built-in one, with SetHScrollBar. There is an example of that in DynamicSashWindow.py in the demo.

···

On 9/6/10 11:32 PM, FranzSt wrote:

Robin Dunn wrote:

On 9/6/10 8:41 AM, franz steinhaeusler wrote:

Still one problem: The stc Window is so big (in the horizontal
direction). That can be seen because of the horizontal scrollbars. How
can I fit the stc window into the reserved space of the splitterwindow?

The STC always assumes that there is potentially a very long line of
text, so it sets the scrollbar to accommodate that.

Is there a possibility to set the scrollbar in a way, which orients on
the longest line. If scroll is not needed, to hide the scrollbar?

--
Robin Dunn
Software Craftsman