can I move stc's scroll by using panel's scroll which is parent?

I made stc control on Panel control.
I would like to move stc's scroll by using Panel's scroll.
can I move stc's scroll by using panel's scroll which is parent?

Wonjun, Choi

Not automatically, but some people have had some luck with catching the scroll events and programatically manipulating the target window's scroll position.

···

On 10/10/11 10:29 PM, Wonjun, Choi wrote:

I made stc control on Panel control.
I would like to move stc's scroll by using Panel's scroll.
can I move stc's scroll by using panel's scroll which is parent?

--
Robin Dunn
Software Craftsman

do you mean kind of like this code?

def __init__(self, parent):
    self._init_ctrls(parent)

    self.styledTextCtrl1.Bind(wx.EVT_SCROLLWIN, self.OnScroll1)
    self.styledTextCtrl2.Bind(wx.EVT_SCROLLWIN, self.OnScroll2)

def OnScroll1(self, event):
    clone = event.Clone()
    clone.SetId(wxID_FRAME1STYLEDTEXTCTRL2)
    clone.SetEventObject(self.styledTextCtrl2)
    self.GetEventHandler().ProcessEvent(clone)
    event.Skip()

def OnScroll2(self, event):
    clone = event.Clone()
    clone.SetId(wxID_FRAME1STYLEDTEXTCTRL1)
    clone.SetEventObject(self.styledTextCtrl1)
    self.GetEventHandler().ProcessEvent(clone)
    event.Skip()
···

2011/10/12 Robin Dunn robin@alldunn.com

On 10/10/11 10:29 PM, Wonjun, Choi wrote:

I made stc control on Panel control.

I would like to move stc’s scroll by using Panel’s scroll.

can I move stc’s scroll by using panel’s scroll which is parent?

Not automatically, but some people have had some luck with catching the scroll events and programatically manipulating the target window’s scroll position.

Robin Dunn

Software Craftsman

http://wxPython.org

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

it seems this code doesn’t work.

···

2011/10/13 최원준 wonjunchoi001@gmail.com

do you mean kind of like this code?

def __init__(self, parent):
    self._init_ctrls(parent)

    self.styledTextCtrl1.Bind(wx.EVT_SCROLLWIN, self.OnScroll1)
    self.styledTextCtrl2.Bind(wx.EVT_SCROLLWIN, self.OnScroll2)



def OnScroll1(self, event):
    clone = event.Clone()
    clone.SetId(wxID_FRAME1STYLEDTEXTCTRL2)
    clone.SetEventObject(self.styledTextCtrl2)
    self.GetEventHandler().ProcessEvent(clone)


    event.Skip()

def OnScroll2(self, event):
    clone = event.Clone()
    clone.SetId(wxID_FRAME1STYLEDTEXTCTRL1)
    clone.SetEventObject(self.styledTextCtrl1)
    self.GetEventHandler().ProcessEvent(clone)


    event.Skip()

2011/10/12 Robin Dunn robin@alldunn.com

On 10/10/11 10:29 PM, Wonjun, Choi wrote:

I made stc control on Panel control.

I would like to move stc’s scroll by using Panel’s scroll.

can I move stc’s scroll by using panel’s scroll which is parent?

Not automatically, but some people have had some luck with catching the scroll events and programatically manipulating the target window’s scroll position.

Robin Dunn

Software Craftsman

http://wxPython.org

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

    2011/10/12 Robin Dunn <robin@alldunn.com <mailto:robin@alldunn.com>>

            I made stc control on Panel control.
            I would like to move stc's scroll by using Panel's scroll.
            can I move stc's scroll by using panel's scroll which is parent?

        Not automatically, but some people have had some luck with
        catching the scroll events and programatically manipulating the
        target window's scroll position.

it seems this code doesn't work.

2011/10/13 최원준 <wonjunchoi001@gmail.com <mailto:wonjunchoi001@gmail.com>>

    do you mean kind of like this code?

    def __init__(self, parent):
    self._init_ctrls(parent)

    self.styledTextCtrl1.Bind(wx.EVT_SCROLLWIN, self.OnScroll1)
    self.styledTextCtrl2.Bind(wx.EVT_SCROLLWIN, self.OnScroll2)

    def OnScroll1(self, event):
    clone = event.Clone()
    clone.SetId(wxID_FRAME1STYLEDTEXTCTRL2)
    clone.SetEventObject(self.styledTextCtrl2)
    self.GetEventHandler().ProcessEvent(clone)
    event.Skip()

    def OnScroll2(self, event):
    clone = event.Clone()
    clone.SetId(wxID_FRAME1STYLEDTEXTCTRL1)
    clone.SetEventObject(self.styledTextCtrl1)
    self.GetEventHandler().ProcessEvent(clone)
    event.Skip()

No, I meant catching the scroll events from the panel and then manipulate the scroll position of the STCs by calling their scroll related methods.

···

        On 10/10/11 10:29 PM, Wonjun, Choi wrote:

On 10/13/11 1:41 AM, 최원준 wrote:

--
Robin Dunn
Software Craftsman

you mean like this?

