daily pastebin goal
75%
SHARE
TWEET

Untitled

a guest Sep 22nd, 2016 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import scene, ui
  2.  
  3. class MainMenu(ui.View):
  4.     def __init__(self):
  5.         ui.View.__init__(self)
  6.         self.scene_view = scene.SceneView()
  7.         self.scene_view.scene = MainMenuScene()
  8.         self.present(hide_title_bar=True)
  9.         self.scene_view.frame = self.bounds
  10.         self.add_subview(self.scene_view)
  11.     def set_login_scene(self):
  12.         loading_scene = LoadingScene(self._login_complete)
  13.         self.scene_view.scene.present_modal_scene(loading_scene)
  14.         #loading_scene.showUiElements()
  15.     def _login_complete(self, username, password):
  16.         self.controller.set_credentials(username, password)
  17.         self.scene_view.scene.dismiss_modal_scene()
  18.  
  19. class MainMenuScene(scene.Scene):
  20.     def __init__(self):
  21.         scene.Scene.__init__(self)
  22.         self.background_color = 'midnightblue'
  23.         self.add_child(scene.Node()) # Dummy node as a bugfix
  24.         pass
  25.        
  26. class LoadingScene (scene.Scene):
  27.     def __init__(self, callback):
  28.         scene.Scene.__init__(self)
  29.         self.callback = callback
  30.         # More setup stuff here
  31.        
  32.     def setup(self):
  33.         self.background_color = "#101020"
  34.         # More setup stuff here
  35.         self.setupUiElements()
  36.        
  37.     def setupUiElements(self):
  38.         self.login_view = ui.load_view('login')
  39.         self.login_view.background_color = 'clear'
  40.         self.login_view.center = self.size/2
  41.         self.login_view.set_callback(self.complete_callback)
  42.         self.presenting_scene.view.add_subview(self.login_view)
  43.        
  44. class LoginView (ui.View): # Actual view is defined in UI Designer File
  45.     def set_callback(self, callback):
  46.         self.callback = callback
  47.     def did_load(self):
  48.         self['connect_button'].action = self.do_callback
  49.     def do_callback(self, sender):
  50.         username = self['txtUsername'].text
  51.         password = self['txtPassword'].text
  52.         if username != "" and password != "":
  53.             self.callback(username, password)
  54.     def keyboard_frame_will_change(self, frame):
  55.         if not self.superview:
  56.             return
  57.         if sum(frame) == 0:
  58.             # Keyboard disappeared
  59.             self.center = (self.superview.width/2, self.superview.height/2)
  60.         else:
  61.             # Keyboard opened
  62.             self.center = (self.superview.width/2, min(self.superview.height/2, frame[1]-100))
  63.            
  64. MainMenu()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top