def constroi_linha(self, lista): nome, *args = lista n = 1 spacing = "10sp" padding = [f"{i}sp" for i in [0, 0, 10, 0]] grid = GridLayout(cols=1, size_hint_y=None) grid.bind(minimum_height=grid.setter("height")) label = Label(text=nome) label.size_hint_y = None label.height = self.height * .1 label.font_size = self.fonte_padrao * n label.valign = "center" label.halign = "center" label.text_size = [self.width * .9, self.height * .9] grid.add_widget(label) #grid.ids["descricao"] = label for valor in args: label = Label(text=valor) label.size_hint_y = .1 label.halign = label.valign = "center" label.text = valor label.height = self.height * .1 label.font_size = self.fonte_padrao * .9 label.text_size = [self.width * .9, self.height * .9] grid.add_widget(label) #grid.ids["valor"] = label #self.ids[f"{self.nome_tela}_campo_{self.n}"] = grid return grid
def build(self): layout = BoxLayout(orientation='vertical') inputKeyLabel = Label(text='Enter api key: ', size_hint_y=None) inputKeyLabel.height = 30 inputKeyField = TextInput( text= 'xoxp-3278486248-78952291655-256623167682-8311d81d495b53995888c2a3d8c1e52f', multiline=False, size_hint_y=None) inputKeyField.height = 30 inputNameLabel = Label(text='Enter bot name: ', size_hint_y=None) inputNameLabel.height = 30 inputNameField = TextInput(text='Default Bot Name', multiline=False, size_hint_y=None) inputNameField.height = 30 inputChannelLabel = Label(text='Enter chanel name: ', size_hint_y=None) inputChannelLabel.height = 30 inputChannelField = TextInput(text='test', multiline=False, size_hint_y=None) inputChannelField.height = 30 inputMessLabel = Label(text='Enter message: ', size_hint_y=None) inputMessLabel.height = 30 inputMessField = TextInput(text='', size_hint_y=None, multiline=False) inputMessField.height = 30 botStatusLabel = Label(text='Bot Status: ', size_hint_y=None) botStatusLabel.height = 30 botStatus = Label(text='') botStatus.color = (1, 0, 0) runButton = Button(text='Run Slackbot') runButton.height = 30 def start_bot(instance): with Session() as session: s = SlackCrawler(inputKeyField.text, session, inputNameField.text) s.start() runButton.bind(on_press=start_bot) layout.add_widget(inputKeyLabel) layout.add_widget(inputKeyField) layout.add_widget(inputNameLabel) layout.add_widget(inputNameField) layout.add_widget(inputChannelLabel) layout.add_widget(inputChannelField) layout.add_widget(inputMessLabel) layout.add_widget(inputMessField) layout.add_widget(botStatusLabel) layout.add_widget(botStatus) layout.add_widget(runButton) return layout
def build(): tela = FloatLayout() global Data_text Data_text = TextInput(font_size=30) Data_text.size_hint = None, None Data_text.height, Data_text.width, Data_text.x, Data_text.y = TAMANHO_ALTURA, 500, TEXT_X, 500 tela.add_widget(Data_text) Data_lb = Label(text='Data', font_size=30) Data_lb.size_hint = None, None Data_lb.height, Data_lb.width, Data_lb.x, Data_lb.y = TAMANHO_ALTURA, 100, LABEL_X, 500 tela.add_widget(Data_lb) global Tipo_text Tipo_text = TextInput(font_size=30) Tipo_text.size_hint = None, None Tipo_text.height, Tipo_text.width, Tipo_text.x, Tipo_text.y = TAMANHO_ALTURA, 500, TEXT_X, 400 tela.add_widget(Tipo_text) Tipo_lb = Label(text='Tipo', font_size=30) Tipo_lb.size_hint = None, None Tipo_lb.height, Tipo_lb.width, Tipo_lb.x, Tipo_lb.y = 50, 100, LABEL_X, 400 tela.add_widget(Tipo_lb) global Valor_Text Valor_Text = TextInput(font_size=30) Valor_Text.size_hint = None, None Valor_Text.height, Valor_Text.width, Valor_Text.x, Valor_Text.y = 50, 500, TEXT_X, 300 tela.add_widget(Valor_Text) Valor_lb = Label(text='Valor', font_size=30) Valor_lb.size_hint = None, None Valor_lb.width, Valor_lb.height, Valor_lb.x, Valor_lb.y = 50, 100, 30, 280 tela.add_widget(Valor_lb) Botao_salva = Button(text='Salvar', font_size=30) Botao_salva.size_hint = None, None Botao_salva.background_color = [0, 0.5, 0.9, 1] Botao_salva.height, Botao_salva.width, Botao_salva.x, Botao_salva.y = 50, 100, 650, 450 Botao_salva.on_press = salvar tela.add_widget(Botao_salva) Botao_Fechar = Button(text='Fechar', font_size=30) Botao_Fechar.size_hint = None, None Botao_Fechar.background_color = [0, 0.5, 0.9, 1] Botao_Fechar.height, Botao_Fechar.width, Botao_Fechar.x, Botao_Fechar.y = 50, 100, 650, 350 Botao_Fechar.on_press = janela.stop tela.add_widget(Botao_Fechar) Botao_buscar = Button(text='buscar', font_size=30) Botao_buscar.size_hint = None, None Botao_buscar.background_color = [0, 0.5, 0.9, 1] Botao_buscar.height, Botao_buscar.width, Botao_buscar.x, Botao_buscar.y = 50, 100, 650, 250 Botao_buscar.on_press = nova_tela tela.add_widget(Botao_buscar) return tela
def __init__(self, title, choices, key, callback): Factory.Popup.__init__(self) print(choices, type(choices)) if type(choices) is list: choices = dict(map(lambda x: (x, x), choices)) layout = self.ids.choices layout.bind(minimum_height=layout.setter('height')) for k, v in sorted(choices.items()): l = Label(text=v) l.height = '48dp' l.size_hint_x = 4 cb = CheckBox(group='choices') cb.value = k cb.height = '48dp' cb.size_hint_x = 1 def f(cb, x): if x: self.value = cb.value cb.bind(active=f) if k == key: cb.active = True layout.add_widget(l) layout.add_widget(cb) layout.add_widget(Widget(size_hint_y=1)) self.callback = callback self.title = title self.value = key self.app = App.get_running_app()
def constroi_titulo(self): label = Label(text=self.titulo, bold=True) label.size_hint_y = None label.height = self.size[1] * .1 label.font_size = self.fonte_padrao label.font_size *= 1.3 self.add_widget(label)
def __init__(self, title, choices, key, callback, keep_choice_order=False): Factory.Popup.__init__(self) print(choices, type(choices)) if keep_choice_order: orig_index = {choice: i for (i, choice) in enumerate(choices)} sort_key = lambda x: orig_index[x[0]] else: sort_key = lambda x: x if type(choices) is list: choices = dict(map(lambda x: (x,x), choices)) layout = self.ids.choices layout.bind(minimum_height=layout.setter('height')) for k, v in sorted(choices.items(), key=sort_key): l = Label(text=v) l.height = '48dp' l.size_hint_x = 4 cb = CheckBox(group='choices') cb.value = k cb.height = '48dp' cb.size_hint_x = 1 def f(cb, x): if x: self.value = cb.value cb.bind(active=f) if k == key: cb.active = True layout.add_widget(l) layout.add_widget(cb) layout.add_widget(Widget(size_hint_y=1)) self.callback = callback self.title = title self.value = key
def update(self, *args): if self.data is None: return if not self.canvas: Clock.schedule_once(self.update, 0) return if not hasattr(self, '_palbox'): self._palbox = PalletBox(orientation='vertical', size_hint_y=None) self.add_widget(self._palbox) else: self._palbox.clear_widgets() self.labels = [] self.pallets = [] for (text, filename) in self.data: label = Label(text=text, size_hint=(None, None), halign='center') label.texture_update() label.height = label.texture.height label.width = self._palbox.width self._palbox.bind(width=label.setter('width')) pallet = Pallet(filename=filename, size_hint=(None, None)) pallet.width = self._palbox.width self._palbox.bind(width=pallet.setter('width')) pallet.height = pallet.minimum_height pallet.bind(minimum_height=pallet.setter('height'), height=self._trigger_reheight) self.labels.append(label) self.pallets.append(pallet) n = len(self.labels) assert (n == len(self.pallets)) for i in range(0, n): self._palbox.add_widget(self.labels[i]) self._palbox.add_widget(self.pallets[i])
def markDestination(self, destination): ''' Takes in a parking garage object called destination Gets the location of the destination and places a map marker on top of it Parameters: destination - ParkingGarage object Returns: coords - tuple with the coordinates of the map marker ''' if not isinstance(destination, ParkingGarage): pop = Popup(title="Error", content=Label(text="No Destination Input"), size_hint=(.2, .2)) pop.open() return #Get the coordinates of the destination coder = GoogleGeocoder("AIzaSyDPOAePgFbDCBU0rsOdvWX66C2CPUB2CZM") g = coder.get(destination.getLocation()) coords = (g[0].geometry.location.lat, g[0].geometry.location.lng) #Create a marker that holds information on the parking garage bub = Bubble(size_hint=(None, None), size=(200, 50), arrow_pos='bottom_left') lab = Label(text=(" " + destination.getName()), text_size=(self.width, None)) lab.height = lab.texture_size[1] lab.halign = 'center' bub.add_widget(lab) m1 = MapMarkerPopup(lat=coords[0], lon=coords[1], placeholder=bub) #Mark the map and return the coordinates of the marker self.ids.map1.add_marker(m1) return coords
def __init__(self, title, choices, key, callback): Factory.Popup.__init__(self) if type(choices) is list: choices = dict(map(lambda x: (x,x), choices)) layout = self.ids.choices layout.bind(minimum_height=layout.setter('height')) for k, v in sorted(choices.items()): l = Label(text=v) l.height = '48dp' l.size_hint_x = 4 cb = CheckBox(group='choices') cb.value = k cb.height = '48dp' cb.size_hint_x = 1 def f(cb, x): if x: self.value = cb.value cb.bind(active=f) if k == key: cb.active = True layout.add_widget(l) layout.add_widget(cb) layout.add_widget(Widget(size_hint_y=1)) self.callback = callback self.title = title self.value = key
def __init__(self, title, choices, key, callback, *, description='', keep_choice_order=False): Factory.Popup.__init__(self) self.description = description if keep_choice_order: orig_index = {choice: i for (i, choice) in enumerate(choices)} sort_key = lambda x: orig_index[x[0]] else: sort_key = lambda x: x if type(choices) is list: choices = dict(map(lambda x: (x,x), choices)) layout = self.ids.choices layout.bind(minimum_height=layout.setter('height')) for k, v in sorted(choices.items(), key=sort_key): l = Label(text=v) l.height = '48dp' l.size_hint_x = 4 cb = CheckBox(group='choices') cb.value = k cb.height = '48dp' cb.size_hint_x = 1 def f(cb, x): if x: self.value = cb.value cb.bind(active=f) if k == key: cb.active = True layout.add_widget(l) layout.add_widget(cb) layout.add_widget(Widget(size_hint_y=1)) self.callback = callback self.title = title self.value = key
def mostrar_palabras(self): if self.palabra: self.gl_palabras.clear_widgets() consonante, asonante = riman_con(self.palabra, Configuracion.obtener("db")) l = Label() l.text = "Rima consonante" l.size_hint_y = None l.height = 60 l.color = [0, 0, 0, 1] self.gl_palabras.add_widget(l) if consonante: for c in consonante: b = Button(text=c) b.size_hint_y = None b.height = 60 b.bind(on_press=self.btn_palabra_on_press) self.gl_palabras.add_widget(b) else: l = Label() l.text = "[ninguna]" l.size_hint_y = None l.height = 60 l.color = [0, 0, 0, 1] self.gl_palabras.add_widget(l) l = Label() l.text = "Rima asonante" l.size_hint_y = None l.height = 60 l.color = [0, 0, 0, 1] self.gl_palabras.add_widget(l) if asonante: for c in asonante: b = Button(text=c) b.size_hint_y = None b.height = 60 b.bind(on_press=self.btn_palabra_on_press) self.gl_palabras.add_widget(b) else: l = Label() l.text = "[ninguna]" l.size_hint_y = None l.height = 60 l.color = [0, 0, 0, 1] self.gl_palabras.add_widget(l)
def build(self): c = CustomLayout() c.add_widget( AsyncImage( source="Login/background-login.jpg")) lbl = Label(text='Bem vindo') lbl.font_size= '60sp' lbl.bold= True lbl.color= [1,1,1,1] lbl.size_hint = None, None lbl.height = 30 lbl.width = 300 lbl.y = 370 lbl.x = 250 bt = Button(text="Iniciar captura de face") bt.size_hint = None, None bt.height = 50 bt.width = 200 bt.y = 210 bt.x = 300 def callback(self): #inserir codigo de reconhecimento facial-captura de fotos bt.bind(on_press=callback) bt2 = Button(text="Iniciar Treino") bt2.size_hint = None, None bt2.height = 50 bt2.width = 200 bt2.y = 150 bt2.x = 300 def callback(self): # inserir codigo de treino bt2.bind(on_press=callback) bt3 = Button(text="Iniciar Reconhecimento") bt3.size_hint = None, None bt3.height = 50 bt3.width = 200 bt3.y = 90 bt3.x = 300 def callback(self): # inserir codigo de visualização do reconhecimento bt3.bind(on_press=callback) c.add_widget(lbl) c.add_widget(bt) c.add_widget(bt2) c.add_widget(bt3) return c
def update_pms(self): user = App.get_running_app().get_user() main_scr = App.get_running_app().get_main_screen() ooc = main_scr.ooc_window self.previous_line = None for line in self.current_conversation.msgs.splitlines(): username = line.split(':', 1)[0] if username == self.current_conversation.username: try: avatar = Image(source=characters[ooc.online_users[ self.current_conversation.username].char_lbl_text]. avatar, size_hint_x=None, width=60) # Placeholder until we do better except KeyError: avatar = Image(source=characters['RedHerring'].avatar, size_hint_x=None, width=60) else: avatar = Image(source=user.get_char().avatar, size_hint_x=None, width=60) # if username == self.previous_line: # avatar.color = [0, 0, 0, 0] line_splitted = " [u]" + line.split( ':', 1)[0] + "[/u]:" + '\n' + line.split(':', 1)[1] line_widget = Label(text=line_splitted, markup=True, on_ref_press=main_scr.log_window.copy_text, size=[self.pm_body.parent.width, 60], text_size=[self.pm_body.parent.width, None], halign='left', valign='top', padding_x=60) if username == self.previous_line: line_widget.text = line.split(':', 1)[1] line_widget.height = line_widget.texture_size[1] if len(line_widget.text) > 120: self.pm_body.add_widget( Image(source=characters['RedHerring'].avatar, size_hint_x=None, width=60, opacity=0)) self.pm_body.add_widget(Label(text='')) self.pm_body.add_widget(avatar) self.pm_body.add_widget(line_widget) if len(line_widget.text) > 120: self.pm_body.add_widget( Image(source=characters['RedHerring'].avatar, size_hint_x=None, width=60, opacity=0)) self.pm_body.add_widget(Label(text='')) self.previous_line = username self.pm_body.parent.scroll_y = 0
def __init__(self, **kwargs): super(WaitPanel, self).__init__(**kwargs) self.cols = 1 self.height = self.minimum_height = 400 self.size_hint_y = None self.bind(minimum_height=self.setter('height')) w = Label(text='waiting for connection...') w.size_hint_y = None w.height = 60 self.add_widget(w)
def append_text_line(self, text): font_size = 15 my_label = Label(text=text, markup=True, halign="left", font_name="RobotoMono-Regular.ttf", font_size=font_size) my_label.bind(size=my_label.setter('text_size')) self.add_widget(my_label) my_label.size_hint_y = None my_label.height = 1.5 * my_label.font_size my_label.padding = [8, 0]
def longTextLabel(): _long_text = """\n\n[b]Programmers[/b]\nCarmen Bruni ([email protected]), Jia Gou ([email protected]), Christina Koch ([email protected]), Bernhard Konrad ([email protected]) and Jerome Lefebvre ([email protected])\n [b]Art[/b]\nIsabell Graf ([email protected]) \n [b]Music[/b]\nCarmen Bruni\n [b]Contact & Feedback[/b]\[email protected]""" reallyLongText = _long_text myLabel = Label(text=reallyLongText, text_size=(700,None), line_height=1.5, markup=True) myLabel.size_hint_y = None myLabel.height = 650 return myLabel
def __init__(self, init_values): super().__init__() self.widget_list = [] box_layout = BoxLayout(orientation='vertical') box_layout.size_hint_y = None box_layout.height = 0 all_params = self.filter_params # set the initial values as specified by the pipeline for key, init_value in init_values.items(): all_params[key]['init_val'] = init_value # create all the widgets for name, params in all_params.items(): # Add slider to widgets slider_widget = Slider(min=params['min_val'], max=params['max_val'], value=params['init_val'], step=params['step_val']) slider_widget.label_name = name slider_widget.bind(value=self._on_value_changed) slider_widget.size_hint_y = None slider_widget.height = '32sp' self.widget_list.append(slider_widget) # create label and value with widgets underneath widget_box_layout = BoxLayout(orientation='vertical') widget_box_layout.size_hint_y = None widget_box_layout.height = 0 widget_label = Label(size_hint=(1, None)) widget_label.label_name = name widget_label.display_callback = self.get_display_callback(name) widget_label.text = self.get_widget_display_text( widget_label, str(int(params['init_val']))) widget_label.texture_update() widget_label.height = widget_label.texture_size[1] slider_widget.label_widget = widget_label # put it all together widget_box_layout.add_widget(widget_label) widget_box_layout.add_widget(slider_widget) widget_box_layout.padding = (5, -5) box_layout.add_widget(widget_box_layout) widget_box_layout.height = widget_label.height + slider_widget.height + 5 box_layout.height += widget_box_layout.height self.size_hint_y = None self.height = box_layout.height self.add_filter_widget(box_layout)
def populate(self, historyArray): # Clear history first for i in range(len(self.history_container.children)): self.history_container.remove_widget( self.history_container.children[0]) # Insert all of the history into the popup for elem in historyArray: newLabel = Label() newLabel.text = elem newLabel.font_size = 14 newLabel.size_hint = (1, None) newLabel.height = 20 self.history_container.add_widget(newLabel)
def __init__(self, title, labels_text, parent): root_layout = BoxLayout(orientation="vertical", padding="10dp") layout = BoxLayout(orientation="vertical", spacing=10, size_hint_y=None) layout.bind(minimum_height=layout.setter('height')) for item in labels_text: label = Label(text=item) label.size_hint = (1, None) label.height = "50dp" layout.add_widget(label) root = ScrollView(size_hint=(1, 1), size=(Window.width, Window.height)) root.add_widget(layout) root_layout.add_widget(root) root_layout.add_widget(Button(text="Zamknij okno", size_hint_y=0.1, on_release=lambda *args: parent.close_info())) self.popup = Popup(title=title, content=root_layout, size_hint=(0.9, 0.7))
def __init__(self, title, choices, key, callback): Factory.Popup.__init__(self) for k, v in choices.items(): l = Label(text=v) l.height = '48dp' cb = CheckBox(group='choices') cb.value = k cb.height = '48dp' def f(cb, x): if x: self.value = cb.value cb.bind(active=f) if k == key: cb.active = True self.ids.choices.add_widget(l) self.ids.choices.add_widget(cb) self.ids.choices.add_widget(Widget(size_hint_y=1)) self.callback = callback self.title = title self.value = key
def __init__(self, title, labels_text, buttons=()): self.screen_names = ["workout", "meal", "water", "hunger", "home"] root_layout = BoxLayout(orientation="vertical") self.screen_manager = ScreenManager() """Home Popup Screen""" home_screen = Screen(name=self.screen_names[-1]) secondary_layout = BoxLayout(orientation="vertical") layout = BoxLayout(orientation="vertical", spacing=10, size_hint_y=None) layout.bind(minimum_height=layout.setter('height')) for item in labels_text: label = Label(text=item) label.size_hint = (1, None) label.height = 80 layout.add_widget(label) buttons = ("Wysiłek fizyczny", "Posiłek", "Woda", "Głód") button0 = Button(text=buttons[0], on_release=lambda *args: self.change_screen(self.screen_names[0])) button1 = Button(text=buttons[1], on_release=lambda *args: self.change_screen(self.screen_names[1])) button2 = Button(text=buttons[2], on_release=lambda *args: self.open_water_popup()) button3 = Button(text=buttons[3], on_release=lambda *args: self.hunger()) for button in [button0, button1, button2, button3]: button.size_hint_y = None button.height = "60dp" layout.add_widget(button) root = ScrollView(size_hint=(1, 1), size=(Window.width, Window.height)) root.add_widget(layout) secondary_layout.add_widget(root) home_screen.add_widget(secondary_layout) self.screen_manager.add_widget(home_screen) root_layout.add_widget(self.screen_manager) root_layout.add_widget(Button(text="Zamknij okno", size_hint_y=0.1, on_release=lambda *args: UserHub.close_info())) """Workout Screen""" workout_screen = Screen(name=self.screen_names[0]) workout_screen.add_widget(self.workout_screen_init()) self.screen_manager.add_widget(workout_screen) meal_screen = Screen(name=self.screen_names[1]) meal_screen.add_widget(MealScreen()) self.screen_manager.add_widget(meal_screen) self.popup = Popup(title=title, content=root_layout, size_hint=(0.9, 0.9))
def add_alarm(alarm_entry, alarm_repeat, days, list_view): if 'Hour' in alarm_entry or 'Minute' in alarm_entry: return Logger.log_info_message('Adding new alarm: ' + alarm_entry) repeat_days = [] if alarm_repeat == 'down': for day in days.children[::-1]: if day.state == 'down': repeat_days.append(day.text) if 'pm' in alarm_entry: alarm_entry = alarm_entry.replace('pm', '') + 'pm' if 'am' in alarm_entry: alarm_entry = alarm_entry.replace('am', '') + 'am' alarm_entry = '{0}, Repeat On: {1}'.format(alarm_entry, ','.join(repeat_days)) new_alarm = Label(text=alarm_entry, size_hint=(1, None)) new_alarm.height = new_alarm.texture_size[1] new_alarm.text_size = (300, None) list_view.add_widget(new_alarm) Clock.schedule_interval(lambda x: sound_alarms(list_view), 1)
def gerarTelaDietaAtual(self,*args): if db.getConfig('DietaAlterada') == '1': auxBoxLayout = self.ids['scDietaDia_Buttons_BoxLayout'] auxBoxLayout.bind(minimum_height=auxBoxLayout.setter('height')) auxBoxLayout.clear_widgets() df = db.retDF_DietaAtual() if len(df) != 0: strRefeicao = '#####' for index,row in df.iterrows(): if strRefeicao != row['strRefeicao']: if strRefeicao != '#####': btnRef.criar() auxBoxLayout.add_widget(btnRef) strRefeicao = row['strRefeicao'] # Cria novo widBtnRef btnRef = widBtnRef() btnRef.bind(on_press = partial(btnRef.evento_click,self.manager)) btnRef.iniciar(row['strRefeicao'],db.strHrBr(row['hrHora'])) btnRef.optAppend(row['strOpt']) else: btnRef.optAppend(row['strOpt']) # Ao final deve adicionar o último botão criado if strRefeicao != '#####': btnRef.criar() auxBoxLayout.add_widget(btnRef) db.setConfig('DietaAlterada','0') # Ao alterar a Dieta Atual seja consumindo algo ou etc, preciso refazer essa tela ou mandar excluir o botao else: lbAux = Label(text='Você já consumiu todos os alimentos de hoje!') lbAux.halign = 'center' lbAux.valign = 'middle' lbAux.text_size = 300, None lbAux.font_size = '20sp' lbAux.markup = True lbAux.size_hint_y = None lbAux.height = 100 auxBoxLayout.add_widget(lbAux)
def openPampaMT(self, project): self.clear_widgets() self.add_widget(self.image_back_ground) self.project = project lb_creating_the_project = Label() lb_creating_the_project.text = lang['Creating_the_Project'] lb_creating_the_project.bold = True lb_creating_the_project.font_size = 17 lb_creating_the_project.size_hint = None, None lb_creating_the_project.height = 30 lb_creating_the_project.width = 150 lb_creating_the_project.center_y = 250 lb_creating_the_project.center_x = 400 self.add_widget(lb_creating_the_project) self.progress_bar_finish = ProgressBar() self.progress_bar_finish.size_hint = None, None self.progress_bar_finish.width = 350 self.progress_bar_finish.height = 10 self.progress_bar_finish.value = 1 self.progress_bar_finish.center_x = 400 self.progress_bar_finish.center_y = 150 self.add_widget(self.progress_bar_finish) self.lb_finish = Label(text=lang['Creating...']) self.lb_finish.size_hint = None, None self.lb_finish.width = 350 self.lb_finish.height = 30 self.lb_finish.center_x = 400 self.lb_finish.center_y = 120 self.add_widget(self.lb_finish) parallel_progress_bar = threading.Thread(target=self.finish_project) parallel_progress_bar.start()
def __init__(self, **kwargs): super().__init__(**kwargs) self.orientation = "vertical" lab1 = Label(text = "Hello World" ) lab1.size_hint = (None,None) lab1.halign = "right" lab1.height = 30 lab1.width = 200 lab1.color = ( 1,0,0,1) txt1 = TextInput(text = "hi there!") txt1.multiline = False txt1.hint_text = "greeting" txt2 = TextInput() txt1.bind(on_text_validate=self.on_text_validate) clone_widget(txt1,txt2) lab2 = Label(text ="hello") clone_widget(lab1,lab2) self.add_widget(lab1) self.add_widget(lab2) self.add_widget(txt1) self.add_widget(txt2)
def constroi_mensagem(self): grid = GridLayout(cols=1, size_hint_y=None) grid.bind(minimum_height=grid.setter("height")) for log in self.logs: #print("criando: ", log) log = "[color=008080]" + log + "[/color]" label = Label(text=log) label.size_hint_y = None label.height = self.height * .1 label.markup = True label.font_size = self.fonte_padrao label.text_size = self.width * .9, self.height * 1 label.halign = label.valign = "center" grid.add_widget(label) scroll = ScrollView(size_hint_y=None) scroll.height = self.height * .6 scroll.width = self.width scroll.add_widget(grid) box = GridLayout(cols=1) box.add_widget(scroll) return box
def show_help(self, *args): popup = Popup(size_hint=(.8, .8), auto_dismiss=True, title="Help") popup.content = BoxLayout(orientation="vertical", spacing=5, padding=5) scroll = ScrollView(pos_hint={'center_x': .5, 'center_y': .5}, do_scroll_x=False, size_hint=(1, 1)) popup.content.add_widget(scroll) scrollbox = GridLayout(cols=1, padding=5, spacing=5, size_hint=(1, None)) scrollbox.bind(minimum_height=scrollbox.setter('height')) scroll.add_widget(scrollbox) close = Button(on_press=hide_keyboard, text="Close", on_release=popup.dismiss, height="40dp", size_hint=(1, None)) popup.content.add_widget(close) def on_ref(instance, value): if value == "email": open_url("mailto:[email protected]") elif value == "site": open_url("http://davideddu.altervista.org/software/") elif value == "gpl": open_url("http://gnu.org/licenses/gpl.html") elif value == "donate": open_url("http://davideddu.altervista.org/blog/donate/") label = Label(markup=True, size_hint_y=None, halign="center", on_ref_press=on_ref) label.height = int((215. * len(label.text)) / 600)# * (596. / self.label.width)) def setsize(instance, value): #print len(instance.text), instance.text.split("\n", 1)[0], instance.width instance.text_size[0] = value[0] instance.texture_size[1] = value[1] instance.height = int((215. * len(label.text)) / 600 * (596. / instance.width)) label.bind(size=setsize) #self.label.setter("texture_size")) oses = {"linux": "Linux", "android": "Android", "macosx": "Mac OS X", "win": "Windows (use this program on Linux for best performance)"} label.text = """[size=24dp][b]AFS USA Student Finder[/b] {version}[/size] by [ref=email][color=#32A4CE]Davide Depau[/color][/ref] - [ref=site][color=#32A4CE]Homepage[/color][/ref] Running on {0} AFS USA Student Finder is Free Software, but its development takes precious time. You can [ref=donate][color=#32A4CE]donate[/color][/ref] to help its development. [size=20dp][b]How to use the application[/b][/size] Use this application as you would with any touch app: to scroll, don't use the mouse wheel, just drag the items, like you would do with your phone. [size=16dp][b]Normal search[/b][/size] It is like in the AFS website: just write a zip code in the first box, and tap the "search" button (the one with the lens). Wait a few seconds, and it will show a list of students going near to the ZIP you put. You can filter them using the menus on the bottom, or using the "Name" box. Tapping the "Show more" button will show a lot of information, most of which is not available in AFS website. [size=16dp][b]Automatic search[/b][/size] When you click the "Autosearch" button, the program will check one by one all the ZIP codes. This might be useful if you are going to go the USA with AFS and you want to find your profile. Please note that: - this operation requires a lot of time (if you are lucky, about ten hours...) - once started the operation cannot be stopped/paused unless you close the application - slow PCs or phones may become very slow while running this software - your carrier may charge you if you use it with mobile broadband - the application cannot manage very big amounts of data, so you should enable some filters (like the country, the gender and the name) before starting the operation If you are running this application on a mobile phone/tablet, please also note that if you do something else while the app is working, the Android OS might close the app to free some resources needed by the other applications. [size=16dp][b]Persistence[/b][/size] «Automatic search is very slow and takes a lot of hours! Can I close the application and make it start where it had finished?» Of course you can! When you open the app, [b]before searching anything[/b], click on the "persistence" button (the floppy). Choose a file; you can create a new one or choose an existing one. Then click "Load". If you previously used the same file, the program will automatically load the old student list. You can then start autosearch: it will continue from the point it has been stopped. If you want to create a new list on the same file, enable "Reset file content" before clicking "Load". Pros: - You don't have to keep the PC turned on to parse the entire list of ZIPs - You don't lose your list if the app crashes for any reason Cons: - It doesn't work on Android - The persistence may become very big [size=12dp]I am not in any way related to AFS, AFS USA or other associations/companies. Every trademark is of his respective owner. I decline every responsibility due to the use of this program to the user. Copyright © Davide Depau 2013. This program is licensed under a GNU GPL version 3 license or later [ref=gpl]<[color=#32A4CE]http://gnu.org/licenses/gpl.html[/color]>\[/ref]. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.[/size]""".format(oses[opsys], version=__version__) scrollbox.add_widget(label) global container container.popup = popup def onopen(*args, **kwargs): global container container.shown = True def ondismiss(*args, **kwargs): global container container.shown = False self.bind(on_open=onopen, on_dismiss=ondismiss) popup.open()
def full_redraw(self): """Draw the game's chrome """ self.reinit_before() self.time_labels = [[None, None], [None, None]] self.side_labels = [None, None] self.canvas.after.clear() with self.canvas.after: PopMatrix() PushMatrix() cell_size = self.board.cell_size for edge in range(2): # Messages at the non-player sides Color(0, 0, 0, 0.5) Rectangle(pos=(0, 0), size=(self.board.window_width, cell_size)) # Turn number turn_number = self.round_number * 2 + self.current_solver + 1 num_turns = NUM_ROUNDS * 2 if turn_number > num_turns: text = '' else: text = 'Turn {0}/{1}'.format(turn_number, num_turns) l = Label(text=text, pos=(0, 0), size=(self.board.window_width, cell_size), fontsize=cell_size) # Clocks for player in range(2): Color(1, 1, 1, 1) l = Label(text=time_format(self.times[player]), fontsize=cell_size) l.texture_update() l.width = l.texture.width if player ^ edge: l.pos = cell_size, 0 else: l.right = self.board.window_width - cell_size l.height = self.board.cell_size self.time_labels[edge][player] = l Translate( self.board.window_width / 2, self.board.window_height / 2, 0, ) Rotate(90, 0, 0, 1) # Messages to the players if edge ^ self.current_solver: color = (0.7, 0.7, 0, 1) else: color = (0, 0.5, 1, 1) l = Label( text=self.messages[edge], pos=( -self.board.window_height / 2, -self.board.window_width / 2, ), size=(self.board.window_height, cell_size), bold=True, fontsize=cell_size, color=color, ) self.side_labels[edge] = l if edge == 1: break Rotate(90, 0, 0, 1) Translate( -self.board.window_width / 2, -self.board.window_height / 2, 0, ) PopMatrix() self.fully_drawn = True
def draws_lines_rho( x0, y0, dx, dy, fzoom, border, xmin, xmax, ymin, ymax, limx, limy, label_y): xf = x0 + dx yf = y0 + dy deca_x = range(xmin, xmax + 1) deca_y = range(ymin, ymax + 1) scale = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000, 20000000, 30000000, 40000000, 50000000, 60000000, 70000000, 80000000, 90000000, 100000000] scale_log = [] for i in scale: scale_log.append(log10(i)) scale_log_zoom = [] for i in scale_log: scale_log_zoom.append(i * fzoom) lay = FloatLayout() with lay.canvas: Color(rgba=[0, 0, 0, 1]) Line(points=[x0, y0, xf, y0], width=border) Color(rgba=[0, 0, 0, 1]) Line(points=[x0, y0, x0, yf], width=border) Color(rgba=[0, 0, 0, 1]) Line(points=[xf, y0, xf, yf], width=border) Color(rgba=[0, 0, 0, 1]) Line(points=[x0, yf, xf, yf], width=border) Color(rgba=[0, 0, 0, 1]) Color(rgba=[.2, .2, .2, 1.]) Ellipse(size=[6, 6], pos=[int(((dx / 3) * 2) + x0 - 23), yf + 7]) c = 0 for i in scale_log_zoom: if scale[c] > limx: continue else: Color(rgba=[0., 0., 0., 1.]) Line(points=[i + x0, y0, i + x0, y0 - 5]) c += 1 c = 0 for i in scale_log_zoom: if scale[c] > limy: continue else: Color(rgba=[0, 0, 0, 1]) Line(points=[x0, i + y0, x0 - 5, i + y0]) c += 1 c = 0 for i in scale_log_zoom: if scale[c] > limy: continue else: Color(rgba=[0, 0, 0, 1]) Line(points=[xf, i + y0, xf + 5, i + y0]) c += 1 for i in deca_y: if deca_y[0] < 0: pos = -deca_y[0] lb = Label() lb.color = [0, 0, 0, 1] lb.markup = True lb.text = '10' + '[sup][size=10]' + str(i) + '[/size][/sup]' lb.size_hint = None, None lb.height = 30 lb.width = 30 y = int((y0 - 20) + ((i + pos) * fzoom)) lb.pos = x0 - 35, y lay.add_widget(lb) for i in deca_x: if deca_x[0] < 0: pos = -deca_x[0] lb = Label() lb.color = [0, 0, 0, 1] lb.markup = True lb.text = '10' + '[sup][size=10]' + str(i) + '[/size][/sup]' lb.size_hint = None, None lb.height = 30 lb.width = 30 x = int((x0 - 20) + ((i + pos) * fzoom)) lb.pos = x + 5, y0 - 35 lay.add_widget(lb) if label_y == True: lb_rho_ohm_meter = LabelRot() lb_rho_ohm_meter.size_hint = None, None lb_rho_ohm_meter.height = 100 lb_rho_ohm_meter.width = 25 lb_rho_ohm_meter.markup = True lb_rho_ohm_meter.italic = True lb_rho_ohm_meter.text = 'ρ (Ω.m)' lb_rho_ohm_meter.color = [0., 0., 0., 1.] lb_rho_ohm_meter.center_x = x0 - 40 lb_rho_ohm_meter.center_y = int(y0 + dy / 2) lay.add_widget(lb_rho_ohm_meter) bt_rho_xy = PointPlotEX() bt_rho_xy.center_x = int(((dx/3) + x0)-20) bt_rho_xy.center_y = yf + 10 lb_rho_xy = Label() lb_rho_xy.size_hint = None, None lb_rho_xy.height = 30 lb_rho_xy.width = 30 lb_rho_xy.center_x = int((dx/3) + x0) lb_rho_xy.center_y = yf + 15 lb_rho_xy.markup = True lb_rho_xy.text = 'ρ[sub]xy[/sub]' lb_rho_xy.color = [.2, .2, .2, 1.] lb_rho_xy.font_size = 23 lay.add_widget(bt_rho_xy) lay.add_widget(lb_rho_xy) lb_rho_yx = Label() lb_rho_yx.size_hint = None, None lb_rho_yx.height = 30 lb_rho_yx.width = 30 lb_rho_yx.center_x = int(((dx / 3) * 2) + x0) lb_rho_yx.center_y = yf + 15 lb_rho_yx.markup = True lb_rho_yx.text = 'ρ[sub]yx[/sub]' lb_rho_yx.color = [.2, .2, .2, 1.] lb_rho_yx.font_size = 23 lay.add_widget(lb_rho_yx) return lay
def draws_lines_Z(x0, y0, dx, dy, fzoom,fzoomy, border, xmin, xmax, ymin, ymax, limx, limy, label_y, scale_y, component): xf = x0 + dx yf = y0 + dy deca_x = range(xmin, xmax + 1) deca_y = range(ymin, ymax, 5) # if limy == 90: # lb_y = [0, 45, 90] # elif limy == 180: # lb_y = [0, 90, 180] lb_y = [-15, -10, -5, 0, 5, 10, 15] #lb_y = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] scale = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000, 20000000, 30000000, 40000000, 50000000, 60000000, 70000000, 80000000, 90000000, 100000000] scale_log = [] for i in scale: scale_log.append(log10(i)) scale_log_zoom = [] for i in scale_log: scale_log_zoom.append(i * fzoom) lay = FloatLayout() with lay.canvas: Color(rgba=[0, 0, 0, 1]) Line(points=[x0, y0, xf, y0], width=border) Color(rgba=[0, 0, 0, 1]) Line(points=[x0, y0, x0, yf], width=border) Color(rgba=[0, 0, 0, 1]) Line(points=[xf, y0, xf, yf], width=border) Color(rgba=[0, 0, 0, 1]) Line(points=[x0, yf, xf, yf], width=border) Color(rgba=[0, 0, 0, 1]) Color(rgba=[.2, .2, .2, 1.]) Ellipse(size=[6, 6], pos=[int(((dx / 3) * 2) + x0 + 5), yf + 10]) c = 0 for i in scale_log_zoom: if scale[c] > limx: continue else: Color(rgba=[0., 0., 0., 1.]) Line(points=[i + x0, y0, i + x0, y0 - 5]) c += 1 for i in deca_y: i = int(i * fzoomy) Color(rgba=[0., 0., 0., 1.]) Line(points=[x0 - 5, i + y0, x0, i + y0]) for i in deca_y: i = int(i * fzoomy) Color(rgba=[0., 0., 0., 1.]) Line(points=[xf + 5, i + y0, xf, i + y0]) if scale_y == True: for i in lb_y: lb_phi = Label() lb_phi.color = [0, 0, 0, 1] lb_phi.markup = True lb_phi.text = str(i) lb_phi.size_hint = None, None lb_phi.height = 30 lb_phi.width = 30 if limy == 180: y = (i/2 * fzoomy) + y0 elif limy == 90: y = ((i+15) * fzoomy) + y0 lb_phi.center_x = xf + 25 lb_phi.center_y = y lay.add_widget(lb_phi) for i in deca_x: if deca_x[0] < 0: pos = -deca_x[0] lb = Label() lb.color = [0,0,0,1] lb.markup = True lb.text = '10' + '[sup][size=10]' + str(i) + '[/size][/sup]' lb.size_hint = None, None lb.height = 30 lb.width = 30 x = int((x0 - 15) + ((i + pos) * fzoom)) lb.pos = x, y0 - 30 lay.add_widget(lb) lb_title = Label() lb_title.color = [0, 0, 0, 1.] lb_title.font_size = 17 lb_title.text = 'Z' + component lb_title.size_hint = None, None lb_title.height = 30 lb_title.width = 370 lb_title.center_x = int((lb_title.width/2) + x0) - 25 lb_title.center_y = yf + 15 #lay.add_widget(lb_title) if label_y == True: lb_rho_ohm_meter = LabelRot() lb_rho_ohm_meter.size_hint = None, None lb_rho_ohm_meter.height = 100 lb_rho_ohm_meter.width = 25 lb_rho_ohm_meter.markup =True lb_rho_ohm_meter.italic = True lb_rho_ohm_meter.text = 'φ (graus)' lb_rho_ohm_meter.color = [0., 0., 0., 1.] lb_rho_ohm_meter.center_x = x0 - 40 lb_rho_ohm_meter.center_y = int(y0 + dy/2) lay.add_widget(lb_rho_ohm_meter) bt_rho_xy = PointPlotEX() bt_rho_xy.center_x = int(((dx / 3) + x0) - 50) bt_rho_xy.center_y = yf + 14 lb_rho_xy = Label() lb_rho_xy.size_hint = None, None lb_rho_xy.height = 30 lb_rho_xy.width = 30 lb_rho_xy.center_x = int((dx / 3) + x0 - 20) lb_rho_xy.center_y = yf + 15 lb_rho_xy.markup = True lb_rho_xy.text = 'Re Z[sub][size=15]'+ component +'[/size][/sub]' lb_rho_xy.color = [.2, .2, .2, 1.] lb_rho_xy.font_size = 17 lay.add_widget(bt_rho_xy) lay.add_widget(lb_rho_xy) lb_rho_yx = Label() lb_rho_yx.size_hint = None, None lb_rho_yx.height = 30 lb_rho_yx.width = 30 lb_rho_yx.center_x = int(((dx / 3) * 2) + x0 + 40) lb_rho_yx.center_y = yf + 15 lb_rho_yx.markup = True lb_rho_yx.text = 'Im Z[sub][size=15]'+ component +'[/size][/sub]' lb_rho_yx.color = [.2, .2, .2, 1.] lb_rho_yx.font_size = 17 lay.add_widget(lb_rho_yx) return lay
def on_press_plot(self): self.ids.plot_1_point.clear_widgets() self.ids.plot_2_point.clear_widgets() self.list_active_file_pplt = [] for band in site.files_plot.keys(): for file_pplt in site.files_plot[band]: if file_pplt.active == True: self.list_active_file_pplt.append(file_pplt) self.list_bt_plot = [] self.box_view_select.clear_widgets() j = 0 for file_pplt in self.list_active_file_pplt: i = 0 coor_pixel_file_pplt = self.read_file_pplt_to_coord_pixel( file_pplt) for T in file_pplt.obj_pplt.activated: bt_rho_xy = PointPlot(pos=[ coor_pixel_file_pplt[0][i], coor_pixel_file_pplt[1][i] ], file_pplt=file_pplt.obj_pplt, i=i) bt_rho_xy.cor = file_pplt.obj_pplt.color bt_rho_xy.n = i + 1 bt_rho_yx = PointPlotCirc(pos=[ coor_pixel_file_pplt[0][i], coor_pixel_file_pplt[2][i] ], file_pplt=file_pplt.obj_pplt, i=i) bt_rho_yx.cor = file_pplt.obj_pplt.color bt_phi_xy = PointPlot(pos=[ coor_pixel_file_pplt[3][0][i], coor_pixel_file_pplt[3][1][i] ], file_pplt=file_pplt.obj_pplt, i=i) bt_phi_xy.cor = file_pplt.obj_pplt.color bt_phi_xy.height = 4 bt_phi_xy.width = 4 bt_phi_yx = PointPlotCirc(pos=[ coor_pixel_file_pplt[4][0][i], coor_pixel_file_pplt[4][1][i] ], file_pplt=file_pplt.obj_pplt, i=i) bt_phi_yx.cor = file_pplt.obj_pplt.color bt_phi_yx.height = 4 bt_phi_yx.width = 4 bt_RZ_xx = PointPlot(pos=[ coor_pixel_file_pplt[5][i], coor_pixel_file_pplt[6][i] ], file_pplt=file_pplt.obj_pplt, i=i) bt_RZ_xx.cor = file_pplt.obj_pplt.color bt_RZ_xx.height = 4 bt_RZ_xx.width = 4 bt_IZ_xx = PointPlotCirc(pos=[ coor_pixel_file_pplt[5][i], coor_pixel_file_pplt[7][i] ], file_pplt=file_pplt.obj_pplt, i=i) bt_IZ_xx.cor = file_pplt.obj_pplt.color bt_IZ_xx.height = 4 bt_IZ_xx.width = 4 bt_RZ_xy = PointPlot(pos=[ coor_pixel_file_pplt[5][i], coor_pixel_file_pplt[8][i] ], file_pplt=file_pplt.obj_pplt, i=i) bt_RZ_xy.cor = file_pplt.obj_pplt.color bt_RZ_xy.height = 4 bt_RZ_xy.width = 4 bt_IZ_xy = PointPlotCirc(pos=[ coor_pixel_file_pplt[5][i], coor_pixel_file_pplt[9][i] ], file_pplt=file_pplt.obj_pplt, i=i) bt_IZ_xy.cor = file_pplt.obj_pplt.color bt_IZ_xy.height = 4 bt_IZ_xy.width = 4 bt_RZ_yx = PointPlot(pos=[ coor_pixel_file_pplt[5][i], coor_pixel_file_pplt[10][i] ], file_pplt=file_pplt.obj_pplt, i=i) bt_RZ_yx.cor = file_pplt.obj_pplt.color bt_RZ_yx.height = 4 bt_RZ_yx.width = 4 bt_IZ_yx = PointPlotCirc(pos=[ coor_pixel_file_pplt[5][i], coor_pixel_file_pplt[11][i] ], file_pplt=file_pplt.obj_pplt, i=i) bt_IZ_yx.cor = file_pplt.obj_pplt.color bt_IZ_yx.height = 4 bt_IZ_yx.width = 4 bt_RZ_yy = PointPlot(pos=[ coor_pixel_file_pplt[5][i], coor_pixel_file_pplt[12][i] ], file_pplt=file_pplt.obj_pplt, i=i) bt_RZ_yy.cor = file_pplt.obj_pplt.color bt_RZ_yy.height = 4 bt_RZ_yy.width = 4 bt_IZ_yy = PointPlotCirc(pos=[ coor_pixel_file_pplt[5][i], coor_pixel_file_pplt[13][i] ], file_pplt=file_pplt.obj_pplt, i=i) bt_IZ_yy.cor = file_pplt.obj_pplt.color bt_IZ_yy.height = 4 bt_IZ_yy.width = 4 bt_rho_xy.points_inte = [ bt_rho_yx, bt_phi_xy, bt_phi_yx, bt_RZ_xx, bt_IZ_xx, bt_RZ_xy, bt_IZ_xy, bt_RZ_yx, bt_IZ_yx, bt_RZ_yy, bt_IZ_yy ] bt_rho_yx.points_inte = [ bt_rho_xy, bt_rho_xy, bt_phi_yx, bt_RZ_xx, bt_IZ_xx, bt_RZ_xy, bt_IZ_xy, bt_RZ_yx, bt_IZ_yx, bt_RZ_yy, bt_IZ_yy ] bt_phi_xy.points_inte = [ bt_rho_xy, bt_rho_yx, bt_phi_yx, bt_RZ_xx, bt_IZ_xx, bt_RZ_xy, bt_IZ_xy, bt_RZ_yx, bt_IZ_yx, bt_RZ_yy, bt_IZ_yy ] bt_phi_yx.points_inte = [ bt_rho_xy, bt_rho_yx, bt_phi_xy, bt_RZ_xx, bt_IZ_xx, bt_RZ_xy, bt_IZ_xy, bt_RZ_yx, bt_IZ_yx, bt_RZ_yy, bt_IZ_yy ] bt_RZ_xx.points_inte = [ bt_rho_xy, bt_rho_yx, bt_phi_xy, bt_phi_yx, bt_IZ_xx, bt_RZ_xy, bt_IZ_xy, bt_RZ_yx, bt_IZ_yx, bt_RZ_yy, bt_IZ_yy ] bt_IZ_xx.points_inte = [ bt_rho_xy, bt_rho_yx, bt_phi_xy, bt_phi_yx, bt_RZ_xx, bt_RZ_xy, bt_IZ_xy, bt_RZ_yx, bt_IZ_yx, bt_RZ_yy, bt_IZ_yy ] bt_RZ_xy.points_inte = [ bt_rho_xy, bt_rho_yx, bt_phi_xy, bt_phi_yx, bt_RZ_xx, bt_IZ_xx, bt_IZ_xy, bt_RZ_yx, bt_IZ_yx, bt_RZ_yy, bt_IZ_yy ] bt_IZ_xy.points_inte = [ bt_rho_xy, bt_rho_yx, bt_phi_xy, bt_phi_yx, bt_RZ_xx, bt_IZ_xx, bt_RZ_xy, bt_RZ_yx, bt_IZ_yx, bt_RZ_yy, bt_IZ_yy ] bt_RZ_yx.points_inte = [ bt_rho_xy, bt_rho_yx, bt_phi_xy, bt_phi_yx, bt_RZ_xx, bt_IZ_xx, bt_RZ_xy, bt_IZ_xy, bt_IZ_yx, bt_RZ_yy, bt_IZ_yy ] bt_IZ_yx.points_inte = [ bt_rho_xy, bt_rho_yx, bt_phi_xy, bt_phi_yx, bt_RZ_xx, bt_IZ_xx, bt_RZ_xy, bt_IZ_xy, bt_RZ_yx, bt_RZ_yy, bt_IZ_yy ] bt_RZ_yy.points_inte = [ bt_rho_xy, bt_rho_yx, bt_phi_xy, bt_phi_yx, bt_RZ_xx, bt_IZ_xx, bt_RZ_xy, bt_IZ_xy, bt_RZ_yx, bt_IZ_yx, bt_IZ_yy ] bt_IZ_yy.points_inte = [ bt_rho_xy, bt_rho_yx, bt_phi_xy, bt_phi_yx, bt_RZ_xx, bt_IZ_xx, bt_RZ_xy, bt_IZ_xy, bt_RZ_yx, bt_IZ_yx, bt_RZ_yy ] if T: bt_rho_xy.select() bt_rho_yx.select() bt_phi_xy.select() bt_phi_yx.select() bt_RZ_xx.select() bt_IZ_xx.select() bt_RZ_xy.select() bt_IZ_xy.select() bt_RZ_yx.select() bt_IZ_yx.select() bt_RZ_yy.select() bt_IZ_yy.select() self.ids.plot_1_point.add_widget(bt_rho_xy) self.ids.plot_1_point.add_widget(bt_rho_yx) self.ids.plot_1_point.add_widget(bt_phi_xy) self.ids.plot_1_point.add_widget(bt_phi_yx) self.ids.plot_2_point.add_widget(bt_RZ_xx) self.ids.plot_2_point.add_widget(bt_IZ_xx) self.ids.plot_2_point.add_widget(bt_RZ_xy) self.ids.plot_2_point.add_widget(bt_IZ_xy) self.ids.plot_2_point.add_widget(bt_RZ_yx) self.ids.plot_2_point.add_widget(bt_IZ_yx) self.ids.plot_2_point.add_widget(bt_RZ_yy) self.ids.plot_2_point.add_widget(bt_IZ_yy) self.list_bt_plot.append(bt_rho_xy) i += 1 j += 1 lb_view_select = Label() lb_view_select.size_hint_y = None lb_view_select.height = 30 lb_view_select.text = file_pplt.obj_pplt.rate + '/' + file_pplt.obj_pplt.name lb_view_select.color = file_pplt.obj_pplt.color self.box_view_select.add_widget(lb_view_select) self.box_view_select.add_widget(LabelDivX()) self.box_view_select.height = int(j * 31)
def build(self): Config.set('input', 'mouse', 'mouse, multitouch_on_demand') # disable multi-touch emulation self.icon = '../GraphViewer/images/Icon_128x128.ico' # set the app icon globals.main_view_widget = MainViewWidget() globals.graph_manager = GraphManager(False) globals.main_view_widget.ids.input_text.bind(text=globals.main_view_widget.text_event) dropdown = AlgDropDownList() globals.main_view_widget.ids.algorithm_btn.bind(on_release=dropdown.open) dropdown.bind(on_select=lambda instance, x: setattr(globals.main_view_widget.ids.algorithm_btn, 'Algorithms', x)) globals.algorithms_drop_down_list = dropdown globals.algorithms_drop_down_list.ids.bfs_btn.bind(on_press=BfsButton.on_press) globals.algorithms_drop_down_list.ids.dfs_btn.bind(on_press=DfsButton.on_press) globals.algorithms_drop_down_list.ids.dijkstra_btn.bind(on_press=DijkstraButton.on_press) dropdown = InputDropDownList() globals.main_view_widget.ids.input_btn.bind(on_release=dropdown.open) dropdown.bind(on_select=lambda instance, x: setattr(globals.main_view_widget.ids.input_btn, 'Input', x)) globals.input_drop_down_list = dropdown globals.input_drop_down_list.ids.listOfEdges_btn.bind(on_press=ListOfEdgesButton.on_press) globals.input_drop_down_list.ids.adjacencyList_btn.bind(on_press=AdjacencyListButton.on_press) globals.input_drop_down_list.ids.adjacencyMatrix_btn.bind(on_press=AdjacencyMatrixButton.on_press) globals.input_drop_down_list.ids.costMatrix_btn.bind(on_press=CostMatrixButton.on_press) globals.main_view_widget.ids.undirected_btn.bind(on_press=UndirectedButton.on_press) globals.main_view_widget.ids.directed_btn.bind(on_press=DirectedButton.on_press) globals.main_view_widget.ids.draw_lbl.multiline = True globals.main_view_widget.ids.settings_btn.bind(on_release=SettingsButton.on_release) globals.main_view_widget.ids.save_btn.bind(on_press=SaveFileButton.on_press) globals.main_view_widget.ids.open_btn.bind(on_press=OpenFileButton.on_press) globals.NodeWidgetBackgroundColor = globals.colors['white'] # it used to be [0.9, 0.9, 0.9, 1] globals.NodeWidgetColor = globals.colors['black'] # it used to be [0, 0, 0, 1] globals.EdgeWidgetColor = globals.colors['black'] # it used to be [0, 0, 0, 1] globals.main_view_widget.ids.switch.bind(active=callback) Factory.register('KivyB', module='LabelB') globals.main_screen = screen_manager.MainScreen() globals.main_screen.add_widget(globals.main_view_widget) globals.theory_screen = screen_manager.TheoryScreen() globals.screen_manager = screen_manager.ScreenManager(transition=FadeTransition(duration=.05)) globals.screen_manager.add_widget(globals.main_screen) globals.screen_manager.add_widget(globals.theory_screen) with open("../GraphViewer/theory/chapter1.txt", encoding='utf-8') as f: line = f.readline(200) while line != "": if line.startswith("../GraphViewer/images/") == True: box = BoxLayout(orientation='horizontal', spacing=50) img = Image(source=line.strip('\n')) box.size_hint_y = None box.height = 500 box.add_widget(img) line = f.readline(200) while line != "" and line.startswith("../GraphViewer/images/") == True: img = Image(source=line.strip('\n')) box.add_widget(img) line = f.readline(200) globals.theory_screen.ids.box_layout.add_widget(box) else: text = line number_of_lines = 1 line = f.readline(200) while line != "" and line.startswith("../GraphViewer/images/") == False: text += line number_of_lines += 1 line = f.readline(200) lbl = Label(text=text, color= [0, 0, 0, 1], font_size=25, font_name='./font/FreeSans.ttf') lbl.text_size = [1100, None] lbl.size_hint_y = None lbl.height = 40 * number_of_lines globals.theory_screen.ids.box_layout.add_widget(lbl) return globals.screen_manager
def on_press_plot(self): self.ids.plot_1_point.clear_widgets() self.ids.plot_2_point.clear_widgets() self.list_active_file_pplt = [] for band in site.files_plot.keys(): for file_pplt in site.files_plot[band]: if file_pplt.active == True: self.list_active_file_pplt.append(file_pplt) self.list_bt_plot = [] self.box_view_select.clear_widgets() j = 0 for file_pplt in self.list_active_file_pplt: i = 0 coor_pixel_file_pplt = self.read_file_pplt_to_coord_pixel(file_pplt) for T in file_pplt.obj_pplt.activated: bt_rho_xy = PointPlot(pos=[coor_pixel_file_pplt[0][i], coor_pixel_file_pplt[1][i]], file_pplt=file_pplt.obj_pplt, i=i) bt_rho_xy.cor = file_pplt.obj_pplt.color bt_rho_xy.n = i+1 bt_rho_yx = PointPlotCirc(pos=[coor_pixel_file_pplt[0][i], coor_pixel_file_pplt[2][i]], file_pplt=file_pplt.obj_pplt, i=i) bt_rho_yx.cor = file_pplt.obj_pplt.color bt_phi_xy = PointPlot(pos=[coor_pixel_file_pplt[3][0][i], coor_pixel_file_pplt[3][1][i]], file_pplt=file_pplt.obj_pplt, i=i) bt_phi_xy.cor = file_pplt.obj_pplt.color bt_phi_xy.height = 4 bt_phi_xy.width = 4 bt_phi_yx = PointPlotCirc(pos=[coor_pixel_file_pplt[4][0][i], coor_pixel_file_pplt[4][1][i]], file_pplt=file_pplt.obj_pplt, i=i) bt_phi_yx.cor = file_pplt.obj_pplt.color bt_phi_yx.height = 4 bt_phi_yx.width = 4 bt_RZ_xx = PointPlot(pos=[coor_pixel_file_pplt[5][i], coor_pixel_file_pplt[6][i]], file_pplt=file_pplt.obj_pplt, i=i) bt_RZ_xx.cor = file_pplt.obj_pplt.color bt_RZ_xx.height = 4 bt_RZ_xx.width = 4 bt_IZ_xx = PointPlotCirc(pos=[coor_pixel_file_pplt[5][i], coor_pixel_file_pplt[7][i]], file_pplt=file_pplt.obj_pplt, i=i) bt_IZ_xx.cor = file_pplt.obj_pplt.color bt_IZ_xx.height = 4 bt_IZ_xx.width = 4 bt_RZ_xy = PointPlot(pos=[coor_pixel_file_pplt[5][i], coor_pixel_file_pplt[8][i]], file_pplt=file_pplt.obj_pplt, i=i) bt_RZ_xy.cor = file_pplt.obj_pplt.color bt_RZ_xy.height = 4 bt_RZ_xy.width = 4 bt_IZ_xy = PointPlotCirc(pos=[coor_pixel_file_pplt[5][i], coor_pixel_file_pplt[9][i]], file_pplt=file_pplt.obj_pplt, i=i) bt_IZ_xy.cor = file_pplt.obj_pplt.color bt_IZ_xy.height = 4 bt_IZ_xy.width = 4 bt_RZ_yx = PointPlot(pos=[coor_pixel_file_pplt[5][i], coor_pixel_file_pplt[10][i]], file_pplt=file_pplt.obj_pplt, i=i) bt_RZ_yx.cor = file_pplt.obj_pplt.color bt_RZ_yx.height = 4 bt_RZ_yx.width = 4 bt_IZ_yx = PointPlotCirc(pos=[coor_pixel_file_pplt[5][i], coor_pixel_file_pplt[11][i]], file_pplt=file_pplt.obj_pplt, i=i) bt_IZ_yx.cor = file_pplt.obj_pplt.color bt_IZ_yx.height = 4 bt_IZ_yx.width = 4 bt_RZ_yy = PointPlot(pos=[coor_pixel_file_pplt[5][i], coor_pixel_file_pplt[12][i]], file_pplt=file_pplt.obj_pplt, i=i) bt_RZ_yy.cor = file_pplt.obj_pplt.color bt_RZ_yy.height = 4 bt_RZ_yy.width = 4 bt_IZ_yy = PointPlotCirc(pos=[coor_pixel_file_pplt[5][i], coor_pixel_file_pplt[13][i]], file_pplt=file_pplt.obj_pplt, i=i) bt_IZ_yy.cor = file_pplt.obj_pplt.color bt_IZ_yy.height = 4 bt_IZ_yy.width = 4 bt_rho_xy.points_inte = [bt_rho_yx, bt_phi_xy, bt_phi_yx, bt_RZ_xx, bt_IZ_xx, bt_RZ_xy, bt_IZ_xy, bt_RZ_yx, bt_IZ_yx, bt_RZ_yy, bt_IZ_yy] bt_rho_yx.points_inte = [bt_rho_xy, bt_rho_xy, bt_phi_yx, bt_RZ_xx, bt_IZ_xx, bt_RZ_xy, bt_IZ_xy, bt_RZ_yx, bt_IZ_yx, bt_RZ_yy, bt_IZ_yy] bt_phi_xy.points_inte = [bt_rho_xy, bt_rho_yx, bt_phi_yx, bt_RZ_xx, bt_IZ_xx, bt_RZ_xy, bt_IZ_xy, bt_RZ_yx, bt_IZ_yx, bt_RZ_yy, bt_IZ_yy] bt_phi_yx.points_inte = [bt_rho_xy, bt_rho_yx, bt_phi_xy, bt_RZ_xx, bt_IZ_xx, bt_RZ_xy, bt_IZ_xy, bt_RZ_yx, bt_IZ_yx, bt_RZ_yy, bt_IZ_yy] bt_RZ_xx.points_inte = [bt_rho_xy, bt_rho_yx, bt_phi_xy, bt_phi_yx, bt_IZ_xx, bt_RZ_xy, bt_IZ_xy, bt_RZ_yx, bt_IZ_yx, bt_RZ_yy, bt_IZ_yy] bt_IZ_xx.points_inte = [bt_rho_xy, bt_rho_yx, bt_phi_xy, bt_phi_yx, bt_RZ_xx, bt_RZ_xy, bt_IZ_xy, bt_RZ_yx, bt_IZ_yx, bt_RZ_yy, bt_IZ_yy] bt_RZ_xy.points_inte = [bt_rho_xy, bt_rho_yx, bt_phi_xy, bt_phi_yx, bt_RZ_xx, bt_IZ_xx, bt_IZ_xy, bt_RZ_yx, bt_IZ_yx, bt_RZ_yy, bt_IZ_yy] bt_IZ_xy.points_inte = [bt_rho_xy, bt_rho_yx, bt_phi_xy, bt_phi_yx, bt_RZ_xx, bt_IZ_xx, bt_RZ_xy, bt_RZ_yx, bt_IZ_yx, bt_RZ_yy, bt_IZ_yy] bt_RZ_yx.points_inte = [bt_rho_xy, bt_rho_yx, bt_phi_xy, bt_phi_yx, bt_RZ_xx, bt_IZ_xx, bt_RZ_xy, bt_IZ_xy, bt_IZ_yx, bt_RZ_yy, bt_IZ_yy] bt_IZ_yx.points_inte = [bt_rho_xy, bt_rho_yx, bt_phi_xy, bt_phi_yx, bt_RZ_xx, bt_IZ_xx, bt_RZ_xy, bt_IZ_xy, bt_RZ_yx, bt_RZ_yy, bt_IZ_yy] bt_RZ_yy.points_inte = [bt_rho_xy, bt_rho_yx, bt_phi_xy, bt_phi_yx, bt_RZ_xx, bt_IZ_xx, bt_RZ_xy, bt_IZ_xy, bt_RZ_yx, bt_IZ_yx, bt_IZ_yy] bt_IZ_yy.points_inte = [bt_rho_xy, bt_rho_yx, bt_phi_xy, bt_phi_yx, bt_RZ_xx, bt_IZ_xx, bt_RZ_xy, bt_IZ_xy, bt_RZ_yx, bt_IZ_yx, bt_RZ_yy] if T: bt_rho_xy.select() bt_rho_yx.select() bt_phi_xy.select() bt_phi_yx.select() bt_RZ_xx.select() bt_IZ_xx.select() bt_RZ_xy.select() bt_IZ_xy.select() bt_RZ_yx.select() bt_IZ_yx.select() bt_RZ_yy.select() bt_IZ_yy.select() self.ids.plot_1_point.add_widget(bt_rho_xy) self.ids.plot_1_point.add_widget(bt_rho_yx) self.ids.plot_1_point.add_widget(bt_phi_xy) self.ids.plot_1_point.add_widget(bt_phi_yx) self.ids.plot_2_point.add_widget(bt_RZ_xx) self.ids.plot_2_point.add_widget(bt_IZ_xx) self.ids.plot_2_point.add_widget(bt_RZ_xy) self.ids.plot_2_point.add_widget(bt_IZ_xy) self.ids.plot_2_point.add_widget(bt_RZ_yx) self.ids.plot_2_point.add_widget(bt_IZ_yx) self.ids.plot_2_point.add_widget(bt_RZ_yy) self.ids.plot_2_point.add_widget(bt_IZ_yy) self.list_bt_plot.append(bt_rho_xy) i += 1 j += 1 lb_view_select = Label() lb_view_select.size_hint_y = None lb_view_select.height = 30 lb_view_select.text = file_pplt.obj_pplt.rate + '/' + file_pplt.obj_pplt.name lb_view_select.color = file_pplt.obj_pplt.color self.box_view_select.add_widget(lb_view_select) self.box_view_select.add_widget(LabelDivX()) self.box_view_select.height = int(j*31)
def add_space(self, lay): foo = Label(size_hint=[None, None]) foo.height = "40dp" foo.width = "80dp" lay.add_widget(foo)
def full_redraw(self): """Draw the game's chrome """ self.reinit_before() self.time_labels = [[None, None], [None, None]] self.side_labels = [None, None] self.canvas.after.clear() with self.canvas.after: PopMatrix() PushMatrix() cell_size = self.board.cell_size for edge in range(2): # Messages at the non-player sides Color(0, 0, 0, 0.5) Rectangle(pos=(0, 0), size=(self.board.window_width, cell_size)) # Turn number turn_number = self.round_number * 2 + self.current_solver + 1 num_turns = NUM_ROUNDS * 2 if turn_number > num_turns: text = '' else: text = 'Turn {0}/{1}'.format(turn_number, num_turns) l = Label(text=text, pos=(0, 0), size=(self.board.window_width, cell_size), fontsize=cell_size) # Clocks for player in range(2): Color(1, 1, 1, 1) l = Label(text=time_format(self.times[player]), fontsize=cell_size) l.texture_update() l.width = l.texture.width if player ^ edge: l.pos = cell_size, 0 else: l.right = self.board.window_width - cell_size l.height = self.board.cell_size self.time_labels[edge][player] = l Translate( self.board.window_width / 2, self.board.window_height / 2, 0, ) Rotate(90, 0, 0, 1) # Messages to the players if edge ^ self.current_solver: color = (0.7, 0.7, 0, 1) else: color = (0, 0.5, 1, 1) l = Label(text=self.messages[edge], pos=( -self.board.window_height / 2, -self.board.window_width / 2, ), size=(self.board.window_height, cell_size), bold=True, fontsize=cell_size, color=color, ) self.side_labels[edge] = l if edge == 1: break Rotate(90, 0, 0, 1) Translate( -self.board.window_width / 2, -self.board.window_height / 2, 0, ) PopMatrix() self.fully_drawn = True
def build(self): c = CustomLayout() c.add_widget(AsyncImage(source="background-login.jpg")) lbl = Label(text='Capture Face') lbl.font_size = '60sp' lbl.bold = True lbl.color = [1, 1, 1, 1] lbl.size_hint = None, None lbl.height = 30 lbl.width = 300 lbl.y = 370 lbl.x = 250 lbl2 = Label(text='Entre abaixo com seu usuário:') lbl2.font_size = '20sp' lbl2.bold = True lbl2.color = [1, 1, 1, 1] lbl2.size_hint = None, None lbl2.height = 30 lbl2.width = 300 lbl2.y = 290 lbl2.x = 250 lbl3 = Label(text='Agora digite sua senha, está quase lá!') lbl3.font_size = '20sp' lbl3.bold = True lbl3.color = [1, 1, 1, 1] lbl3.size_hint = None, None lbl3.height = 30 lbl3.width = 300 lbl3.y = 220 lbl3.x = 255 usuario = TextInput() usuario.size_hint = None, None usuario.height = 30 usuario.width = 300 usuario.y = 250 usuario.x = 250 senha = TextInput() senha.size_hint = None, None senha.height = 30 senha.width = 300 senha.y = 180 senha.x = 250 senha.password = True bt = Button(text="Acessar") bt.size_hint = None, None bt.height = 50 bt.width = 200 bt.y = 90 bt.x = 300 c.add_widget(lbl) c.add_widget(lbl2) c.add_widget(lbl3) c.add_widget(usuario) c.add_widget(senha) c.add_widget(bt) def callback(self): cursor = db.cursor() # Executa a consulta na tabela selecionada cursor.execute( "SELECT * FROM inteligenciaArtificialDB.tb_usuarios") # Laco for para retornar os valores, ex.: row[0] primeira coluna, row[1] segunda coluna, row[2] terceira coluna, etc. for row in cursor.fetchall(): if usuario.text == row[1] and senha.text == row[2]: popup = Popup( title='Logado', content=Label(text='Logon realizado com sucesso!'), size_hint=(None, None), size=(250, 150), auto_dismiss=True) popup.open() #abre janela principal Principal().run() bt.bind(on_press=callback) return c