Guest User

Untitled

a guest
Mar 29th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.72 KB | None | 0 0
  1. import kivy.app
  2. import kivy.uix.boxlayout
  3. import kivy.uix.textinput
  4. import kivy.uix.label
  5. import kivy.uix.button
  6.  
  7. #import urllib.request
  8. import requests #crash at this line
  9.  
  10. #import json
  11.  
  12. class SimpleApp(kivy.app.App):
  13.     def build(self):
  14.         self.__labelOutput = kivy.uix.label.Label(text="Reply from the server")
  15.         self.__textInput = kivy.uix.textinput.TextInput()
  16.         self.__textInput.hint_text = "Input value as \n5,2\n1,3"
  17.        
  18.         self.__buttonSendMsg = kivy.uix.button.Button(text="Get results")
  19.         self.__buttonSendMsg.bind(on_press=self.sendMessage)
  20.        
  21.         self.__boxLayout = kivy.uix.boxlayout.BoxLayout(orientation="vertical")
  22.         self.__boxLayout.add_widget(self.__labelOutput)
  23.         self.__boxLayout.add_widget(self.__textInput)        
  24.         self.__boxLayout.add_widget(self.__buttonSendMsg)
  25.  
  26.         return self.__boxLayout
  27.    
  28.     def __DisabledUI(self, val):
  29.         self.__textInput.disabled = val
  30.         self.__buttonSendMsg = val
  31.    
  32.     def __inputToJson(self):
  33.         coordinates = self.__textInput.text.split("\n")
  34.         print(coordinates)
  35.         json_contents = {"data" : []}
  36.         for cordi in coordinates:
  37.             cordi_in_data = []            
  38.             for val in cordi.split(","):                
  39.                 cordi_in_data.append(float(val))
  40.             json_contents["data"].append(cordi_in_data)
  41.            
  42.         print("dcit:", json_contents)        
  43.        
  44.         return json_contents    
  45.  
  46.     def sendMessage(self, btn):
  47.         self.__DisabledUI(True)
  48.                
  49.        
  50.        
  51.         self.__DisabledUI(False)
  52.  
  53.  
  54. if __name__ == "__main__":
  55.     simpleApp = SimpleApp()
  56.     simpleApp.run()
Advertisement
Add Comment
Please, Sign In to add comment