def set_position_horizontal_line(self, SETTINGS, label_strg = 'pleave provide input', cmd_line_string = 'please provide input and press ENTER', window_title = 'window'): got_value, new_value = one_input(SETTINGS, label_strg, cmd_line_string, window_title) # nothing given - return. if not got_value: return # save the new value self.write_position_horizontal_line(new_value)
def on_key_press(self, symbol, modifiers): ''' basic kpf ''' if symbol == key.A: # show / hide axes if modifiers == key.MOD_CTRL + self.mod_offset: if self.SHOW_AXES: self.coord_axes, self.y_axis_tics, self.SHOW_AXES = False, False, False else: self.SHOW_AXES = True self.coord_axes, self.y_axis_tics = axes_default_with_y_ticks(self) elif symbol == key.C: self.plot_queue = setup_plotting_queue() print "Cleared Plot-Queue" elif symbol == key.F: # show / hide FPS display self.SHOW_FPS = not self.SHOW_FPS elif symbol == key.H: # show help menu from pyglet_app_strings import main_help_menu # the tkinterface is currently buggy - show console output by default. if self.SETTINGS.TKINTER_AVAILABLE and (modifiers == key.MOD_CTRL + self.mod_offset): from pyglet_app_tkinter_dialogs import text_info help_win = text_info() help_win.run('help', main_help_menu) else: print main_help_menu elif symbol == key.P: # switch between plotting modes from pyglet_app_screen_update_elements_static_line import StaticLineUpdateScreen from pyglet_app_screen_update_elements_moving_line import MovingLineUpdateScreen # we have three different modes currently that we can choose from. self._screen_update_mode = (self._screen_update_mode + 1) % 3 if self._screen_update_mode == 0: current_screen = StaticLineUpdateScreen mode = 0 elif self._screen_update_mode == 1: current_screen = StaticLineUpdateScreen mode = 1 elif self._screen_update_mode == 2: current_screen = MovingLineUpdateScreen mode = None self.clearCurrentScreen() self.set_current_screen(current_screen) self.current_screen.mode = mode self.startCurrentScreen() elif symbol == key.Q: # show number of elements in plot queue print "Plot-Queue size: %d" % (len(self.plot_queue)) elif symbol == key.S: # take screenshot of current screen content if (modifiers == key.MOD_SHIFT + self.mod_offset): # set screenshot path label_strg = 'Screenshot path ' if self.SETTINGS.SCREENSHOT_PATH is not None: label_strg = label_strg + '(currently %s) '%self.SETTINGS.SCREENSHOT_PATH got_value, new_value = one_input(self.SETTINGS, label_strg, 'Please provide new Screenshot path and press ENTER: ', 'Screenshot path') # nothing given - return. if not got_value: return # replace '\' with '/' because path.join() transforms everything to '/' notation. self.SETTINGS.SCREENSHOT_PATH = new_value.replace('\\', '/') elif not (modifiers == key.MOD_CTRL + self.mod_offset): try: now = datetime.now().strftime("%Y-%m-%d--%H-%M-%S") filename = 'Screenshot-from-%s---%s.png' %(now, self.PLUGIN_NAME) if self.SETTINGS.SCREENSHOT_PATH is not None: filename = os.path.join(self.SETTINGS.SCREENSHOT_PATH, filename) pyglet.image.get_buffer_manager().get_color_buffer().save(filename) print 'File "%s" saved.' % filename except Exception, e: print "An error occurred while saving the screenshot: " print e pass