Hi,
Here is my code (StaticBox.py) where you can “add” and “remove” StaticBox. But I have a problem:
When you add a new StaticBox, the label of the StaticBox appears in the top left of the window (like a ghost), and I do not know why.
How could I eliminate this problem? Thank you very much.


StaticBox.py (2.61 KB)
I would upload this as .py file but cannot do so from this computer, however, I found the cause of your “ghost” widgets.
In the second line of your Add function you have for i in range(self.p) and self.p is keeping track of how many StaticBox widgets are currently visible / added to the screen. While this works “ok” when you add the first StaticBox widget, this causes issues later on. For example, when you create the second StaticBox you actually end up creating 2 instead of 1. The first one gets properly added to the screen while the second has nowhere to go. The number of “ghost” widgets increases every time the add button is clicked.
My recommendation is:
-
Remove the line for i in range(self.p):
-
Change n = ‘Maintenance %s’ % i to n = ‘Maintenance %s’ % self.p
-
And of course remove the extra spaces from the beginning of each line starting with n = ‘Maintenance %s’ % self.p through self.sizer2.Add((10, -1) , 0)
By doing the above steps your script worked on Win 7 64bit, Python 2.7.5, wxPython 2.9.5.0
···
On Thursday, May 29, 2014 11:26:33 AM UTC-4, Lucas Gagneten wrote:
Hi,
Here is my code (StaticBox.py) where you can “add” and “remove” StaticBox. But I have a problem:
When you add a new StaticBox, the label of the StaticBox appears in the top left of the window (like a ghost), and I do not know why.
How could I eliminate this problem? Thank you very much.
Great! Thanks Mike! You are a genius.
Just for the records: in Ubuntu 14.04 64 bits with Python 2.7 and wxPython 2.8.12.1 I cant reproduce the bug, here all works fine, no ghost 
Saludos / Best regards
Mario Lacunza
Email:: mlacunza@gmail.com
Personal Website:: http://www.lacunza.biz/
Hosting:: http://mlv-host.com/
Mascotas Perdidas:: http://mascotas-perdidas.com/
Google Talk / Y! messenger / Skype: mlacunzav
···
El 29/05/14 10:26, Lucas Gagneten escribió:
Hi,
Here is my code (StaticBox.py) where you can "add" and "remove" StaticBox. But I have a problem:
When you add a new StaticBox, the label of the StaticBox appears in the top left of the window (like a ghost), and I do not know why.
How could I eliminate this problem? Thank you very much.
--
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 wxpython-users+unsubscribe@googlegroups.com <mailto:wxpython-users+unsubscribe@googlegroups.com>.
For more options, visit https://groups.google.com/d/optout.
Your welcome Lucas, the changes I made were based on how I interpreted your question and the code provided. I came to the conclusion that you only wanted to add a single StaticBox with each press of the Add button since the delete button was coded to only remove them 1 at a time.
···
On Monday, June 2, 2014 10:38:09 AM UTC-4, Lucas Gagneten wrote:
Great! Thanks Mike! You are a genius.