Simple question: I have a text box and I have assigned the property as a number. I have created a function shown below which takes a user input and multiplies that number by 5. Cannot get this function to work,any assistance is greatly appreciated.
The first is that self.tbx_hole_dia.text
is “None”, meaning it is not initialised or it is out of scope. If this function is in the same form that contains the text box, is the text box actually named “tbx_hole_dia”?
Secondly, if it did contain a value, you would be trying to multiply a string with a number.
Try this instead :
The text box might be a “number” type, but that only affects the validation of the values it will accept. The “text” property is still exactly that, text.
Finally, when posting code please wrap it in triple backticks :
```
print(“code here”)
```
which will display like this :
Hi David…firstly, thanks for the quick feedback! The text box is named “tbx_hole_dia” and I also tried your suggestion before this post:
‘’’
def equation(self):
return int(self.tbx_hole_dia.text) * 5
‘’’
…I invariably get the following error: TypeError: int() argument must be a string or a number, not ‘NoneType’
Ok, please could you post a clone link so I can take a look at your project?
To get the clone link, click the gear icon in your App browser, and you should see this :
Click “Share App” and look for “Share your source code and data with others”, and copy that link. You can either post it here if it’s non-sensitive or you can PM me if it is.
Works!! Great catch! Again…thanks for the immediate assistance. Still trying the free version but looks like I will pulling the trigger soon on a paid version. Great product!!