[wxPython-users] how can I make scroll in panel?

1,196 views
Skip to first unread message

Wonjun, Choi

unread,
Oct 28, 2011, 4:19:24 AM10/28/11
to wxPython-users
I make like this but when I move the vertical scrollbar, it scrolls
nothing.
how can I make working scroll?


class TestPanel(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent, -1)

self.Autosizer = wx.FlexGridSizer(cols=2, hgap = -190, vgap =
-1)
self.Autosizer.SetFlexibleDirection(wx.VERTICAL)

self.scrolled_panel = scrolled.ScrolledPanel(self, -1,
style = wx.TAB_TRAVERSAL|
wx.SUNKEN_BORDER, name="panel1")
self.scrolled_panel.SetAutoLayout(1)
self.scrolled_panel.SetupScrolling()

self.scrolled_panel.SetSizer(self.Autosizer)


panelSizer = wx.BoxSizer(wx.VERTICAL)
panelSizer.Add(self.scrolled_panel, 1, wx.EXPAND)
# panelSizer.Add(btn)
self.SetSizer(panelSizer)

what I want to do is :
when I move the scroll, the containers in flexGridSizer will be
scrolled.

Wonjun, Choi

werner

unread,
Oct 28, 2011, 5:08:34 AM10/28/11
to wxpytho...@googlegroups.com
On 10/28/2011 10:19 AM, Wonjun, Choi wrote:
> I make like this but when I move the vertical scrollbar, it scrolls
> nothing.
> how can I make working scroll?
>
What are you trying to accomplish with ", hgap = -190, vgap=-1)" on your
sizer?

Your code doesn't show how you add controls to all this.

The code you have should work, so I suspect it is in your code where you
add controls.

Attached a sample app based on your code with some additional stuff
(less your hgap setting) showing that it works.

Werner

scrollpanel.py

G. Nikiforov

unread,
Oct 28, 2011, 6:00:25 AM10/28/11
to wxpytho...@googlegroups.com
> I make like this but when I move the vertical scrollbar, it scrolls
> nothing.
> how can I make working scroll?
>
> what I want to do is :
> when I move the scroll, the containers in flexGridSizer will be
> scrolled.

Hi, I also struggled with that and what worked in the end for me is using wx.ScrolledWindow as opposed to a panel. This is the documentations which I was reading:
http://xoomer.virgilio.it/infinity77/wxPython/Widgets/wx.ScrolledWindow.html
To make the window scrollable, I used the command SetScrollRate as described in the third bullet at the top in the document above.
In addition, to set the size of the window (the actual window which appears on the screen with the scrollbars, and not the virtual window through which you are scrolling), I used the SetMinSize command on the ScrolledWindow.
Finally, in my case was populating the scrolled window with widgets during the program was running. In that case in order to show the widgets I used the Layout() command and afterwards FitInside as opposed to Fit in order to keep the same, as Fit will change the size of the scrolled window.
If the above explanation is confusing, you can send a simple and complete executable example script (not just a class) and I can take a closer look.

최원준

unread,
Oct 29, 2011, 12:47:35 AM10/29/11
to wxpytho...@googlegroups.com


2011/10/28 G. Nikiforov <g_nik...@hotmail.com>



I see, thank you

Wonjun, Choi

최원준

unread,
Oct 29, 2011, 1:09:56 AM10/29/11
to wxpytho...@googlegroups.com


2011/10/29 최원준 <wonjun...@gmail.com>



btw, can I change the height of stc when I type text in it?
I want to delete the scroll of stc.
and when user type some text in stc, the stc's height will be changed.
Reply all
Reply to author
Forward
0 new messages