def generate(self): if self.ids.input.text == '': self.showHelp() else: sm.transition = RiseInTransition() sm.current = 'display' self.start()
def build(self): self.title = '(^_^)' self.icon = 'data/icon.png' screen_manager = ScreenManager(transition=RiseInTransition()) screen_manager.add_widget(LoginScreen()) screen_manager.add_widget(DisplayScreen()) return screen_manager
def __init__(self, **kwargs): super(PostScreenManager, self).__init__(**kwargs) self.transition = RiseInTransition() # get the post wall and post carousel references wall = self.ids['pw'] carousel = self.ids['pc'] # pass the refernece to the screen manager wall.screen_manager = self carousel.screen_manager = self # generate new data data = post_generator.generate_new_data() self.number_of_posts = len(data) # pass the data tot he post wall wall.data = data # feed the carousel with the data for item in data: if 'ImagePost' in item['viewclass']: carousel.add_widget(Image(source=item['image_path'])) elif 'TextPost' in item['viewclass']: carousel.add_widget(Label(text=item['label_text'])) self._keyboard = Window.request_keyboard(self._keyboard_closed, self) if not self._keyboard: return self._keyboard.bind(on_key_down=self.on_keyboard_down) self.movement_flag = False #self.current_active_post_index = None Clock.schedule_once(wall.center_first_post, 1)
def __init__(self, **kwargs): super(RootWidget, self).__init__(**kwargs) self.transition = RiseInTransition() self.error_message = '' self.previous_screens = [] self.add_widget(StartAppModalScreen()) self.current = StartAppModalScreen.NAME self.current_screen.data = dict(start_app_callback=self.start_app)
def on_touch_up(self, touch): if touch.grab_current is self: touch.ungrab(self) self.ripple_fade() self.root.ids.profilePage.reg_no = self.parent.ids.lbl1.text self.root.transition = RiseInTransition() self.root.current = "profilepage" return True return False
def open(self, view): self.ensure_unique_name(view) self.unfocus_maybe() name = view.name if self.has_screen(name): self.remove_widget(self.get_screen(name)) self.add_widget(view) self.transition = RiseInTransition() self.current = name self.history.append(view)
def trocar(self, nome_tela, tipo_transicao='Slide', sentido_da_imagem='up'): if (tipo_transicao == 'Slide'): self.manager.transition = FadeTransition() else: self.manager.transition = RiseInTransition() self.manager.transition.direction = sentido_da_imagem self.manager.current = nome_tela
def build(self): languages_yaml = strictyaml.load( Path("lang_template.yaml").bytes().decode('utf8')).data self._languages = {k: dict(v) for k, v in languages_yaml.items()} self._selected_language = next(iter(self._languages)) # get a language self._m = Manager(self._config, transition=RiseInTransition()) self._config.PRICEFEED.start() self._config.STATUS.start() return self._m
def first_start(self, *_): self.root.ids.sm.transition = FallOutTransition() \ if self.theme_cls.theme_style == 'Dark' else RiseInTransition() self.set_decorations() self.root.ids.sm.current = 'scr 1' self.root.ids.sm.transition = SlideTransition() self.root.ids.sm.transition.direction = 'up'
def asigna_sectores(self, sectores=()): from pickle import loads Logger.debug("%s: asigna_sectores %s" % (APP, sectores)) n_sectores = self.horario.n_sectores() for i in range(0, n_sectores): s = "s%d" % (i + 1) if self.restarting: self.horario.actualiza_sector(s, self.config.get('general', s)) else: self.horario.actualiza_sector(s, sectores[i]) self.config.set('general', s, sectores[i]) if self.restarting: # Pickle parece que tiene un bug con la lista al guardar # en el archivo. Utilizamos la codifiación en base64 para evitarlo string = self.config.get('general', 'alarmas') # Logger.debug("%s: String %s" % (APP, str(string))) self.alarmas = loads(b64decode(string)) else: self.alarmas = self.calculate_alarms() self.config.set('general', 'alarmas', b64encode(dumps(self.alarmas))) Logger.debug("%s: alarmas: %s" % (APP, pformat(self.alarmas))) # Necesitamos un copy para que los observadores reaccionen self.horario = copy(self.horario) if not self.planilla: self.planilla = PlanillaScreen() self.scmgr.add_widget(self.planilla) self.planilla.pw.bind(on_touch_down=self.show_image) if not self.imagescreen: self.imagescreen = ImageScreen() self.imagescreen.app = self self.scmgr.add_widget(self.imagescreen) self.imagescreen.load("data/%s.png" % self.horario.planilla) self.scmgr.transition = RiseInTransition() self.scmgr.current = 'planilla' Logger.debug("%s: current 'planilla' - RiseIn" % APP) self.config.set('general', 'numero', self.numero) self.config.set('general', 'planilla', self.horario.planilla) self.config.set('general', 'final', self.horario.final.strftime("%d/%m/%y %H:%M")) self.config.write() self.arrancar_servicio()
def handleRequest(self, data): self.get_screen("aio").reset() if data[0] == "info": if len(data) > 1: self.get_screen("aio").set_color(data[1]) if len(data) > 2: self.get_screen("aio").set_text(data[2]) if len(data) > 3: self.get_screen("aio").set_title(data[3]) if len(data) > 4: self.get_screen("aio").set_image(data[4]) if len(data) > 5: try: time = int(data[5]) Clock.schedule_once(self.startIt, time) except: pass prevTransition = self.transition self.transition = RiseInTransition() self.current = "aio" self.transition = prevTransition if data[0] == "image": if len(data) > 1: self.get_screen("aio").set_image(data[1]) if len(data) > 2: self.get_screen("aio").set_color(data[2]) if len(data) > 3: try: time = int(data[3]) Clock.schedule_once(self.startIt, time) except: pass prevTransition = self.transition self.transition = RiseInTransition() self.current = "aio" self.transition = prevTransition
def build(self): self.title = 'Gépjármű-nyilvántartás' formScreen = FormScreen(name="Form") sm.add_widget(formScreen) listaScreen = ListaScreen(name="Lista") sm.add_widget(listaScreen) infoScreen = InfoScreen(name="Info") sm.add_widget(infoScreen) sm.transition = RiseInTransition() sm.current = "Form" return sm
class CamApp(MDApp): ######## Global Variables ######## username = None screen_manager = ScreenManager(transition=RiseInTransition()) # Add the screens to the manager and then supply a name # that is used to switch screens def build(self): CamApp.screen_manager.add_widget(HomeScreen(name="HomeScreen")) CamApp.screen_manager.add_widget(LoginScreen(name="LogMeIn")) CamApp.screen_manager.add_widget(UserHome(name="UserHomePage")) # self.capture = None # self.my_camera = LoginScreen(capture=self.capture, fps=30) return CamApp.screen_manager
def change_screen(name): global CURRENT_SCREEN previous = index_of_screen(sm.current) new = index_of_screen(name) if name == "end": sm.transition = RiseInTransition() else: sm.transition = SlideTransition() direction = (new - previous) % len(SCREEN_LIST) if direction == 1: sm.transition.direction = "left" else: sm.transition.direction = "right" sm.current = name CURRENT_SCREEN = new
def btnLogin(self): user = self.nameField.text password = self.passwField.text ## Check username and password for correctness ## if good... if (userDatabase.credentialCheck(user, password)): manageWin.transition = RiseInTransition() manageWin.transition.duration = 0.15 manageWin.current = "mainWin" MainWindow.currentUsername = user self.reset() ## clear the form ## if bad else: invalidLogin()
def build(self): # Sets the window/application title. self.title = APP_NAME self.icon = 'es_gui/resources/logo/Quest_App_Icon_256.png' # Create ScreenManager. sm = QuEStScreenManager(transition=RiseInTransition(duration=0.2, clearcolor=[1, 1, 1, 1])) #sm = QuEStScreenManager(transition=SwapTransition(duration=0.2)) # Instantiate DataManager. self.data_manager = DataManager() # Create BoxLayout container. bx = BoxLayout(orientation='vertical') # Add stop flag for threading management. bx.stop = threading.Event() # Create ActionBar and pass it a reference to the screen manager. ab = NavigationBar(sm) ab.sm = sm # Fill BoxLayout. bx.add_widget(ab) bx.add_widget(sm) # Pass reference of navigation bar to screen manager. sm.nav_bar = ab # Create Settings widget and add to settings screen. with open(os.path.join(dirname, 'es_gui', 'resources', 'settings', 'general.json'), 'r') as settings_json: self.settings.add_json_panel('General', self.config, data=settings_json.read()) with open(os.path.join(dirname, 'es_gui', 'resources', 'settings', 'data_manager.json'), 'r') as settings_json: self.settings.add_json_panel('QuESt Data Manager', self.config, data=settings_json.read()) with open(os.path.join(dirname, 'es_gui', 'resources', 'settings', 'valuation.json'), 'r') as settings_json: self.settings.add_json_panel('QuESt Valuation', self.config, data=settings_json.read()) with open(os.path.join(dirname, 'es_gui', 'resources', 'settings', 'btm.json'), 'r') as settings_json: self.settings.add_json_panel('QuESt BTM', self.config, data=settings_json.read()) self.settings.bind(on_close=sm.settings_screen.dismiss) sm.settings_screen.settings_box.add_widget(self.settings) return bx
def SetPageEffect(self,*,uEffect:str) -> bool: """ Sets the page effect for showing a page """ self.uCurrentEffect = uEffect try: if uEffect==u'': return True uType=ToUnicode(type(self.oRootSM.transition)) if uEffect==u'no': self.oRootSM.transition = NoTransition() if uEffect==u'fade': if uType.endswith(u'FadeTransition\'>'): return True self.oRootSM.transition = FadeTransition() elif uEffect==u'slide': if uType.endswith(u'SlideTransition\'>'): return True self.oRootSM.transition = SlideTransition() elif uEffect==u'wipe': if uType.endswith(u'WipeTransition\'>'): return True self.oRootSM.transition = WipeTransition() elif uEffect==u'swap': if uType.endswith(u'SwapTransition\'>'): return True self.oRootSM.transition = SwapTransition() elif uEffect==u'fallout': if uType.endswith(u'FallOutTransition\'>'): return True self.oRootSM.transition = FallOutTransition() elif uEffect==u'risein': if uType.endswith(u'RiseInTransition\'>'): return True self.oRootSM.transition = RiseInTransition() # noinspection PyArgumentList self.oRootSM.transition.bind(on_complete=self.On_Transition_Complete) # noinspection PyArgumentList self.oRootSM.transition.bind(on_progress=self.On_Transition_Started) return True except Exception as e: ShowErrorPopUp(uMessage=LogError(uMsg=u'TheScreen: Can not set page effect:' + uEffect,oException=e)) return False
def GameOver(): ''' This function is called when the clock ran out and the game ends. The user is Propmted for their name, and it's entered in the high score file and list if it is among the top 5 scores. The top five scores are displayed. Highscores are written to a file named high_scores.txt, if there doesn't exist one one is created. ''' try: # check that data is initialized GameOver.input_text except AttributeError: # initialize data GameOver.input_text = None GameOver.score_list = [] # update board status and animations _Board._highlighted.clear() Clock.unschedule(_Board.game_timer.tile_drop) _Board.game_timer.cover_timer = -1 _Board.tile_cover.pos = -5000, -5000 _Board.manager.transition = RiseInTransition(duration=.5) _Board.manager.current = 'menu' # create the popup prompt for user name box = BoxLayout() text_in = TextInput(multiline = False, font_size = 40) box.add_widget(text_in) popup = Popup(title='Enter Your Name') popup.content = box popup.auto_dismiss = False popup.size_hint = (None, None) popup.size=(550, 120) # go to last screen when user presses 'enter' text_in.on_text_validate = LastScreen GameOver.input_text = text_in GameOver.input_text.popup = popup # Read in highscore file of 5 highest scores must end with newline try: file = open('high_scores.txt', 'r') for line in file: line = line.strip().split(",") line[1] = ' '.join(line[1].split()) try: GameOver.score_list.append((line[0],line[1])) except: # if blank line do nothing continue file.close() except: # Do nothing if no file or empty line pass # THIS SHOULDN'T HAPPEN, but if the highscore file ended up # with more than 5 things in it, we will rewrite the new one to have 5 # by removing lowest scores while(len(GameOver.score_list)>5): GameOver.score_list.pop(0) # IF LIST LESS THAN 5 RECORDS LONG THEN FILL IT WITH EMPTIES while(len(GameOver.score_list)<5): GameOver.score_list = [(0, 'No Record Yet')] + GameOver.score_list popup.open()
def on_press(self): self.parent.parent.parent.parent.parent.transition = RiseInTransition() self.parent.parent.parent.parent.parent.current = self.name
def __init__(self, **kwargs): super(Juggler, self).__init__(**kwargs) self.fade = FadeTransition() self.fall = FallOutTransition() self.rise = RiseInTransition() self.transition = self.fade
def prototype(self): self.manager.transition = RiseInTransition() self.manager.current = 'prototype'
def home_screen(): controller.transition = RiseInTransition() controller.current = "Home"
def b_improve(self): self.manager.transition = RiseInTransition() self.manager.current = 'bimprove'
def calc_risk(self): if "AGE" in values and values["AGE"]: age = 30 try: age = float(values["AGE"]) except ValueError: pass except TypeError: pass if age < 10 or 50 < age: res_scr.curr_risk_color = [ 153.0 / 255, 93.0 / 255, 77.0 / 255, 1 ] res_scr.curr_risk_label = 'HIGH RISK' res_scr.curr_risk_level = 1 sm.current = 'result' return # Find highest ranking model that contained in the provided variables model_dir = None model_vars = None vv = set([]) for k in values: if values[k]: vv.add(k) print vv for info in models_info: v = set(info[1]) res = v.issubset(vv) #print res, info[1] if res: model_dir = info[0] model_vars = info[1] break if not model_dir or not models_info: res_scr.curr_risk_color = [0.5, 0.5, 0.5, 1] res_scr.curr_risk_label = 'INSUFFICIENT DATA' res_scr.curr_risk_level = 0 sm.transition = RiseInTransition() sm.current = 'result' return print "FOUND MODEL !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" print model_dir print model_vars predictor = gen_predictor(os.path.join(model_dir, 'nnet-params')) N = len(model_vars) model_min = [] model_max = [] with open(os.path.join(model_dir, 'bounds.txt')) as bfile: lines = bfile.readlines() for line in lines: line = line.strip() parts = line.split() model_min.append(float(parts[1])) model_max.append(float(parts[2])) print model_min print model_max v = [None] * (N + 1) v[0] = 1 for i in range(N): var = model_vars[i] if var in values: try: v[i + 1] = float(values[var]) if var in units and units[var] != var_def_unit[var]: # Need to convert units c, f = var_unit_conv[var] print "convert", var, v[i + 1], "->", f * (v[i + 1] + c) v[i + 1] = f * (v[i + 1] + c) except ValueError: pass except TypeError: pass if None in v: res_scr.curr_risk_color = [0.5, 0.5, 0.5, 1] res_scr.curr_risk_label = 'INSUFFICIENT DATA' res_scr.curr_risk_level = 0 sm.current = 'result' return for i in range(N): f = (v[i + 1] - model_min[i]) / (model_max[i] - model_min[i]) if f < 0: v[i + 1] = 0 elif 1 < f: v[i + 1] = 1 else: v[i + 1] = f print values print v X = np.array([v]) probs = predictor(X) pred = probs[0] print "------------->", pred, type(pred) res_scr.curr_risk_level = float(pred) if pred < 0.5: res_scr.curr_risk_color = [ 121.0 / 255, 192.0 / 255, 119.0 / 255, 1 ] res_scr.curr_risk_label = 'LOW RISK' else: level = float((pred - 0.5) / 0.5) res_scr.curr_risk_color = [153.0 / 255, 93.0 / 255, 77.0 / 255, 1] res_scr.curr_risk_label = 'HIGH RISK' sm.transition = RiseInTransition() #sm.transition = SlideTransition(direction='left') sm.current = 'result'
def build(self): self.title = 'CRSum抽取式摘要系統' self.icon = getResourcePath('icon.png') return RootScreenManager(transition=RiseInTransition(duration=0.4))
def yahoocrusher(self): self.manager.transition = RiseInTransition() self.manager.current = 'yahoocrush'
def show_image(self, widget, touch): Logger.debug("%s: show_image" % APP) if self.planilla.pw.collide_point(*touch.pos): self.scmgr.transition = RiseInTransition() self.scmgr.current = 'image'
def knowmore(self): self.manager.transition = RiseInTransition() self.manager.current = 'knowmore'
def yahootwin(self): self.manager.transition = RiseInTransition() self.manager.current = 'yahootwin'
def edit_login(self): self.manager.transition = RiseInTransition() self.manager.current = 'editlogin'