class TestPanel(wx.Panel):

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

    self.Bind(wx.EVT_SCROLLWIN, self.onScroll1)
    self..Bind(wx.EVT_SCROLLWIN, self.OnScroll2)

     def OnScroll1(self, event):

           clone = event.Clone()

           clone.SetId(wxID_FRAME1STYLEDTEXTCTRL2)

           clone.SetEventObject(self.styledTextCtrl2)

           self.GetEventHandler().ProcessEvent(clone)

           event.Skip()

     def OnScroll2(self, event):

           clone = event.Clone()

           clone.SetId(wxID_FRAME1STYLEDTEXTCTRL1)

           clone.SetEventObject(self.styledTextCtrl1)

           self.GetEventHandler().ProcessEvent(clone)

           event.Skip()
···

2011/10/14 Robin Dunn robin@alldunn.com

2011/10/12 Robin Dunn <robin@alldunn.com mailto:robin@alldunn.com>

    On 10/10/11 10:29 PM, Wonjun, Choi wrote:



        I made stc control on Panel control.

        I would like to move stc's scroll by using Panel's scroll.

        can I move stc's scroll by using panel's scroll which is parent?





    Not automatically, but some people have had some luck with

    catching the scroll events and programatically manipulating the

    target window's scroll position.

On 10/13/11 1:41 AM, 최원준 wrote:

it seems this code doesn’t work.

2011/10/13 최원준 <wonjunchoi001@gmail.com mailto:wonjunchoi001@gmail.com>

do you mean kind of like this code?



def __init__(self, parent):

self._init_ctrls(parent)



self.styledTextCtrl1.Bind(wx.EVT_SCROLLWIN, self.OnScroll1)

self.styledTextCtrl2.Bind(wx.EVT_SCROLLWIN, self.OnScroll2)



def OnScroll1(self, event):

clone = event.Clone()

clone.SetId(wxID_FRAME1STYLEDTEXTCTRL2)

clone.SetEventObject(self.styledTextCtrl2)

self.GetEventHandler().ProcessEvent(clone)

event.Skip()



def OnScroll2(self, event):

clone = event.Clone()

clone.SetId(wxID_FRAME1STYLEDTEXTCTRL1)

clone.SetEventObject(self.styledTextCtrl1)

self.GetEventHandler().ProcessEvent(clone)

event.Skip()

No, I meant catching the scroll events from the panel and then manipulate the scroll position of the STCs by calling their scroll related methods.

Robin Dunn

Software Craftsman

http://wxPython.org

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

Yes, but if sending the synthesized events doesn't work you can probably do it by calling SetFirstVisibleLine or similar.

···

On 10/13/11 11:09 PM, 최원준 wrote:

    No, I meant catching the scroll events from the panel and then
    manipulate the scroll position of the STCs by calling their scroll
    related methods.

you mean like this?

class TestPanel(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent, -1)

self.Bind(wx.EVT_SCROLLWIN, self.onScroll1)
self..Bind(wx.EVT_SCROLLWIN, self.OnScroll2)

def OnScroll1(self, event):
clone = event.Clone()
clone.SetId(wxID_FRAME1STYLEDTEXTCTRL2)
clone.SetEventObject(self.styledTextCtrl2)
self.GetEventHandler().ProcessEvent(clone)
event.Skip()

def OnScroll2(self, event):
clone = event.Clone()
clone.SetId(wxID_FRAME1STYLEDTEXTCTRL1)
clone.SetEventObject(self.styledTextCtrl1)
self.GetEventHandler().ProcessEvent(clone)
event.Skip()

--
Robin Dunn
Software Craftsman

I got an error and I don’t understand this message :

Original exception was:
RuntimeError: maximum recursion depth exceeded while calling a Python object
Exception RuntimeError: ‘maximum recursion depth exceeded while calling a Python object’ in ignored
Exception RuntimeError: ‘maximum recursion depth exceeded’ in ignored

Error in sys.excepthook:
RuntimeError: maximum recursion depth exceeded

I coded like this :

    self.Bind(wx.EVT_SCROLLWIN, self.OnScroll1)
    self.Bind(wx.EVT_SCROLLWIN, self.OnScroll2)


def OnScroll1(self, event):
    clone = event.Clone()
    clone.SetId(wx.NewId())
    clone.SetEventObject(self.stc2)
    self.GetEventHandler().ProcessEvent(clone)
    event.Skip()


def OnScroll2(self, event):
    clone = event.Clone()
    clone.SetId(wx.NewId())
    clone.SetEventObject(self.stc)
    self.GetEventHandler().ProcessEvent(clone)
    event.Skip()
···

2011/10/14 Robin Dunn robin@alldunn.com

On 10/13/11 11:09 PM, 최원준 wrote:

No, I meant catching the scroll events from the panel and then

manipulate the scroll position of the STCs by calling their scroll

related methods.

you mean like this?

class TestPanel(wx.Panel):

def init(self, parent):

wx.Panel.init(self, parent, -1)

self.Bind(wx.EVT_SCROLLWIN, self.onScroll1)

self…Bind(wx.EVT_SCROLLWIN, self.OnScroll2)

def OnScroll1(self, event):

clone = event.Clone()

