Beispiel #1
0
 def post_back(self):
     Window.release_all_keyboards()
     label = self.ids.verified
     if label.text == 'verified':        
         self.ids._screen_manager.current = 'msgs'
     else:
         self.ids._screen_manager.current = 'login'
Beispiel #2
0
    def save_notes(self):

        App.get_running_app().tog.next()
        Window.release_all_keyboards()
        self.data2['user']=self.user.text
        self.data2['pass']=self.passwor.text
        Clock.schedule_once(self.login_m,1)
Beispiel #3
0
 def confirmacion(self):
     Window.release_all_keyboards()
     self.fecha = self.validar_anulacion()
     if self.fecha:
         self.popup = ConfirmPopup(text="\rSeguro deseas anular el ticket\r\n del día %s?" % (self.fecha))
         self.popup.bind(on_answer=self._on_answer)
         self.popup.open()
Beispiel #4
0
 def print_ticket_grupal(self, cant, delegacion, cat, date, recibo):
     """
     Imprime el ticket grupal para el día(date), para la delegación
     dada y la cantidad solicitada.
     """
     user = user_session.get_user()
     id_log = controlador.insert_log(user, 'comprar_grupal', UNIDAD)
     ticket_grupal = controlador.comprar_ticket_grupal(
         cant, delegacion, cat, date, recibo, id_log
     )
     row = controlador.get_ticket_grupal_by_id(ticket_grupal)
     id_log = controlador.insert_log(user, 'imprimir_grupal', UNIDAD)
     controlador.insert_ticket_log(ticket_grupal, id_log)
     print_thread = Thread(
         target=impresora.imprimir_ticket_grupal,
         args=(
             user['nombre'],
             user['dni'],
             row['id'],
             UNIDAD,
             row['fecha'].strftime('%d/%m/%Y'),
             row['cantidad'],
             row['barcode'],
             row['importe'],
             row['delegacion'],
             row['recibo']
         )
     )
     print_thread.start()
     Window.release_all_keyboards()
     self.cancel()
Beispiel #5
0
    def do_email(self, popup, address, filename, widget):
        thread = SenderThread(address, filename)
        thread.daemon = True
        thread.start()
        popup.dismiss()

        layout = BoxLayout(orientation='vertical')
        label = Label(
            text='Just sent this image to:\n\n{}'.format(address),
            font_size=30)
        button = Button(
            text='Awesome!',
            font_size=30,
            background_color=(0, 1, 0, 1))
        layout.add_widget(label)
        layout.add_widget(button)

        popup = Popup(
            title='Just thought you should know...',
            content=layout,
            size_hint=(.5, .5))

        button.bind(on_release=popup.dismiss)
        from kivy.core.window import Window

        Window.release_all_keyboards()
        self.reset_email_textinput()
        popup.open()
Beispiel #6
0
 def show_popup(self, inst, val):
     self.popup.size_hint = self.hint_xy
     #self.listeBoutons.size = self.popup.size
     if val:
         # On laisse béton les éventuelles appui clavier
         Window.release_all_keyboards()
         self.popup.open()
Beispiel #7
0
	def encryptstring(self, string, key, pass_key=None):
		
		if key == 'ROT 13':
			encrypted_text = [encode(letter, 'rot13') for letter in string if \
							  ord(letter) in range(32, 127)]
			encrypted_text = "".join(str(letter) for letter in encrypted_text)
			return encrypted_text

		elif key == '128 Bit' and len(pass_key) > 0:
			if len(pass_key) > 16:
				Window.release_all_keyboards()
				MaxPassPopup().open()
				return ""
			elif len(pass_key) < 16:
				#Add filler bits to password 
				pass_key = pass_key + ("x" * (16 - len(pass_key)))
			block_size = 16
			padding = '{'
			pad = lambda s: s + (block_size - len(s) % block_size) * padding
			EncodeAES = lambda c, s: base64.b64encode(c.encrypt(pad(s)))	
			cipher = AES.new(pass_key)
			encoded = EncodeAES(cipher, encode(string, 'utf-8'))
			return encoded

		elif key == '128 Bit' and pass_key == "":
			Window.release_all_keyboards()
			NoPassPopup().open()
			return ""

		else:
			return "(Select Encryption Type)"
Beispiel #8
0
    def go_back(self, notedited=True):
        Window.release_all_keyboards()

        if self.return_to_main_screen:
            self._main_screen.switch_screen("main_screen")
        else:
            self._main_screen.switch_screen("search_tag")
Beispiel #9
0
    def on_touch_down(self, touch, *kwargs):
        if not self.collide_point(*touch.pos):
            return
        if self.keyboard_mode == "global":
            self.request_keyboard()
        else:
            Window.release_all_keyboards()
            self.browser.GetFocusedFrame().ExecuteJavascript("__kivy__keyboard_requested = false;")

        touch.moving = False
        self.touches.append(touch)
        touch.grab(self)

        if len(self.touches) == 1:
            # Only mouse click when single touch
            y = self.height-touch.pos[1] + self.pos[1]
            x = touch.x - self.pos[0]
            self.browser.SendMouseClickEvent(
                x,
                y,
                cefpython.MOUSEBUTTON_LEFT,
                mouseUp=False,
                clickCount=1
            )
        return True
Beispiel #10
0
    def monitor_screen_change(self,dt):

        if self.current_screen != roboprinter.robo_screen():
            if self._keyboard:
                Window.release_all_keyboards()

            return False
Beispiel #11
0
    def do_email(self, popup, address, filename, widget):
        thread = SenderThread(address, filename)
        thread.daemon = True
        thread.start()
        popup.dismiss()

        layout = BoxLayout(orientation='vertical')
        label = Label(text='Just sent this image to:\n\n{}'.format(address),
                      font_size=30)
        button = Button(text='Awesome!',
                        font_size=30,
                        background_color=(0, 1, 0, 1))
        layout.add_widget(label)
        layout.add_widget(button)

        popup = Popup(title='Just thought you should know...',
                      content=layout,
                      size_hint=(.5, .5))

        button.bind(on_release=popup.dismiss)
        from kivy.core.window import Window

        Window.release_all_keyboards()
        self.reset_email_textinput()
        popup.open()
    def __init__(self, ctrl, index=None, **kwargs):
        super().__init__(**kwargs)
        self.content = TransactionDetails(ctrl, index=index)
        self.title = "Transaction"

        self.size_hint = self.pHint
        Window.release_all_keyboards()
        self.open()
Beispiel #13
0
 def confirmacion(self):
     Window.release_all_keyboards()
     self.fecha = self.validar_anulacion()
     if self.fecha:
         self.popup = ConfirmPopup(
             text='\rSeguro deseas anular el ticket\r\n del día %s?' %
             (self.fecha))
         self.popup.bind(on_answer=self._on_answer)
         self.popup.open()
Beispiel #14
0
 def clear(self):
     """Limpia los campos de texto y libera el teclado virtual"""
     self.ids.dni.text = ""
     self.ids.nombre.text = ""
     self.ids.lu.text = ""
     self.ids.mail.text = ""
     self.ids.facultad.text = ""
     self.ids.provincia.text = ""
     Window.release_all_keyboards()
Beispiel #15
0
 def ok(self):
     text = self.fname_input.text[:]
     if text.strip() == "": 
         self.cancel()
         return
     if not text.endswith('.pex'): text += '.pex'
     self.load_save_widget.save_filename(text)
     self.load_save_widget.new_file_popup.dismiss()
     Window.release_all_keyboards()
Beispiel #16
0
 def ok(self):
     text = self.fname_input.text[:]
     if text.strip() == "":
         self.cancel()
         return
     if not text.endswith('.pex'): text += '.pex'
     self.load_save_widget.save_filename(text)
     self.load_save_widget.new_file_popup.dismiss()
     Window.release_all_keyboards()
Beispiel #17
0
 def clear(self):
     """Limpia los campos de texto y libera el teclado virtual"""
     self.ids.dni.text = ""
     self.ids.nombre.text = ""
     self.ids.lu.text = ""
     self.ids.mail.text = ""
     self.ids.facultad.text = ""
     self.ids.provincia.text = ""
     Window.release_all_keyboards()
    def __init__(self, ctrl, **kwargs):
        super().__init__(**kwargs)
        self.content = DateSelectionDetails(ctrl)
        self.title = "Date selection"
        ctrl.popup = self

        self.size_hint = self.pHint
        Window.release_all_keyboards()
        self.open()
Beispiel #19
0
    def show_popup(self, *args):
        """ 
        Open popup if TextInput long-pressed
        """

        # Automatically dismiss the keyboard
        # that results from the textInput
        Window.release_all_keyboards()
        self.popup.open()
Beispiel #20
0
    def show_popup(self, *args):
        """ 
        Open popup if TextInput long-pressed
        """

        # Automatically dismiss the keyboard
        # that results from the textInput
        Window.release_all_keyboards()
        self.popup.open()
Beispiel #21
0
 def confirmacion(self):
     """Llamada a popup de confirmación de anulación."""
     Window.release_all_keyboards()
     fecha = self.validar_anulacion()
     if fecha:
         self.popup = ConfirmPopup(
             text='\rSeguro deseas anular el ticket\r\n del día %s?' %
             (fecha))
         self.popup.bind(on_answer=self._on_answer)
         self.popup.open()
Beispiel #22
0
    def show_popup(self, isnt, val):
        """ 
		Open popup if textinput focused, 
		and regardless update the popup size_hint 
		"""
        if val:
            # Automatically dismiss the keyboard
            # that results from the textInput
            Window.release_all_keyboards()
            self.popup.open()
Beispiel #23
0
 def submit_post(self):
     Window.release_all_keyboards()
     label = self.ids.verified
     if label.text == 'unverified':
         self.ids._screen_manager.current = 'login'
         return
     self.ids._screen_manager.current = 'loading'
     App.get_running_app().tog.next()
     self.post = self.ids.post.text
     #print('submit: %s' % self.post)
     Clock.schedule_once(partial(self.login_m,self.post),1)
Beispiel #24
0
 def confirmacion(self):
     """Llamada a popup de confirmación de anulación."""
     Window.release_all_keyboards()
     fecha = self.validar_anulacion()
     if fecha:
         self.popup = ConfirmPopup(
             text='\rSeguro deseas anular el ticket\r\n del día %s?' %
             (fecha)
         )
         self.popup.bind(on_answer=self._on_answer)
         self.popup.open()
Beispiel #25
0
 def show_popup(self, isnt, val):
     """ 
     Open popup if textinput focused, 
     and regardless update the popup size_hint 
     """
     self.popup.size_hint=self.pHint        
     if val:
         # Automatically dismiss the keyboard 
         # that results from the textInput 
         Window.release_all_keyboards()
         self.popup.open()
Beispiel #26
0
 def show_popup(self, isnt, val):
     """
     Open popup if textinput focused,
     and regardless update the popup size_hint
     """
     self.popup.size_hint = self.pHint
     if val:
         # Automatically dismiss the keyboard
         # that results from the textInput
         Window.release_all_keyboards()
         self.ctw.time = datetime.datetime.strptime(self.text, self.format)
         self.popup.open()
Beispiel #27
0
    def transition_focus_normal(self, *args, **kwargs):
        # ====================================================================
        # F O C U S  =>  N O R M A L
        screen_width, screen_height = self.view.size

        self.scrollview_hidden = False

        # close the keyboard
        Window.release_all_keyboards()

        # disable the controls (workaround until 1.8.0)
        self.controls.disable()

        # hide the controls
        ani = Animation(
            opacity=0.0,
            duration=.3)
        # ani.bind(on_complete=self._remove_widget_after_ani)
        self.start_and_log(ani, self.preview_label)
        if self.controls:
            self.start_and_log(ani, self.controls)

        # set the background to normal
        ani = Animation(
            size_hint=(3, 1.5),
            t='in_out_quad',
            duration=.5)
        self.start_and_log(ani, self.background)

        # show the scrollview and drawer
        ani = Animation(
            y=0,
            t='in_out_quad',
            opacity=1.0,
            duration=.5)
        self.start_and_log(ani, search(self, 'scrollview_area'))
        self.start_and_log(ani, self.drawer)

        # hide the focus widget
        ani = Animation(
            pos_hint={'top': 0},
            height=screen_height * .25,
            t='in_out_quad',
            duration=.5)
        ani &= Animation(
            opacity=0.0,
            duration=.5)
        self.start_and_log(ani, self.focus_widget)

        # schedule a unlock
        self.locked = True
        Clock.schedule_once(self.unlock, .5)
