def kpf_change_y_lims(self, symbol, modifiers, mod_offset): do_resize = 0 key_matched = False if symbol == key.Y: # set y lims explicitly key_matched = True lower = False # upper limit is default. if modifiers == key.MOD_CTRL + mod_offset: # GUI to change both values if not self.SETTINGS.TKINTER_AVAILABLE: print "GUI is not working on your machine." else: try: from pyglet_app_tkinter_dialogs import get_two_inputs a = get_two_inputs() a.run('change y limits', 'y min', 'y max', self.Y_LIMS[0], self.Y_LIMS[1]) # user submitting at least one new value. if a.dialog.result: self.Y_LIMS = check_y_lims(self.Y_LIMS, a.dialog.result[0], 0) self.Y_LIMS = check_y_lims(self.Y_LIMS, a.dialog.result[1], 1) do_resize = 1 except Exception, e: pass print "An error occurred:" print e elif modifiers == key.MOD_SHIFT + mod_offset: # lower limit? lower = True # 'y' and 'Y' cases. if not (modifiers == key.MOD_CTRL + mod_offset): while 1: if lower: strg = 'lower' index = 0 else: strg = 'upper' index = 1 t = raw_input( 'Please provide %s y limit (currently %s) and press ENTER: ' % (strg, self.Y_LIMS[index])) if len(t) == 0: break try: new_value = float(t) self.Y_LIMS = check_y_lims(self.Y_LIMS, new_value, index) do_resize = 1 except Exception, e: # print "Error in 'kpf_change_y_lims()': ", e pass print "non numeric value given - will ignore and keep old threshold" break
def kpf_change_y_lims(self, symbol, modifiers, mod_offset): do_resize = 0 key_matched = False if symbol == key.Y: # set y lims explicitly key_matched = True lower = False # upper limit is default. if modifiers == key.MOD_CTRL + mod_offset: # GUI to change both values if not self.SETTINGS.TKINTER_AVAILABLE: print "GUI is not working on your machine." else: try: from pyglet_app_tkinter_dialogs import get_two_inputs a = get_two_inputs() a.run("change y limits", "y min", "y max", self.Y_LIMS[0], self.Y_LIMS[1]) # user submitting at least one new value. if a.dialog.result: self.Y_LIMS = check_y_lims(self.Y_LIMS, a.dialog.result[0], 0) self.Y_LIMS = check_y_lims(self.Y_LIMS, a.dialog.result[1], 1) do_resize = 1 except Exception, e: pass print "An error occurred:" print e elif modifiers == key.MOD_SHIFT + mod_offset: # lower limit? lower = True # 'y' and 'Y' cases. if not (modifiers == key.MOD_CTRL + mod_offset): while 1: if lower: strg = "lower" index = 0 else: strg = "upper" index = 1 t = raw_input( "Please provide %s y limit (currently %s) and press ENTER: " % (strg, self.Y_LIMS[index]) ) if len(t) == 0: break try: new_value = float(t) self.Y_LIMS = check_y_lims(self.Y_LIMS, new_value, index) do_resize = 1 except Exception, e: # print "Error in 'kpf_change_y_lims()': ", e pass print "non numeric value given - will ignore and keep old threshold" break
def change_y_values_GUI(self): do_resize = 0 if not self.mainapp.SETTINGS.TKINTER_AVAILABLE: print "GUI is not working on your machine." else: try: from pyglet_app_tkinter_dialogs import get_two_inputs a = get_two_inputs() a.run('change y limits', 'y min', 'y max', self.mainapp.Y_LIMS[0], self.mainapp.Y_LIMS[1]) # user submitting at least one new value. if a.dialog.result: self.mainapp.Y_LIMS = check_y_lims(self.mainapp.Y_LIMS, a.dialog.result[0], 0) self.mainapp.Y_LIMS = check_y_lims(self.mainapp.Y_LIMS, a.dialog.result[1], 1) self.mainapp.Y_LIMS = sorted(self.mainapp.Y_LIMS) do_resize = 1 except Exception, e: pass print "An error occurred:" print e