Beispiel #1
0
    def init_ui(self):

        f0 = self.engine.get_frame(self)
        #create graph!
        #Figure: The top level container for all the plot elements.
        self.fig = Figure()
        self.fig.subplots_adjust(hspace=1.0)
        self.canvas = FigureCanvasTkAgg(self.fig, f0)
        toolbar = nav_tool(self.canvas, f0)
        toolbar.update()
        self.canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=1)

        f0.pack(fill=tk.BOTH, expand=1)
Beispiel #2
0
    def init_ui(self):

        f0 = self.nametowidget(".").engine.get_frame(self)

        #create graph!
        #Figure: The top level container for all the plot elements.
        self.fig = Figure()
        #self.fig.subplots_adjust(bottom=0.10, right=0.98, left=0.10, top=0.88,wspace=0.08)
        self.fig.subplots_adjust(hspace=0.65, left=0.125, right=0.9)
        self.canvas = FigureCanvasTkAgg(self.fig, f0)
        toolbar = nav_tool(self.canvas, f0)
        toolbar.update()
        self.canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=1)

        f0.pack(fill=tk.BOTH, expand=1)
Beispiel #3
0
    def init_ui(self):

        f0 = self.engine.get_frame(self)

        #create graph!
        #Figure: The top level container for all the plot elements.
        #figsize:width, height in inches, figsize=(6.4, 4.8)
        self.fig = Figure()
        #fig.suptitle(self.engine.title, fontsize=20,fontweight='bold')
        #self.fig.subplots_adjust(bottom=0.10, right=0.98, left=0.10, top=0.88,wspace=0.08)
        self.fig.subplots_adjust(hspace=0.65, left=0.125, right=0.9)
        self.canvas = FigureCanvasTkAgg(self.fig, f0)
        toolbar = nav_tool(self.canvas, f0)
        toolbar.update()
        self.canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=1)

        f0.pack(fill=tk.BOTH, expand=1)
