Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to sync the scrollbars of two grids in wx
    text
    copied!<p>One custom wx.frame is created to contain a splitter window with two grid controls inside. It's used to compare the data in each of the grid. At this point the scrollbar of two grids need to support sync scroll. </p> <p>Questions:</p> <ol> <li>How to get these two grid's scroll event? I have tried to bin the wx.EVT_SCROLL event at the frame but failed. I also try to bind the scroll event in the custom grid control, it's failed too.</li> <li>How to sync scroll the scrollbar of the two grids? An answer of a relative <a href="https://stackoverflow.com/questions/8665633/how-to-make-auto-scrolling-wx-grid-table">question</a> mentioned to use gridInstance.Scroll(row, col) to scroll the grid client window. But it doesn't contain how to sync the scrollbar. </li> </ol> <p>Many thanks for any suggestion. </p> <p>The init method of the custom frame</p> <pre><code> def __init__(self, parent): wx.Frame.__init__(self, parent, -1, title='', size=(640,480)) main_panel = wx.Panel(self, -1) self.TBFLAGS = ( wx.TB_HORIZONTAL| wx.NO_BORDER| wx.TB_FLAT) self.controller = None self.isSyncScroll = True #hsizer = wx.BoxSizer(wx.VERTICAL) gsizer = wx.FlexGridSizer(rows = 1, cols = 1, vgap = 2, hgap = 2) gsizer.AddGrowableRow(0) gsizer.AddGrowableCol(0) self.tb = self.init_toolbar() (sub_panel0, sub_panel1) = self.init_splitter(main_panel) self.grid0 = self.init_grid(sub_panel0) self.grid1 = self.init_grid(sub_panel1) self.init_status_bar() gsizer.Add(main_panel, 1, wx.EXPAND) self.SetSizer(gsizer) ico = wx.Icon(u'Compare.ico', wx.BITMAP_TYPE_ICO) self.SetIcon(ico) self.Maximize() #can't catch the scroll event at the frame self.Bind(wx.EVT_SCROLL, self.OnScroll, self.grid0) #self.Bind(wx.EVT_SCROLL, self.OnScroll) #self.Bind(wx.EVT_SCROLL, self.OnScroll, id=self.grid0.GetId()) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload