···
##################################
import wx, wx.lib.scrolledpanel
class MyFrame(wx.Frame):
def __init__(self, *args, **kwargs):
wx.Frame.__init__(self, *args, **kwargs)
scrolled_panel = \
wx.lib.scrolledpanel.ScrolledPanel(parent=self, id=-1)
scrolled_panel.SetupScrolling()
text = "Ooga booga\n" * 50
static_text=wx.StaticText(scrolled_panel, -1, text)
sizer=wx.BoxSizer(wx.VERTICAL)
sizer.Add(static_text, wx.EXPAND, 0)
# Uncomment the following 2 lines to see how adding
# a text control to the scrolled panel makes the
# mouse wheel work.
#
#text_control=wx.TextCtrl(scrolled_panel, -1)
#sizer.Add(text_control, wx.EXPAND, 0)
scrolled_panel.SetSizer(sizer)
self.Show()
if __name__=="__main__":
app = wx.PySimpleApp()
my_frame=MyFrame(None, -1)
#import cProfile; cProfile.run("app.MainLoop()")
app.MainLoop()
######################################
On Jul 20, 1:16 am, cool-RR <ram.rac...@gmail.com> wrote:
Is this necessary? I see that ScrolledPanel already has the
functionality to support the mouse wheel, the problem is that it's
only being used when there is a text control in it. Can't I make it
work without a text control?
On Jul 20, 12:29 am, Steven Sproat <spro...@gmail.com> wrote:
> cool-RR wrote:
> > Anyone has a clue?
> > On Jul 19, 12:23 am, cool-RR <ram.rac...@gmail.com> wrote:
> >> Hello everyone,
> >> I have a problem:
> >> In my wxPython application I've created a wx.ScrolledPanel, in which
> >> there is a big wx.StaticBitmap that needs to be scrolled.
> >> The scroll bars do appear and I can scroll with them, but I'd also
> >> like to be able to scroll with the mouse wheel and the arrow keys on
> >> the keyboard. It would also be nice if the "Home", "Page Up", and
> >> those other keys would function as expected.
> >> I noticed that the mouse wheel does work when I place a wx.TextCtrl
> >> inside the ScrolledPanel and focus on it. I guess this has something
> >> to do with the focus.
> >> So what do I do?
> >> Thanks,
> >> Ram.
> for the middle mouse, check out the wx.lib.dragscroller and bind it to
> the appropriate events
> for home and end you'll have to do some calculations in relation to the
> bitmap's size on the canvas