Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- imageChanged=None#flag
- class ImageButton(ButtonBehavior, AsyncImage):
- def on_press(self):
- popupBox=BoxLayout(orientation='vertical')
- imageURL=TextInput(hint_text='Enter an image url for your profile picture...',
- size_hint=(1, .25),multiline=False)
- avatarPopup=Popup(title='Add an avatar',
- content=popupBox,
- size_hint=(None, None),
- size=(500,200),
- pos=(200,300),
- auto_dismiss=False)
- popupSubmit=Button(text='Submit')#add better size later
- popupBox.add_widget(imageURL)
- popupBox.add_widget(popupSubmit)
- avatarPopup.open()
- def closeAndSend(self):
- #ONE FOR EVERY input
- if (".jpg" or ".png" or ".jpeg" or ".gif" or ".bmp") in imageURL.text:
- imageChanged=True
- store.put('userAvatarURL',url=imageURL.text)
- #HERE
- #need to reload avatarButton
- else:
- errorPop=Label(text='Must be image url with common format like .jpg, .png, etc')
- errorPopup=Popup(title='Error', size_hint=(None, None),
- size=(450,100), pos=(200,300), content=errorPop)
- #errorPopup.add_widget(errorPop)
- errorPopup.open()
- avatarPopup.dismiss()
- popupSubmit.bind(on_press=closeAndSend)
- class Profile(Screen):
- profile_l = ObjectProperty(None)
- #def bindAndSend(self):
- # self.createProfilePopup.dismiss
- def __init__(self, **kwargs):
- super(Profile, self).__init__(**kwargs)
- profile=self.profile_l
- popupBox=BoxLayout(orientation='vertical')
- my_textinputs={}
- userInfo='username,password,age,stance,location'.split(",")
- userInfoKeys=userInfo
- for each in userInfo:
- textinput=TextInput(hint_text='Enter your '+each+'...',
- size_hint=(1, .25),multiline=False)
- my_textinputs[each]=textinput
- popupBox.add_widget(textinput)
- popupSubmit=Button(text='Submit')
- popupBox.add_widget(popupSubmit)
- createProfilePopup=Popup(title='Create Profile',
- content=popupBox,
- size_hint=(None, None),
- size=(300,300),
- pos=(200,300),
- auto_dismiss=False)
- #if userLogin==true:
- createProfilePopup.open()
- def assembleProfile():
- profileLayout=FloatLayout(size_hint=(1, 1))
- #inside=BoxLayout()
- #image crop as well
- #add default custom avatar
- #if store.exists('userAvatarURL')
- avatarButton=ImageButton(source=store.get('userAvatarURL')['url'], pos=(100,720), size_hint=(.5,.25))#, size=(320, 240))
- profileLayout.add_widget(avatarButton)
- profile.add_widget(profileLayout)
- def closeAndSend(self):
- #ONE FOR EVERY input
- store.put('userInfo',
- username=my_textinputs['username'].text,
- password=my_textinputs['password'].text,
- age=my_textinputs['age'].text,
- stance=my_textinputs['stance'].text,
- location=my_textinputs['location'].text)
- createProfilePopup.dismiss()
- assembleProfile()
- popupSubmit.bind(on_press=closeAndSend)
- pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement