wx.Panel 边框不会被 Destroy() 方法破坏

发布于 2024-11-04 21:25:00 字数 1523 浏览 2 评论 0原文

所以我开始使用 wx 来生成我的 GUI。我使用 FlexGridSizer 创建了一个自定义表格,然后我想在按下按钮时清除该表格。所以我的方法是:

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() 

这些基本上是我在表格网格上拥有的所有组件。此方法适用于静态文本按钮单选按钮。但这并没有给我一个桌子的外观。所以我用谷歌搜索了一下,发现你不能绘制网格的边框。因此,我在每个网格位置添加了一个面板,在其顶部绘制表格组件。表格看起来更好,但现在销毁方法不会清除面板的边框。

我正在创建这样的组件:

        panel = wx.Panel(self, -1, style=wx.BORDER_SIMPLE)
        wx.RadioButton(panel,-1,self.sids[i])
        self.sidsGUI.append(panel)

clearPressed 方法现在会销毁所有组件,甚至部分边框,但不是全部。我的基本 gui 结构如下:

Frame->MainFlexGridSizer->OneVerticalBoxSizer (其中包含一些其他按钮和我不想删除的内容) ---------------------------------->TableArrangementFlexGridSizer->VetricalBoxSizer(包含表格标题和一些信息) -------------------------------------------------- ---------------------------------->TableFlexGrid(包含边框在销毁时不会消失的表格的实际面板) -------------------------------------------------- --------------------------------->VerticalBoxSizer(一些其他页脚按钮和信息)

问候, 博格丹

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 the 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

尽揽少女心 2024-11-11 21:25:00

这看起来是一个非常复杂的方法。你看过使用wxGrid吗?您可能会失去一点灵活性,但是您将不必编写大量代码来处理诸如此类的常规网格管理任务。

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.

墨小沫ゞ 2024-11-11 21:25:00

当你说“clearPressed 方法现在会破坏所有组件,甚至部分边框,但不是全部”时,你是什么意思?这是否意味着在销毁所有组件后您会在框架上看到一些伪影?如果是这样,请尝试在clearPressed方法之后调用顶部框架的Refresh()方法。此方法将重绘框架及其所有子框架。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文