10

我正在尝试修改面板的控件,对其进行更新,然后继续执行代码。问题似乎是面板在刷新之前等待空闲。我当然尝试过刷新以及 GetSizer().Layout(),甚至使用 SendSizeEvent() 方法向框架发送了调整大小事件,但无济于事。我在这里不知所措,我很难相信没有办法强制重绘这个面板。这是更改控件的代码:

def HideButtons(self):
        self.newButton.Show(False)
        self.openButton.Show(False)
        self.exitButton.Show(False)
        self.buttonSizer.Detach(self.newButton)
        self.buttonSizer.Detach(self.openButton)
        self.buttonSizer.Detach(self.exitButton)
        loadingLabel = wx.StaticText(self.splashImage, wx.ID_ANY, "Loading...", style=wx.ALIGN_LEFT)
        loadingLabel.SetBackgroundColour(wx.WHITE)
        self.buttonSizer.Add(loadingLabel)
        self.GetSizer().Layout()
        self.splashImage.Refresh()

有没有其他人遇到过这样的事情?如果是这样,你是如何解决的?

4

4 回答 4

13

您需要调用该Update方法。

于 2009-08-05T07:41:06.147 回答
4

同样,我有一个StaticBitmap不会通过任何这些技术进行更新(包括Update接受的答案中建议的)。

我发现调用.Hide()and .Show()onPanel就足以刷新图像了。我怀疑如果我针对像StaticBitmap.

于 2013-07-13T02:43:02.313 回答
2

您可以将面板的可变部分放在子面板上,例如:

def MakeButtonPanels(self):
    self.buttonPanel1 = wx.Panel(self)
    self.Add(self.buttonPanel1, 0, wxALL|wxALIGN_LEFT, 5)
    # ... make the three buttons and the button sizer on buttonPanel1

    self.buttonPanel2 = wx.Panel(self)
    self.Add(self.buttonPanel2, 0, wxALL|wxALIGN_LEFT, 5)
    # ... make the loading label and its sizer on buttonPanel2

    self.buttonPanel2.Show(False) # hide it by default

def HideButtons(self):
    self.buttonPanel1.Show(False)
    self.buttonPanel2.Show(True)
    self.Layout()
于 2009-08-05T01:22:19.550 回答
0

要更新 Frame 中的 UI 更改,请使用以下命令

self.Layout()
self.Update()
于 2022-02-22T07:57:08.563 回答