Beispiel #4
0
    def init_ui(self):

        self.pack(
            fill=BOTH,
            expand=1,
        )

        #-----------------------------------------------------------------------
        f0 = Frame(self, bd=5)

        w = LabelFrame(f0, text='Tests')
        self.cbTests = ttk.Combobox(w)
        self.cbTests.bind("<<ComboboxSelected>>", self.on_selected_test)
        self.cbTests.pack(side=TOP, fill=X, expand=0)
        w.pack(side=TOP, fill=X, expand=0)

        w = LabelFrame(f0, text='Batchs')
        self.lstBatchs = self.engine.get_listbox(w, height=5)
        self.lstBatchs.bind("<<ListboxSelect>>", self.on_selected_batch)
        self.lstBatchs.bind('<Button-3>', self.on_batch_activated)
        w.pack(side=TOP, fill=BOTH, expand=0)

        f1 = Frame(f0, bd=5)
        w = LabelFrame(f1, text='Batch data', font='Helvetica 10 bold')

        Label(w, text="Target").pack()
        Label(w, bg='lavender', foreground="blue",
              textvariable=self.target).pack(fill=X, padx=2, pady=2)
        Label(w, text="SD").pack()
        Label(w, bg='lemon chiffon', foreground="green",
              textvariable=self.sd).pack(fill=X, padx=2, pady=2)
        Label(w, text="Expiration").pack()
        Label(w, bg='white', textvariable=self.expiration).pack(fill=X,
                                                                padx=2,
                                                                pady=2)

        self.engine.get_spin_box(w, "Elements", 1, 365, 3,
                                 self.elements).pack()

        w.pack(side=LEFT, fill=Y, expand=0)

        w = LabelFrame(f1, text='Cal data', font='Helvetica 10 bold')

        Label(w, text="Average").pack()
        Label(w, bg='lavender', foreground="blue",
              textvariable=self.average).pack(fill=X, padx=2, pady=2)
        Label(w, text="SD").pack()
        Label(w,
              bg='lemon chiffon',
              foreground="green",
              textvariable=self.calculated_sd).pack(fill=X, padx=2, pady=2)
        Label(w, text="CV%").pack()
        Label(w,
              foreground="white",
              bg='orange3',
              textvariable=self.calculated_cv).pack(fill=X, padx=2, pady=2)
        Label(w, text="Westgard").pack()

        self.lblWestgard = Label(w, bg='white', textvariable=self.westgard)
        self.lblWestgard.pack(fill=X, padx=2, pady=2)

        Label(w, text="Bias").pack()
        Label(w, bg='white', textvariable=self.bias).pack(fill=X,
                                                          padx=2,
                                                          pady=2)
        Label(w, text="Range").pack()
        Label(w, bg='white', textvariable=self.range).pack(fill=X,
                                                           padx=2,
                                                           pady=2)

        w.pack(side=RIGHT, fill=Y, expand=0)

        f1.pack(side=TOP, fill=Y, expand=0)

        w = LabelFrame(f0, text='Results')
        self.lstResults = self.engine.get_listbox(w, )
        self.lstResults.bind("<<ListboxSelect>>", self.on_selected_result)
        self.lstResults.bind('<Double-Button-1>', self.on_result_activated)
        w.pack(side=TOP, fill=BOTH, expand=1)

        f0.pack(side=LEFT, fill=Y, expand=0)
        #-----------------------------------------------------------------------

        #create graph!
        f2 = Frame(
            self,
            bd=5,
        )
        f2.pack(side=RIGHT, fill=BOTH, expand=1, padx=5, pady=5)
        #Figure: The top level container for all the plot elements.
        gs = gridspec.GridSpec(1, 2, width_ratios=[2, 1])
        fig = Figure()
        fig.suptitle(self.engine.title, fontsize=16)
        fig.subplots_adjust(bottom=0.10,
                            right=0.96,
                            left=0.06,
                            top=0.88,
                            wspace=0.10)
        self.lj = fig.add_subplot(gs[0], facecolor=('xkcd:light grey'))
        self.frq = fig.add_subplot(gs[1], facecolor=('xkcd:light grey'))
        self.canvas = FigureCanvasTkAgg(fig, f2)
        toolbar = nav_tool(self.canvas, f2)
        toolbar.update()
        self.canvas._tkcanvas.pack(side=TOP, fill=BOTH, expand=1)
    def __init__(self,
                 parent,
                 ylims,
                 size=100,
                 time=1,
                 sampling_frequency=None,
                 frame=None,
                 phase_limits=None,
                 show_yvals=False,
                 window_name=None,
                 styles=None,
                 ylabels=None,
                 yticks=[],
                 legends=[],
                 interval_msec=0.001,
                 shared_queue=None):
        """
        Initializes a multi-plot with specified Y-axis limits as a list of pairs; e.g.,
        [(-1,+1), (0.,5)].  Optional parameters are:

        size             size of display (X axis) in arbitrary time steps
        time             unit time if plot same time in plot (sec)
        phaselims        xlim,ylim for phase plot
        show_yvals       display Y values in plot if True
        window_name      name to display at the top of the figure
        styles           plot styles (e.g., 'b-', 'r.'; default='b-')
        yticks           Y-axis tick / grid positions
        legends          list of legends for each subplot
        interval_msec    animation update in milliseconds

        For overlaying plots, use a tuple for styles; e.g., styles=[('r','g'), 'b']
        """

        # Variable for GUI
        super().__init__()

        self.parent = parent
        self.var = tk.IntVar()
        self.interval = tk.DoubleVar()
        self.queue = queue.Queue()
        self.block_size = 0
        self.my_thread = None
        self.id_after = None
        self.operation_mode = (
            'Exponential',
            'Normal',
        )
        self._shared_queue = shared_queue
        # Row count is provided by Y-axis limits
        nrows = len(ylims)

        # Bozo filters
        styles = _check_param(nrows, styles, 'styles', 'b-')
        ylabels = _check_param(nrows, ylabels, 'ylabels', '')
        yticks = _check_param(nrows, yticks, 'yticks', [])
        self.legends = _check_param(nrows, legends, 'legends', [])
        if sampling_frequency is None:
            raise ValueError

        # Get the current plot
        self.fig = plt.gcf()

        # Set up subplots
        self.axes = [None] * nrows
        ncols = 2 if phase_limits else 1
        self.sideline = None

        if phase_limits:
            side = plt.subplot(1, 2, 1)
            # Phase Plot square shape
            side.set_aspect('equal')
            self.sideline = side.plot(y, y, 'o', animated=True)
            side.set_xlim(phase_limits[0])
            side.set_ylim(phase_limits[1])

        # locate the axes(plot)
        for k in range(nrows):
            self.axes[k] = plt.subplot(nrows, ncols, ncols * (k + 1))
        self.window_name = 'RealtimePlotter' if window_name is None else window_name

        # Set up handler for window-close events
        self.fig.canvas.mpl_connect('close_event', self.handleClose)
        self.is_open = True

        self.sampling_frequency = sampling_frequency
        len_xaxis = int(time * self.sampling_frequency)
        self.t = np.arange(0, len_xaxis)
        amplitudes = np.zeros(len_xaxis)

        self.lines = []
        for j in range(len(styles)):
            style = styles[j]
            ax = self.axes[j]
            legend = self.legends[j] if len(self.legends) > 0 else None
            styles_for_row = style if type(style) == tuple else [style]
            for k in range(len(styles_for_row)):
                label = legend[k] if legend and len(legend) > 0 else ''
                self.lines.append(
                    ax.plot(self.t, amplitudes, styles_for_row[k],
                            label=label)[0])
                # , animated=True
            if legend is not None and len(legend) > 0:
                ax.legend()

        # Create baselines, initially hidden
        self.baselines = [
            axis.plot(self.t, amplitudes, 'k', animated=True)[0]
            for axis in self.axes
        ]
        self.baseflags = [False] * nrows

        # Add properties as specified
        # Set axis limits, ticks, gridlines, hide x axis tics and lables
        for axis, ylabel, ylim, ytick in zip(self.axes, ylabels, ylims,
                                             yticks):
            axis.set_xlim((0, len_xaxis))
            axis.set_ylim(ylim)
            axis.yaxis.set_ticks(ytick)
            axis.yaxis.grid(True if yticks else False)
            axis.xaxis.set_visible(False)

        # Allow interval specification
        self.interval_msec = interval_msec

        # Add axis text if indicated
        self.axis_texts = [axis.text(0.8, ylim[1] - .1 * (ylim[1] - ylim[0]), '') for axis, ylim in
                           zip(self.axes, ylims)] \
            if show_yvals else []

        # combine Figure to Canvas
        self.canvas = FigureCanvasTkAgg(self.fig, self.parent)

        toolbar = nav_tool(self.canvas, self.parent)
        toolbar.update()

        self.canvas.tkcanvas.pack(fill=tk.BOTH, expand=1)
