quick visual question

996 views
Skip to first unread message

Nathan smith

unread,
Aug 24, 2019, 10:05:40 AM8/24/19
to wxpytho...@googlegroups.com
Hi there,

I'm running wx python classic, and have the following code:

 def setup_screen1(self):

  # code to create a panel and sizer goes here...

  self.info1 = wx.ListCtrl(panel, -1, style = wx.LC_REPORT)
  hbox1.Add(self.info1, 1, wx.EXPAND|wx.ALIGN_LEFT|wx.ALL,5)

  # code for adding items to the list, and the rest of the panel code
goes here.


That works as expected.

My question is this.

In my program, I would like the info list to show up on multiple screens.

I do not call panel.Destroy() at any time, though I hide and show it a
few times.

therefore, is this code okay?

 def setup_screen2(self):

  #create the panel and sizer
  hbox1.Add(self.info1, 1, wx.EXPAND|wx.ALIGN_LEFT|wx.ALL,5)

  # code for the rest of the panel.


will this add the same list, that looks the same on every screen correctly?

thanks

Nathan

Robin Dunn

unread,
Aug 24, 2019, 3:49:13 PM8/24/19
to wxPython-users
No, a widget can only have one parent at a time. You could use the Reparent method to switch it over to a new parent panel when needed, but usually it's better to just create a new listctrl for each panel.  If you're concerned about duplicating the data in each listctrl then you could use the wx.LC_VIRTUAL flag and keep your data in a list or some other data object that they all share. The listctrl will then ask you, via overridden methods, for the data and attributes as it needs them for display.

Robin
Reply all
Reply to author
Forward
0 new messages