wxScrollWindow Demo

Robin

It took me quite a while to get an example that demonstrated the problem.
My really simple demos didn't, thus the complexity. You'll notice that the
framework is from wxGlade but the canvas class is my own. The scrolling
leaves lines across the canvas.

Nigel

strategy.py (8.73 KB)

No lines seen on Windows M & wxPython 2.4.0.2 & python 2.2.2

Chris.

···

----- Original Message -----
From: Nigel Moriarty

To: wxPython-users

Sent: Wednesday, February 05, 2003 10:09 AM

Subject: [wxPython-users] wxScrollWindow Demo

Robin

It took me quite a while to get an example that demonstrated the problem.
My really simple demos didn’t, thus the complexity. You’ll notice that the
framework is from wxGlade but the canvas class is my own. The scrolling
leaves lines across the canvas.

Nigel


#!/usr/bin/env python

generated by wxGlade 0.1.3 on Mon Dec 09 12:49:10 2002

from wxPython.wx import *

class TaskTreeCtrl(wxPanel):
def init(self, *args, **kwds):
# begin wxGlade: init
wxPanel.init(self, *args, **kwds)

    self.__set_properties()
    self.__do_layout()
    # end wxGlade

def __set_properties(self):
    # begin wxGlade: __set_properties
    pass
    # end wxGlade

def __do_layout(self):
    # begin wxGlade: __do_layout
    pass
    # end wxGlade

end of class TaskTreeCtrl

class TaskNoteBookClass(wxNotebook):
def init(self, *args, **kwds):
# begin wxGlade: init
kwds[“style”] = 0
wxNotebook.init(self, *args, **kwds)
self.task_tree_ctrl = TaskTreeCtrl(self, -1)

    self.__set_properties()
    self.__do_layout()
    # end wxGlade

def __set_properties(self):
    # begin wxGlade: __set_properties
    nb_sizer = wxNotebookSizer(self)
    self.AddPage(self.task_tree_ctrl, "tab1")
    # end wxGlade

def __do_layout(self):
    # begin wxGlade: __do_layout
    pass
    # end wxGlade

end of class TaskNoteBookClass

class MenuWrapClass(wxPanel):
def init(self, *args, **kwds):
# begin wxGlade: init
wxPanel.init(self, *args, **kwds)
self.task_notebook = TaskNoteBookClass(self, -1)

    self.__set_properties()
    self.__do_layout()
    # end wxGlade

def __set_properties(self):
    # begin wxGlade: __set_properties
    pass
    # end wxGlade

def __do_layout(self):
    # begin wxGlade: __do_layout
    sizer_3 = wxBoxSizer(wxHORIZONTAL)
    sizer_3.Add(self.task_notebook, 1, wxEXPAND, 0)
    self.SetAutoLayout(1)
    self.SetSizer(sizer_3)
    sizer_3.Fit(self)
    self.Layout()
    # end wxGlade

end of class MenuWrapClass

class TaskCanvas(wxPanel):
def init(self, *args, **kwds):
# begin wxGlade: init
wxPanel.init(self, *args, **kwds)

    self.__set_properties()
    self.__do_layout()
    # end wxGlade

def __set_properties(self):
    # begin wxGlade: __set_properties
    self.SetBackgroundColour(wxColour(0, 0, 255))
    # end wxGlade

def __do_layout(self):
    # begin wxGlade: __do_layout
    pass
    # end wxGlade

end of class TaskCanvas

class TaskCanvasClass(wxScrolledWindow):
“”"
A canvas for tasks and strategies.

Tasks can be added and removed.

Tasks can be connected to the form strategies.

“”"
def init(self, parent, id,
name=“Canvas”):
self.parent = parent
wxScrolledWindow.init(self, parent, id, name=name)
self.SetWindowStyle(wxSUNKEN_BORDER|wxCLIP_CHILDREN)
self.SetBackgroundColour(wxColour(255,255,255))

self.thumb = 10

self.brush = wxBrush(wxColour(255,25,255))
self.Width = 1000
self.Height = 1000

self.SetScrollbars(self.thumb, self.thumb,
                   self.Width/self.thumb, self.Height/self.thumb)

EVT_PAINT(self, self.OnPaint)
EVT_ERASE_BACKGROUND(self, self.OnBackground)

def OnPaint(self, evt):
“”"
Create a DC and ask Linker to draw any connections.
“”"
dc=wxPaintDC(self)
self.PrepareDC(dc)

self.EraseBackground(dc)

self.Draw(dc)

def Draw(self, dc):
rPen = wxPen(wxColour(0,0,0),3)
rPen.SetCap(wxCAP_PROJECTING)
dc.SetPen(rPen)
dc.DrawRectangle(10,10,500,500)

def EraseBackground(self, dc):
dc.SetBackground(self.brush)
dc.Clear()

def OnBackground(self, evt):
try:
dc = evt.GetDC()
self.EraseBackground(dc)
except:
pass

class StrategyNotebookClass(wxNotebook):
def init(self, *args, **kwds):
# begin wxGlade: init
kwds[“style”] = 0
wxNotebook.init(self, *args, **kwds)
self.task_canvas = TaskCanvasClass(self, -1)

    self.__set_properties()
    self.__do_layout()
    # end wxGlade

def __set_properties(self):
    # begin wxGlade: __set_properties
    nb_sizer = wxNotebookSizer(self)
    self.AddPage(self.task_canvas, "S1")
    # end wxGlade

def __do_layout(self):
    # begin wxGlade: __do_layout
    pass
    # end wxGlade

end of class StrategyNotebookClass

class CanvasWrapClass(wxPanel):
def init(self, *args, **kwds):
# begin wxGlade: init
wxPanel.init(self, *args, **kwds)
self.StrategyNotebook = StrategyNotebookClass(self, -1)

    self.__set_properties()
    self.__do_layout()
    # end wxGlade

def __set_properties(self):
    # begin wxGlade: __set_properties
    pass
    # end wxGlade

def __do_layout(self):
    # begin wxGlade: __do_layout
    sizer_4 = wxBoxSizer(wxHORIZONTAL)
    sizer_4.Add(self.StrategyNotebook, 1, wxEXPAND, 0)
    self.SetAutoLayout(1)
    self.SetSizer(sizer_4)
    sizer_4.Fit(self)
    self.Layout()
    # end wxGlade

end of class CanvasWrapClass

class StrategyWindowClass(wxSplitterWindow):
def init(self, *args, **kwds):
# begin wxGlade: init
kwds[“style”] = wxSP_3D|wxSP_3DSASH|wxSP_3DBORDER
wxSplitterWindow.init(self, *args, **kwds)
self.canvas_wrap = CanvasWrapClass(self, -1)
self.menu_wrap = MenuWrapClass(self, -1)

    self.__set_properties()
    self.__do_layout()
    # end wxGlade

def __set_properties(self):
    # begin wxGlade: __set_properties
    self.SplitVertically(self.menu_wrap, self.canvas_wrap)
    self.SetSashPosition(124)
    # end wxGlade

def __do_layout(self):
    # begin wxGlade: __do_layout
    pass
    # end wxGlade

end of class StrategyWindowClass

class InterfaceWrapClass(wxPanel):
def init(self, *args, **kwds):
# begin wxGlade: init
wxPanel.init(self, *args, **kwds)
self.splitter_window = StrategyWindowClass(self, -1)

    self.__set_properties()
    self.__do_layout()
    # end wxGlade

def __set_properties(self):
    # begin wxGlade: __set_properties
    pass
    # end wxGlade

def __do_layout(self):
    # begin wxGlade: __do_layout
    sizer_2 = wxBoxSizer(wxHORIZONTAL)
    sizer_2.Add(self.splitter_window, 1, wxEXPAND, 0)
    self.SetAutoLayout(1)
    self.SetSizer(sizer_2)
    sizer_2.Fit(self)
    self.Layout()
    # end wxGlade

end of class InterfaceWrapClass

class MainNotebookClass(wxNotebook):
def init(self, *args, **kwds):
# begin wxGlade: init
kwds[“style”] = 0
wxNotebook.init(self, *args, **kwds)
self.notebook_1_pane_1 = InterfaceWrapClass(self, -1)

    self.__set_properties()
    self.__do_layout()
    # end wxGlade

def __set_properties(self):
    # begin wxGlade: __set_properties
    nb_sizer = wxNotebookSizer(self)
    self.AddPage(self.notebook_1_pane_1, "strategy")
    # end wxGlade

def __do_layout(self):
    # begin wxGlade: __do_layout
    pass
    # end wxGlade

end of class MainNotebookClass

class MyFrame(wxFrame):
def init(self, *args, **kwds):
# begin wxGlade: init
kwds[“style”] = wxDEFAULT_FRAME_STYLE
wxFrame.init(self, *args, **kwds)
self.main_notebook = MainNotebookClass(self, -1)
self.frame_1_statusbar = self.CreateStatusBar(1)

    # Menu Bar
    self.frame_1_menubar = wxMenuBar()
    self.SetMenuBar(self.frame_1_menubar)
    wxglade_tmp_menu = wxMenu()
    self.frame_1_menubar.Append(wxglade_tmp_menu, "File")
    # Menu Bar end

    self.__set_properties()
    self.__do_layout()
    # end wxGlade