Beispiel #28
0
    def hook_keyboard(self, window, key, *_):
        """This function receives keyboard events, such as the 'back' or 'escape' key."""

        del window
        if key == 27:  #Escape/Back key
            if Window.keyboard_height > 0:
                Window.release_all_keyboards()
                return True
            elif not self.screen_manager.current_screen:
                return False
            elif self.screen_manager.current != 'main':
                self.main()
                return True
Beispiel #29
0
    def show_popup(self, inst, val):
        """ 
        Open popup if textinput focused, 
        and regardless update the popup size_hint 
        """

        self.popup.size_hint = None, None
        self.popup.width = min(Window.width * 0.9, 600)
        self.popup.height = self.popup.width * 0.75  # always use a 4:3 aspect ratio

        if val:
            # Automatically dismiss the keyboard
            # that results from the textInput
            Window.release_all_keyboards()
            self.popup.open()
Beispiel #30
0
    def on_touch_down(self, touch, *kwargs):
        if not self.collide_point(*touch.pos):
            return
        if self.keyboard_mode == "global":
            self.request_keyboard()
        else:
           Window.release_all_keyboards()

        touch.is_dragging = False
        touch.is_scrolling = False
        touch.is_right_click = False
        self.touches.append(touch)
        touch.grab(self)

        return True
Beispiel #31
0
    def set_callback(self, callback, layout):
        """
        Set the function to be called when key presses occur.
        """
        Window.release_all_keyboards()
        self._keyboard = Window.request_keyboard(self._keyboard_close, self)

        #if self._keyboard.widget:
        Logger.info("main.py: self._keyboard.widget=" +
                    str(self._keyboard.widget))
        #if self._keyboard.widget:
        #vkeyboard = self._keyboard.widget
        #vkeyboard.layout = layout
        #vkeyboard.bind(on_key_down=callback)
        if self._keyboard:
            self._keyboard.layout = layout
            self._keyboard.bind(on_key_down=callback)
            self._callback = callback
Beispiel #32
0
 def checkAnswer(self):
     Window.release_all_keyboards()
     if "".join(self.mutatedWord) in self.words:
         # self.correct_sound.play()
         self.pb_score.value += 10
         if self.pb_score.value >= 500:
             self.lb_msg.text = "You Win The Game!!"
             self.save_score()
         else:
             # self.correct_sound.on_stop = self.playAgain
             self.playAgain()
     elif self.pb_score.value >= 5:
         # self.wrong_sound.play()
         self.lb_msg.text = "Wrong, try again"
         self.pb_score.value -= 5
     else:
         # self.wrong_sound.play()
         self.lb_msg.text = "Game Over!!"
Beispiel #33
0
    def set_callback(self, callback, layout):
        """
        Set the function to be called when key presses occur.
        """
        Window.release_all_keyboards()
        self._keyboard = Window.request_keyboard(
            self._keyboard_close,
            self)

        #if self._keyboard.widget:
        Logger.info("main.py: self._keyboard.widget=" +
                    str(self._keyboard.widget))
        #if self._keyboard.widget:
            #vkeyboard = self._keyboard.widget
            #vkeyboard.layout = layout
            #vkeyboard.bind(on_key_down=callback)
        if self._keyboard:
            self._keyboard.layout = layout
            self._keyboard.bind(on_key_down=callback)
            self._callback = callback
Beispiel #34
0
        def go_back_to_screen(self, current, destination):
            # Goes back to destination and deletes current screen
            #ps = self.get_screen(current)
            try:
                for s in self.screen_names:
                    if s is current:
                        d = self.get_screen(s)
                        self.remove_widget(d)
                self.current = destination
                #self.remove_widget(ps)
                #Logger.info('go_back_to_screen: current {}, dest {}'.format(current, destination))

                if current == 'wifi_config[1]':
                    Window.release_all_keyboards()
                #used to delete keyboards after user hits backbutton from Wifi Config Screen. This is a brute force implementation.... TODO figure out a more elegant and efficient way to perform this call.
                return
            except Exception as e:
                Logger.info("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " + str(e))
                traceback.print_exc()
                self.go_back_to_main('printer_status_tab')
Beispiel #35
0
    def transition_focus_normal(self, *args, **kwargs):
        # ====================================================================
        # F O C U S  =>  N O R M A L
        screen_width, screen_height = self.view.size

        self.scrollview_hidden = False

        # close the keyboard
        Window.release_all_keyboards()

        # disable the controls (workaround until 1.8.0)
        self.controls.disable()

        # hide the controls
        ani = Animation(opacity=0.0, duration=.3)
        # ani.bind(on_complete=self._remove_widget_after_ani)
        self.start_and_log(ani, self.preview_label)
        if self.controls:
            self.start_and_log(ani, self.controls)

        # set the background to normal
        ani = Animation(size_hint=(3, 1.5), t='in_out_quad', duration=.5)
        self.start_and_log(ani, self.background)

        # show the scrollview and drawer
        ani = Animation(y=0, t='in_out_quad', opacity=1.0, duration=.5)
        self.start_and_log(ani, search(self, 'scrollview_area'))
        self.start_and_log(ani, self.drawer)

        # hide the focus widget
        ani = Animation(pos_hint={'top': 0},
                        height=screen_height * .25,
                        t='in_out_quad',
                        duration=.5)
        ani &= Animation(opacity=0.0, duration=.5)
        self.start_and_log(ani, self.focus_widget)

        # schedule a unlock
        self.locked = True
        Clock.schedule_once(self.unlock, .5)
Beispiel #36
0
 def _key_handler(self, *args):
     key = args[1]
     #check if the user presses esc or android's back button
     if key in (1000, 27):
         #first check if the keyboard is on since its the first thing we want to remove
         if Window.keyboard_height is 0:
             #check if there is any modalview opened
             if self.sm.modal_state is 1:
                 #check if we are at the last screen so we can exit the app
                 if len(self.history) == 1:
                     self.stop()
                 self.prev = self.history[len(self.history) - 2]
                 #delete the current screen
                 del self.history[-1]
                 #switch to the previous screen
                 self.sm.current = self.prev
                 return True
             else:
                 self.sm.modal_state.dismiss()
                 self.sm.modal_state = 1
         else:
             Window.release_all_keyboards()
Beispiel #37
0
 def _key_handler(self, *args):
     key = args[1]
     #check if the user presses esc or android's back button
     if key in (1000, 27):
         #first check if the keyboard is on since its the first thing we want to remove
         if Window.keyboard_height is 0:
             #check if there is any modalview opened
             if self.sm.modal_state is 1:
                 #check if we are at the last screen so we can exit the app
                 if len(self.history) == 1:
                     self.stop()
                 self.prev = self.history[len(self.history) - 2]
                 #delete the current screen
                 del self.history[-1]
                 #switch to the previous screen
                 self.sm.current = self.prev
                 return True
             else:
                 self.sm.modal_state.dismiss()
                 self.sm.modal_state = 1
         else:
             Window.release_all_keyboards()
Beispiel #38
0
    def generate_connecting_screen(self, obj, *args):
        # remove keyboard from screen
        self.wifi_status = 'nothing'
        Window.release_all_keyboards()

        # wifi credentials
        if obj.id == 'encrypted':
            psk = obj.password_buffer
        else:
            psk = ''
        ssid = obj.ssid
        self.wifi_data = {'ssid': ssid, 'psk': psk, 'force': True}

        # layout for connecting screen
        s = Screen(name=self.name + '[2]')
        c = WifiConnecting(ssid=ssid)
        s.add_widget(c)
        self.rsm.add_widget(s)
        self.rsm.current = s.name
        self.temp_screen = s

        thread.start_new_thread(self.connectWifi_thread, ())
        Clock.schedule_interval(self.connectWifi_callback, 1)
    def __init__(self, title, option_list, option_init=None, callback=None, multiselect=True, **kwargs):
        super().__init__(**kwargs)
        self.title = title
        self.callback = callback
        self.main_layout = AnchorLayout()
        if option_init is None:
            option_init = [True] * len(option_list)

        self.grid = GridLayout(cols=1)
        self.opt_boxes = []
        self.labels = []
        for i, opt in enumerate(option_list):
            box = BoxLayout(orientation='horizontal')
            check_box = CheckBox(active=option_init[i])
            if not multiselect:
                check_box.group = "Single_Select_Only_Group"
            label = Label(text=str(opt))
            self.opt_boxes.append(check_box)
            self.labels.append(label)
            box.add_widget(check_box)
            box.add_widget(label)
            self.grid.add_widget(box)
        cancel_button = Button(text="Cancel")
        cancel_button.bind(on_press=self.cancel_callback)
        ok_button = Button(text="Ok")
        ok_button.bind(on_press=self.ok_callback)
        box = BoxLayout(orientation='horizontal')
        box.add_widget(cancel_button)
        box.add_widget(ok_button)
        self.grid.add_widget(box)

        self.main_layout.add_widget(self.grid)

        self.content = self.main_layout
        self.size_hint = self.pHint
        Window.release_all_keyboards()
        self.open()
Beispiel #40
0
	def decryptstring(self, string, key, pass_key=None):
		
		if key == 'ROT 13':
			decrypted_text = [decode(letter, 'rot13') for letter in string if \
							  ord(letter) in range(32, 127)]
			decrypted_text= "".join(str(value) for value in decrypted_text)
			return decrypted_text

		elif key == '128 Bit' and len(pass_key) > 0:
			if len(pass_key) > 16:
				Window.release_all_keyboards()
				MaxPassPopup().open()
				return ""
			elif len(pass_key) < 16:
				#Add filler bits to password
				pass_key = pass_key + ("x" * (16 - len(pass_key)))
			try:
				padding = '{'
				DecodeAES = lambda c, e: \
						    c.decrypt(base64.b64decode(e)).rstrip(padding)
				cipher = AES.new(pass_key)
				decoded = DecodeAES(cipher, string)
				return encode(decoded, 'utf-8', 'replace')
				
			except UnicodeDecodeError:
				"""Fixes invalid continuation byte and invalid start byte error 
				   thrown by user entering wrong password when decrypting text.
				"""
				return ""

		elif key == '128 Bit' and pass_key == "":
			Window.release_all_keyboards()
			NoPassPopup().open()
			return ""

		else:
			return '(Select Encryption Type)'
Beispiel #41
0
    def build(self):
        ''' runs after build_config '''
        Config.set('kivy', 'exit_on_escape', '0')

        self.title = 'ZAPS Mahjong Scorer'
        self.settings_cls = SettingsWithTabbedPanel
        self.use_kivy_settings = False

        Builder.load_string(Mjcomponents.get_kv())
        Builder.load_string(MjGameStatus.get_kv())
        Builder.load_string(MjScoreTable.get_kv())
        Builder.load_string(Mjwhodidit.get_kv())
        Builder.load_string(PlayerUI.get_kv())

        root = Builder.load_string(Mjui.get_kv())

        self.game = root.ids['game_status']
        self.yesno_popup = Factory.YesNoPopup()
        self.deltascore_popup = Factory.DeltaScorePopup()
        self.popup_menu = Factory.Mjmenu()

        Window.release_all_keyboards()
        Window.bind(on_keyboard=self.key_input)

        self.japanese_numbers = self.config.getboolean('main',
                                                       'japanese_numbers')
        self.set_wind_labels(self.config.getboolean('main', 'japanese_winds'))

        self.__mjio = Mjio(token=self.config.get('main', 'auth_token'),
                           server_path=self.config.get('main', 'server_path'))

        self.bg_colour = self.__get_gb_color(
            self.config.get('main', 'bg_colour'))

        Clock.schedule_once(lambda dt: self.get_users())

        return root
