godot-python
godot-python copied to clipboard
Text Edit or LineEdit have double the characters
When trying to use a control node of type TextEdit or LineEdit on Windows Godot 3.0.6 I get double the characters in the text data of the TextEdit UI node.
Here is the code:
from godot import exposed, export
from godot.bindings import LineEdit
from godot.globals import *
import requests
@exposed
class machinelearning(LineEdit):
def classify(self,t):
key = "65396840-e76e-11e8-950e-27607d2268b343b7eb4d-17e2-4aad-8d33-90757ef57720"
url = "https://machinelearningforkids.co.uk/api/scratch/"+ key + "/classify"
response = requests.get(url, params={ "data" : t })
if response.ok:
responseData = response.json()
topMatch = responseData[0]
return topMatch
else:
response.raise_for_status()
def _on_Button_pressed(self):
print(self.text)
demo = self.classify(self.text)
label = demo["class_name"]
confidence = demo["confidence"]
# CHANGE THIS to do something different with the result
print ("result: '%s' with %d%% confidence" % (label, confidence))

When I press the 's' character once I get this
Hi,
How did you configured the manchinelearning node in your scene graph ? I suspect you connected the _on_Button_pressed to an event, so may there is something silly there.
Also if you could provide a minimal example that would help a lot ;-)