def __set_properties(self):
    # begin wxGlade: __set_properties
    self.SetTitle("frame_1")
    self.frame_1_statusbar.SetStatusWidths([-1])
    # statusbar fields
    frame_1_statusbar_fields = ['frame_1_statusbar']
    for i in range(len(frame_1_statusbar_fields)):
        self.frame_1_statusbar.SetStatusText(frame_1_statusbar_fields[i], i)
    # end wxGlade

def __do_layout(self):
    # begin wxGlade: __do_layout
    main_sizer = wxBoxSizer(wxHORIZONTAL)
    main_sizer.Add(self.main_notebook, 1, wxEXPAND, 0)
    self.SetAutoLayout(1)
    self.SetSizer(main_sizer)
    main_sizer.Fit(self)
    self.Layout()
    # end wxGlade

end of class MyFrame

class MyApp(wxApp):
def OnInit(self):
wxInitAllImageHandlers()
frame_1 = MyFrame(None, -1, “”)
self.SetTopWindow(frame_1)
frame_1.Show(1)
return 1

end of class MyApp

if name == “main”:
wxPhenix = MyApp()
wxPhenix.MainLoop()



Nigel W. Moriarty
Building 4R0230
Physical Biosciences Division
Lawrence Berkeley National Laboratory
Berkeley, CA 94720-8235
Phone : 510-486-5709
Fax : 510-486-5909
Email : NWMoriarty@LBL.gov
Web : CCI.LBL.gov



To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

Yea, it's a wxGTK thing.

···

On Wed, 5 Feb 2003 11:13:42 +1030 Chris Munchenberg <cjm@ava.com.au> wrote:

No lines seen on Windows M & wxPython 2.4.0.2 & python 2.2.2

Chris.
----- Original Message -----
From: Nigel Moriarty
To: wxPython-users
Sent: Wednesday, February 05, 2003 10:09 AM
Subject: [wxPython-users] wxScrollWindow Demo

Robin

It took me quite a while to get an example that demonstrated the
problem.
My really simple demos didn't, thus the complexity. You'll notice that
the
framework is from wxGlade but the canvas class is my own. The scrolling
leaves lines across the canvas.

Nigel

-------------------------------------------------------------------------
-------

#!/usr/bin/env python
# generated by wxGlade 0.1.3 on Mon Dec 09 12:49:10 2002

from wxPython.wx import *

class TaskTreeCtrl(wxPanel):
    def __init__(self, *args, **kwds):
        # begin wxGlade: __init__
        wxPanel.__init__(self, *args, **kwds)

        self.__set_properties()
        self.__do_layout()
        # end wxGlade

    def __set_properties(self):
        # begin wxGlade: __set_properties
        pass
        # end wxGlade

    def __do_layout(self):
        # begin wxGlade: __do_layout
        pass
        # end wxGlade

# end of class TaskTreeCtrl

class TaskNoteBookClass(wxNotebook):
    def __init__(self, *args, **kwds):
        # begin wxGlade: __init__
        kwds["style"] = 0
        wxNotebook.__init__(self, *args, **kwds)
        self.task_tree_ctrl = TaskTreeCtrl(self, -1)

        self.__set_properties()
        self.__do_layout()
        # end wxGlade

    def __set_properties(self):
        # begin wxGlade: __set_properties
        nb_sizer = wxNotebookSizer(self)
        self.AddPage(self.task_tree_ctrl, "tab1")
        # end wxGlade

    def __do_layout(self):
        # begin wxGlade: __do_layout
        pass
        # end wxGlade

# end of class TaskNoteBookClass

class MenuWrapClass(wxPanel):
    def __init__(self, *args, **kwds):
        # begin wxGlade: __init__
        wxPanel.__init__(self, *args, **kwds)
        self.task_notebook = TaskNoteBookClass(self, -1)

        self.__set_properties()
        self.__do_layout()
        # end wxGlade

    def __set_properties(self):
        # begin wxGlade: __set_properties
        pass
        # end wxGlade

    def __do_layout(self):
        # begin wxGlade: __do_layout
        sizer_3 = wxBoxSizer(wxHORIZONTAL)
        sizer_3.Add(self.task_notebook, 1, wxEXPAND, 0)
        self.SetAutoLayout(1)
        self.SetSizer(sizer_3)
        sizer_3.Fit(self)
        self.Layout()
        # end wxGlade