Beispiel #42
0
	def user_login(self):
		username = self.ids.txt_userLogin.text
		Window.release_all_keyboards() 
		utilities = Utilities()
		if len(username) != 0:
			server_response = utilities.send_message('{"action":"INIT_SESSION", "data":{"username":"******"}}')
			if server_response != '':
				js_response = json.loads(server_response)
				if js_response != '' and js_response["status"] == 'OK':
					global id_user
					id_user = js_response["data"]["id_user"]
					print 'console >> Usuario con id',id_user,'conectado'
					if not sm.has_screen('userList'): sm.add_widget(UserListScreen(name='userList'))
					sm.transition = SlideTransition(direction='up')
					self.manager.current = 'userList'
				else:
					# Mostrar popup
					utilities.popup('Error', 'Elija otro nombre de usuario')
			else:
				print 'console >> Connection problem'
				utilities.popup('Error', 'Error de conexion')
		else:
			print 'console >> No username written'
			utilities.popup('Error', 'Escriba su nombre de usuario')
Beispiel #43
0
    def get_flickr_images(self, *args):
        ''' hide keyboard '''
        Window.release_all_keyboards()
        reader = codecs.getreader("utf-8")
        url = 'https://api.instagram.com/v1/users/528817151/media/recent?access_token='+ access_token
        user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.7) Gecko/2009021910 Firefox/3.0.7'
        headers={'User-Agent':user_agent,} 
        request=urllib.request.Request(url,None,headers) #The assembled request
        flickr_images_xml = urllib.request.urlopen(request)
        str_response = flickr_images_xml.readall().decode('utf-8')
        data = json.loads(str_response)
        log = open("log.txt", "w")
        log.write(json.dumps(data, sort_keys=True, indent=2))
        
        print(data[0][1])
        #print(data.get("data",{}).get("images",{}))
              #.get("standard_resolution",{}).get("url"))
        
        log.close()
        #tree = ET.parse(flickr_images_xml)
        #photo_total = int(tree.find('photos').attrib.get('total'))
        #photo_pages = int(tree.find('photos').attrib.get('pages'))
        #photo_perpage = int(tree.find('photos').attrib.get('perpage'))
        #photo_list = tree.findall('photos/photo')

        if photo_total != 0:
            # randomize flickr image selections
            if photo_pages == 1:
                random_selection = [randint(0,photo_total) for _ in range(picture_count)]
            elif photo_pages > 1:
                random_selection = [randint(0,photo_perpage) for _ in range(picture_count)]
            print(random_selection)
            count = 0

            for photo in photo_list:
                if count in random_selection:
                    try:
                        # parse xml for image url_o
                        url_o = photo.attrib.get('url_o')
                        print(url_o)

                        if str(url_o) != 'None':
                            # load the photo
                            #img = AsyncImage(source= url_o, mipmap=False, allow_stretch=True)
                            #self.root.add_widget(img)
                            flickr_photo = FlickrPhoto(source = url_o,
                                                       rotation=randint(-30,30),
                                                       #pos=(randint(200,5500),randint(200,1800)), 
                                                       #scale_min =.5,
                                                       #scale_max=15)
                                                       )
                            # add to the main field
                            self.root.add_widget(flickr_photo)
                            
                        else:
                            error4 = Popup(title='ERROR!', content=Label(text='Image Missing url_o', font_size=25), size_hint=(None, None), size=(300, 200), pos_hint={'x': .5, 'top': .8})
                            error4.open()
                            break
                    except Exception as e:
                        Logger.exception('Pictures: Unable to load <%s>' % url_o)
                count += 1
            else:
                error3 = Popup(title='ERROR!', content=Label(text='No Images Available', font_size=25), size_hint=(None, None), size=(300, 200), pos_hint={'x': .5, 'top': .8})
                error3.open()
        else:
            error2 = Popup(title='ERROR!', content=Label(text='Invalid User Name', font_size=25), size_hint=(None, None), size=(300, 200), pos_hint={'x': .5, 'top': .8})
            error2.open()
Beispiel #44
0
 def close(self):
     self.text_input_popup.dismiss()
     Window.release_all_keyboards()
     Clock.schedule_once(self._schedule_validate, .2)
    def populate_error(self, error):

        acceptable_errors = {
            'MAINBOARD': {
                'title':
                roboprinter.lang.pack['Error_Detection']['MAINBOARD']['Title'],
                'body':
                roboprinter.lang.pack['Error_Detection']['MAINBOARD']['Body'],
                'icon':
                "Icons/Printer Status/main board warning.png",
                'function':
                self.main_board_disconnect,
                'caret':
                True
            },
            'FIRMWARE': {
                'title':
                roboprinter.lang.pack['Error_Detection']['FIRMWARE']['Title'],
                'body':
                roboprinter.lang.pack['Error_Detection']['FIRMWARE']['Body'],
                'icon':
                "Icons/Printer Status/Firmware warning.png",
                'function':
                self.firmware_updating,
                'caret':
                True,
            },
            'BED_HOT': {
                'title':
                roboprinter.lang.pack['Error_Detection']['BED_HOT']['Title'],
                'body':
                roboprinter.lang.pack['Error_Detection']['BED_HOT']['Body'],
                'icon':
                "Icons/Printer Status/bed heating.png",
                'function':
                self.bed_hot_warning,
                'caret':
                True,
            },
            'BED_DISCONNECT': {
                'title':
                roboprinter.lang.pack['Error_Detection']['BED_DISCONNECT']
                ['Title'],
                'body':
                roboprinter.lang.pack['Error_Detection']['BED_DISCONNECT']
                ['Body'],
                'icon':
                "Icons/Printer Status/bed warning.png",
                'function':
                self.bed_disconnect_screen,
                'caret':
                True,
            },
            'PAUSED': {
                'title':
                roboprinter.lang.pack['Error_Detection']['PAUSED']['Title'],
                'body':
                "[color=#69B3E7]" +
                roboprinter.lang.pack['Error_Detection']['PAUSED']['Body'],
                'icon':
                "Icons/Printer Status/Pause.png",
                'function':
                self.placeholder,
                'caret':
                False
            },
            'FIL_RUNOUT': {
                'title':
                roboprinter.lang.pack['Error_Detection']['FIL_RUNOUT']
                ['Title'],
                'body':
                roboprinter.lang.pack['Error_Detection']['FIL_RUNOUT']['Body'],
                'icon':
                "Icons/Printer Status/Filament warning.png",
                'function':
                self.fil_runout,
                'caret':
                True
            },
            'NONE': {
                'title': "",
                'body': "",
                'icon': "Icons/Printer Status/blank-warning.png",
                'function': self.placeholder,
                'caret': False
            },
            'DEFAULT': {
                'title':
                roboprinter.lang.pack['Error_Detection']['DEFAULT']
                ['Title_Idle']
                if not roboprinter.printer_instance._printer.is_printing() else
                roboprinter.lang.pack['Error_Detection']['DEFAULT']
                ['Title_Active'],
                'body':
                "[color=#69B3E7]" + roboprinter.lang.pack['Error_Detection']
                ['DEFAULT']['Body_Idle'] + "[/color]"
                if not roboprinter.printer_instance._printer.is_printing() else
                "[color=#69B3E7]" + roboprinter.lang.pack['Error_Detection']
                ['DEFAULT']['Body_Active'] + "[/color]",
                'icon':
                "Icons/check_icon.png",
                'function':
                self.placeholder,
                'caret':
                False
            }
        }

        if error in acceptable_errors:
            session_saver.saved['current_error'] = error
            self.error_title = acceptable_errors[error]['title']
            self.error_body = acceptable_errors[error]['body']
            self.error_icon = acceptable_errors[error]['icon']
            self.error_function = acceptable_errors[error]['function']

            if acceptable_errors[error]['caret']:
                self.caret_size = 0.2
            else:
                self.caret_size = 0.0

            #if the error is not a warning, then pop the error
            if error is not 'BED_HOT' and error is not 'DEFAULT' and error is not self.last_error:
                acceptable_errors[error]['function']()

                #kill any attached keyboard
                Window.release_all_keyboards()
        else:
            session_saver.saved['current_error'] = 'DEFAULT'
            self.error_title = acceptable_errors['DEFAULT']['title']
            self.error_body = acceptable_errors['DEFAULT']['body']
            self.error_icon = acceptable_errors['DEFAULT']['icon']
            self.error_function = acceptable_errors['DEFAULT']['function']

        #check to see if this is the first error to populate the system. If it is then kill the splash screen
        if not self.first_default:
            self.first_default = True
            subprocess.call(['sudo pkill omxplayer'], shell=True)

        self.last_error = error
Beispiel #46
0
 def cancel(self):
     self.load_save_widget.new_file_popup.dismiss()
     Window.release_all_keyboards()
 def on_dismiss(self):
     Window.release_all_keyboards()
Beispiel #48
0
 def get_flickr_images(self, *args):
     ''' hide keyboard '''
     Window.release_all_keyboards()
     
     ''' get flickr user id from username '''
     user_name = textbox.text
     if len(user_name) > 0:
         print user_name
         flickr_username_xml = urllib2.urlopen('http://api.flickr.com/services/rest/?method=flickr.urls.lookupUser&api_key='+api_key+'&url=http://www.flickr.com/photos/'+user_name+'/')
         tree = ET.parse(flickr_username_xml)
         tree_root = tree.getroot()
         if tree_root.attrib['stat'] == 'ok':
             user_id = tree_root.find('user').attrib['id']
             print user_id
             
             ''' get flickr images with user id '''
             print ('http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key='+api_key+'&user_id='+user_id+'&extras=url_o'+'&per_page=500')
             flickr_images_xml = urllib2.urlopen('http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key='+api_key+'&user_id='+user_id+'&extras=url_o')
             tree = ET.parse(flickr_images_xml)
             photo_total = int(tree.find('photos').attrib.get('total'))
             photo_pages = int(tree.find('photos').attrib.get('pages'))
             photo_perpage = int(tree.find('photos').attrib.get('perpage'))
             photo_list = tree.findall('photos/photo')
             
             if photo_total != 0:
                 # randomize flickr image selections
                 if photo_pages == 1:
                     random_selection = [randint(0,photo_total) for _ in xrange(picture_count)]
                 elif photo_pages > 1:
                     random_selection = [randint(0,photo_perpage) for _ in xrange(picture_count)]
                 print random_selection
                 count = 0
                 
                 for photo in photo_list:
                     if count in random_selection:
                         try:
                             # parse xml for image url_o
                             url_o = photo.attrib.get('url_o')
                             print url_o
                             
                             if str(url_o) != 'None':
                                 # load the photo
                                 flickr_photo = FlickrPhoto(source = url_o,
                                                            rotation=randint(-30,30),
                                                            #pos=(randint(200,5500),randint(200,1800)), 
                                                            scale_min =.5,
                                                            scale_max=15)                
                                 # add to the main field
                                 self.root.add_widget(flickr_photo)
                             else:
                                 error4 = Popup(title='ERROR!', content=Label(text='Image Missing url_o', font_size=25), size_hint=(None, None), size=(300, 200), pos_hint={'x': .5, 'top': .8})
                                 error4.open()
                                 break
                         except Exception, e:
                             Logger.exception('Pictures: Unable to load <%s>' % url_o)
                     count += 1
             else:
                 error3 = Popup(title='ERROR!', content=Label(text='No Images Available', font_size=25), size_hint=(None, None), size=(300, 200), pos_hint={'x': .5, 'top': .8})
                 error3.open()
         else:
             error2 = Popup(title='ERROR!', content=Label(text='Invalid User Name', font_size=25), size_hint=(None, None), size=(300, 200), pos_hint={'x': .5, 'top': .8})
             error2.open()
Beispiel #49
0
    def get_flickr_images(self, *args):
        ''' hide keyboard '''
        Window.release_all_keyboards()
        
        ''' get flickr user id from username '''
        user_name = textbox.text
        if len(user_name) > 0:
            print(user_name)
            user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.7) Gecko/2009021910 Firefox/3.0.7'
            url = 'https://www.flickr.com/services/rest/?method=flickr.urls.lookupUser&format=rest&foo=bar&api_key='+api_key+'&url=http://www.flickr.com/photos/'+user_name
            url = 'https://api.flickr.com/services/rest/?method=flickr.urls.lookupUser&api_key='+api_key+'&url=http://www.flickr.com/photos/'+user_name+'/'
            headers={'User-Agent':user_agent,} 
            request=urllib.request.Request(url,None,headers) #The assembled request
            '''Logger.info('THE URL TO TEST: '+request)'''
            flickr_username_xml = urllib.request.urlopen(request)
            tree = ET.parse(flickr_username_xml)
            tree_root = tree.getroot()
            if tree_root.attrib['stat'] == 'ok':
                user_id = tree_root.find('user').attrib['id']
                print(user_id)
                
                ''' get flickr images with user id '''
                print('https://api.flickr.com/services/rest/?method=flickr.photos.search&api_key='+api_key+'&user_id='+user_id+'&extras=url_o'+'&per_page=500')
                url = 'https://api.flickr.com/services/rest/?method=flickr.photos.search&api_key='+api_key+'&user_id='+user_id+'&extras=url_o'
                request=urllib.request.Request(url,None,headers) #The assembled request
                flickr_images_xml = urllib.request.urlopen(request)
                tree = ET.parse(flickr_images_xml)
                photo_total = int(tree.find('photos').attrib.get('total'))
                photo_pages = int(tree.find('photos').attrib.get('pages'))
                photo_perpage = int(tree.find('photos').attrib.get('perpage'))
                photo_list = tree.findall('photos/photo')
                
                if photo_total != 0:
                    # randomize flickr image selections
                    if photo_pages == 1:
                        random_selection = [randint(0,photo_total) for _ in range(picture_count)]
                    elif photo_pages > 1:
                        random_selection = [randint(0,photo_perpage) for _ in range(picture_count)]
                    print(random_selection)
                    count = 0

                    for photo in photo_list:
                        if count in random_selection:
                            try:
                                # parse xml for image url_o
                                url_o = photo.attrib.get('url_o')
                                print(url_o)
                                if str(url_o) != 'None':
                                    # load the photo
                                    
                                    # sc = Scatter(size_hint=(None, None), size=(450,250), pos=(300, 300), do_rotation=True, do_scale=True)
                                    # img = AsyncImage(source= url_o,
                                    #                rotation=randint(-30,30),
                                    #                #pos=(randint(200,5500),randint(200,1800)), 
                                    #                scale_min =0.5,
                                    #                scale_max=15)
                                    #self.root.add_widget(img)
                                    # sc.add_widget(img)
                                    # self.root.add_widget(sc)
                                    flickr_photo = FlickrPhoto(source = url_o,
                                                               rotation=randint(-30,30))
                                                               #pos=(randint(200,5500),randint(200,1800))) 
                                                               #scale_min =.5,
                                                               #scale_max=15)
                                                               
                                    # add to the main field
                                    self.root.add_widget(flickr_photo)
                                else:
                                    error4 = Popup(title='ERROR!', content=Label(text='Image Missing url_o', font_size=25), size_hint=(None, None), size=(300, 200), pos_hint={'x': .5, 'top': .8})
                                    error4.open()
                                    break
                            except Exception as e:
                                Logger.exception('Pictures: Unable to load <%s>' % url_o)
                        count += 1
                    #self.root.add_widget(sc)
                else:
                    error3 = Popup(title='ERROR!', content=Label(text='No Images Available', font_size=25), size_hint=(None, None), size=(300, 200), pos_hint={'x': .5, 'top': .8})
                    error3.open()
            else:
                error2 = Popup(title='ERROR!', content=Label(text='Invalid User Name', font_size=25), size_hint=(None, None), size=(300, 200), pos_hint={'x': .5, 'top': .8})
                error2.open()
        else:
                error1 = Popup(title='ERROR!', content=Label(text='User Name Required', font_size=25), size_hint=(None, None), size=(300, 200), pos_hint={'x': .5, 'top': .8})
                error1.open()
        
        ''' clear textbox for next user '''
        textbox.text = ''
Beispiel #50
0
 def release_all_keyboard(*l):
     Window.release_all_keyboards()
Beispiel #51
0
 def clear(self):
     """Limpia los campos de texto y libera el teclado virtual"""
     self.ids.dni.text = ""
     self.ids.passw.text = ""
     Window.release_all_keyboards()
Beispiel #52
0
 def Rechercher(self, *args):
     self.filtre = self.ctrl_recherche.text
     self.Remplissage() 
     Window.release_all_keyboards()
Beispiel #53
0
 def release_all_keyboard(*l):
     Window.release_all_keyboards()
Beispiel #54
0
 def on_focus(self, instance, value):
     if not value:
         Window.release_all_keyboards()
 def Rechercher(self, *args):
     self.filtre = self.ctrl_recherche.text
     self.Remplissage()
     Window.release_all_keyboards()
Beispiel #56
0
    def change_state(self, state, **kwargs):
        if self.locked:
            return

        # replace with a state machine in the future?  ...yes.
        if state == 'preview' and self.preview_widget is None:
            self.update_preview()
            return

        screen_width = Config.getint('graphics', 'width')
        screen_height = Config.getint('graphics', 'height')

        new_state = state
        old_state = self.state
        self.state = new_state
        transition = (old_state, self.state)

        logger.debug('transitioning state %s', transition)

        # ====================================================================
        #  F O C U S  =>  N O R M A L
        if transition == ('focus', 'normal'):
            self.scrollview_hidden = False

            # cancel all running animations
            Animation.cancel_all(self.controls)
            Animation.cancel_all(self.scrollview)
            Animation.cancel_all(self.background)
            Animation.cancel_all(self.focus_widget)

            # close the keyboard
            from kivy.core.window import Window

            Window.release_all_keyboards()

            # disable the controls (workaround until 1.8.0)
            self.controls.disable()

            # hide the controls
            ani = Animation(
                opacity=0.0,
                duration=.3)
            ani.bind(on_complete=self._remove_widget_after_ani)
            ani.start(self.preview_label)
            if self.controls:
                ani.start(self.controls)

            # set the background to normal
            x, y = self._calc_bg_pos()
            ani = Animation(
                y=y + 100,
                x=x,
                t='in_out_quad',
                duration=.5)
            ani.start(self.background)

            # show the scrollview
            x, y = self._scrollview_pos[0], self.scrollview.original_y
            ani = Animation(
                x=x,
                y=y,
                t='in_out_quad',
                opacity=1.0,
                duration=.5)
            ani.start(self.scrollview)

            # show the camera button
            ani = Animation(
                y=0,
                t='in_out_quad',
                opacity=1.0,
                duration=.5)
            ani.start(self.preview_button)

            # hide the focus widget
            ani = Animation(
                y=-1000,
                x=self.focus_widget.x + OFFSET,
                size=self.small_preview_size,
                t='in_out_quad',
                duration=.5)

            ani &= Animation(
                opacity=0.0,
                duration=.5)

            ani.start(self.focus_widget)

            # schedule a unlock
            self.locked = True
            Clock.schedule_once(self.unlock, .5)

        #=====================================================================
        #  N O R M A L  =>  F O C U S
        elif transition == ('normal', 'focus'):
            widget = kwargs['widget']
            self.scrollview_hidden = True

            # cancel all running animations
            Animation.cancel_all(self.scrollview)
            Animation.cancel_all(self.background)
            Animation.cancel_all(self.focus_widget)
            Animation.cancel_all(self.preview_button)

            # set the focus widget to have the same image as the one picked
            # do a bit of mangling to get a more detailed image
            thumb, detail, original, comp = self.get_paths()
            filename = jpath(detail, os.path.basename(widget.source))
            original = jpath(original, os.path.basename(widget.source))

            # get a medium resolution image for the preview
            self.focus_widget.source = filename

            # show the controls
            self.controls = SharingControls()
            self.controls.filename = original
            self.controls.size_hint = .40, 1
            self.controls.opacity = 0

            ani = Animation(
                opacity=1.0,
                duration=.3)
            ani.start(self.preview_label)
            ani.start(self.controls)

            self.preview_label.pos_hint = {'x': .25, 'y': .47}

            # set the z to something high to ensure it is on top
            self.add_widget(self.controls)

            # hide the scrollview and camera button
            ani = Animation(
                x=0,
                y=-1000,
                t='in_out_quad',
                opacity=0.0,
                duration=.7)
            ani.start(self.scrollview)
            ani.start(self.preview_button)

            # start a simple animation on the background
            ani = Animation(
                y=self.background.y - 100,
                x=-self.background.width / 2.5,
                t='in_out_quad',
                duration=.5)
            ani += Animation(
                x=0,
                duration=480)
            ani.start(self.background)

            hh = (screen_height - self.large_preview_size[1]) / 2

            # show the focus widget
            ani = Animation(
                opacity=1.0,
                y=screen_height - self.large_preview_size[1] - hh,
                x=(1280 / 2) - 250,
                size=self.large_preview_size,
                t='in_out_quad',
                duration=.5)
            ani &= Animation(
                opacity=1.0,
                duration=.5)
            ani.start(self.focus_widget)

            # schedule a unlock
            self.locked = True
            Clock.schedule_once(self.unlock, .5)

        #=====================================================================
        #  N O R M A L  =>  P R E V I E W
        elif transition == ('normal', 'preview'):
            self.scrollview_hidden = True

            # cancel all running animations
            Animation.cancel_all(self.scrollview)
            Animation.cancel_all(self.background)
            Animation.cancel_all(self.focus_widget)
            Animation.cancel_all(self.preview_exit)
            Animation.cancel_all(self.preview_button)
            Animation.cancel_all(self.preview_widget)

            # show the preview exit button
            ani = Animation(
                x=1280 - self.preview_exit.width,
                t='in_out_quad',
                duration=.5)
            ani &= Animation(
                opacity=1.0,
                duration=.5)
            ani.start(self.preview_exit)

            # show the camera preview
            ani = Animation(
                y=0,
                t='in_out_quad',
                duration=.5)
            ani &= Animation(
                opacity=1.0,
                duration=.5)
            ani.start(self.preview_widget)

            # hide the scrollview and camera button
            ani = Animation(
                x=0,
                y=-1000,
                t='in_out_quad',
                opacity=0.0,
                duration=.7)
            ani.start(self.scrollview)
            ani.start(self.preview_button)

            # schedule a unlock
            self.locked = True
            Clock.schedule_once(self.unlock, .5)

            # schedule an interval to update the preview widget
            interval = pkConfig.getfloat('camera', 'preview-interval')
            Clock.schedule_interval(self.update_preview, interval)

        #=====================================================================
        #  P R E V I E W  =>  N O R M A L
        elif transition == ('preview', 'normal'):
            self.scrollview_hidden = False

            # cancel all running animations
            Animation.cancel_all(self.scrollview)
            Animation.cancel_all(self.background)
            Animation.cancel_all(self.focus_widget)
            Animation.cancel_all(self.preview_exit)
            Animation.cancel_all(self.preview_widget)
            Animation.cancel_all(self.preview_button)

            # hide the preview exit button
            ani = Animation(
                x=1280,
                t='in_out_quad',
                duration=.5)
            ani &= Animation(
                opacity=0.0,
                duration=.5)
            ani.start(self.preview_exit)

            # hide the camera preview
            ani = Animation(
                y=-self.preview_widget.height,
                t='in_out_quad',
                duration=.5)
            ani &= Animation(
                opacity=0.0,
                duration=.5)
            ani.start(self.preview_widget)

            # set the background to normal
            x, y = self._calc_bg_pos()
            ani = Animation(
                y=y + 100,
                x=x,
                t='in_out_quad',
                duration=.5)
            ani.start(self.background)

            # show the scrollview
            x, y = self._scrollview_pos[0], self.scrollview.original_y
            ani = Animation(
                x=x,
                y=y,
                t='in_out_quad',
                opacity=1.0,
                duration=.5)
            ani.start(self.scrollview)

            # show the camera button
            ani = Animation(
                y=0,
                t='in_out_quad',
                opacity=1.0,
                duration=.5)
            ani.start(self.preview_button)

            # schedule a unlock
            self.locked = True
            Clock.schedule_once(self.unlock, .5)

            # unschedule the preview updater
            Clock.unschedule(self.update_preview)
Beispiel #57
0
 def on_dismiss(self, *arg):
     Window.release_all_keyboards()