2013-08-02 6 views
0

wxnotebook을 사용하여 페이지 밖으로 스크롤 할 수있는 프로그램을 만들고 싶습니다. 모니터에서 작업해야하는 영역이 프로그램에 비해 너무 작기 때문입니다. 나는 하나의 방법을 시도했지만, 스크롤은 작동하지 않습니다. 여기에 내가 가진 것에 대한 예제 코드가 있습니다. 모든 버튼에 액세스 할 수 있도록 스크롤 할 수 있어야합니다. 미리 감사드립니다.wxnotebook 영역 모니터로 스크롤

import wx 
import math as m 
import wx.lib.scrolledpanel as scrolled 



class PageOne(scrolled.ScrolledPanel): 


    def __init__(self, parent): 
     scrolled.ScrolledPanel.__init__(self, parent, 
             style = wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER) 

     self.SetupScrolling() 

     font = wx.Font(10, wx.ROMAN, wx.NORMAL, wx.NORMAL) 


     self.name1= wx.TextCtrl(self, -1, '', (10, 35), (70, -1)) 
     self.name2= wx.TextCtrl(self, -1, '', (10, 35+30), (70, -1)) 
     self.name3= wx.TextCtrl(self, -1, '', (10, 35+60), (70, -1)) 
     self.name4= wx.TextCtrl(self, -1, '', (10, 35+90), (70, -1)) 
     self.name5= wx.TextCtrl(self, -1, '', (10, 35+120), (70, -1)) 
     self.name6= wx.TextCtrl(self, -1, '', (10, 35+150), (70, -1)) 
     self.name7= wx.TextCtrl(self, -1, '', (10, 35+180), (70, -1)) 
     self.name8= wx.TextCtrl(self, -1, '', (10, 35+210), (70, -1)) 
     self.name9= wx.TextCtrl(self, -1, '', (10, 35+240), (70, -1)) 
     self.name10= wx.TextCtrl(self, -1, '', (10, 35+270), (70, -1)) 
     self.name11= wx.TextCtrl(self, -1, '', (10, 35+300), (70, -1)) 
     self.name12= wx.TextCtrl(self, -1, '', (10, 35+330), (70, -1)) 
     self.name13= wx.TextCtrl(self, -1, '', (10, 35+360), (70, -1)) 
     self.name14= wx.TextCtrl(self, -1, '', (10, 35+390), (70, -1)) 
     self.name15= wx.TextCtrl(self, -1, '', (10, 35+420), (70, -1)) 
     self.name16= wx.TextCtrl(self, -1, '', (10, 35+450), (70, -1)) 
     self.name17= wx.TextCtrl(self, -1, '', (10, 35+480), (70, -1)) 
     self.name18= wx.TextCtrl(self, -1, '', (10, 35+510), (70, -1)) 


     self.to1= wx.TextCtrl(self, -1, '', (90, 35), (40, -1)) 
     self.to2= wx.TextCtrl(self, -1, '', (90, 35+30), (40, -1)) 
     self.to3= wx.TextCtrl(self, -1, '', (90, 35+60), (40, -1)) 
     self.to4= wx.TextCtrl(self, -1, '', (90, 35+90), (40, -1)) 
     self.to5= wx.TextCtrl(self, -1, '', (90, 35+120), (40, -1)) 
     self.to6= wx.TextCtrl(self, -1, '', (90, 35+150), (40, -1)) 
     self.to7= wx.TextCtrl(self, -1, '', (90, 35+180), (40, -1)) 
     self.to8= wx.TextCtrl(self, -1, '', (90, 35+210), (40, -1)) 
     self.to9= wx.TextCtrl(self, -1, '', (90, 35+240), (40, -1)) 
     self.to10= wx.TextCtrl(self, -1, '', (90, 35+270), (40, -1)) 
     self.to11= wx.TextCtrl(self, -1, '', (90, 35+300), (40, -1)) 
     self.to12= wx.TextCtrl(self, -1, '', (90, 35+330), (40, -1)) 
     self.to13= wx.TextCtrl(self, -1, '', (90, 35+360), (40, -1)) 
     self.to14= wx.TextCtrl(self, -1, '', (90, 35+390), (40, -1)) 
     self.to15= wx.TextCtrl(self, -1, '', (90, 35+420), (40, -1)) 
     self.to16= wx.TextCtrl(self, -1, '', (90, 35+450), (40, -1)) 
     self.to17= wx.TextCtrl(self, -1, '', (90, 35+480), (40, -1)) 
     self.to18= wx.TextCtrl(self, -1, '', (90, 35+510), (40, -1)) 


     self.topc1= wx.TextCtrl(self, -1, '', (140, 35), (40, -1)) 
     self.topc2= wx.TextCtrl(self, -1, '', (140, 35+30), (40, -1)) 
     self.topc3= wx.TextCtrl(self, -1, '', (140, 35+60), (40, -1)) 
     self.topc4= wx.TextCtrl(self, -1, '', (140, 35+90), (40, -1)) 
     self.topc5= wx.TextCtrl(self, -1, '', (140, 35+120), (40, -1)) 
     self.topc6= wx.TextCtrl(self, -1, '', (140, 35+150), (40, -1)) 
     self.topc7= wx.TextCtrl(self, -1, '', (140, 35+180), (40, -1)) 
     self.topc8= wx.TextCtrl(self, -1, '', (140, 35+210), (40, -1)) 
     self.topc9= wx.TextCtrl(self, -1, '', (140, 35+240), (40, -1)) 
     self.topc10= wx.TextCtrl(self, -1, '', (140, 35+270), (40, -1)) 
     self.topc11= wx.TextCtrl(self, -1, '', (140, 35+300), (40, -1)) 
     self.topc12= wx.TextCtrl(self, -1, '', (140, 35+330), (40, -1)) 
     self.topc13= wx.TextCtrl(self, -1, '', (140, 35+360), (40, -1)) 
     self.topc14= wx.TextCtrl(self, -1, '', (140, 35+390), (40, -1)) 
     self.topc15= wx.TextCtrl(self, -1, '', (140, 35+420), (40, -1)) 
     self.topc16= wx.TextCtrl(self, -1, '', (140, 35+450), (40, -1)) 
     self.topc17= wx.TextCtrl(self, -1, '', (140, 35+480), (40, -1)) 
     self.topc18= wx.TextCtrl(self, -1, '', (140, 35+510), (40, -1)) 


     panel = wx.Panel(self, -1, (195,35), (5,630), style=wx.SUNKEN_BORDER) 

     wx.ToggleButton(self, 1, '', (210, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+40, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+80, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+120, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+160, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+200, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+240, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+280, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+320, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+360, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+400, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+440, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+480, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+520, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+560, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+600, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+640, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+680, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+720, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+760, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+800, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+840, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+880, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+920, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+960, 35),(30,20)) 










