Reputation: 11
I'm new to Python and just started writing a basic GUI program with wxPython. I have a series of text boxes where the user enters data and then they click a submit button.
The submit button triggers a getvalue
method for each box (it looks like a=self.textbox1.GetValue()
).
The there is a function that simply reads answer=a+b+c+d+e+f+g+h
.
Then finally there's the wx.MessageDialog(self, answer, Title, wx.OK | wx.ICON_EXCLAMATION)
that prints the answer in a msg
dialog.
But instead of printing the sum of the numbers, it just prints them in a series.
I was messing around and replaced the variables in the answer function with actual integers and it gives me an error that says:
String or Unicode type required
I can't really think of any way to fix it since I only have like two days experience with Python.
How can I fix this?
Upvotes: 1
Views: 230
Reputation: 76792
GetValue()
gives you the string value of what was typed.
You want to convert the strings to integers before trying to sum them.
a = int(self.textbox1.GetValue())
Upvotes: 1