Exemple #1
0
    def plot(self, Rs=None, Vg=0):
        pg.setConfigOption('background', 'w')
        pg.setConfigOption('foreground', 'k')

        # Generate plot
        plt = pg.plot(title=self.__class__.__name__, clear=True)
        plt.setYRange(0, self.IDSS_MAX)
        plt.setXRange(self.VP_MAX, 0)
        plt.showGrid(True, True, 1.0)
        plt.setLabel('left', "Id (mA)")
        plt.setLabel('bottom', "Vgs (V)")

        (x, y) = self.id_max_points()
        plt.plot(x, y, pen=pg.mkPen('g', width=3))

        (x, y) = self.id_min_points()
        plt.plot(x, y, pen=pg.mkPen('b', width=3))

        if Rs is not None:
            (x, y) = self.vg_intercept(Rs, Vg)
            plt.plot(x, y, pen=pg.mkPen('r', width=3))

        # Display plot
        QtGui.QApplication.instance().exec_()
        pg.exit()
Exemple #2
0
def update():
    global curve_01, curve_02, data_01, data_02, ptr, p1, p2, fps_counter
    data = readfun()
    eeg_01.append(data[0])
    del eeg_01[0]
    eeg_02.append(data[1])
    del eeg_02[0]
#     curve_01.setData(data[0])
#     curve_02.setData(data[1])

    # lane used for benchmarking
    fps_counter += 1
    print(fps_counter)
    if fps_counter == 24000:
        elapsed_time = time.time() - start_time
        print('')
        print(elapsed_time)
        pg.exit()

    curve_01.setData(eeg_01)
    curve_02.setData(eeg_02)
    if ptr == 0:
        p1.enableAutoRange('xy', False)
        p2.enableAutoRange('xy', False)    
    ptr += 1

    print(len(eeg_01))
Exemple #3
0
def on_press(key):
    check = 0 if keys.pop() != Key.shift else 2
    if key == KeyCode(char='b'):
        Cubies[0, :, :] = v.rotate(Cubies[0, :, :], check,
                                   (1, 0, 0))  #Back Face
    elif key == KeyCode(char='f'):
        Cubies[2, :, :] = v.rotate(Cubies[2, :, :], check,
                                   (1, 0, 0))  #Front Face
    elif key == KeyCode(char='l'):
        Cubies[:, 0, :] = v.rotate(Cubies[:, 0, :], check,
                                   (0, 1, 0))  #Left Face
    elif key == KeyCode(char='r'):
        Cubies[:, 2, :] = v.rotate(Cubies[:, 2, :], check,
                                   (0, 1, 0))  #Right Face
    elif key == KeyCode(char='d'):
        Cubies[:, :, 0] = v.rotate(Cubies[:, :, 0], check,
                                   (0, 0, 1))  #Down Face
    elif key == KeyCode(char='u'):
        Cubies[:, :, 2] = v.rotate(Cubies[:, :, 2], check, (0, 0, 1))  #Up Face
    keys.append(key)
    if key == Key.space:
        # randomize(30)
        algo()
    if key == Key.enter:
        v.w.opts['fov'] = 70
        v.w.opts['elevation'] = 25
        v.w.opts['azimuth'] = 30
        v.update()
    if key == Key.esc:
        pg.exit()
Exemple #4
0
    def _run(self):
        # Sanity check and warning if pyqtgraph isn't found
        if self.do_plot:
            try:
                import pyqtgraph as pg
            except ImportError as e:
                binwalk.core.common.warning(
                    "Failed to import pyqtgraph module, visual entropy graphing will be disabled")
                self.do_plot = False

        for fp in iter(self.next_file, None):

            if self.display_results:
                self.header()

            self.calculate_file_entropy(fp)

            if self.display_results:
                self.footer()

        if self.do_plot:
            if not self.save_plot:
                from pyqtgraph.Qt import QtGui
                QtGui.QApplication.instance().exec_()
            pg.exit()
Exemple #5
0
    def _run(self):
        # Sanity check and warning if pyqtgraph isn't found
        if self.do_plot:
            try:
                import pyqtgraph as pg
            except ImportError as e:
                binwalk.core.common.warning(
                    "Failed to import pyqtgraph module, visual entropy graphing will be disabled"
                )
                self.do_plot = False

        for fp in iter(self.next_file, None):

            if self.display_results:
                self.header()

            self.calculate_file_entropy(fp)

            if self.display_results:
                self.footer()

        if self.do_plot:
            if not self.save_plot:
                from pyqtgraph.Qt import QtGui
                QtGui.QApplication.instance().exec_()
            pg.exit()
Exemple #6
0
 def _print_error(self, curve_name):
     """Print Error in case of curve name problem with rt plot """
     if self.is_rt is True:
         print("ERROR : The curve '" + curve_name + "'' is not present in")
         print(
             "the configuration file, but a point has to be added to this")
         print("curve.")
         pg.exit()
Exemple #7
0
def main(arglist):
    app = QApplication([])
    app.aboutToQuit.connect(app.deleteLater)
    # gui = interface.GUI(display)
    gui = GUI()
    app.exec_()
    save_answer(gui.lcdNumber.value(), module, question, True)
    pg.exit()
Exemple #8
0
def main():

    # run application
    app = QtGui.QApplication(sys.argv)
    Iltis = Main(verbose=True)
    return_code = app.exec_()
    
    if return_code != 0:
        print "exiting with return code: ", return_code
        
    # after closing MainWindow, do cleanup and exit
    pg.exit() # the exit hammer
    pass
Exemple #9
0
def main():

    # run application
    app = QtWidgets.QApplication(sys.argv)
    Iltis = Main(verbose=True)
    return_code = app.exec_()

    if return_code != 0:
        print(("exiting with return code: ", return_code))

    # after closing MainWindow, do cleanup and exit
    pg.exit()  # the exit hammer
    pass
Exemple #10
0
    def run(self):
        for fp in iter(self.next_file, None):

            if self.display_results:
                self.header()

            self.calculate_file_entropy(fp)

            if self.display_results:
                self.footer()

        if self.do_plot:
            import pyqtgraph as pg

            if not self.save_plot:
                from pyqtgraph.Qt import QtGui
                QtGui.QApplication.instance().exec_()

            pg.exit()
Exemple #11
0
    def run(self):
        for fp in iter(self.next_file, None):

            if self.display_results:
                self.header()

            self.calculate_file_entropy(fp)

            if self.display_results:
                self.footer()

        if self.do_plot:
            import pyqtgraph as pg

            if not self.save_plot:
                from pyqtgraph.Qt import QtGui
                QtGui.QApplication.instance().exec_()

            pg.exit()
Exemple #12
0
def run(debug=False):
    fn.set_process_id("radie")
    # fn.setup_style()
    app = fn.instantiate_app(sys.argv)

    fn.set_popup_exceptions()
    cfg.set_dpi_scaling()
    main_window = MainWindow()
    main_window.show()

    if debug:
        from radie.plugins import examples
        main_window.treeView_dataFrames.addDataFrame(examples.example_powderdiffraction())
        main_window.treeView_dataFrames.addDataFrame(examples.example_vsm())

    # sys.exit(app.exec_())
    # use pyqtgraph.exit to avoid crashes on exit
    # https://stackoverflow.com/questions/27131294/error-qobjectstarttimer-qtimer-can-only-be-used-with-threads-started-with-qt
    app.exec_()
    pg.exit()
Exemple #13
0
    def closeEvent(self, event):
        # safe_exit_confirmed = False

        # self.send_msg_to_controllers(Message.EXIT)

        # while not safe_exit_confirmed:
        #     if self.main_controller.search(Message.SAFE_TO_EXIT):
        #         safe_exit_confirmed = True

        # self.main_controller.send(Message.GUI_EXIT)
        if FeatureFlags.BOARD:
            self.send_msg_to_controllers(Message.EXIT)

            safe_exit(self.board, self.main_controller, [
                self.tagger_biosignal,
            ])

            self.main_controller.send(Message.GUI_EXIT)

        pg.exit()
        event.accept()
