我使用的是wxPython 2.8,并试图在wx.Frame的右侧添加滚动条功能。这个“右边”是一个大小;我尝试过使用wx.ScrolledWindow,但它似乎只在wx.Frame上起作用。是否必须在滚动条的客户端添加wx.Panel?怎么做到的?有没有一个例子?
下面这段代码中,我创建了“正确的”大小:
btnSizer = wx.GridSizer(6,num_art_per_riga)
for elemento in lista_elementi:
self.button = MyButton(self.scroll, elemento.descrizionebreve, elemento.descrizione, is_articolo)
self.button.Bind(wx.EVT_BUTTON , self.aggiungi_su_listbox)
btnSizer.Add(self.button, proportion=0, flag=wx.ALIGN_LEFT|wx.EXPAND, border=0)
btnSizer.Layout()
box = wx.StaticBox(self.scroll, -1, descrizione_box)
staticSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
staticSizer.Add(btnSizer)
self.toolbar.Add(staticSizer) # this is the sizer at the right side
self.scroll.SetVirtualSize((600, 400)) #this is the scroll !在这个例子中,“工具栏”没有显示,什么也没有出现。滚动是使用以下构造函数创建的:
self.scroll = wx.ScrolledWindow(self, -1)其中,self是一个wx.Panel。
谢谢你的帮助
发布于 2010-06-21 02:57:41
尝试使用ScrolledPanel,它是一个“更好”的ScrolledWindow。
(并确保将sizer分配给面板)
发布于 2010-06-16 11:13:56
为了回答你的一个问题,有很多例子。下载wxPython文档和演示,您将有大量的示例可供参考。
https://stackoverflow.com/questions/2978272
复制相似问题