quick visual question

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

quick visual question

Nathan Smith
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

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/8cb1a5cc-75e7-211d-d62a-10843035c433%40gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: quick visual question

Robin Dunn
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


On Saturday, August 24, 2019 at 7:05:40 AM UTC-7, Nathan smith wrote:
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

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/8588ee0e-5cc2-4e73-b06c-a7ba5f65b244%40googlegroups.com.