def test_cursor_blink(self): ti = TextInput(cursor_blink=True) ti.focus = True # overwrite blinking event, because too long delay ti._do_blink_cursor_ev = Clock.create_trigger( ti._do_blink_cursor, 0.01, interval=True ) self.render(ti) # from kwargs cursor_blink == True self.assertTrue(ti.cursor_blink) self.assertTrue(ti._do_blink_cursor_ev.is_triggered) # set whether to blink & check if resets ti.cursor_blink = False for i in range(30): self.advance_frames(int(0.01 * Clock._max_fps) + 1) self.assertFalse(ti._do_blink_cursor_ev.is_triggered) # no blinking, cursor visible self.assertFalse(ti._cursor_blink) ti.cursor_blink = True self.assertTrue(ti.cursor_blink) for i in range(30): self.advance_frames(int(0.01 * Clock._max_fps) + 1) self.assertTrue(ti._do_blink_cursor_ev.is_triggered)
def test_cursor_blink(self): ti = TextInput(cursor_blink=True) ti.focus = True # overwrite blinking event, because too long delay ti._do_blink_cursor_ev = Clock.create_trigger(ti._do_blink_cursor, 0.01, interval=True) self.render(ti) # from kwargs cursor_blink == True self.assertTrue(ti.cursor_blink) self.assertTrue(ti._do_blink_cursor_ev.is_triggered) # set whether to blink & check if resets ti.cursor_blink = False for i in range(30): self.advance_frames(int(0.01 * Clock._max_fps) + 1) self.assertFalse(ti._do_blink_cursor_ev.is_triggered) # no blinking, cursor visible self.assertFalse(ti._cursor_blink) ti.cursor_blink = True self.assertTrue(ti.cursor_blink) for i in range(30): self.advance_frames(int(0.01 * Clock._max_fps) + 1) self.assertTrue(ti._do_blink_cursor_ev.is_triggered)
def build(self): layout = FloatLayout() label_p = Label() label_p.text = '''Conversor de Números Inteiros\nRetorna um texto representando o número por extenso.\n O número deve estar entre 0 e 999999999999999999.''' label_p.pos_hint = {'center_x': 0.5, 'top': 0.98} label_p.size_hint = (0.7, (1 / 4)) label_p.halign = 'center' label_p.font_size = 20 label_p.color = [1, 1, 1, 1] texto_area = TextInput() texto_area.pos_hint = {'x': 0.05, 'y': 0.40} texto_area.size_hint = (0.6, (1 / 4)) texto_area.background_color = [1, 1, 1, 1] texto_area.input_filter = 'int' texto_area.hint_text = "Digite um número natural..." texto_area.hint_text_color = (1, 0, 0, 1) texto_area.multiline = False texto_area.font_size = '23sp' texto_area_f = TextInput() texto_area_f.pos_hint = {'center_x': 0.5, 'y': 0.03} texto_area_f.size_hint = (0.99, (1 / 3)) texto_area_f.background_color = [1, 1, 1, 1] texto_area_f.readonly = True texto_area_f.cursor_blink = False texto_area_f.font_size = '20sp' texto_area_f.foreground_color = (0, 0, 0, 1) botao_1 = Button() botao_1.text = "CONVERTER" botao_1.pos_hint = {'x': 0.65, 'y': 0.40} botao_1.size_hint = (0.15, (1 / 4)) botao_1.background_color = (0, 0, 0, 1) botao_1.background_normal = '' botao_copia = Button() botao_copia.text = "COPIAR" botao_copia.pos_hint = {'x': 0.80, 'y': 0.40} botao_copia.size_hint = (0.15, (1 / 4)) botao_copia.background_color = (0, 0, 0, 1) botao_copia.background_normal = '' layout.add_widget(label_p) layout.add_widget(texto_area) layout.add_widget(texto_area_f) layout.add_widget(botao_1) layout.add_widget(botao_copia) Window.size = (800, 300) Window.clearcolor = (0.2, 0.8, 1, 1) def copia_texto(): texto_area_f.copy(data=texto_area_f.text) def ver_num(): if texto_area.text == "": texto_area_f.text = 'Vazio' else: if int(texto_area.text) >= 0 and int( texto_area.text) <= 999999999999999999: texto_area_f.text = num_exten(int(texto_area.text)) else: texto_area.text = "" texto_area_f.text = "" botao_1.on_press = ver_num botao_copia.on_press = copia_texto return layout