Exemple #14
0
def main():
    """Read the configuration file, the data file and plot"""
    parser = argparse.ArgumentParser(description="Plot datas from a CSV file")

    parser.add_argument("data_file_list",
                        metavar="DATAFILE",
                        nargs="*",
                        help="Input CSV data files")

    parser.add_argument("-c",
                        "--configFile",
                        dest="config_file",
                        default=DEFAULT_CONFIG_FILE,
                        help="configuration plot file\
                        (default: " + DEFAULT_CONFIG_FILE + ")")

    parser.add_argument("-p",
                        "--printable",
                        dest="printable",
                        action="store_const",
                        const=True,
                        default=False,
                        help="add option to run printable easy_plotter")

    parser.add_argument("-rx",
                        "--resolution-x",
                        dest="res_x",
                        default=DEFAULT_RESOLUTION_X,
                        type=int,
                        help="X resolution of window\
                        (default: " + str(DEFAULT_RESOLUTION_X) + ")")

    parser.add_argument("-ry",
                        "--resolution-y",
                        dest="res_y",
                        default=DEFAULT_RESOLUTION_Y,
                        type=int,
                        help="Y resolution of window\
                        (default: " + str(DEFAULT_RESOLUTION_Y) + ")")

    parser.add_argument("-i",
                        "--IP",
                        dest="server_ip",
                        default=None,
                        help="server IP address")

    parser.add_argument("-po",
                        "--port",
                        dest="port",
                        default=DEFAULT_PORT,
                        type=int,
                        help="server port (default: " + str(DEFAULT_PORT) +
                        ")")

    parser.add_argument("-r",
                        "--refresh-period",
                        dest="refresh_period",
                        type=float,
                        default=DEFAULT_REFRESH_PERIOD,
                        help="refresh period for real time plot\
                        (default: 0.1s)")

    parser.add_argument("-s",
                        "--sort",
                        dest="sort",
                        action="store_const",
                        const=True,
                        default=False,
                        help="sort datas on abscissa\
                        (automatic with several data files)")

    parser.add_argument("-v",
                        "--version",
                        action="version",
                        version="%(prog)s " + VERSION)

    args = parser.parse_args()

    config_file = args.config_file
    data_file_list = args.data_file_list
    res_x = args.res_x
    res_y = args.res_y
    server_ip = args.server_ip
    port = args.port
    refresh_period = args.refresh_period
    printable = args.printable
    sort = args.sort

    if len(data_file_list) > 1 and sort is False:
        yes = set(['YES', 'Y', 'yes', 'y', 'ye', ''])
        no_ = set(['NO', 'N', 'no', 'n'])
        continu = True
        while continu:
            print("You have parsed several data files.")
            print("Do you want to sort datas on abscissa? (Yes/no)")
            choice = raw_input().lower()
            if choice in yes:
                sort = True
                continu = False
                print("Abscissa's datas will be sorted by ascending order")
            elif choice in no_:
                continu = False
            else:
                sys.stdout.write("Please respond with 'yes' or 'no'")

    if server_ip and data_file_list:
        print("Please chose plotting datas from a file OR from a server.")
        print("If using option '-i' or '--IP', please do not specify a")
        print("data file to read.'")
        pg.exit()

    # Test if configuration file exists
    if not os.path.isfile(config_file):
        print("ERROR : File '" + config_file + "' cannot be found")
        pg.exit()

    # Test if all data files exist
    for data_file in data_file_list:
        if not os.path.isfile(data_file):
            print("ERROR : File '" + data_file + "' cannot be found")
            pg.exit()

    # Create the window
    if server_ip is not None:
        win = Window(config_file=args.config_file,
                     res_x=res_x,
                     res_y=res_y,
                     printable=printable,
                     is_rt=True)
    else:
        win = Window(config_file=args.config_file,
                     res_x=res_x,
                     res_y=res_y,
                     printable=printable,
                     is_rt=False)

    abscissa = win.abscissa

    # Plotting from CSV files
    csv_dic = {}
    element_number = 0
    for data_file in data_file_list:
        dic_data = csv.DictReader(open(data_file))

        element_number = 0
        for index, row in enumerate(dic_data):
            # Test if abscissa key exist in dic_data
            if not index:
                if abscissa not in row:
                    print("ERROR : '%s' not find in File '%s'\
                    " % (abscissa, data_file))
                    pg.exit()

            test_datax_flag = False
            try:
                data_x = float(row[abscissa])
                test_datax_flag = True
            except BaseException:
                print("WARNING: a data x value is not a number")

            if test_datax_flag is True:
                for key, value in row.items():
                    test_datay_flag = False
                    if value is not None:
                        try:
                            data_y = float(value)
                            test_datay_flag = True
                        except (TypeError, ValueError):
                            print("WARNING: " + str(value) + " in " +
                                  str(key) + " is not a number")
                            pg.exit()
                    else:
                        print("WARNING: None Value in " + str(key))

                    if test_datay_flag is True:
                        data = Data(data_x, data_y)
                        cur_curve = csv_dic.setdefault(key, {})
                        cur_curve.update({element_number: data})
                        element_number += 1

    if len(data_file_list) > 0:
        win.check_curves_in_csv(csv_dic.keys())

    for curve in csv_dic.keys():

        datas_x = []
        datas_y = []

        datas_num = csv_dic[curve].keys()

        if sort is True:
            datas_dic = {}
            for num in datas_num:
                datas_dic[csv_dic[curve]
                          [num].data_x] = csv_dic[curve][num].data_y

            datas_x = datas_dic.keys()
            datas_x.sort()

            for x_value in datas_x:
                datas_y.append(datas_dic[x_value])

        else:
            datas_num.sort()

            for num in datas_num:
                datas_x.append(csv_dic[curve][num].data_x)
                datas_y.append(csv_dic[curve][num].data_y)

        for data_x, data_y in zip(datas_x, datas_y):
            win.add_point(curve, data_x, data_y, False)

    for curve in win.curves:
        win.curve_display(curve)

    # In case of plotting from CSV file(s), hide buttons
    if not server_ip and printable is False:
        for fig in win.figures.values():
            fig.button.hide_all()

    # In case of plotting from a socket, begin to ask (in another thread)
    # if datas are avaible and plot them
    if server_ip is not None:
        thread = threading.Thread(target=easy_plot_connection.Client,
                                  args=(win, server_ip, port, refresh_period))
        thread.daemon = True
        thread.start()

    win.run()