# end of class MenuWrapClass

class TaskCanvas(wxPanel):
    def __init__(self, *args, **kwds):
        # begin wxGlade: __init__
        wxPanel.__init__(self, *args, **kwds)

        self.__set_properties()
        self.__do_layout()
        # end wxGlade

    def __set_properties(self):
        # begin wxGlade: __set_properties
        self.SetBackgroundColour(wxColour(0, 0, 255))
        # end wxGlade

    def __do_layout(self):
        # begin wxGlade: __do_layout
        pass
        # end wxGlade

# end of class TaskCanvas

class TaskCanvasClass(wxScrolledWindow):
  """
  A canvas for tasks and strategies.

    Tasks can be added and removed.

    Tasks can be connected to the form strategies.
  """
  def __init__(self, parent, id,
               name="Canvas"):
    self.parent = parent
    wxScrolledWindow.__init__(self, parent, id, name=name)
    self.SetWindowStyle(wxSUNKEN_BORDER|wxCLIP_CHILDREN)
    self.SetBackgroundColour(wxColour(255,255,255))

    self.thumb = 10

    self.brush = wxBrush(wxColour(255,25,255))
    self.Width = 1000
    self.Height = 1000

    self.SetScrollbars(self.thumb, self.thumb,
                       self.Width/self.thumb, self.Height/self.thumb)

    EVT_PAINT(self, self.OnPaint)
    EVT_ERASE_BACKGROUND(self, self.OnBackground)
    
  def OnPaint(self, evt):
    """
    Create a DC and ask Linker to draw any connections.
    """
    dc=wxPaintDC(self)
    self.PrepareDC(dc)

    self.EraseBackground(dc)

    self.Draw(dc)

  def Draw(self, dc):
    rPen = wxPen(wxColour(0,0,0),3)
    rPen.SetCap(wxCAP_PROJECTING)
    dc.SetPen(rPen)
    dc.DrawRectangle(10,10,500,500)
    
  def EraseBackground(self, dc):
    dc.SetBackground(self.brush)
    dc.Clear()

  def OnBackground(self, evt):
    try:
      dc = evt.GetDC()
      self.EraseBackground(dc)
    except:
      pass
    
class StrategyNotebookClass(wxNotebook):
    def __init__(self, *args, **kwds):
        # begin wxGlade: __init__
        kwds["style"] = 0
        wxNotebook.__init__(self, *args, **kwds)
        self.task_canvas = TaskCanvasClass(self, -1)

        self.__set_properties()
        self.__do_layout()
        # end wxGlade

    def __set_properties(self):
        # begin wxGlade: __set_properties
        nb_sizer = wxNotebookSizer(self)
        self.AddPage(self.task_canvas, "S1")
        # end wxGlade

    def __do_layout(self):
        # begin wxGlade: __do_layout
        pass
        # end wxGlade

# end of class StrategyNotebookClass

class CanvasWrapClass(wxPanel):
    def __init__(self, *args, **kwds):
        # begin wxGlade: __init__
        wxPanel.__init__(self, *args, **kwds)
        self.StrategyNotebook = StrategyNotebookClass(self, -1)

        self.__set_properties()
        self.__do_layout()
        # end wxGlade

    def __set_properties(self):
        # begin wxGlade: __set_properties
        pass
        # end wxGlade

    def __do_layout(self):
        # begin wxGlade: __do_layout
        sizer_4 = wxBoxSizer(wxHORIZONTAL)
        sizer_4.Add(self.StrategyNotebook, 1, wxEXPAND, 0)
        self.SetAutoLayout(1)
        self.SetSizer(sizer_4)
        sizer_4.Fit(self)
        self.Layout()
        # end wxGlade

# end of class CanvasWrapClass

class StrategyWindowClass(wxSplitterWindow):
    def __init__(self, *args, **kwds):
        # begin wxGlade: __init__
        kwds["style"] = wxSP_3D|wxSP_3DSASH|wxSP_3DBORDER
        wxSplitterWindow.__init__(self, *args, **kwds)
        self.canvas_wrap = CanvasWrapClass(self, -1)
        self.menu_wrap = MenuWrapClass(self, -1)

        self.__set_properties()
        self.__do_layout()
        # end wxGlade

    def __set_properties(self):
        # begin wxGlade: __set_properties
        self.SplitVertically(self.menu_wrap, self.canvas_wrap)
        self.SetSashPosition(124)
        # end wxGlade

    def __do_layout(self):
        # begin wxGlade: __do_layout
        pass
        # end wxGlade

