I'm making a game with wxpython
and I want to calculate the result every time button is clicked, so I created first the result on the screen, with StaticText
, and then when any button is clicked, I want to add (+1)
to the result.
But my problem is that I can't use integers as a label in StaticText
, and then I can't also use SetLabel
to set new result.
Example:
# Error
self.answers_count_num = wx.StaticText(self.panel, pos=(645, 50), label=0)
def answers_count(self, event):
result = int(self.answers_count_num.GetLabel()) + 1
self.answers_count_num.SetLabel(result)
Is there a way to use integers in a StaticText
?
To use integers as the label of a wx.StaticText
object, you first need to convert them to strings. Like:
# Error
self.answers_count_num = wx.StaticText(self.panel, pos=(645, 50), label=str(0))
def answers_count(self, event):
result = str(int(self.answers_count_num.GetLabel()) + 1)
self.answers_count_num.SetLabel(result)