Exemple #15
0
 def run(self):
     """Public method : Run application"""
     if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
         self.app.instance().exec_()
         print
         pg.exit()
Exemple #16
0
    def __init__(self,
                 config_file=DEFAULT_CONFIG_FILE,
                 res_x=DEFAULT_RESOLUTION_X,
                 res_y=DEFAULT_RESOLUTION_Y,
                 printable=False,
                 is_rt=False):
        parameters = read_cfg.Parameters(config_file)

        self.app = QtGui.QApplication([])
        self.app.setOrganizationName('Aldebaran')
        self.app.setOrganizationDomain('aldebaran.com')
        self.app.setApplicationName('Easy Plot')

        self.max_time = parameters.max_time
        self.title = parameters.title
        self.abscissa = parameters.abscissa
        self.label_x = parameters.label_x
        self.unit_x = parameters.unit_x
        self.anti_aliasing = parameters.anti_aliasing
        self.link_x_all = parameters.link_x_all
        self.printable = printable
        self.is_rt = is_rt

        pg.setConfigOption('background', 'k')  # 101010')
        pg.setConfigOption('foreground', 'w')

        if printable is not False:
            self.window = pg.GraphicsWindow(title=self.title, border=True)
        else:
            self.window = QtGui.QWidget()
            self.window.setStyleSheet("QWidget {background-color: #111111 }")
            self.layout = QtGui.QGridLayout()

        self.window.setWindowTitle(self.title)
        self.window.resize(res_x, res_y)

        pg.setConfigOptions(antialias=self.anti_aliasing)

        # A figure contains 0 or more curves
        self.figures = {}

        # A curve belong to exactly one figure
        self.curves = {}

        # Populate the figures dictionnary
        for pos, figure_param in parameters.figures.items():
            row = pos[0]
            column = pos[1]

            if printable is not False:
                win = self.window
            else:
                win = self.layout

            self.figures[pos] = Figure(win,
                                       row,
                                       column,
                                       self.max_time,
                                       figure_param.title,
                                       self.label_x,
                                       self.unit_x,
                                       figure_param.label_y,
                                       figure_param.unit_y,
                                       figure_param.min_y,
                                       figure_param.max_y,
                                       figure_param.grid_x,
                                       figure_param.grid_y,
                                       printable=printable)

        viewbox_prec = None

        for pos, figure_param in parameters.figures.items():
            row = pos[0]
            column = pos[1]

            if self.link_x_all is False:
                if figure_param.link is not None:
                    try:
                        self.figures[pos].link = self.figures[
                            figure_param.link]  # .viewbox
                        self.figures[pos].define_link()
                    except (IndexError, KeyError):

                        figure1 = "[" + str(row) + "-" + str(column) + "]"
                        figure2 = str(figure_param.link).replace(", ", "-")
                        figure2 = figure2.replace("(", "[")
                        figure2 = figure2.replace(")", "]")

                        print("ERROR: Figure " + figure1)
                        print("       can't be linked with figure " + figure2)
                        print("       because this figure doesn't exist")
                        print("       Please, check configuration file")
                        pg.exit()
            else:
                if viewbox_prec is not None:
                    self.figures[pos].link = viewbox_prec
                    self.figures[pos].define_link()

                viewbox_prec = self.figures[pos]  # .viewbox

        # Populate the curves dictionnary
        for name, curve_param in parameters.curves.items():
            curve_row = curve_param.row
            curve_column = curve_param.column

            try:
                figure = self.figures[(curve_row, curve_column)]
            except KeyError:
                txt = "[" + str(curve_row) + "-" + str(curve_column) + "]"
                print("ERROR: Curve " + name + " is define at " + txt)
                print("       but there is no figure at these coordonates")
                print("       Please, check configuration file")
                pg.exit()

            plot = figure.plot_widget.plot(pen=curve_param.color,
                                           name=curve_param.legend)

            curve = Curve(curve_param.legend, curve_param.color, plot)

            self.curves[name] = curve
            self.figures[(curve_row, curve_column)].curves_list.append(curve)

        if self.printable is False:
            self.window.setLayout(self.layout)

            if self.is_rt is True:
                for fig in self.figures.values():

                    if fig.link is None:
                        fig.button.btn1.setText("Auto Scale: ON")
                        fig.button.btn2.setText("Auto Range: ON")
                        fig.button.auto_scale = 1
                        fig.button.auto_range = 1

                    fig.button.timer_btn.timeout.connect(fig.button.update)
                    fig.button.timer_btn.start(PERIOD_CHECK_BUTTON)

                    fig.button.timer_action.timeout.connect(fig.action_button)
                    fig.button.timer_action.start(PERIOD_CHECK_ACTION)

        self.window.show()
Exemple #17
0
 def closeApp(self):
     pg.exit()
Exemple #18
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 24 11:03:55 2015

@author: yboetz
"""

import pyqtgraph as pg
from pyqtgraph.Qt import QtGui
from qtwindow import MainWindow


if __name__ == "__main__":
    # Start Qt applicatoin
    app = QtGui.QApplication([])
    # Create main window
    win = MainWindow()
    app.exec()
    pg.exit()
Exemple #19
0
 def stop_button_function(self):
     save_answer(self.lcdNumber.value(), module, question, False)
     pg.exit()
            if display: display.send_pixels(pixels)

            gui.update_fps(len(frame_times))
            if not audio.is_paused:
                gui.update_time(t)
            gui.update_pixels(pixels)

            gui.app.processEvents()

            if gui.pause_requested:
                gui.pause_requested = False
                if not audio.is_paused:
                    audio.pause()
                else:
                    audio.unpause()

            if display and not display.running:
                break
    except:
        traceback.print_exc()
    finally:
        audio.stop()
        if display: display.stop()    
        gui.stop()

        util.timer()

        import pyqtgraph
        pyqtgraph.exit()
def main():
    app = QApplication(sys.argv)
    window = Ui()
    window.show()
    app.exec_()
    pg.exit()