class MainFrame(wx.Frame): 
    def __init__(self): 
     wx.Frame.__init__(self, None, -1, "Scroll",(1,1),(3000,800)) 

     # Here we create a panel and a notebook on the panel 
     p = wx.Panel(self) 
     nb = wx.Notebook(p) 

     # create the page windows as children of the notebook 
     page1 = PageOne(nb) 


     # add the pages to the notebook with the label to show on the tab 
     nb.AddPage(page1, "Page 1") 


     # finally, put the notebook in a sizer for the panel to manage 
     # the layout 
     sizer = wx.BoxSizer() 
     sizer.Add(nb, 1, 0) 
     p.SetSizer(sizer) 


if __name__ == "__main__": 
    app = wx.App() 
    MainFrame().Show() 
    app.MainLoop() 

답변

0

가까운 사이입니다. 실제로 스크롤 한 패널을 노트북의 페이지 대신 상단 패널로 사용하려고합니다. 따라서이 대신 수행

import wx 
import math as m 
import wx.lib.scrolledpanel as scrolled 



class PageOne(wx.Panel): 


    def __init__(self, parent): 
     wx.Panel.__init__(self, parent) 

     font = wx.Font(10, wx.ROMAN, wx.NORMAL, wx.NORMAL) 


     self.name1= wx.TextCtrl(self, -1, '', (10, 35), (70, -1)) 
     self.name2= wx.TextCtrl(self, -1, '', (10, 35+30), (70, -1)) 
     self.name3= wx.TextCtrl(self, -1, '', (10, 35+60), (70, -1)) 
     self.name4= wx.TextCtrl(self, -1, '', (10, 35+90), (70, -1)) 
     self.name5= wx.TextCtrl(self, -1, '', (10, 35+120), (70, -1)) 
     self.name6= wx.TextCtrl(self, -1, '', (10, 35+150), (70, -1)) 
     self.name7= wx.TextCtrl(self, -1, '', (10, 35+180), (70, -1)) 
     self.name8= wx.TextCtrl(self, -1, '', (10, 35+210), (70, -1)) 
     self.name9= wx.TextCtrl(self, -1, '', (10, 35+240), (70, -1)) 
     self.name10= wx.TextCtrl(self, -1, '', (10, 35+270), (70, -1)) 
     self.name11= wx.TextCtrl(self, -1, '', (10, 35+300), (70, -1)) 
     self.name12= wx.TextCtrl(self, -1, '', (10, 35+330), (70, -1)) 
     self.name13= wx.TextCtrl(self, -1, '', (10, 35+360), (70, -1)) 
     self.name14= wx.TextCtrl(self, -1, '', (10, 35+390), (70, -1)) 
     self.name15= wx.TextCtrl(self, -1, '', (10, 35+420), (70, -1)) 
     self.name16= wx.TextCtrl(self, -1, '', (10, 35+450), (70, -1)) 
     self.name17= wx.TextCtrl(self, -1, '', (10, 35+480), (70, -1)) 
     self.name18= wx.TextCtrl(self, -1, '', (10, 35+510), (70, -1)) 


     self.to1= wx.TextCtrl(self, -1, '', (90, 35), (40, -1)) 
     self.to2= wx.TextCtrl(self, -1, '', (90, 35+30), (40, -1)) 
     self.to3= wx.TextCtrl(self, -1, '', (90, 35+60), (40, -1)) 
     self.to4= wx.TextCtrl(self, -1, '', (90, 35+90), (40, -1)) 
     self.to5= wx.TextCtrl(self, -1, '', (90, 35+120), (40, -1)) 
     self.to6= wx.TextCtrl(self, -1, '', (90, 35+150), (40, -1)) 
     self.to7= wx.TextCtrl(self, -1, '', (90, 35+180), (40, -1)) 
     self.to8= wx.TextCtrl(self, -1, '', (90, 35+210), (40, -1)) 
     self.to9= wx.TextCtrl(self, -1, '', (90, 35+240), (40, -1)) 
     self.to10= wx.TextCtrl(self, -1, '', (90, 35+270), (40, -1)) 
     self.to11= wx.TextCtrl(self, -1, '', (90, 35+300), (40, -1)) 
     self.to12= wx.TextCtrl(self, -1, '', (90, 35+330), (40, -1)) 
     self.to13= wx.TextCtrl(self, -1, '', (90, 35+360), (40, -1)) 
     self.to14= wx.TextCtrl(self, -1, '', (90, 35+390), (40, -1)) 
     self.to15= wx.TextCtrl(self, -1, '', (90, 35+420), (40, -1)) 
     self.to16= wx.TextCtrl(self, -1, '', (90, 35+450), (40, -1)) 
     self.to17= wx.TextCtrl(self, -1, '', (90, 35+480), (40, -1)) 
     self.to18= wx.TextCtrl(self, -1, '', (90, 35+510), (40, -1)) 


     self.topc1= wx.TextCtrl(self, -1, '', (140, 35), (40, -1)) 
     self.topc2= wx.TextCtrl(self, -1, '', (140, 35+30), (40, -1)) 
     self.topc3= wx.TextCtrl(self, -1, '', (140, 35+60), (40, -1)) 
     self.topc4= wx.TextCtrl(self, -1, '', (140, 35+90), (40, -1)) 
     self.topc5= wx.TextCtrl(self, -1, '', (140, 35+120), (40, -1)) 
     self.topc6= wx.TextCtrl(self, -1, '', (140, 35+150), (40, -1)) 
     self.topc7= wx.TextCtrl(self, -1, '', (140, 35+180), (40, -1)) 
     self.topc8= wx.TextCtrl(self, -1, '', (140, 35+210), (40, -1)) 
     self.topc9= wx.TextCtrl(self, -1, '', (140, 35+240), (40, -1)) 
     self.topc10= wx.TextCtrl(self, -1, '', (140, 35+270), (40, -1)) 
     self.topc11= wx.TextCtrl(self, -1, '', (140, 35+300), (40, -1)) 
     self.topc12= wx.TextCtrl(self, -1, '', (140, 35+330), (40, -1)) 
     self.topc13= wx.TextCtrl(self, -1, '', (140, 35+360), (40, -1)) 
     self.topc14= wx.TextCtrl(self, -1, '', (140, 35+390), (40, -1)) 
     self.topc15= wx.TextCtrl(self, -1, '', (140, 35+420), (40, -1)) 
     self.topc16= wx.TextCtrl(self, -1, '', (140, 35+450), (40, -1)) 
     self.topc17= wx.TextCtrl(self, -1, '', (140, 35+480), (40, -1)) 
     self.topc18= wx.TextCtrl(self, -1, '', (140, 35+510), (40, -1)) 


     panel = wx.Panel(self, -1, (195,35), (5,630), style=wx.SUNKEN_BORDER) 

     wx.ToggleButton(self, 1, '', (210, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+40, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+80, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+120, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+160, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+200, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+240, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+280, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+320, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+360, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+400, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+440, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+480, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+520, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+560, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+600, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+640, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+680, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+720, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+760, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+800, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+840, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+880, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+920, 35),(30,20)) 
     wx.ToggleButton(self, 1, '', (210+960, 35),(30,20)) 

class MainFrame(wx.Frame): 
    def __init__(self): 
     wx.Frame.__init__(self, None, -1, "Scroll",(1,1),(600,600)) 

     # Here we create a panel and a notebook on the panel 
     s = scrolled.ScrolledPanel(self, style = wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER) 
     s.SetupScrolling() 
     nb = wx.Notebook(s) 

     # create the page windows as children of the notebook 
     page1 = PageOne(nb) 


     # add the pages to the notebook with the label to show on the tab 
     nb.AddPage(page1, "Page 1") 


     # finally, put the notebook in a sizer for the panel to manage 
     # the layout 
     sizer = wx.BoxSizer() 
     sizer.Add(nb, 1, 0) 
     s.SetSizer(sizer) 


if __name__ == "__main__": 
    app = wx.App() 
    MainFrame().Show() 
    app.MainLoop()