Beispiel #6
0
    def init_ui(self):

        self.main_frame = self.engine.get_frame(self, 8)

        f0 = ttk.Frame(self.main_frame, )

        f1 = ttk.Frame(f0, )

        ttk.Label(f1, text='Tests').pack(side=tk.TOP, fill=tk.X, expand=0)
        #self.cbTests =  ttk.Combobox(f1,state='readonly')
        self.cbTests = ttk.Combobox(f1, )
        self.cbTests.bind("<<ComboboxSelected>>", self.on_selected_test)
        self.cbTests.pack(side=tk.TOP, fill=tk.X, pady=5, expand=0)

        w = ttk.LabelFrame(f1, text='Batches')
        self.lstBatches = self.engine.get_listbox(w, height=5)
        self.lstBatches.bind("<<ListboxSelect>>", self.on_selected_batch)
        self.lstBatches.bind('<Double-Button-1>', self.on_update_batch)
        w.pack(side=tk.TOP, fill=tk.BOTH, expand=0)

        f2 = ttk.Frame(f1, )

        w = tk.LabelFrame(f2, text='Batch data', font='Helvetica 10 bold')

        ttk.Label(w, text="Target").pack()
        ttk.Label(w,
                  style='Target.TLabel',
                  anchor=tk.CENTER,
                  textvariable=self.target).pack(fill=tk.X, padx=2, pady=2)
        ttk.Label(w, text="SD").pack()
        ttk.Label(w,
                  style='black_and_withe.TLabel',
                  anchor=tk.CENTER,
                  textvariable=self.sd).pack(fill=tk.X, padx=2, pady=2)
        ttk.Label(w, text="TE%").pack()
        ttk.Label(w,
                  style='black_and_withe.TLabel',
                  anchor=tk.CENTER,
                  textvariable=self.te).pack(fill=tk.X, padx=2, pady=2)

        w.pack(side=tk.LEFT, fill=tk.X, expand=0)

        w = tk.LabelFrame(f2, text='Cal data', font='Helvetica 10 bold')

        ttk.Label(w, text="Average").pack()
        ttk.Label(w,
                  style='Average.TLabel',
                  anchor=tk.CENTER,
                  textvariable=self.average).pack(fill=tk.X, padx=2, pady=2)
        ttk.Label(w, text="sd").pack()
        ttk.Label(w,
                  style='black_and_withe.TLabel',
                  anchor=tk.CENTER,
                  textvariable=self.calculated_sd).pack(fill=tk.X,
                                                        padx=2,
                                                        pady=2)
        ttk.Label(w, text="CV%").pack()
        ttk.Label(w,
                  style='black_and_withe.TLabel',
                  anchor=tk.CENTER,
                  textvariable=self.cva).pack(fill=tk.X, padx=2, pady=2)

        w.pack(side=tk.LEFT, fill=tk.X, expand=0)

        w = tk.LabelFrame(f2, text='Other data', font='Helvetica 10 bold')

        ttk.Label(w, text="Westgard").pack()

        self.lblWestgard = ttk.Label(w,
                                     style='black_and_withe.TLabel',
                                     anchor=tk.CENTER,
                                     textvariable=self.westgard)
        self.lblWestgard.pack(fill=tk.X, padx=2, pady=2)

        ttk.Label(w, text="Range").pack()
        ttk.Label(w,
                  style='black_and_withe.TLabel',
                  anchor=tk.CENTER,
                  textvariable=self.range).pack(fill=tk.X, padx=2, pady=2)

        ttk.Label(w, text="Bias%").pack()
        ttk.Label(w,
                  style='black_and_withe.TLabel',
                  anchor=tk.CENTER,
                  textvariable=self.bias).pack(fill=tk.X, padx=2, pady=2)

        w.pack(side=tk.RIGHT, fill=tk.X, expand=0)

        w = ttk.LabelFrame(f1, text='Results')
        self.lstResults = self.engine.get_listbox(w, )
        self.lstResults.bind("<<ListboxSelect>>", self.on_selected_result)
        self.lstResults.bind('<Double-Button-1>', self.on_update_result)
        w.pack(side=tk.BOTTOM, fill=tk.BOTH, expand=1)

        #create graph!
        f3 = ttk.Frame(f0, )
        #Figure: The top level container for all the plot elements.
        gs = gridspec.GridSpec(1, 2, width_ratios=[3, 1])
        fig = Figure()
        #fig.suptitle(self.engine.title, fontsize=16)
        fig.subplots_adjust(bottom=0.10,
                            right=0.96,
                            left=0.08,
                            top=0.95,
                            wspace=0.10)
        self.lj = fig.add_subplot(gs[0], facecolor=('xkcd:light grey'))
        self.frq = fig.add_subplot(gs[1], facecolor=('xkcd:light grey'))
        self.canvas = FigureCanvasTkAgg(fig, f3)
        toolbar = nav_tool(self.canvas, f3)
        toolbar.update()
        self.canvas._tkcanvas.pack(fill=tk.BOTH, expand=1)

        f0.pack(side=tk.TOP, fill=tk.BOTH, expand=1)
        f1.pack(side=tk.LEFT, fill=tk.Y, expand=0)
        f2.pack(side=tk.LEFT, fill=tk.Y, expand=0)
        f3.pack(side=tk.RIGHT, fill=tk.BOTH, expand=1)

        self.main_frame.pack(fill=tk.BOTH, expand=1)