Advertisement
Guest User

Untitled

a guest
Mar 29th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.36 KB | None | 0 0
  1. imageChanged=None#flag
  2.  
  3. class ImageButton(ButtonBehavior, AsyncImage):
  4.  
  5. def on_press(self):
  6. popupBox=BoxLayout(orientation='vertical')
  7. imageURL=TextInput(hint_text='Enter an image url for your profile picture...',
  8. size_hint=(1, .25),multiline=False)
  9. avatarPopup=Popup(title='Add an avatar',
  10. content=popupBox,
  11. size_hint=(None, None),
  12. size=(500,200),
  13. pos=(200,300),
  14. auto_dismiss=False)
  15. popupSubmit=Button(text='Submit')#add better size later
  16. popupBox.add_widget(imageURL)
  17. popupBox.add_widget(popupSubmit)
  18. avatarPopup.open()
  19. def closeAndSend(self):
  20. #ONE FOR EVERY input
  21. if (".jpg" or ".png" or ".jpeg" or ".gif" or ".bmp") in imageURL.text:
  22. imageChanged=True
  23. store.put('userAvatarURL',url=imageURL.text)
  24. #HERE
  25. #need to reload avatarButton
  26. else:
  27. errorPop=Label(text='Must be image url with common format like .jpg, .png, etc')
  28. errorPopup=Popup(title='Error', size_hint=(None, None),
  29. size=(450,100), pos=(200,300), content=errorPop)
  30. #errorPopup.add_widget(errorPop)
  31. errorPopup.open()
  32. avatarPopup.dismiss()
  33. popupSubmit.bind(on_press=closeAndSend)
  34.  
  35.  
  36. class Profile(Screen):
  37. profile_l = ObjectProperty(None)
  38.  
  39. #def bindAndSend(self):
  40. # self.createProfilePopup.dismiss
  41.  
  42. def __init__(self, **kwargs):
  43. super(Profile, self).__init__(**kwargs)
  44. profile=self.profile_l
  45. popupBox=BoxLayout(orientation='vertical')
  46. my_textinputs={}
  47. userInfo='username,password,age,stance,location'.split(",")
  48. userInfoKeys=userInfo
  49. for each in userInfo:
  50. textinput=TextInput(hint_text='Enter your '+each+'...',
  51. size_hint=(1, .25),multiline=False)
  52. my_textinputs[each]=textinput
  53. popupBox.add_widget(textinput)
  54. popupSubmit=Button(text='Submit')
  55. popupBox.add_widget(popupSubmit)
  56. createProfilePopup=Popup(title='Create Profile',
  57. content=popupBox,
  58. size_hint=(None, None),
  59. size=(300,300),
  60. pos=(200,300),
  61. auto_dismiss=False)
  62. #if userLogin==true:
  63. createProfilePopup.open()
  64.  
  65.  
  66.  
  67.  
  68. def assembleProfile():
  69. profileLayout=FloatLayout(size_hint=(1, 1))
  70. #inside=BoxLayout()
  71. #image crop as well
  72. #add default custom avatar
  73. #if store.exists('userAvatarURL')
  74. avatarButton=ImageButton(source=store.get('userAvatarURL')['url'], pos=(100,720), size_hint=(.5,.25))#, size=(320, 240))
  75.  
  76. profileLayout.add_widget(avatarButton)
  77. profile.add_widget(profileLayout)
  78.  
  79.  
  80. def closeAndSend(self):
  81. #ONE FOR EVERY input
  82. store.put('userInfo',
  83. username=my_textinputs['username'].text,
  84. password=my_textinputs['password'].text,
  85. age=my_textinputs['age'].text,
  86. stance=my_textinputs['stance'].text,
  87. location=my_textinputs['location'].text)
  88. createProfilePopup.dismiss()
  89. assembleProfile()
  90. popupSubmit.bind(on_press=closeAndSend)
  91. pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement