Python kivy.app.App.get_running_app() Examples
The following are 30
code examples of kivy.app.App.get_running_app().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
kivy.app.App
, or try the search function
.
Example #1
Source File: main.py From kivy-smoothie-host with GNU General Public License v3.0 | 6 votes |
def handle_exception(exc_type, exc_value, exc_traceback): """ handle all exceptions """ # KeyboardInterrupt is a special case. # We don't raise the error dialog when it occurs. if issubclass(exc_type, KeyboardInterrupt): return Logger.error("Unhandled Exception:") Logger.error("".join(traceback.format_exception(exc_type, exc_value, exc_traceback))) try: App.get_running_app().stop() except Exception: pass # we want to handle TERM signal cleanly (sent by sv down)
Example #2
Source File: __init__.py From PyCon-Mobile-App with GNU General Public License v3.0 | 6 votes |
def go_back_in_history(): app = App.get_running_app() from utils import pause_app try: scr = app._navigation_higherarchy.pop() if scr.name == 'ScreenSchedule': # we are at top of Nav higherarchy pause_app() return # we are not at root of Nav higherarchy scr = app._navigation_higherarchy[-1] load_screen( scr.name, manager=scr.manager, store_back=False) except (IndexError, ScreenManagerException): # check if current screen is schedule screen? if app.navigation_manager.current == 'ScreenSchedule': pause_app() return load_screen("ScreenSchedule", manager=app.navigation_manager)
Example #3
Source File: interpreter.py From Pyonic-interpreter with GNU General Public License v3.0 | 6 votes |
def __init__(self, *args, **kwargs): super(InterpreterInput, self).__init__(*args, **kwargs) self.register_event_type('on_request_completions') self.register_event_type('on_clear_completions') self.register_event_type('on_get_completions') if platform != 'android': from pygments.lexers import PythonLexer self.lexer = PythonLexer() App.get_running_app().bind(on_pause=self.on_pause) # self.text = '''for i in range(5): # print(i) # time.sleep(1)'''
Example #4
Source File: main.py From Pyonic-interpreter with GNU General Public License v3.0 | 6 votes |
def go_back(self): app = App.get_running_app() if self.current == 'interpreter': # current top level screen app.back_button_leave_app() self.transition = SlideTransition(direction='right') if self.current == self.back_screen_name: self.back_screen_name = 'interpreter' if self.back_screen_name in self.screen_names: self.current = self.back_screen_name else: self.current = 'interpreter' self.transition = SlideTransition(direction='left')
Example #5
Source File: viewer.py From kivy-smoothie-host with GNU General Public License v3.0 | 6 votes |
def __init__(self, comms=None, **kwargs): super(GcodeViewerScreen, self).__init__(**kwargs) self.app = App.get_running_app() self.last_file_pos = None self.canv = InstructionGroup() self.bind(pos=self._redraw, size=self._redraw) self.last_target_layer = 0 self.tx = 0 self.ty = 0 self.scale = 1.0 self.comms = comms self.twod_mode = self.app.is_cnc self.rval = 0.0
Example #6
Source File: calibrationFrameWidget.py From GroundControl with GNU General Public License v3.0 | 6 votes |
def on_Exit(self): ''' This function run when the process is completed or quit is pressed ''' App.get_running_app().data.calibrationInProcess = False App.get_running_app().data.message_queue.put("Message: Notice: Exiting the calibration process early may result in incorrect calibration.") #remove the old widget try: self.cFrameWidgetSpace.remove_widget(self.currentWidget) except: pass #there was no widget to remove self.done()
Example #7
Source File: measureDistBetweenMotors.py From GroundControl with GNU General Public License v3.0 | 6 votes |
def on_Enter(self): ''' This function runs when the step is entered ''' self.data = App.get_running_app().data self.data.measureRequest = self.readMotorSpacing self.originalChainOverSproketDir = App.get_running_app().data.config.get('Advanced Settings', 'chainOverSprocket') #pretend we are in the "Top" configuration during this step App.get_running_app().data.config.set('Advanced Settings', 'chainOverSprocket', 'Top') #set the threshold for warning that the machine is off target to 200mm essentially turning it off. We don't want this to trigger when pulling the chain tight self.data.gcode_queue.put("$42=2000 ")
Example #8
Source File: measureOneChain.py From GroundControl with GNU General Public License v3.0 | 6 votes |
def on_Enter(self): ''' This function runs when the step is entered ''' self.data = App.get_running_app().data self.data.measureRequest = self.readMotorSpacing self.originalChainOverSproketDir = self.data.config.get('Advanced Settings', 'chainOverSprocket') #pretend we are in the "Top" configuration during this step App.get_running_app().data.config.set('Advanced Settings', 'chainOverSprocket', 'Top') #set the threshold for warning that the machine is off target to 200mm esentially turning it off. We dont' want this to trigger when pulling the chain tight self.data.gcode_queue.put("$42=200 ")
Example #9
Source File: computeChainCorrectionFactors.py From GroundControl with GNU General Public License v3.0 | 6 votes |
def on_Enter(self): ''' This function runs when the step is entered ''' self.data = App.get_running_app().data try: self.leftCorrectionFactor = (abs(self.data.motorsDist - self.data.leftChainMeasurement)/self.data.leftChainMeasurement)*100.0 self.rightCorrectionFactor = (abs(self.data.motorsDist - self.data.rightChainMeasurement)/self.data.rightChainMeasurement)*100.0 self.selfText.text = ("When measured manually: " + str(self.data.motorsDist) + "\nWhen measured with the left chain:" + str(self.data.leftChainMeasurement) + "\nWhen measured with the right chain:" + str(self.data.rightChainMeasurement) + "\n\nLeft chain correction factor: " + str(self.leftCorrectionFactor) + "\nRight chain correction factor: " + str(self.rightCorrectionFactor) ) except: self.selfText.text = "unable to compute correction factors"
Example #10
Source File: configv2_editor.py From kivy-smoothie-host with GNU General Public License v3.0 | 6 votes |
def open(self): self.app = App.get_running_app() self.ids.placeholder.add_widget(Label(text='Loading....')) self.manager.current = 'config_editor' self.config = ConfigParser.get_configparser('Smoothie Config') if self.config is None: self.config = ConfigParser(name='Smoothie Config') else: for section in self.config.sections(): self.config.remove_section(section) # get config, parse and populate self.app.comms.redirect_incoming(self._add_line) # issue command self.app.comms.write('cat /sd/config.ini\n') self.app.comms.write('\n') # get an ok to indicate end of cat
Example #11
Source File: generalelements.py From Snu-Photo-Manager with GNU Lesser General Public License v3.0 | 6 votes |
def on_touch_down(self, touch): app = App.get_running_app() if self.collide_point(*touch.pos): if touch.is_double_tap and not app.shift_pressed: if self.displayable: if self.total_photos_numeric > 0: app.show_album(self) else: self.parent.selected = {} self.parent.selected = self.data self.on_press() if self.dragable: self.drag = True app = App.get_running_app() temp_coords = self.to_parent(touch.opos[0], touch.opos[1]) widget_coords = (temp_coords[0]-self.pos[0], temp_coords[1]-self.pos[1]) window_coords = self.to_window(touch.opos[0], touch.opos[1]) app.drag_treeview(self, 'start', window_coords, offset=widget_coords)
Example #12
Source File: reviewMeasurements.py From GroundControl with GNU General Public License v3.0 | 6 votes |
def on_Enter(self): ''' This function runs when the step is entered ''' self.data = App.get_running_app().data tempString = "Lets review the measurements to make sure everything looks good. You can use the back button to repeat any step.\n\nThe current values are:" tempString = tempString + "\nDistance between motors: " + self.data.config.get('Maslow Settings', 'motorSpacingX') + "mm" tempString = tempString + "\nVertical motor offset: " + self.data.config.get('Maslow Settings', 'motorOffsetY') + "mm" tempString = tempString + "\nKinematics type: " + self.data.config.get('Advanced Settings', 'kinematicsType') tempString = tempString + "\nChain feed type: " + self.data.config.get('Advanced Settings', 'chainOverSprocket') if self.data.config.get('Advanced Settings', 'kinematicsType') == 'Triangular': tempString = tempString + "\nRotation radius: " + self.data.config.get('Advanced Settings', 'rotationRadius') + "mm" tempString = tempString + "\nChain sag correction value: " + self.data.config.get('Advanced Settings', 'chainSagCorrection') else: tempString = tempString + "\nSled mount spacing: " + self.data.config.get('Maslow Settings', 'sledWidth') + "mm" self.measurementsReadout.text = tempString
Example #13
Source File: generalelements.py From Snu-Photo-Manager with GNU Lesser General Public License v3.0 | 5 votes |
def on_selected(self, *_): app = App.get_running_app() if self.selected: new_color = app.theme.selected else: new_color = [0, 0, 0, 0] if app.animations: anim = Animation(underlay_color=new_color, duration=app.animation_length) anim.start(self) else: self.underlay_color = new_color
Example #14
Source File: generalelements.py From Snu-Photo-Manager with GNU Lesser General Public License v3.0 | 5 votes |
def set_color(self): app = App.get_running_app() if self.selected: self.bgcolor = app.theme.selected else: if self.index % 2 == 0: self.bgcolor = app.list_background_even else: self.bgcolor = app.list_background_odd
Example #15
Source File: interpreterwrapper.py From Pyonic-interpreter with GNU General Public License v3.0 | 5 votes |
def __init__(self, service_name, use_thread=True, throttle_output=True, thread_name='default'): self.service_name = service_name self.register_event_type('on_execution_complete') self.register_event_type('on_missing_labels') self.register_event_type('on_stdout') self.register_event_type('on_stderr') self.register_event_type('on_notification') self.register_event_type('on_user_message') self.register_event_type('on_request_input') self.subprocess = None py_ver = sys.version_info.major offset = (py_ver % 2) * 2 self.interpreter_port = 3000 + offset + 4 * InterpreterWrapper.interpreter_number self.receive_port = 3001 + offset + 4 * InterpreterWrapper.interpreter_number InterpreterWrapper.interpreter_number += 1 self.use_thread = use_thread self.throttle_output = throttle_output self.thread_name = thread_name self.start_interpreter(thread_name) self.input_index = 0 # The current input number self.inputs = {} # All the inputs so far Clock.schedule_interval(self.read_osc_queue, 0.05) self.init_osc() self._interpreter_state = 'waiting' # This check_interpreter method is not reliable enough to enable yet. # App.get_running_app().bind(on_resume=self.check_interpreter)
Example #16
Source File: generalelements.py From Snu-Photo-Manager with GNU Lesser General Public License v3.0 | 5 votes |
def on_text(self, instance, text): del instance app = App.get_running_app() if self.blinker: self.stop_blinking() if text: no_bg = [.5, .5, .5, 0] yes_bg = app.theme.info_background self.blinker = Animation(bgcolor=yes_bg, duration=0.33) + Animation(bgcolor=no_bg, duration=0.33) + Animation(bgcolor=yes_bg, duration=0.33) + Animation(bgcolor=no_bg, duration=0.33) + Animation(bgcolor=yes_bg, duration=0.33) + Animation(bgcolor=no_bg, duration=0.33) + Animation(bgcolor=yes_bg, duration=0.33) + Animation(bgcolor=no_bg, duration=0.33) + Animation(bgcolor=yes_bg, duration=0.33) + Animation(bgcolor=no_bg, duration=0.33) + Animation(bgcolor=yes_bg, duration=0.33) + Animation(bgcolor=no_bg, duration=0.33) + Animation(bgcolor=yes_bg, duration=0.33) + Animation(bgcolor=no_bg, duration=0.33) self.blinker.start(self)
Example #17
Source File: generalelements.py From Snu-Photo-Manager with GNU Lesser General Public License v3.0 | 5 votes |
def on_touch_up(self, touch): super().on_touch_up(touch) if self.drag: app = App.get_running_app() window_coords = self.to_window(touch.pos[0], touch.pos[1]) app.drag(self, 'end', window_coords) self.drag = False
Example #18
Source File: interpreter.py From Pyonic-interpreter with GNU General Public License v3.0 | 5 votes |
def exec_file(self): App.get_running_app().root.switch_to( 'filechooser', open_method=self._exec_file, success_screen_name='interpreter', purpose='exec file')
Example #19
Source File: generalelements.py From Snu-Photo-Manager with GNU Lesser General Public License v3.0 | 5 votes |
def on_touch_down(self, touch): super().on_touch_down(touch) if self.collide_point(*touch.pos): if touch.is_double_tap: if not self.temporary and self.view_album: app = App.get_running_app() if not app.shift_pressed: app.show_album(self) return app = App.get_running_app() if app.shift_pressed: self.parent.select_range(self.index, touch) return self.parent.select_with_touch(self.index, touch) self.owner.update_selected() if self.dragable: thumbnail = self.ids['thumbnail'] self.drag = True app = App.get_running_app() temp_coords = self.to_parent(touch.opos[0], touch.opos[1]) widget_coords = (temp_coords[0] - thumbnail.pos[0], temp_coords[1] - thumbnail.pos[1]) window_coords = self.to_window(touch.pos[0], touch.pos[1]) try: num_photos = self.owner.get_selected_photos(fullpath=True) num_photos.append(self.fullpath) num_photos = len(set(num_photos)) except: num_photos = 1 app.drag(self, 'start', window_coords, image=self.image, offset=widget_coords, fullpath=self.fullpath, photos=num_photos)
Example #20
Source File: interpreter.py From Pyonic-interpreter with GNU General Public License v3.0 | 5 votes |
def ensure_ctrl_c_button(self): if not App.get_running_app().ctypes_working: return Clock.schedule_once(self._switch_to_ctrl_c_button, 0.4)
Example #21
Source File: generalelements.py From Snu-Photo-Manager with GNU Lesser General Public License v3.0 | 5 votes |
def on_touch_move(self, touch): if self.drag: delay = time.time() - touch.time_start if delay >= drag_delay: app = App.get_running_app() window_coords = self.to_window(touch.pos[0], touch.pos[1]) app.drag_treeview(self, 'move', window_coords)
Example #22
Source File: interpreter.py From Pyonic-interpreter with GNU General Public License v3.0 | 5 votes |
def __init__(self, *args, **kwargs): super(InterpreterGui, self).__init__(*args, **kwargs) self.animation = Animation(input_fail_alpha=0., t='out_expo', duration=0.5) self.interpreter = InterpreterWrapper( 'Interpreter', use_thread=True, throttle_output=App.get_running_app().setting__throttle_output, thread_name='interpreter') self.interpreter.bind(interpreter_state=self.setter('interpreter_state')) self.interpreter.bind(lock_input=self.setter('lock_input')) self.interpreter.bind(on_execution_complete=self.execution_complete) self.interpreter.bind(on_stdout=self.on_stdout) self.interpreter.bind(on_stderr=self.on_stderr) self.interpreter.bind(on_notification=self.on_notification) self.interpreter.bind(on_user_message=self.on_user_message) self.interpreter.bind(on_missing_labels=self.on_missing_labels) self.interpreter.bind(on_request_input=self.on_request_input) # self.interpreter = DummyInterpreter() # Clock.schedule_interval(self._dequeue_output_label, 0.05) # Clock.schedule_interval(self._clear_output_label_queue, 1) Clock.schedule_once(self.post_init_check, 0)
Example #23
Source File: filechooser.py From Pyonic-interpreter with GNU General Public License v3.0 | 5 votes |
def return_selection(self): if self.current_selection is None: return if self.open_method is None: return self.open_method(join(self.folder, self.current_selection.filename)) from kivy.app import App if self.success_screen_name: App.get_running_app().manager.switch_to(self.success_screen_name) else: App.get_running_app().manager.go_back()
Example #24
Source File: interpreterwrapper.py From Pyonic-interpreter with GNU General Public License v3.0 | 5 votes |
def start_interpreter(self, thread_name='default'): # if thread_name == 'interpreter': # return print('trying to start interpreter', self.service_name) interpreter_script_path = join(dirname(realpath(__file__)), 'interpreter_subprocess', 'interpreter.py') # prepare settings to send to interpreter # throttle_output = '1' if App.get_running_app().setting__throttle_output else '0' throttle_output = '1' if self.throttle_output else '0' use_thread = '1' if self.use_thread else '0' argument = ('throttle_output={}:use_thread={}:' 'send_port={}:receive_port={}').format( throttle_output, use_thread, self.receive_port, self.interpreter_port) if platform == 'android': from jnius import autoclass service = autoclass('{}.Service{}'.format(package_name, self.service_name)) mActivity = autoclass('org.kivy.android.PythonActivity').mActivity # service.start(mActivity, argument, thread_name) service.start(mActivity, argument) print('did service start', service, mActivity) else: # This may not actually work everywhere, but let's assume it does print('starting subprocess') python_name = 'python{}'.format(sys.version_info.major) print('python name is', python_name) os.environ['PYTHON_SERVICE_ARGUMENT'] = argument s = subprocess.Popen([python_name, '{}'.format(interpreter_script_path)]) App.get_running_app().subprocesses.append(s) self.subprocess = s pass
Example #25
Source File: settings.py From Pyonic-interpreter with GNU General Public License v3.0 | 5 votes |
def setting_updated(self, setting, instance, value): setattr(App.get_running_app(), setting, value)
Example #26
Source File: measureDistBetweenMotors.py From GroundControl with GNU General Public License v3.0 | 5 votes |
def on_Exit(self): ''' This function run when the process is completed or quit is pressed ''' #Restore original chain over sprocket direction App.get_running_app().data.config.set('Advanced Settings', 'chainOverSprocket', self.originalChainOverSproketDir) #restore all settings to the values stored in the current settings file self.data.gcode_queue.put("$$ ")
Example #27
Source File: enterDistanceBetweenMotors.py From GroundControl with GNU General Public License v3.0 | 5 votes |
def on_Enter(self): ''' This function runs when the step is entered ''' self.data = App.get_running_app().data
Example #28
Source File: triangularCalibration.py From GroundControl with GNU General Public License v3.0 | 5 votes |
def on_Enter(self): ''' This function runs when the step is entered ''' self.data = App.get_running_app().data
Example #29
Source File: setSprocketsVertical.py From GroundControl with GNU General Public License v3.0 | 5 votes |
def on_Enter(self): ''' This function runs when the step is entered ''' self.data = App.get_running_app().data
Example #30
Source File: rotationRadiusGuess.py From GroundControl with GNU General Public License v3.0 | 5 votes |
def on_Enter(self): ''' This function runs when the step is entered ''' self.data = App.get_running_app().data