So I`ve started using wx to generate my GUI. I created a custom table using a FlexGridSizer and then I wanted to clear the table when I push a button. So my method is:
def clearPressed(self,event):
self.label_ID.Destroy()
self.label_NAME.Destroy()
self.label_ADMIN.Destroy()
self.label_SELECTED.Destroy()
self.label_OPERATION.Destroy()
self.label_STRUCTURE.Destroy()
i = 0
while i < self.nrEntries:
self.idsGUI[i].Destroy()
self.pidsGUI[i].Destroy()
self.aidsGUI[i].Destroy()
self.sidsGUI[i].Destroy()
self.nidsGUI[i].Destroy()
self.stidsGUI[i].Destroy()
i = i + 1
self.clearBut.Destroy()
self.tableTitleLabel.Destroy()
self.tableGrid.Layout()
Those are basically all the component i have on t开发者_运维问答he table grid. This method works fine for StaticText buttons radiobutons. But this doesnt give me a table look. So I googled a bit and found out that you cannot draw the borders of a grid. So i added a panel in each grid location on top of which I draw my table components. Table looks better but now the destroy method doesnt clear the borders of the panels.
I`m creating my components like this:
panel = wx.Panel(self, -1, style=wx.BORDER_SIMPLE)
wx.RadioButton(panel,-1,self.sids[i])
self.sidsGUI.append(panel)
The clearPressed method now destroys all components and even part of the borders but not all of it. My basic gui structure is the following:
Frame->MainFlexGridSizer->OneVerticalBoxSizer (This contains some other buttons and stuff I dont want to delete) ------------------------------------->TableArrangementFlexGridSizer->VetricalBoxSizer(Contains table title and some info) ----------------------------------------------------------------------------------->TableFlexGrid(Contains actuals panels for the table whom borders dont dissapear in destroy) ----------------------------------------------------------------------------------->VerticalBoxSizer(Some other footer buttons and info)
Regards, Bogdan
This seems like a very complicated approach. Have you looked at using wxGrid? You might lose a little flexibility, but you will save yourself having to write tremendous amounts of code to look after routine grid management tasks such as this.
What do you mean when saying "The clearPressed method now destroys all components and even part of the borders but not all of it."? Does this means that you see some artifacts on the frame after destroying all components? If so, then try to call Refresh() method of your top frame after clearPressed method. This method will redraw the frame and all its children.
精彩评论