Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import kivy.app
- import kivy.uix.boxlayout
- import kivy.uix.textinput
- import kivy.uix.label
- import kivy.uix.button
- #import urllib.request
- import requests #crash at this line
- #import json
- class SimpleApp(kivy.app.App):
- def build(self):
- self.__labelOutput = kivy.uix.label.Label(text="Reply from the server")
- self.__textInput = kivy.uix.textinput.TextInput()
- self.__textInput.hint_text = "Input value as \n5,2\n1,3"
- self.__buttonSendMsg = kivy.uix.button.Button(text="Get results")
- self.__buttonSendMsg.bind(on_press=self.sendMessage)
- self.__boxLayout = kivy.uix.boxlayout.BoxLayout(orientation="vertical")
- self.__boxLayout.add_widget(self.__labelOutput)
- self.__boxLayout.add_widget(self.__textInput)
- self.__boxLayout.add_widget(self.__buttonSendMsg)
- return self.__boxLayout
- def __DisabledUI(self, val):
- self.__textInput.disabled = val
- self.__buttonSendMsg = val
- def __inputToJson(self):
- coordinates = self.__textInput.text.split("\n")
- print(coordinates)
- json_contents = {"data" : []}
- for cordi in coordinates:
- cordi_in_data = []
- for val in cordi.split(","):
- cordi_in_data.append(float(val))
- json_contents["data"].append(cordi_in_data)
- print("dcit:", json_contents)
- return json_contents
- def sendMessage(self, btn):
- self.__DisabledUI(True)
- self.__DisabledUI(False)
- if __name__ == "__main__":
- simpleApp = SimpleApp()
- simpleApp.run()
Advertisement
Add Comment
Please, Sign In to add comment