2015-12-07 3 views
0

По умолчанию wx.lib.scrolledpanel поддерживает вертикальную прокрутку колесика мыши, но не поддерживает горизонтальную прокрутку при нажатии shift. Я не могу найти способ активировать его. Это даже где-то или я должен написать соответствующий обработчик событий сам? Как это сделать, если так?wxPython горизонтальная прокрутка со сдвигом + колесиком мыши

ответ

0

Для прокрутки по горизонтали вы должны навести указатель мыши на горизонтальную полосу прокрутки, а затем вращать колесико мыши.

import wx 
import wx.lib.scrolledpanel as scrolled 
class TestPanel(scrolled.ScrolledPanel): 
    def __init__(self, parent): 
     scrolled.ScrolledPanel.__init__(self, parent, -1) 
     vbox = wx.BoxSizer(wx.VERTICAL) 
     desc1 = wx.StaticText(self, -1, "1. These lines are really quite long and should not fit in the window requiring you to use the horizontal scroll bar or position the mouse over the scroll bar and spin the wheel\n\n") 
     desc2 = wx.StaticText(self, -1, "2. These lines are really quite long and should not fit in the window requiring you to use the horizontal scroll bar or position the mouse over the scroll bar and spin the wheel\n\n") 
     desc3 = wx.StaticText(self, -1, "3. These lines are really quite long and should not fit in the window requiring you to use the horizontal scroll bar or position the mouse over the scroll bar and spin the wheel\n\n") 
     desc4 = wx.StaticText(self, -1, "4. These lines are really quite long and should not fit in the window requiring you to use the horizontal scroll bar or position the mouse over the scroll bar and spin the wheel\n\n") 
     desc5 = wx.StaticText(self, -1, "5. These lines are really quite long and should not fit in the window requiring you to use the horizontal scroll bar or position the mouse over the scroll bar and spin the wheel\n\n") 
     desc6 = wx.StaticText(self, -1, "6. These lines are really quite long and should not fit in the window requiring you to use the horizontal scroll bar or position the mouse over the scroll bar and spin the wheel\n\n") 
     vbox.Add(desc1, wx.NewId(), wx.ALIGN_LEFT|wx.ALL, 5) 
     vbox.Add(desc2, wx.NewId(), wx.ALIGN_LEFT|wx.ALL, 5) 
     vbox.Add(desc3, wx.NewId(), wx.ALIGN_LEFT|wx.ALL, 5) 
     vbox.Add(desc4, wx.NewId(), wx.ALIGN_LEFT|wx.ALL, 5) 
     vbox.Add(desc5, wx.NewId(), wx.ALIGN_LEFT|wx.ALL, 5) 
     vbox.Add(desc6, wx.NewId(), wx.ALIGN_LEFT|wx.ALL, 5) 
     self.SetSizer(vbox) 
     self.SetAutoLayout(1) 
     self.SetupScrolling(scroll_x=True, scroll_y=True, rate_x=20, rate_y=20, scrollToTop=True, scrollIntoView=True) 
app = wx.App(0) 
frame = wx.Frame(None, wx.ID_ANY,size=(500,200)) 
tp = TestPanel(frame) 
frame.Show() 
app.MainLoop() 
Смежные вопросы