# end of class StrategyWindowClass

class InterfaceWrapClass(wxPanel):
    def __init__(self, *args, **kwds):
        # begin wxGlade: __init__
        wxPanel.__init__(self, *args, **kwds)
        self.splitter_window = StrategyWindowClass(self, -1)

        self.__set_properties()
        self.__do_layout()
        # end wxGlade

    def __set_properties(self):
        # begin wxGlade: __set_properties
        pass
        # end wxGlade

    def __do_layout(self):
        # begin wxGlade: __do_layout
        sizer_2 = wxBoxSizer(wxHORIZONTAL)
        sizer_2.Add(self.splitter_window, 1, wxEXPAND, 0)
        self.SetAutoLayout(1)
        self.SetSizer(sizer_2)
        sizer_2.Fit(self)
        self.Layout()
        # end wxGlade

# end of class InterfaceWrapClass

class MainNotebookClass(wxNotebook):
    def __init__(self, *args, **kwds):
        # begin wxGlade: __init__
        kwds["style"] = 0
        wxNotebook.__init__(self, *args, **kwds)
        self.notebook_1_pane_1 = InterfaceWrapClass(self, -1)

        self.__set_properties()
        self.__do_layout()
        # end wxGlade

    def __set_properties(self):
        # begin wxGlade: __set_properties
        nb_sizer = wxNotebookSizer(self)
        self.AddPage(self.notebook_1_pane_1, "strategy")
        # end wxGlade

    def __do_layout(self):
        # begin wxGlade: __do_layout
        pass
        # end wxGlade

# end of class MainNotebookClass

class MyFrame(wxFrame):
    def __init__(self, *args, **kwds):
        # begin wxGlade: __init__
        kwds["style"] = wxDEFAULT_FRAME_STYLE
        wxFrame.__init__(self, *args, **kwds)
        self.main_notebook = MainNotebookClass(self, -1)
        self.frame_1_statusbar = self.CreateStatusBar(1)

        # Menu Bar
        self.frame_1_menubar = wxMenuBar()
        self.SetMenuBar(self.frame_1_menubar)
        wxglade_tmp_menu = wxMenu()
        self.frame_1_menubar.Append(wxglade_tmp_menu, "File")
        # Menu Bar end

        self.__set_properties()
        self.__do_layout()
        # end wxGlade

    def __set_properties(self):
        # begin wxGlade: __set_properties
        self.SetTitle("frame_1")
        self.frame_1_statusbar.SetStatusWidths([-1])
        # statusbar fields
        frame_1_statusbar_fields = ['frame_1_statusbar']
        for i in range(len(frame_1_statusbar_fields)):
           
self.frame_1_statusbar.SetStatusText(frame_1_statusbar_fields[i], i)
        # end wxGlade

    def __do_layout(self):
        # begin wxGlade: __do_layout
        main_sizer = wxBoxSizer(wxHORIZONTAL)
        main_sizer.Add(self.main_notebook, 1, wxEXPAND, 0)
        self.SetAutoLayout(1)
        self.SetSizer(main_sizer)
        main_sizer.Fit(self)
        self.Layout()
        # end wxGlade

# end of class MyFrame

class MyApp(wxApp):
    def OnInit(self):
        wxInitAllImageHandlers()
        frame_1 = MyFrame(None, -1, "")
        self.SetTopWindow(frame_1)
        frame_1.Show(1)
        return 1

# end of class MyApp

if __name__ == "__main__":
    wxPhenix = MyApp()
    wxPhenix.MainLoop()

-------------------------------------------------------------------------
-------

--
Nigel W. Moriarty
Building 4R0230
Physical Biosciences Division
Lawrence Berkeley National Laboratory
Berkeley, CA 94720-8235
Phone : 510-486-5709
Fax : 510-486-5909
Email : NWMoriarty@LBL.gov
Web : CCI.LBL.gov

Nigel Moriarty wrote:

Robin

It took me quite a while to get an example that demonstrated the problem. My really simple demos didn't, thus the complexity. You'll notice that the
framework is from wxGlade but the canvas class is my own. The scrolling
leaves lines across the canvas.

wxGTK has an old problem with wxScrolledWindows in a wxNotebook. (See https://sourceforge.net/tracker/?func=detail&aid=216861&group_id=9863&atid=109863)

The workaround is to put your scrolled window on a panel with a sizer or something that sizes the scrolled window to completly fill the panel, and then put the panel in the notebook.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!