Problem split splitterwindow again

138 views
Skip to first unread message

franz steinhaeusler

unread,
Sep 3, 2010, 6:08:09 AM9/3/10
to wxPython-users
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

werner

unread,
Sep 3, 2010, 6:49:59 AM9/3/10
to wxpytho...@googlegroups.com
Hi Franz,

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

franzSplitter.py

FranzSt

unread,
Sep 3, 2010, 7:50:11 AM9/3/10
to wxpytho...@lists.wxwidgets.org
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

unread,
Sep 3, 2010, 7:54:22 AM9/3/10
to wxpytho...@lists.wxwidgets.org
FranzSt wrote:

More accurate, it resizes horizontally, but not vertically.

werner

unread,
Sep 3, 2010, 8:15:02 AM9/3/10
to wxpytho...@googlegroups.com
Hi Franz,

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

Will try and have a look later this afternoon.

Werner


FranzSt

unread,
Sep 3, 2010, 8:28:20 AM9/3/10
to wxpytho...@lists.wxwidgets.org
werner wrote:

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


FranzSt

unread,
Sep 3, 2010, 9:09:40 AM9/3/10
to wxpytho...@lists.wxwidgets.org
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.

FranzSt

unread,
Sep 3, 2010, 9:42:54 AM9/3/10
to wxpytho...@lists.wxwidgets.org
> 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... ;)

franz steinhaeusler

unread,
Sep 6, 2010, 11:41:54 AM9/6/10
to wxPython-users
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?

franz steinhaeusler

unread,
Sep 6, 2010, 11:44:48 AM9/6/10
to wxPython-users
The whole code (gtk)

http://pastebin.com/AkmatVU0

Robin Dunn

unread,
Sep 6, 2010, 6:39:11 PM9/6/10
to wxpytho...@googlegroups.com

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

--
Robin Dunn
Software Craftsman
http://wxPython.org

FranzSt

unread,
Sep 7, 2010, 2:32:59 AM9/7/10
to wxpytho...@lists.wxwidgets.org
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

unread,
Sep 7, 2010, 3:40:01 AM9/7/10
to wxpytho...@lists.wxwidgets.org
FranzSt wrote:

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)


Robin Dunn

unread,
Sep 7, 2010, 4:48:54 PM9/7/10
to wxpytho...@googlegroups.com

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.

Reply all
Reply to author
Forward
0 new messages