newbie question: obtain a scrollable Panel

Hi all.

I’m a new wxPython user and I found immediatly some problems. My only know of direct GUI programming from source code came from Java world…

What I wanna obtain is a window with some subelements (and this is simple). One of those subelement is a Panel, with other element inside (for now a Grid). The grid can contains many and many rows, So I need that the Panel outside to be scrollable.

But I find some problems to get his to work. Playing with Panel style I can make the scrollbar to appear, but nothing more (using the scrollbar do nothing at all!!!).

There’s a simple example to follow, or some indication that I can use? I tryed the wx.lib.scrolledpanel.ScrolledPanel, but nothing changed…

Thanks all!

Hi Luca,

Luca wrote:

Hi all.

I'm a new wxPython user and I found immediatly some problems. My only know of direct GUI programming from source code came from Java world...

What I wanna obtain is a window with some subelements (and this is simple). One of those subelement is a Panel, with other element inside (for now a Grid). The grid can contains many and many rows, So I need that the Panel outside to be scrollable.

But I find some problems to get his to work. Playing with Panel style I can make the scrollbar to appear, but nothing more (using the scrollbar do nothing at all!!!).

There's a simple example to follow, or some indication that I can use? I tryed the wx.lib.scrolledpanel.ScrolledPanel, but nothing changed...

Thanks all!

You should not need to do anything special at all, wxPython handles scrolling for you in the majority of cases. I have attached a very simple example of a grid in a frame with another control, that scrolls just fine with no special code. I used a sizer to allow for the other control but it still works if you just put the grid as the only child of the frame.

Perhaps you are using sizers but not giving it a proportion or telling it to expand (depending on which is appropriate), or you are not using sizers and not making it the only child?

Hopefully this helps,
Mike

gridspacedemo.py (575 Bytes)

sizer.Add(grid, 1, wx.EXPAND)

This is what I was missing!!! Thanks very much…

I found a little difficult to find good documentation on wxPython on the web… The starting tutorial is a good point to start, but after that…

Thanks you again!

···

On 4/23/07, Mike Rooney mxr@qvii.com wrote:

Hi Luca,

Luca wrote:

Hi all.

I’m a new wxPython user and I found immediatly some problems. My only
know of direct GUI programming from source code came from Java world…

What I wanna obtain is a window with some subelements (and this is
simple). One of those subelement is a Panel, with other element inside
(for now a Grid). The grid can contains many and many rows, So I need

that the Panel outside to be scrollable.

But I find some problems to get his to work. Playing with Panel style
I can make the scrollbar to appear, but nothing more (using the
scrollbar do nothing at all!!!).

There’s a simple example to follow, or some indication that I can use?
I tryed the wx.lib.scrolledpanel.ScrolledPanel, but nothing changed…

Thanks all!

You should not need to do anything special at all, wxPython handles

scrolling for you in the majority of cases. I have attached a very
simple example of a grid in a frame with another control, that scrolls
just fine with no special code. I used a sizer to allow for the other

control but it still works if you just put the grid as the only child of
the frame.

Perhaps you are using sizers but not giving it a proportion or telling
it to expand (depending on which is appropriate), or you are not using

sizers and not making it the only child?

Hopefully this helps,
Mike

import wx, wx.grid

class MyFrame(wx.Frame):
def init(self):
wx.Frame.init(self, None, title=“Grid example”)

    panel = wx.Panel(self)

    grid = wx.grid.Grid(panel)
    grid.CreateGrid(50, 3)

    sizer = wx.BoxSizer(wx.VERTICAL)
    sizer.Add(grid, 1, wx.EXPAND)
    sizer.Add

(wx.Button(panel, label=“Another control”))

    panel.Sizer = sizer
    sizer.Layout()

if name == “main”:
app = wx.PySimpleApp()
frame = MyFrame()

frame.Show(1)
app.MainLoop()

To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org

For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Hi Luca,

Luca wrote:

>sizer.Add(grid, 1, wx.EXPAND)

This is what I was missing!!! Thanks very much...

I found a little difficult to find good documentation on wxPython on the web... The starting tutorial is a good point to start, but after that...

The demo is always a got starting point (download it from here Redirecting... if you don't have it yet), then the wiki here http://wiki.wxpython.org/, then the new wxPython API doc (not complete but still very useful - NameBright - Coming Soon , also available as a download, then the wxWidgets docs which comes with the demo and last but not least this list is always very helpful.

Then there is also The Book (wxPython in Action) and am sure there are some more places.

Werner