clone.SetId(wxID_FRAME1STYLEDTEXTCTRL2)

clone.SetEventObject(self.styledTextCtrl2)

self.GetEventHandler().ProcessEvent(clone)

event.Skip()

def OnScroll2(self, event):

clone = event.Clone()

clone.SetId(wxID_FRAME1STYLEDTEXTCTRL1)

clone.SetEventObject(self.styledTextCtrl1)

self.GetEventHandler().ProcessEvent(clone)

event.Skip()

Yes, but if sending the synthesized events doesn’t work you can probably do it by calling SetFirstVisibleLine or similar.

Robin Dunn

Software Craftsman

http://wxPython.org

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

Your problem is that you are calling the same event handler
recursively - by the line:

        self.GetEventHandler().ProcessEvent(clone)

you are getting the handler that you are already running and then

calling it. You need to do something like:

        self.MySubWindow.GetEventHandler().ProcessEvent(clone)

Gadget/Steve
···

wxPython-users+unsubscribe@googlegroups.com
http://groups.google.com/group/wxPython-users?hl=en

Thank you, it work well.

···

2011/10/14 Gadget/Steve GadgetSteve@live.co.uk

On 14/10/2011 8:46 AM, 최원준 wrote:

2011/10/14 Robin Dunn robin@alldunn.com

On 10/13/11 11:09 PM, 최원준 wrote:

          No,

I meant catching the scroll events from the panel and then

             manipulate the scroll position of the STCs by calling

their scroll

             related methods.

you mean like this?

          class TestPanel(wx.Panel):

          def __init__(self, parent):

          wx.Panel.__init__(self, parent, -1)



          self.Bind(wx.EVT_SCROLLWIN, self.onScroll1)

          self..Bind(wx.EVT_SCROLLWIN, self.OnScroll2)



          def OnScroll1(self, event):

          clone = event.Clone()

          clone.SetId(wxID_FRAME1STYLEDTEXTCTRL2)

          clone.SetEventObject(self.styledTextCtrl2)

          self.GetEventHandler().ProcessEvent(clone)

          event.Skip()



          def OnScroll2(self, event):

          clone = event.Clone()

          clone.SetId(wxID_FRAME1STYLEDTEXTCTRL1)

          clone.SetEventObject(self.styledTextCtrl1)

          self.GetEventHandler().ProcessEvent(clone)

          event.Skip()
      Yes, but if sending the synthesized events doesn't work you

can probably do it by calling SetFirstVisibleLine or similar.

          --

          Robin Dunn

          Software Craftsman

          [http://wxPython.org](http://wxPython.org)



          --

          To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

          or visit [http://groups.google.com/group/wxPython-users?hl=en](http://groups.google.com/group/wxPython-users?hl=en)
  I got an error and I don't understand this message :

  Original exception was:

  RuntimeError: maximum recursion depth exceeded while calling a

Python object

  Exception RuntimeError: 'maximum recursion depth exceeded while

calling a Python object’ in ignored

  Exception RuntimeError: 'maximum recursion depth exceeded' in 

ignored

  Error in sys.excepthook:

  RuntimeError: maximum recursion depth exceeded



  I coded like this :



          self.Bind(wx.EVT_SCROLLWIN, self.OnScroll1)

          self.Bind(wx.EVT_SCROLLWIN, self.OnScroll2)



      

      def OnScroll1(self, event):

          clone = event.Clone()

          clone.SetId(wx.NewId())

          clone.SetEventObject(self.stc2)

          self.GetEventHandler().ProcessEvent(clone)

          event.Skip()

     

      def OnScroll2(self, event):

          clone = event.Clone()

          clone.SetId(wx.NewId())

          clone.SetEventObject(self.stc)

          self.GetEventHandler().ProcessEvent(clone)

          event.Skip()

  --

  To unsubscribe, send email to

wxPython-users+unsubscribe@googlegroups.com

  or visit [http://groups.google.com/group/wxPython-users?hl=en](http://groups.google.com/group/wxPython-users?hl=en)
Your problem is that you are calling the same event handler

recursively - by the line:

        self.GetEventHandler().ProcessEvent(clone)



you are getting the handler that you are already running and then

calling it. You need to do something like:

        self.MySubWindow.GetEventHandler().ProcessEvent(clone)



Gadget/Steve

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

No Problem :slight_smile:

···

wxPython-users+unsubscribe@googlegroups.com
http://groups.google.com/group/wxPython-users?hl=en

I tried two ways.

  1.  self.Bind(wx.EVT_SCROLLWIN, self.OnScroll1)
    

    def OnScroll1(self, event):
    clone = event.Clone()
    clone.SetId(self.GetParent().GetId())
    clone.SetEventObject(self.GetParent())
    self.GetEventHandler().ProcessEvent(clone)
    event.Skip()

    self.Bind(wx.EVT_MOUSEWHEEL, self.moveparentpanel)
   
def moveparentpanel(self, event):
    self.GetParent().GetEventHandler().ProcessEvent(event)
    event.Skip()

but it’s not move scrolledpanel’s scroll.

scrollpanel.py (3.4 KB)

this issue is solved from you, thanks

Wonjun, Choi