我正在开发一个wxPython应用程序,其中我有一个带有标签文本的按钮' Allocate'。此外,我的应用程序上还有2个无线电选项,即“未分配”和“无线电”。和'分配'。当应用程序默认启动时,无线电选项“未分配”'已选中,按钮的标签文字为“分配”。我已经制作了事件驱动的代码来更改按钮的标签文本' Allocate'重新分配'选择无线电选项'已分配'。现在一切都很好,代码按预期工作。
现在问题出现在无线电选项'已分配'按钮标签确实会获得一个新的标签文本,并且重新分配'但是它会覆盖以前的标签文本而不是更改。然后,只要我将鼠标光标放在按钮上,文本就会刷新并显得干净清晰。以下是我的代码
def rdoAllocated_Click(self, event):
self.btn_Allocate.SetLabelText('Re-Allocate')
def rdoUnAllocated_Click(self, event):
self.btn_Allocate.SetLabelText('Allocate')
有一种方法可以在更改后自动刷新按钮标签文本,以清楚地显示新文本而不是不可读的覆盖文本。 Here is the image how it looks when getting updated
答案 0 :(得分:0)
Try calling self.btn_Allocate.Refresh()
This can happen sometimes, depending on platform and widget types. The Refresh
simply tells the system to send a paint event in the near future, and will most-likely take care of the problem for you. If not then you may need to call the parent window's Refresh
instead.