def build(master=None, initialcolor=None, initfile=None, ignore=None): # create the windows and go for f in RGB_TXT: try: colordb = ColorDB.get_colordb(f) if colordb: break except IOError: pass else: usage(1, 'No color database file found, see the -d option.') # create all output widgets s = Switchboard(colordb, not ignore and initfile) # create the application window decorations app = PyncheWidget(__version__, s, master=master) w = app.window() s.add_view(StripViewer(s, w)) s.add_view(ChipViewer(s, w)) s.add_view(TypeinViewer(s, w)) # get the initial color as components and set the color on all views. if # there was no initial color given on the command line, use the one that's # stored in the option database if initialcolor is None: optiondb = s.optiondb() red = optiondb.get('RED') green = optiondb.get('GREEN') blue = optiondb.get('BLUE') # but if there wasn't any stored in the database, use grey50 if red is None or blue is None or green is None: red, green, blue = initial_color('grey50', colordb) else: red, green, blue = initial_color(initialcolor, colordb) s.update_views(red, green, blue) return app, s
"""Pynche -- The PYthon Natural Color and Hue Editor.
def build(master=None, initialcolor=None, initfile=None, ignore=None, dbfile=None): # create all output widgets s = Switchboard(not ignore and initfile) # defer to the command line chosen color database, falling back to the one # in the .pynche file. if dbfile is None: dbfile = s.optiondb().get('DBFILE') # find a parseable color database colordb = None files = RGB_TXT[:] if dbfile is None: dbfile = files.pop() while colordb is None: try: colordb = ColorDB.get_colordb(dbfile) except (KeyError, IOError): pass if colordb is None: if not files: break dbfile = files.pop(0) if not colordb: usage(1, 'No color database file found, see the -d option.') s.set_colordb(colordb) # create the application window decorations app = PyncheWidget(__version__, s, master=master) w = app.window() # these built-in viewers live inside the main Pynche window s.add_view(StripViewer(s, w)) s.add_view(ChipViewer(s, w)) s.add_view(TypeinViewer(s, w)) # get the initial color as components and set the color on all views. if # there was no initial color given on the command line, use the one that's # stored in the option database if initialcolor is None: optiondb = s.optiondb() red = optiondb.get('RED') green = optiondb.get('GREEN') blue = optiondb.get('BLUE') # but if there wasn't any stored in the database, use grey50 if red is None or blue is None or green is None: red, green, blue = initial_color('grey50', colordb) else: red, green, blue = initial_color(initialcolor, colordb) s.update_views(red, green, blue) return app, s
def build(master=None, initialcolor=None, initfile=None, ignore=None): # create all output widgets s = Switchboard(not ignore and initfile) # load the color database colordb = None try: dbfile = s.optiondb()['DBFILE'] colordb = ColorDB.get_colordb(dbfile) except (KeyError, IOError): # scoot through the files listed above to try to find a usable color # database file for f in RGB_TXT: try: colordb = ColorDB.get_colordb(f) if colordb: break except IOError: pass if not colordb: usage(1, 'No color database file found, see the -d option.') s.set_colordb(colordb) # create the application window decorations app = PyncheWidget(__version__, s, master=master) w = app.window() # these built-in viewers live inside the main Pynche window s.add_view(StripViewer(s, w)) s.add_view(ChipViewer(s, w)) s.add_view(TypeinViewer(s, w)) # get the initial color as components and set the color on all views. if # there was no initial color given on the command line, use the one that's # stored in the option database if initialcolor is None: optiondb = s.optiondb() red = optiondb.get('RED') green = optiondb.get('GREEN') blue = optiondb.get('BLUE') # but if there wasn't any stored in the database, use grey50 if red is None or blue is None or green is None: red, green, blue = initial_color('grey50', colordb) else: red, green, blue = initial_color(initialcolor, colordb) s.update_views(red, green, blue) return app, s
if __name__ == '__main__': # load probe parameters probe_fit = np.load("probe_fit_inverse_2.npy") p_probe = np.poly1d(probe_fit) # user defined settings minvoltage = 300 maxvoltage = 4800 stepvoltage = 50 delay_sw_s = 1.5 t = 1 # Durée d'acquisition (s) # init switchboard: connect, 0V, set coefficients for y=x (0,1,0) sw = Switchboard() sw.open() # set min and max voltage so that we can perform the calibration and the calibrated range will be the allowed range sw.set_maximum_voltage(maxvoltage) sw.set_minimum_voltage(minvoltage) sw.set_voltage(0) sw.set_output_on() sw.reset_calibration_coefficients() time.sleep(1) # init DaqMx mesureAnalogique = DaqMx() sampling_freq = 1000 # Fréquence d'echantillonnage (Hz) target_voltages = np.array(range(minvoltage, maxvoltage + 1, stepvoltage))