def __init__(self, canvas_, parent_):

            self.toolitems = (
                ('Pan', 'Pan axes with left mouse', 'move', 'pan'),
                (None, None, None, None),
            )

            NavigationToolbar2Tk.__init__(self, canvas_, parent_)
Example #2
0
    def __init__(self):
        self.root = Tk()
        self.root.title("Tc Example")
        #------------------------------------------------------------------------
        toolbar = Frame(self.root)
        buttonPhase = Button(toolbar,text="Bode Phase",command=self.plotPhase)
        buttonPhase.pack(side=LEFT,padx=2,pady=2)
        buttonMag = Button(toolbar,text="Bode Mag",command=self.plotMag)
        buttonMag.pack(side=LEFT,padx=2,pady=2)
        buttonStep = Button(toolbar,text="Step",command=self.plotStep)
        buttonStep.pack(side=LEFT,padx=2,pady=2)
        buttonImp = Button(toolbar,text="Impulse",command=self.plotImp)
        buttonImp.pack(side=LEFT,padx=2,pady=4)
        toolbar.pack(side=TOP,fill=X)
        graph = Canvas(self.root)
        graph.pack(side=TOP,fill=BOTH,expand=True,padx=2,pady=4)
        #-------------------------------------------------------------------------------

        f = Figure()
        self.axis = f.add_subplot(111)
        self.sys = signal.TransferFunction([1],[1,1])
        self.w,self.mag,self.phase = signal.bode(self.sys)
        self.stepT,self.stepMag = signal.step(self.sys)
        self.impT,self.impMag = signal.impulse(self.sys)

        self.dataPlot = FigureCanvasTkAgg(f, master=graph)
        self.dataPlot.draw()
        self.dataPlot.get_tk_widget().pack(side=TOP, fill=BOTH, expand=True)
        nav = NavigationToolbar2Tk(self.dataPlot, self.root)
        nav.update()
        self.dataPlot._tkcanvas.pack(side=TOP, fill=X, expand=True)
        self.plotMag()
        #-------------------------------------------------------------------------------
        self.root.mainloop()
Example #3
0
    def draw(self):
        self.fig = plt.figure(num=1)
        self.ax = self.fig.add_subplot(111)

        self.annot = self.ax.annotate("",
                                      xy=(0, 0),
                                      xytext=(-20, 20),
                                      textcoords="offset points",
                                      bbox=dict(boxstyle="round", fc="w"),
                                      arrowprops=dict(arrowstyle="->"))
        self.annot.set_visible(False)

        def format_coord(x, y):
            return 'x=%1.4f, y=%1.4f' % (x, y)

        self.ax.format_coord = format_coord

        self.canvas = FigureCanvasTkAgg(self.fig, self)

        toolbar = NavigationToolbar2Tk(self.canvas, self)
        toolbar.update()
        toolbar.pack(side=tk.TOP, fill=tk.BOTH, expand=False)

        self.canvas.draw()
        self.canvas.get_tk_widget().pack(side=tk.BOTTOM,
                                         fill=tk.BOTH,
                                         expand=True)

        # 鼠标移动事件
        on_move_id = self.fig.canvas.mpl_connect('motion_notify_event',
                                                 self.hover)
    def focus(self):
        x2 = logspace(-5, 5, num=1000)
        Bode = ss.bode(self.H, x2)  # Bode diagram.
        plt.xscale('log')

        # creamos el canvas
        self.graph = Canvas(self)
        # creamos figura y ejes del gráfico de maplotlib
        self.fig = plt.plot(Bode[0], Bode[1])

        # Estos dos objetos dataPlot y nav son el puente entre maplotlib y tkinter
        self.dataPlot = FigureCanvasTkAgg(self.fig, master=self.graph)
        self.nav = NavigationToolbar2Tk(self.dataPlot, self.graph)
        self.dataPlot.get_tk_widget().pack(side=TOP, fill=BOTH, expand=1)
        self.dataPlot._tkcanvas.pack(side=BOTTOM, fill=X, expand=1)

        self.graph.pack(side=TOP, expand=0, fill=BOTH)

        ######################
        # Sets grid.
        plt.minorticks_on()
        plt.grid(which='major', color='black', linewidth=0.8, linestyle='--')
        plt.grid(which='minor', color='black', linewidth=0.4, linestyle=':')

        # Sets figure data.
        plt.title('Bode diagram')
        plt.xlabel('W (log) [rad/seg]')
        plt.ylabel('log(|H(jwt)|)')
        self.dataPlot.draw()
        pass
    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent, bg='#42f498')

        self.controller = controller
        self.parent = parent

        self.graph = tk.Canvas(self)

        self.fig, self.ax1 = plt.subplots()

        self.dataPlot = FigureCanvasTkAgg(self.fig, master=self.graph)
        self.nav = NavigationToolbar2Tk(self.dataPlot, self.graph)
        self.dataPlot.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1)
        self.dataPlot._tkcanvas.pack(side=tk.BOTTOM, fill=tk.X, expand=1)

        self.graph.pack(side=tk.TOP, expand=1, fill=tk.BOTH)

        self.backButton = tk.Button(self,
                                    height=2,
                                    width=50,
                                    text="Volver",
                                    font=Config.SMALL_FONT,
                                    background="#cfffd5",
                                    command=self.goback)
        self.backButton.pack(side=tk.TOP, fill=tk.BOTH)
Example #6
0
    def __init__(self):
        self.root = Tk()
        self.root.title("TP4")

        #------------------------------------------------------------------------
        toolbar = Frame(self.root)
        #toolbar2 = Frame(self.root)

        #primera toolbar

        buttonPhase = Button(toolbar,
                             text="Bode Phase",
                             command=self.plotPhase)
        buttonPhase.pack(side=LEFT, padx=2, pady=2)
        buttonMag = Button(toolbar, text="Bode Mag", command=self.plotMag)
        buttonMag.pack(side=LEFT, padx=2, pady=2)
        buttonStep = Button(toolbar, text="Step", command=self.plotStep)
        buttonStep.pack(side=LEFT, padx=2, pady=2)
        buttonImp = Button(toolbar, text="Impulse", command=self.plotImp)
        buttonImp.pack(side=LEFT, padx=2, pady=4)
        buttonPZ = Button(toolbar, text="Poles and zeros", command=self.plotPZ)
        buttonPZ.pack(side=LEFT, padx=2, pady=4)
        buttonGD = Button(toolbar,
                          text="Group Delay",
                          command=self.plotGroupDelay)
        buttonGD.pack(side=LEFT, padx=2, pady=4)

        # segunda toolbar
        self.SelectFilter()

        #button_low_pass = Button(toolbar2, text = "Low Pass", command = self.set_low_pass)
        #button_low_pass.pack(side=LEFT,padx=2,pady=4)
        #button_high_pass = Button(toolbar2, text = "High Pass", command = self.set_high_pass)
        #button_high_pass.pack(side=LEFT,padx=2,pady=4)
        #button_band_pass = Button(toolbar2, text = "Band Pass", command = self.set_band_pass)
        #button_band_pass.pack(side=LEFT,padx=2,pady=4)
        #button_band_stop = Button(toolbar2, text = "Stop Band", command = self.set_band_stop)
        #button_band_stop.pack(side=LEFT,padx=2,pady=4)
        toolbar.pack(side=TOP, fill=X)
        #toolbar2.pack(side=TOP, fill=X)
        graph = Canvas(self.root)
        graph.pack(side=TOP, fill=BOTH, expand=True, padx=2, pady=4)

        #--------------------------------------------------------------------------------

        f = Figure()
        self.axis = f.add_subplot(111)

        self.dataPlot = FigureCanvasTkAgg(f, master=graph)
        self.dataPlot.draw()
        self.dataPlot.get_tk_widget().pack(side=TOP, fill=BOTH, expand=True)
        nav = NavigationToolbar2Tk(self.dataPlot, self.root)
        nav.update()
        self.dataPlot._tkcanvas.pack(side=TOP, fill=X, expand=True)

        #self.root.geometry("1000x1000")
        self.root.mainloop()
Example #7
0
def plotData(dataSet, w, window, DataType, NoiseData):
    fig = plt.figure(figsize=(4, 4), dpi=100)
    ax = fig.add_subplot(111)
    ax.set_title(DataType + 'dataset')
    plt.xlabel('X')
    plt.ylabel('Y')

    # 畫training/testing data
    labels = dataSet[:, -1]
    idx_1 = np.where(dataSet[:, -1] == 1)
    p1 = ax.scatter(dataSet[idx_1, 1],
                    dataSet[idx_1, 2],
                    marker='o',
                    color='g',
                    label=1,
                    s=20)
    idx_2 = np.where(dataSet[:, -1] == 0)
    p2 = ax.scatter(dataSet[idx_2, 1],
                    dataSet[idx_2, 2],
                    marker='x',
                    color='r',
                    label=0,
                    s=20)

    # 畫雜點
    if len(NoiseData) > 0:
        p3 = ax.scatter(NoiseData[:, :, 1],
                        NoiseData[:, :, 2],
                        marker='^',
                        color='b',
                        label='Noise',
                        s=20)  # NoiseData is 3d-array

    # 畫分割線
    x = np.arange(np.min(dataSet[:, 1]), np.max(dataSet[:, 2]), 0.1)
    if w[2] == 0:
        y = 0
    else:
        y = (w[0] - w[1] * x) / w[2]
    ax.add_line(plt.Line2D(x, y))

    # 示意圖
    plt.legend(loc='upper right')
    # plt.show()

    canvas = FigureCanvasTkAgg(fig, master=window)
    canvas.draw()
    if DataType == 'Training':
        canvas.get_tk_widget().place(x=450, y=80)
    else:
        canvas.get_tk_widget().place(x=850, y=80)

    # toolbar
    toolbar = NavigationToolbar2Tk(canvas, window)
    toolbar.update()
    toolbar.place(x=725, y=10)
Example #8
0
 def plotGraph(self):
     is_first_time = True
     if hasattr(self, 'matplotcanvas'):
         self.matplotcanvas.get_tk_widget().pack_forget()
         is_first_time = False
     else:
         self.introductionCanvas.delete("all")
     f = self.figureAnswer
     self.matplotcanvas = FigureCanvasTkAgg(f, self.introductionCanvas)
     self.matplotcanvas.draw()
     self.matplotcanvas.get_tk_widget().pack(side=BOTTOM, fill=BOTH, expand=True)
     if is_first_time == True:
         toolbar = NavigationToolbar2Tk(self.matplotcanvas, self)
         self.matplotcanvas.tkcanvas.pack(side=TOP, fill=BOTH, expand=True)
Example #9
0
    def populate_stages_plot_frame(self, stages_plot_frame):
        graph = Canvas(stages_plot_frame)
        graph.pack(side=TOP, fill=BOTH, expand=True, padx=2, pady=4)
        f = Figure(figsize=(4, 3))
        self.axis = f.add_subplot(111)

        self.dataPlot = FigureCanvasTkAgg(f,
                                          master=graph)  #Una Tk drawing area
        self.dataPlot.draw()
        self.dataPlot.get_tk_widget().pack(side=TOP)
        nav = NavigationToolbar2Tk(
            self.dataPlot, stages_plot_frame)  #la barra con toda la info
        nav.update()
        self.dataPlot._tkcanvas.pack(side=TOP, fill=X, expand=True)
def plot_sentiment_intensity_in_frame(df, master, sub_name):
    """
    This is a method to display a PyPlot chart inside the GUI.

    Makes a pyplot inside a Frame

    Parameters
    ----------
    df: DataFrame containing sentiment intensity scores (from apply_sentiment_intensity).

    Returns
    --------
    A tkinter Frame containing the plot
    """
    # the figure that will contain the plot
    fig = Figure(figsize=(5, 5), dpi=100)

    # adding the subplot
    ax = fig.add_subplot(111)
    canvas_frame = Frame(master)
    # creating the Tkinter canvas
    # containing the Matplotlib figure
    canvas = FigureCanvasTkAgg(fig, master=canvas_frame)
    canvas.draw()

    # placing the canvas on the Tkinter window
    canvas.get_tk_widget().pack()

    # Apply moving-window average, and plot results
    df.set_index('date', inplace=True)
    df.resample("H").mean().plot(title=f'Hourly mean score for {sub_name}',
                                 ax=ax,
                                 cmap=plt.cm.rainbow)
    # df.ewm(span=100).mean().plot(
    #     label='Moving average',
    #     cmap=plt.cm.rainbow,
    #     ax=ax)

    print('Plotted moving average')

    # creating the Matplotlib toolbar
    toolbar = NavigationToolbar2Tk(canvas, canvas_frame)
    toolbar.update()
    toolbar.pack_configure(expand=True)

    # placing the toolbar on the Tkinter window
    canvas.get_tk_widget().pack()

    return canvas_frame
Example #11
0
def draw_from_lists(xs, ys):
    """
    :param xs: the list of x's
    :param ys: the list of y's such that for all xi  --> yi = f(xi)
    :return: plotting the function in a new window
    """
    app = Tk()
    figure = Figure(figsize=(5, 5), dpi=100)
    figure.add_subplot(111).plot(xs, ys)
    canvas = FigureCanvasTkAgg(figure, master=app)
    canvas.draw()
    canvas.get_tk_widget().pack(side=BOTTOM, fill=BOTH, expand=True)
    toolbar = NavigationToolbar2Tk(canvas, app)
    toolbar.update()
    canvas.get_tk_widget().pack(side=TOP, fill=BOTH, expand=1)
    app.mainloop()
Example #12
0
    def __init__(self, tabControl, xAxis, yAxis):
        super(PlotContainer, self).__init__(tabControl)
        self.graph = Canvas(self)

        self.fig, self.axis = plt.subplots()
        self.dataPlot = FigureCanvasTkAgg(self.fig, master=self.graph)
        #self.dataPlot.draw(self)

        self.nav = NavigationToolbar2Tk(self.dataPlot, self.graph)

        #self.dataPlot.get_tk_widget().pack(side=TOP, fill=BOTH, expand=1)

        self.dataPlot._tkcanvas.pack(side=BOTTOM, fill=X, expand=1)

        self.graph.pack(side=TOP, expand=1, fill=BOTH)

        self.xAxis = xAxis
        self.yAxis = yAxis
    def __init__(self, parent, controller):
        # parent representa el Frame principal del programa, tenemos que indicarle
        # cuando MenuInputOutput será dibujado

        # controller lo utilizamos cuando necesitamos que el controlador principal del programa haga algo

        # llamamos al constructor del padre de MenuInputOutput, que es tk.Frame
        tk.Frame.__init__(self, parent)

        self.controller = controller
        self.parent = parent

        self.title = tk.Label(self,
                              height=1,
                              width=50,
                              text="Entrada - Salida gráfico",
                              font=Config.LARGE_FONT,
                              background="#ffccd5")
        # con pack provocamos que los widgets se dibujen efectivamente en la pantalla
        self.title.pack(side=tk.TOP, fill=tk.BOTH)
        # creamos el canvas
        self.graph = Canvas(self)
        # creamos figura y ejes del gráfico de maplotlib
        self.fig, (self.ax1, self.ax2) = plt.subplots(nrows=2, sharex=True)
        # Estos dos objetos dataPlot y nav son el puente entre maplotlib y tkinter
        self.dataPlot = FigureCanvasTkAgg(self.fig, master=self.graph)
        self.nav = NavigationToolbar2Tk(self.dataPlot, self.graph)
        self.dataPlot.get_tk_widget().pack(side=TOP, fill=BOTH, expand=1)
        self.dataPlot._tkcanvas.pack(side=BOTTOM, fill=X, expand=1)

        self.graph.pack(side=TOP, expand=1, fill=BOTH)
        # boton para volver
        self.backButton = tk.Button(self,
                                    height=2,
                                    width=50,
                                    text="Volver",
                                    font=Config.SMALL_FONT,
                                    background="#cfffd5",
                                    command=self.goBack)
        self.backButton.pack(side=tk.TOP, fill=tk.BOTH)
Example #14
0
 def config_window(self):
     toolbar = NavigationToolbar2Tk(self.canvas, self.master)
     toolbar.update()
     self.canvas.get_tk_widget().pack(side=BOTTOM, fill=BOTH, expand=1)
     start_entry = Entry(textvariable=self.start)
     start_entry.pack()
     end_entry = Entry(textvariable=self.end)
     end_entry.pack()
     enter = Button(
         master=root,
         text='Enter',
         command=self.enter_pressed
     )
     enter.pack()
     b_day = Button(self.master, text="Days", command=self.days)
     b_day.pack(side=TOP)
     b_week = Button(self.master, text="Weeks", command=self.weeks)
     b_week.pack(side=TOP)
     b_months = Button(self.master, text="Months", command=self.months)
     b_months.pack(side=TOP)
     b_years = Button(self.master, text="Years", command=self.years)
     b_years.pack(side=TOP)
Example #15
0
    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)

        self.controller = controller
        self.parent = parent

        self.title = tk.Label(self,
                              height=1,
                              width=50,
                              text="Entrada - Salida gráfico",
                              font=Config.LARGE_FONT,
                              background="#ffccd5")

        self.title.pack(side=tk.TOP, fill=tk.BOTH)

        self.graph = Canvas(self)

        #self.fig, self.axis = plt.subplots()
        self.fig, (self.ax1, self.ax2) = plt.subplots(nrows=2, sharex=True)

        self.dataPlot = FigureCanvasTkAgg(self.fig, master=self.graph)
        # self.dataPlot.draw(self)

        self.nav = NavigationToolbar2Tk(self.dataPlot, self.graph)

        self.dataPlot.get_tk_widget().pack(side=TOP, fill=BOTH, expand=1)

        self.dataPlot._tkcanvas.pack(side=BOTTOM, fill=X, expand=1)

        self.graph.pack(side=TOP, expand=1, fill=BOTH)

        self.backButton = tk.Button(self,
                                    height=2,
                                    width=50,
                                    text="Volver",
                                    font=Config.SMALL_FONT,
                                    background="#cfffd5",
                                    command=self.goBack)
        self.backButton.pack(side=tk.TOP, fill=tk.BOTH)
Example #16
0
    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        self.controller = controller
        self.parent = parent

        self.graph = Canvas(self, width=600)

        self.fig, self.axis = plt.subplots()

        self.fig.set_size_inches(5, 4)

        self.dataPlot = FigureCanvasTkAgg(self.fig, master=self.graph)
        # self.dataPlot.draw(self)

        self.nav = NavigationToolbar2Tk(self.dataPlot, self.graph)

        self.dataPlot._tkcanvas.pack(side=BOTTOM, fill=X, expand=1)

        self.title = tk.Label(self,
                              height=1,
                              text="Espectograma",
                              font=config.LARGE_FONT,
                              background="#ccffd5")
        self.title.pack(side=TOP, expand=1, fill=BOTH)

        self.graph.pack(side=TOP, expand=1, fill=X)

        self.backButton = tk.Button(self,
                                    height=1,
                                    width=50,
                                    text="Volver a empezar",
                                    font=config.SMALL_FONT,
                                    background="#ff644f",
                                    command=self.goBack)

        self.backButton.pack(side=TOP, expand=1, fill=BOTH)

        self.playing = False
Example #17
0
def generate_stem_phantom():
    # Variable used to measure time of execution
    start = time.time()
    if not validate_inputs():
        return

    A = [coord1_x.get(), coord1_y.get(), coord1_z.get()]
    B = [coord2_x.get(), coord2_y.get(), coord2_z.get()]
    x_arc, y_arc, z_arc, C = grapeStemGenerator.generate_arc_coordinates(
        A, B, curve_angle.get())
    X, Y, Z = grapeStemGenerator.generate_cylinder_coordinates(
        x_arc, y_arc, z_arc, radius_cylinder.get(), C)

    if create_plot.get() == 1:
        button["state"] = tk.DISABLED
        window2 = tk.Toplevel(window)
        window2.protocol("WM_DELETE_WINDOW",
                         lambda arg=window2: on_closing(arg))
        fig = grapeStemGenerator.create_figure()
        canvas = FigureCanvasTkAgg(fig, master=window2)  # A tk.DrawingArea.
        canvas.draw()
        grapeStemGenerator.plot_points(X, Y, Z, A, B, C, fig)
        toolbar = NavigationToolbar2Tk(canvas, window2)
        toolbar.update()
        canvas.get_tk_widget().pack()

    digitalPhantomGenerator.create_digital_phantom_of_models(
        'x', X, Y, Z, pgm_size.get())
    digitalPhantomGenerator.create_digital_phantom_of_models(
        'y', X, Y, Z, pgm_size.get())
    digitalPhantomGenerator.create_digital_phantom_of_models(
        'z', X, Y, Z, pgm_size.get())
    print("%.2f - time in seconds to generate plot with %d" %
          (time.time() - start, X.size))
    messagebox.showinfo(
        title="Successful generation",
        message="The PGM files have been generated successfully!")
Example #18
0
    def fig_to_canvas(self, fig, frame):

        self.mem = None

        def on_pick(event):
            picked_obj = event.artist
            self.mem = picked_obj

        def on_move(event):
            if self.mem is not None:
                if type(self.mem) == matplotlib.legend.Legend:
                    try:
                        inv = event.inaxes.transAxes.inverted()
                        self.mem.set_bbox_to_anchor(
                            inv.transform((event.x, event.y)))
                        canvas.draw()
                    except AttributeError as e:
                        pass
                    except TypeError:
                        pass
                else:
                    self.mem.set_position((event.xdata, event.ydata))
                    try:
                        canvas.draw()
                    except TypeError:
                        pass

        def on_release(event):
            self.mem = None

        def on_scroll(event):

            xmin, xmax = event.inaxes.get_xlim()
            ymin, ymax = event.inaxes.get_ylim()
            if event.step > 0:
                event.inaxes.set_xlim((1.05 * xmin, 0.95 * xmax))
                event.inaxes.set_ylim((1.05 * ymin, 0.95 * ymax))
            else:
                event.inaxes.set_xlim((0.95 * xmin, 1.05 * xmax))
                event.inaxes.set_ylim((0.95 * ymin, 1.05 * ymax))
            try:
                canvas.draw()
            except TypeError:
                pass

        figure_frame = Frame(frame)
        toolbar_frame = Frame(frame)

        # frame.rowconfigure(0, weight = 5)
        # frame.rowconfigure(1, weight = 1)

        self.update()
        c_height = self.container.winfo_height()
        c_width = self.container.winfo_width()

        # print 'h %s '%c_height
        # print 'w %s ' %c_width

        pix_per_inch = self.winfo_fpixels('1i')
        fig.set_size_inches(0.8 * c_width / pix_per_inch,
                            0.65 * c_height / pix_per_inch)
        # print fig.get_size_inches()
        canvas = FigureCanvasTkAgg(fig, master=figure_frame)
        canvas.draw()
        canvas.mpl_connect('pick_event', on_pick)
        canvas.mpl_connect('motion_notify_event', on_move)
        canvas.mpl_connect('button_release_event', on_release)
        canvas.mpl_connect('scroll_event', on_scroll)
        # canvas.get_tk_widget().pack(side=TOP, fill=BOTH, expand=False)
        # canvas.get_tk_widget().grid(row=0,  sticky='nsew')
        # self.ctoolbar = NavigationToolbar2Tk(canvas, toolbar_frame)
        self.ctoolbar = NavigationToolbar2Tk(canvas, toolbar_frame)
        self.ctoolbar.update()
        canvas._tkcanvas.pack(side=TOP, fill=BOTH, expand=False)
        # canvas._tkcanvas.grid(row=0,  sticky='nsew')
        # figure_frame.grid(row=0,  sticky='nsew')
        # toolbar_frame.grid(row=1,  sticky='nsew')
        figure_frame.pack(side=TOP, fill=BOTH, expand=False)
        toolbar_frame.pack(side=BOTTOM, fill=BOTH, expand=True)
Example #19
0
    def __init__(self, root, *args, **kwargs):
        tk.Tk.__init__(self, *args, **kwargs)

        self.frame_buttons = Frame(root, width=1, height=1, bg='silver')
        self.frame_buttons.pack(side=TOP)

        self.button_kmeans = Button(
            self.frame_buttons,
            width=25,
            height=2,
            text=" KMEANS ",
            bg='snow',
            command=lambda: self.user_choice_manager(4))
        self.button_kmeans.pack(side=LEFT, padx=10, pady=10)
        self.button_kmedoid = Button(
            self.frame_buttons,
            width=25,
            height=2,
            text=" KMEDOID ",
            bg='snow',
            command=lambda: self.user_choice_manager(1))
        self.button_kmedoid.pack(side=LEFT, padx=10, pady=10)
        self.button_agnes = Button(self.frame_buttons,
                                   width=25,
                                   height=2,
                                   text=" AGNES ",
                                   bg='snow',
                                   command=lambda: self.user_choice_manager(2))
        self.button_agnes.pack(side=LEFT, padx=10, pady=10)
        self.button_dbscan = Button(
            self.frame_buttons,
            width=25,
            height=2,
            text=" DBSCAN ",
            bg='snow',
            command=lambda: self.user_choice_manager(3))
        self.button_dbscan.pack(side=LEFT, padx=10, pady=10)
        #
        self.frame_results_performance = Frame(root,
                                               width=50,
                                               highlightthickness=2,
                                               highlightbackground='black')
        self.frame_results_performance.pack(side=RIGHT,
                                            fill=Y,
                                            padx=5,
                                            pady=20)
        ##
        self.frame_results = Frame(self.frame_results_performance, height=100)
        self.frame_results.pack(fill=X, side=TOP)
        ##
        self.label_results = Label(self.frame_results,
                                   text='RESULTS',
                                   font=("Helvetica", 16))
        self.label_results.pack()
        self.scrollbar_result = Scrollbar(self.frame_results)
        self.scrollbar_result.pack(side=RIGHT, fill=Y)
        self.textfield_results = Text(self.frame_results,
                                      yscrollcommand=self.scrollbar_result.set,
                                      width=55,
                                      state=DISABLED)
        self.textfield_results.pack(padx=2)
        ##
        self.frame_graph = Frame(self.frame_results_performance, height=100)
        #self.frame_graph.pack(fill=X, side=TOP)
        self.fig_graph = Figure(figsize=(5, 4), dpi=100)
        self.ax_graph = self.fig_graph.add_subplot(111)
        canvas = FigureCanvasTkAgg(self.fig_graph, self.frame_graph)
        canvas.draw()
        canvas.get_tk_widget().pack(side=TOP, fill=BOTH, expand=1)
        toolbar = NavigationToolbar2Tk(canvas, self.frame_graph)
        toolbar.update()
        canvas.get_tk_widget().pack(side=TOP, fill=BOTH, expand=1)
        #
        self.frame_inputs = Frame(root,
                                  width=300,
                                  height=300,
                                  highlightthickness=2,
                                  highlightbackground='black')
        self.frame_inputs.pack(side=LEFT, fill=BOTH, padx=5, pady=20)
        #
        self.frame_dataset_errors = Frame(root,
                                          width=500,
                                          height=500,
                                          highlightthickness=2,
                                          highlightbackground='black')
        self.frame_dataset_errors.pack(side=RIGHT, fill=BOTH, padx=5, pady=20)
        ##
        self.frame_dataset = Frame(self.frame_dataset_errors,
                                   width=50,
                                   height=100)
        self.frame_dataset.pack(side=TOP, fill=X, padx=5, pady=5)
        #
        self.frame_execution = Frame(self.frame_dataset_errors)
        self.frame_execution.pack(side=TOP, pady=10, padx=2)
        ##
        image = PIL.Image.open(
            r'C:\Users\Ilyes\PycharmProjects\DataMining_TP\icons\next_icon_50x50.jpg'
        )
        photo = PIL.ImageTk.PhotoImage(image)
        label = Label(root, image=photo)
        label.image = photo  # keep a reference!
        self.button_next = Button(self.frame_execution,
                                  image=photo,
                                  width=48,
                                  height=48,
                                  state=DISABLED,
                                  command=lambda: self.execute_manager())
        self.button_next.pack(side=RIGHT, padx=2)
        ##
        image = PIL.Image.open(
            r'C:\Users\Ilyes\PycharmProjects\DataMining_TP\icons\previous_icon_50x50.jpg'
        )
        photo = PIL.ImageTk.PhotoImage(image)
        label = Label(root, image=photo)
        label.image = photo  # keep a reference!
        self.button_precedent = Button(self.frame_execution,
                                       image=photo,
                                       width=48,
                                       height=48,
                                       state=DISABLED,
                                       command=lambda: self.execute_manager())
        self.button_precedent.pack(side=LEFT, padx=2)
        ##
        image = PIL.Image.open(
            r'C:\Users\Ilyes\PycharmProjects\DataMining_TP\icons\previous_too_icon_50x50.jpg'
        )
        photo = PIL.ImageTk.PhotoImage(image)
        label = Label(root, image=photo)
        label.image = photo  # keep a reference!
        self.button_previous = Button(self.frame_execution,
                                      image=photo,
                                      width=48,
                                      height=48,
                                      state=DISABLED,
                                      command=lambda: self.execute_manager())
        self.button_previous.pack(side=LEFT, padx=2)
        ##
        image = PIL.Image.open(
            r'C:\Users\Ilyes\PycharmProjects\DataMining_TP\icons\next_too_icon_50x50.jpg'
        )
        photo = PIL.ImageTk.PhotoImage(image)
        label = Label(root, image=photo)
        label.image = photo  # keep a reference!
        self.button_nexious = Button(self.frame_execution,
                                     image=photo,
                                     width=48,
                                     height=48,
                                     state=DISABLED,
                                     command=lambda: self.execute_manager())
        self.button_nexious.pack(side=RIGHT, padx=2)
        ##
        image = PIL.Image.open(
            r'C:\Users\Ilyes\PycharmProjects\DataMining_TP\icons\play_icon_50x50.jpg'
        )
        photo = PIL.ImageTk.PhotoImage(image)
        label = Label(root, image=photo)
        label.image = photo  # keep a reference!
        self.button_execute = Button(self.frame_execution,
                                     image=photo,
                                     width=48,
                                     height=48,
                                     state=DISABLED,
                                     command=lambda: self.execute_manager())
        self.button_execute.pack(side=RIGHT, padx=2, expand=1)
        ##
        image = PIL.Image.open(
            r'C:\Users\Ilyes\PycharmProjects\DataMining_TP\icons\pause_icon_50x50.jpg'
        )
        photo = PIL.ImageTk.PhotoImage(image)
        label = Label(root, image=photo)
        label.image = photo  # keep a reference!
        self.button_pause = Button(self.frame_execution,
                                   image=photo,
                                   width=48,
                                   height=48,
                                   state=DISABLED,
                                   command=lambda: self.execute_manager())
        self.button_pause.pack(side=RIGHT, padx=2)
        ###
        self.label_dataset = Label(self.frame_dataset,
                                   text='DATASET',
                                   font=("Helvetica", 16))
        self.label_dataset.pack()
        self.scrollbar_dataset = Scrollbar(self.frame_dataset)
        self.scrollbar_dataset.pack(side=RIGHT, fill=Y)
        self.textfield_dataset = Text(
            self.frame_dataset,
            yscrollcommand=self.scrollbar_dataset.set,
            width=55,
            state=DISABLED)
        self.textfield_dataset.pack(padx=2)
        self.label_error = Label(self.frame_dataset_errors, text="", fg='RED')
        self.label_error.pack(side=BOTTOM)
        ##
        self.frame_visualize_graph = Frame(self.frame_results_performance)
        self.frame_visualize_graph.pack(fill=X)
        ###
        self.graph_text_bit = 1
        self.button_visualize_graph = Button(
            self.frame_visualize_graph,
            text='Visualize le graph',
            command=lambda: self.graph_viewer_manager())
        self.button_visualize_graph.pack(side=RIGHT)
        ##
        self.frame_performance = Frame(self.frame_results_performance,
                                       height=50)
        self.frame_performance.pack(side=BOTTOM, fill=X, padx=5, pady=5)
        ###
        self.frame_label_performance = Frame(self.frame_performance)
        self.frame_label_performance.pack(fill=X)
        self.label_performance = Label(self.frame_label_performance,
                                       text='Performances',
                                       font=("Helvetica", 16))
        self.label_performance.pack(side=LEFT)
        self.frame_frame_performance = Frame(self.frame_performance)
        self.frame_frame_performance.pack(fill=BOTH)
        self.frame_performance_labels = Frame(self.frame_frame_performance)
        self.frame_performance_labels.pack(side=LEFT, padx=10, pady=3)
        self.label_performance_intraclass = Label(
            self.frame_performance_labels,
            text='IntraClass = ',
            font=("Courier New", 12))
        self.label_performance_intraclass.pack()
        self.label_performance_interclass = Label(
            self.frame_performance_labels,
            text='InterClass = ',
            font=("Courier New", 12))
        self.label_performance_interclass.pack()
        self.label_performance_silhouette = Label(
            self.frame_performance_labels,
            text='Silhouette = ',
            font=("Courier New", 12))
        self.label_performance_silhouette.pack()
        ####
        self.frame_performance_textfields = Frame(self.frame_frame_performance)
        self.frame_performance_textfields.pack(side=LEFT)
        self.textfield_performance_intraclass = Text(
            self.frame_performance_textfields,
            width=8,
            height=1,
            state=DISABLED)
        self.textfield_performance_intraclass.pack(pady=2)
        self.textfield_performance_interclass = Text(
            self.frame_performance_textfields,
            width=8,
            height=1,
            state=DISABLED)
        self.textfield_performance_interclass.pack(pady=2)
        self.textfield_performance_silhouette = Text(
            self.frame_performance_textfields,
            width=8,
            height=1,
            state=DISABLED)
        self.textfield_performance_silhouette.pack(pady=2)
        ####
        self.frame_performance_executiontime = Frame(
            self.frame_frame_performance)
        self.frame_performance_executiontime.pack(side=LEFT, padx=10, pady=3)
        self.label_performance_executiontime = Label(
            self.frame_frame_performance,
            text="Temps d'exection (sec) \n= ",
            font=("Courier New", 12))
        self.label_performance_executiontime.pack()
        self.textfield_performance_executiontime = Text(
            self.frame_frame_performance, width=16, height=1, state=DISABLED)
        self.textfield_performance_executiontime.pack()

        global var
        var = IntVar()
        #
        self.frame_path_all = Frame(self.frame_inputs)
        self.frame_path_all.pack(fill=X)
        ##
        self.radiobutton_managepathframe = Radiobutton(
            self.frame_path_all,
            variable=var,
            value=1,
            command=lambda: self.switch_radiobutton_manager())
        self.radiobutton_managepathframe.pack(side=LEFT)
        self.radiobutton_managepathframe.select()  # select it
        ##
        self.frame_path = Frame(self.frame_path_all)
        self.frame_path.pack(side=RIGHT, fill=X)
        ###
        self.entry_path_numsequences_sv = StringVar()
        self.entry_path_numsequences_sv.trace(
            "w",
            lambda name, index, mode, entry_path_numsequences_sv=self.
            entry_path_numsequences_sv: self.callback_updateDataSet(
                self.entry_path_numsequences_sv))
        ###
        self.entry_path_numsequences = Entry(
            self.frame_path,
            width=5,
            state=DISABLED,
            textvariable=self.entry_path_numsequences_sv)
        self.entry_path_numsequences.pack(side=LEFT)
        self.entry_path_numsequences_ready = False
        ###
        self.label_path_numsequences = Label(self.frame_path, text='/####')
        self.label_path_numsequences.pack(side=LEFT, padx=2)
        ###
        self.textfield_filepath = Text(self.frame_path,
                                       width=25,
                                       height=2,
                                       state=DISABLED)
        self.textfield_filepath.pack(side=LEFT, padx=2, pady=3)
        ###
        self.button_open = Button(self.frame_path,
                                  text='Ouvrir',
                                  command=lambda: self.open_dialog())
        self.button_open.pack(side=RIGHT, padx=1)
        #
        self.frame_manual_enter_all = Frame(self.frame_inputs)
        self.frame_manual_enter_all.pack(pady=10, fill=X)
        ##
        self.radiobutton_manageframemanual = Radiobutton(
            self.frame_manual_enter_all,
            variable=var,
            value=2,
            command=lambda: self.switch_radiobutton_manager())
        self.radiobutton_manageframemanual.pack(side=LEFT)
        ##
        self.frame_manual_enter = Frame(self.frame_manual_enter_all)
        self.frame_manual_enter.pack(side=RIGHT, fill=X)
        ###
        self.label_manual_enter = Label(
            self.frame_manual_enter,
            text='Enter the sequence down here:\t\t\t')
        self.label_manual_enter.pack(padx=2)
        ###
        self.scrollbar_manual_enter = Scrollbar(self.frame_manual_enter)
        self.scrollbar_manual_enter.pack(side=RIGHT, fill=Y)
        ###
        self.textfield_manual_enter = Text(
            self.frame_manual_enter,
            yscrollcommand=self.scrollbar_manual_enter.set,
            width=45,
            height=15,
            state=DISABLED)
        self.textfield_manual_enter.pack(side=BOTTOM, padx=2, pady=3)
        #
        self.frame_random_all = Frame(self.frame_inputs)
        self.frame_random_all.pack(fill=X)
        ##
        self.radiobutton_manageframerandom = Radiobutton(
            self.frame_random_all,
            variable=var,
            value=3,
            command=lambda: self.switch_radiobutton_manager())
        self.radiobutton_manageframerandom.pack(side=LEFT)
        ##
        self.frame_random = Frame(self.frame_random_all)
        self.frame_random.pack(fill=X)
        ###
        fig = Figure(figsize=(3, 2), dpi=100)
        fig.gca().axes.get_yaxis().set_visible(False)
        fig.gca().axes.get_xaxis().set_visible(False)
        ax = fig.add_subplot(111)
        canvas = FigureCanvasTkAgg(fig, self.frame_random)
        canvas.draw()
        canvas.get_tk_widget().pack(side=TOP, fill=BOTH, expand=1)
        toolbar = NavigationToolbar2Tk(canvas, self.frame_random)
        toolbar.update()
        canvas.get_tk_widget().pack(side=TOP, fill=BOTH, expand=1)
        global deleting
        deleting = False
        points_list = dict()

        def on_plot(event):
            if event.x > 53 and event.x < 342 and event.y > 28 and event.y < 170:
                m_x, m_y = event.x, event.y
                ix, iy = ax.transData.inverted().transform([m_x, m_y])
                ax.plot(ix, iy, marker='o')
                fig.canvas.draw()
                sequence = BA.adding_sequence(m_x, m_y)
                self.adding_sequence_random_UI(sequence)
                points_list[(m_x, m_y)] = sequence

        def on_delete():
            global data
            ax.clear()
            data = None
            self.textfield_dataset.config(state=NORMAL)
            self.textfield_dataset.delete(0.0, END)
            self.textfield_dataset.config(state=DISABLED)

        canvas.mpl_connect('button_press_event', on_plot)
        ###
        self.button_random = Button(self.frame_random,
                                    text='choose a random sequence',
                                    width=2,
                                    height=2,
                                    state=DISABLED,
                                    command=lambda: on_delete())
        self.button_random.pack()
        #
        self.frame_kmedoid_parameters = Frame(self.frame_dataset_errors)
        ##
        self.label_kmedoid_numclusters = Label(self.frame_kmedoid_parameters,
                                               text='*Nombre de clusters')
        self.label_kmedoid_numclusters.pack(pady=5, side=LEFT)
        ##
        entry_kmedoid_numclusters_sv = StringVar()
        entry_kmedoid_numclusters_sv.trace(
            "w",
            lambda name, index, mode, entry_kmedoid_numclusters_sv=
            entry_kmedoid_numclusters_sv: self.
            callback_check_coherance_kmedoid_numclusters(
                entry_kmedoid_numclusters_sv))
        ##
        self.entry_kmedoid_numclusters = Entry(
            self.frame_kmedoid_parameters,
            width=5,
            textvariable=entry_kmedoid_numclusters_sv)
        self.entry_kmedoid_numclusters.pack(pady=5, side=LEFT)
        ###
        self.kmedoid_ready = False
        #
        self.frame_dbscan_parameters = Frame(
            self.frame_dataset_errors
        )  #The pack is below self.button_execture.pack
        ##
        self.label_dbscan_minpoints = Label(self.frame_dbscan_parameters,
                                            text='*Min Points')
        self.label_dbscan_minpoints.pack(pady=5, side=LEFT)
        ##
        entry_dbscan_minpoints_sv = StringVar()
        entry_dbscan_minpoints_sv.trace(
            "w",
            lambda name, index, mode, entry_dbscan_minpoints_sv=
            entry_dbscan_minpoints_sv: self.
            callback_check_coherance_dbscan_minpoints(entry_dbscan_minpoints_sv
                                                      ))
        ##
        self.entry_dbscan_minpoints = Entry(
            self.frame_dbscan_parameters,
            width=5,
            textvariable=entry_dbscan_minpoints_sv)
        self.entry_dbscan_minpoints.pack(pady=5, side=LEFT)
        ##
        self.label_dbscan_radiun = Label(self.frame_dbscan_parameters,
                                         text='*Radiun')
        self.label_dbscan_radiun.pack(pady=5, padx=3, side=LEFT)
        ##
        entry_dbscan_radiun_sv = StringVar()
        entry_dbscan_radiun_sv.trace(
            "w",
            lambda name, index, mode, entry_dbscan_radiun_sv=
            entry_dbscan_radiun_sv: self.
            callback_check_coherance_dbscan_radiun(entry_dbscan_radiun_sv))
        ##
        self.entry_dbscan_radiun = Entry(self.frame_dbscan_parameters,
                                         width=5,
                                         textvariable=entry_dbscan_radiun_sv)
        self.entry_dbscan_radiun.pack(pady=5, side=LEFT)
        ###
        self.dbscan_ready = [False, False]

        #self.frame_dbscan_parameters.pack(side=TOP, pady=20, fill=X)
        #self.frame_kmedoid_parameters.pack(side=TOP, pady=20, fill=X)
        self.dict_distance = None
Example #20
0
    def __init__(self):

        #------------------------------------Set Tk inter and Grid----------------------------------

        self.root = Tk()
        self.root.title("ASSD: Entorno de Simulacion")
        self.root.resizable(False, False)
        self.ventana_izquierda = Frame(self.root)
        self.ventana_izquierda.grid()

        self.ventana_derecha = Frame(self.root)
        self.ventana_derecha.grid(row=0, column=1)

        self.ventana_inferior = Frame(self.root)
        self.ventana_inferior.grid(row=1)

        #-----------------------------------Set Check Boxes Lists and Labels------------------------------

        self.label_1 = Label(self.ventana_derecha,
                             text="Caracteristicas de la señal:")
        self.label_1.grid(row=0, column=2, columnspan=2, sticky=W)

        self.label_2 = Label(self.ventana_derecha, text="Etapas:"******"AM Modulada")
        self.SignalInputString = StringVar()
        self.SignalInputString.set(SignalList[0])
        InputSignalMenu = OptionMenu(self.ventana_derecha,
                                     self.SignalInputString, *SignalList)
        InputSignalMenu.grid(row=1, column=2)

        self.Frecuency = Scale(self.ventana_derecha,
                               from_=500,
                               to=31000,
                               resolution=10,
                               label='Frecuency:',
                               orient=HORIZONTAL)
        self.Frecuency.set(1500)
        self.Frecuency.grid(row=2, column=2, padx=5, pady=5)

        self.Voltage = Scale(self.ventana_derecha,
                             from_=0,
                             to=10,
                             resolution=0.1,
                             label='Vpp:',
                             orient=HORIZONTAL)
        self.Voltage.set(5)
        self.Voltage.grid(row=3, column=2, columnspan=1, padx=5, pady=5)

        self.check_faa = IntVar()
        self.CheckFAA = Checkbutton(self.ventana_derecha,
                                    text="FAA",
                                    variable=self.check_faa)
        self.CheckFAA.grid(row=6, column=0)

        self.check_sample_and_hold = IntVar()
        self.CheckSAH = Checkbutton(self.ventana_derecha,
                                    text="Sample and Hold",
                                    variable=self.check_sample_and_hold,
                                    command=self.mostrar_config)
        self.CheckSAH.grid(row=6, column=2, columnspan=2, padx=8, pady=8)

        self.Frecuencia_SH = Scale(self.ventana_derecha,
                                   from_=1000,
                                   to=65000,
                                   resolution=50,
                                   label='Frecuencia S&h',
                                   orient=HORIZONTAL)
        self.Frecuencia_SH.set(30000)

        self.Duty_SH = Scale(self.ventana_derecha,
                             from_=5,
                             to=95,
                             label='Duty cycle S&H',
                             orient=HORIZONTAL)
        self.Duty_SH.set(50)

        self.check_llave_analog = IntVar()
        self.CheckANKEY = Checkbutton(self.ventana_derecha,
                                      text="Llave analogica",
                                      variable=self.check_llave_analog,
                                      command=self.mostrar_config_LLA)
        self.CheckANKEY.grid(row=6, column=4, columnspan=2, padx=8, pady=8)

        self.frecuencia_LLA = Scale(self.ventana_derecha,
                                    from_=1000,
                                    to=65000,
                                    resolution=50,
                                    label='Frecuencia',
                                    orient=HORIZONTAL)
        self.frecuencia_LLA.set(3000)

        self.duty_cycle_LLA = Scale(self.ventana_derecha,
                                    from_=5,
                                    to=95,
                                    label='Duty cycle',
                                    orient=HORIZONTAL)
        self.duty_cycle_LLA.set(50)

        self.check_fr = IntVar()
        self.CheckFR = Checkbutton(self.ventana_derecha,
                                   text="FR",
                                   variable=self.check_fr)
        self.CheckFR.grid(row=6, column=6, columnspan=2, padx=8, pady=8)

        self.GraphButtom = Button(self.ventana_derecha,
                                  text="Graficar",
                                  command=self.Graficar)
        self.GraphButtom.grid(row=10, column=6, columnspan=2)

        self.check_frec_graficar = IntVar()
        self.Check_Graph_Frec = Checkbutton(self.ventana_derecha,
                                            text='Frecuencia',
                                            variable=self.check_frec_graficar)
        self.Check_Graph_Frec.grid(row=2, column=5)

        self.check_tiempo_graficar = IntVar()
        self.Check_Graph_Time = Checkbutton(
            self.ventana_derecha,
            text='Tiempo',
            variable=self.check_tiempo_graficar)
        self.Check_Graph_Time.grid(row=2, column=6)

        #-----------------------------------Set Graph--------------------------------------------

        graph = Canvas(self.ventana_izquierda)
        graph.grid(row=1, columnspan=1000, padx=10, pady=10)
        f = Figure()
        self.axis = f.add_subplot(111)

        self.dataPlot = FigureCanvasTkAgg(f, master=graph)
        self.dataPlot.draw()
        self.dataPlot.get_tk_widget().pack(side=TOP, fill=BOTH, expand=True)
        self.nav = NavigationToolbar2Tk(self.dataPlot, self.ventana_inferior)
        self.nav.update()
        self.dataPlot._tkcanvas.pack(side=TOP, expand=True)

        #-----------------------------RootMainLoop----------------------------------------------------

        self.root.mainloop()
    def createWidgets(self, w=800, h=800):
        ws = self.master.winfo_screenwidth()
        hs = self.master.winfo_screenheight()
        x = (ws / 2) - (w / 2)
        y = (hs / 2) - (h / 2)
        self.master.geometry('%dx%d+%d+%d' % (w, h, x, y))
        self.mianFram = Frame(master=self.master)
        self.mianFram.pack(fill='both', expand=YES)
        # self.mianFram.bind_all('<Escape>', self.stop_camera)
        # self.mianFram.bind_all('<Return>', self.push_enter)

        # Graph Right
        if self.id == '1':
            self.fig = plt.figure(figsize=(5, 6))
            self.ax1 = self.fig.add_subplot(2, 1, 1, projection='3d')

            self.ax2 = self.fig.add_subplot(2, 1, 2, projection='3d')

            self.canvas = FigureCanvasTkAgg(self.fig, master=self.mianFram)
            toolbarFrame = tk.Frame(master=self.mianFram)
            toolbarFrame.pack(fill='both', side=BOTTOM)
            self.canvas._tkcanvas.pack(fill='both', side=LEFT)
            self.ax1.mouse_init()
            self.ax2.mouse_init()
            toolbar = NavigationToolbar2Tk(self.canvas, toolbarFrame)
            toolbar.update()
            self.right_part()

        elif self.id == '2':
            self.fig = plt.figure(figsize=(6, 4))
            for j in range(12):
                self.ax = self.fig.add_subplot(12, 1, j + 1)
            self.canvas = FigureCanvasTkAgg(self.fig, master=self.mianFram)
            toolbarFrame = tk.Frame(master=self.mianFram)
            toolbarFrame.pack(fill='both', side=BOTTOM)
            self.canvas._tkcanvas.pack(fill='both', side=LEFT)
            toolbar = NavigationToolbar2Tk(self.canvas, toolbarFrame)
            toolbar.update()
            self.right_part()

        elif self.id == '3':
            # c_leap = client_ui.ClientLeap()
            # x_leap = threading.Thread(target=c_leap.run)
            # x_leap.start()
            #
            # c_glove = client_ui.ClientGlove()
            #
            # x_glove = threading.Thread(target=c_glove.run)
            # x_glove.start()
            # ui = client_ui.ClientUI(c_leap, c_glove)
            # ui.setup_ui()

            self.load_meta_files()

            self.nr_clients = 10

            self.lan_list = ['English', 'Chinese']
            self.lan_index = 0

            self.lan_dict = {'English': self.words_eng,
                             'Chinese': self.words_chs}

            self.group_list = ['group %d' % x for x in range(100)]
            self.group_index = 0

            self.nr_groups = 100
            self.group_size = 100

            self.word_list = self.words_eng
            self.word_index = 0

            self.started = False
            self.t4 = None
            self.t5 = None

            self.info_str = 'Stopped'

            self.warning_str = ''

            # self.ii = self.group_index * self.group_size + self.word_index


            client_list = ['client %d' % x for x in range(20)]
            group_list = ['group %d' % x for x in range(100)]



            # client
            client = tk.Frame(master=self.mianFram)
            # ttk.Button(master=client, text='<-', command=self.on_prev_word, takefocus=0).pack(fill=X, side=LEFT)
            self.client_v = StringVar()
            self.client_v.set('client '+self.client_id)
            w = ttk.Combobox(master=client, state="disabled", textvariable=self.client_v, values=client_list,
                             justify='center')
            w.pack(fill=X, side=LEFT, expand=YES)
            # ttk.Button(master=client, text='->', command=self.on_next_word, takefocus=0)\
            #    .pack(fill=X, side=LEFT)
            client.pack(fill='both', expand=YES)

            # language
            lan = tk.Frame(master=self.mianFram)
            # ttk.Button(master=lan, text='<-', command=self.on_prev_word, takefocus=0).pack(fill=X, side=LEFT)
            self.lan_v = StringVar()
            self.lan_v.set(self.lan)
            self.lan_box = ttk.Combobox(master=lan, state="readonly", textvariable=self.lan_v, values=self.lan_list,
                             justify='center')
            self.lan_box.bind("<<ComboboxSelected>>", self.lan_change)
            self.lan_box.pack(fill=X, side=LEFT, expand=YES)
            # ttk.Button(master=lan, text='->', command=self.on_next_word, takefocus=0).pack(fill=X, side=LEFT)
            lan.pack(fill='both', expand=YES)

            # group
            group = tk.Frame(master=self.mianFram)
            # ttk.Button(master=group, text='<-', command=self.on_prev_word, takefocus=0).pack(fill=X, side=LEFT)
            self.group_v = StringVar()
            self.group_v.set('group %d' % self.group)
            group_box = ttk.Combobox(master=group, state="readonly", textvariable=self.group_v, values=group_list,
                             justify='center')
            group_box.bind("<<ComboboxSelected>>", self.group_change)
            group_box.pack(fill=X, side=LEFT, expand=YES)
            # ttk.Button(master=group, text='->', command=self.on_next_word, takefocus=0).pack(fill=X, side=LEFT)
            group.pack(fill='both', expand=YES)

            # word
            self.word_label = ['word %d' % x for x in range(100)]
            word = tk.Frame(master=self.mianFram)
            ttk.Button(master=word, text='<-', command=lambda
                event=None: self.on_prev_word(event), takefocus=0).pack(fill=X, side=LEFT, expand=YES)
            self.word_v = StringVar()
            self.word_v.set('word %d' % self.word)
            print self.word
            self.word_box = ttk.Combobox(master=word, state="readonly", textvariable=self.word_v, values=self.word_label,
                             justify='center',width=70)
            self.word_box.bind("<<ComboboxSelected>>", self.update_text)
            # self.word_box.bind_all('a', self.on_prev_word)
            # self.word_box.bind_all('d', self.on_next_word)
            self.word_box.pack(fill=X, side=LEFT)
            # w.bind("<space>", self.choose_image)
            ttk.Button(master=word, text='->', command=lambda
                event=None: self.on_next_word(event), takefocus=0).pack(fill=X, side=LEFT, expand=YES)
            word.pack(fill='both', expand=YES, anchor='center')

            # Label
            self.label_v = StringVar()
            self.label_v.set("Stopped")
            show_label = tk.Frame(master=self.mianFram)
            self.s = ttk.Style()
            self.states_label = ttk.Label(master=show_label, textvariable=self.label_v, font=("Times", 28))\
                .pack(expand=YES)
            self.s .configure('TLabel', foreground='red')
            show_label.pack(fill='both', expand=YES)


            # show word
            self.v = StringVar()
            self.v.set(self.word_list[0])
            show_word = tk.Frame(master=self.mianFram)
            self.show_label = tk.Label(master=show_word, textvariable=self.v, font=("Helvetica", 28)).pack(expand=YES)
            show_word.pack(fill='both', expand=YES)

            # start
            start_stop = tk.Frame(master=self.mianFram)
            start_stop_button = ttk.Button(master=start_stop, text='Start/Stop', command=lambda
                event=None: self.glove_leap(event), takefocus=0).pack(fill=X, side=LEFT,expand=YES)
            start_stop.pack(fill='both', expand=YES)
            self.mianFram.bind_all('<space>', self.glove_leap)
            self.setup_ui()

            noteBookFrame = tk.Frame(master=self.mianFram)
            self.notebook = ttk.Notebook(master=noteBookFrame)
            self.log = tk.Text(master=self.notebook, takefocus=0, height=5, state='disable')
            # TreeViewin
            self.file = ttk.Treeview(master=self.notebook, columns=("A", "B"), height=5)
            self.file.heading("#0", text='Item')
            self.file.heading("#1", text='Floder')
            self.file.heading("#2", text='Modification Date')
            self.file.column('#0', anchor="c", stretch=tk.YES)
            self.file.column("#1", anchor="c", stretch=tk.YES)
            self.file.column('#2', anchor="c", stretch=tk.YES)
            self.file.bind('<Double-1>', self.open_file)
            # Menu
            self.menu = tk.Menu(self.file, tearoff=0)
            self.menu.add_command(label="open", command=self.open_file_menu)
            self.menu.add_separator()
            self.menu.add_command(label="delete", command=self.delete_file)
            self.file.bind('<Button-3>', self.show_menu)
            self.notebook.add(self.log, text="Output")
            self.notebook.add(self.file, text="File")
            self.notebook.pack(fill='both', expand=YES)
            noteBookFrame.pack(fill='both', expand=YES)

            self.update_all()
 def pan(self, *args):
     NavigationToolbar2Tk.pan(self)
     self.mode = ""
     self.set_message(self.mode)
Example #23
0
    while True:
        line = infile.readline()
        if not line:
            break
        x_data, y_data = [float(i) for i in line.split()]
        x.append(x_data)
        y.append(y_data)
    infile.close()
    f_plot.clear()
    f_plot.plot(x, y)
    canvs.draw()


canvs = FigureCanvasTkAgg(f, root)
canvs.get_tk_widget().pack(anchor=tk.SE,
                           side=tk.TOP,
                           expand=tk.TRUE,
                           fill=tk.BOTH)
button = tk.Button(fm, text='plot', command=press_button, width=10)
button.pack(anchor=tk.SW, pady=100, padx=50)
toolbar = NavigationToolbar2Tk(canvs, root)
toolbar.update()


def on_key_event(event):
    key_press_handler(event, canvs, toolbar)


canvs.mpl_connect('key_press_event', on_key_event)
root.mainloop()
Example #24
0
    def __init__(self, parent):
        ttk.Frame.__init__(self, parent)

        frameMapControl = ttk.Frame(self)
        frameMapControl.pack(side='bottom')
        ''' Variables '''
        varMapCenterAzimuth = tk.StringVar()
        varMapCenterElevation = tk.StringVar()
        varMapHeight = tk.StringVar()
        varMapWidth = tk.StringVar()
        ''' Label '''
        labelMapCenterAzimuth = ttk.Label(frameMapControl,
                                          text='Center Azimuth:')
        labelMapCenterElevation = ttk.Label(frameMapControl,
                                            text='Center Elevation:')
        labelMapHeight = ttk.Label(frameMapControl, text='Height:')
        labelMapWidth = ttk.Label(frameMapControl, text='Width:')
        labelMapMessage = ttk.Label(frameMapControl, text='Ready to Map')
        ''' Entry '''
        entryMapStartAzimuth = ttk.Entry(frameMapControl,
                                         textvariable=varMapCenterAzimuth)
        entryMapStartElevation = ttk.Entry(frameMapControl,
                                           textvariable=varMapCenterElevation)
        entryMapHeight = ttk.Entry(frameMapControl, textvariable=varMapHeight)
        entryMapWidth = ttk.Entry(frameMapControl, textvariable=varMapWidth)
        ''' Button '''
        buttonMap = ttk.Button(
            frameMapControl,
            text='Map',
            command=lambda: cmdMap(entryMapStartAzimuth.get(
            ), entryMapStartElevation.get(), entryMapHeight.get(),
                                   entryMapWidth.get(), labelMapMessage))
        ''' Other '''
        # progressBar = ttk.Progressbar(frameScanControl, orient='horizontal', length=100, mode='determinate').grid(row=2, column=0, columnspan=5, sticky='nsew')
        # sep = ttk.Separator(frameConnection, orient='horizontal')
        # sep.grid(row=2, column=0, columnspan=2, sticky='we')
        ''' Grid Layout '''
        # Label
        labelMapCenterAzimuth.grid(row=0, column=0, sticky='nsew')
        labelMapCenterElevation.grid(row=1, column=0, sticky='nsew')
        labelMapHeight.grid(row=0, column=2, sticky='nsew')
        labelMapWidth.grid(row=1, column=2, sticky='nsew')
        labelMapMessage.grid(row=2, column=0, columnspan=5)

        # Entry
        entryMapStartAzimuth.grid(row=0, column=1)
        entryMapStartElevation.grid(row=1, column=1)
        entryMapHeight.grid(row=0, column=3)
        entryMapWidth.grid(row=1, column=3)

        # Button
        buttonMap.grid(row=0, column=4, rowspan=2)
        ''' Graph '''
        # make these smaller to increase the resolution
        dx, dy = 0.05, 0.05

        # generate 2 2d grids for the x & y bounds
        y, x = np.mgrid[slice(1, 5 + dy, dy), slice(1, 5 + dx, dx)]

        z = np.sin(x)**10 + np.cos(10 + y * x) * np.cos(x)

        z = z[:-1, :-1]

        # Colorbar Scaling
        levels = MaxNLocator(nbins=15).tick_values(z.min(), z.max())

        figureMap = plt.figure(2)
        plotMap = figureMap.add_subplot(111)

        cf = plotMap.contourf(x[:-1, :-1] + dx / 2.,
                              y[:-1, :-1] + dy / 2.,
                              z,
                              levels=levels,
                              cmap=plt.cm.jet)

        cb = figureMap.colorbar(cf, ax=plotMap)

        plotMap.set_title('Yoink!')

        plotMap.set_xlabel(r'Azimuth ($^\circ$)')
        plotMap.set_ylabel(r'Elevation ($^\circ$)')

        cb.minorticks_on()
        cb.set_label(r'Power ($\mu$W)')

        # Tkinter Matplotlib Graphing Code
        canvasMap = FigureCanvasTkAgg(figureMap, self)
        canvasMap.draw()
        canvasMap.get_tk_widget().pack(side=tk.BOTTOM,
                                       fill=tk.BOTH,
                                       expand=True,
                                       anchor=tk.S)

        toolbarMap = NavigationToolbar2Tk(canvasMap, self)
        toolbarMap.update()
        # canvasMap.tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=True, anchor=tk.S)
        canvasMap.get_tk_widget().pack(side=tk.TOP,
                                       fill=tk.BOTH,
                                       expand=True,
                                       anchor=tk.S)
Example #25
0
entryScanAmount = ttk.Entry(frameScanControl,
                            textvariable=varScanAmount).grid(row=1, column=3)
optionMenuScanDirection = ttk.OptionMenu(
    frameScanControl, varScanDirection, optionListScanDirection[0],
    *optionListScanDirection).grid(row=0, column=3, sticky='nsew')
buttonScan = ttk.Button(frameScanControl, text='Scan').grid(row=0,
                                                            column=4,
                                                            rowspan=2)
# progressBar = ttk.Progressbar(frameScanControl, orient='horizontal', length=100, mode='determinate').grid(row=2, column=0, columnspan=5, sticky='nsew')
# sep = ttk.Separator(frameConnection, orient='horizontal')
# sep.grid(row=2, column=0, columnspan=2, sticky='we')

# Plots
canvasScan = FigureCanvasTkAgg(figScan, tabScan)
canvasScan.draw()
canvasScan.get_tk_widget().pack(side=tk.BOTTOM,
                                fill=tk.BOTH,
                                expand=True,
                                anchor=tk.S)

toolbarScan = NavigationToolbar2Tk(canvasScan, tabScan)
toolbarScan.update()
canvasScan.tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=True, anchor=tk.S)

tab_main.pack(expand=1, fill='both', side='right')
tab_info.pack(side='top', anchor='w', fill='both')
tab_files.pack(side='top', anchor='w', fill='y', expand=1)

mrtGUI.resizable(False, False)
mrtGUI.mainloop()
Example #26
0
    def __init__(self):
        self.root = Tk()
        self.root.title("Tc Example")

        self.m = Model()

        self.is_filter_type_set = False

        self.filter_type_list = self.m.get_available_filters()
        self.approximation_type_list = ["Approximation type"]

        self.existing_filters = []  #contiene tuples de filter_ID y nombre

        #------------------------------------------------------------------------
        # create a toplevel menu
        #------------------------------------------------------------------------
        menubar = Menu(self.root)
        menubar.add_command(label="About...", command=self.show_credits)
        menubar.add_command(label="Quit", command=self.root.quit)
        self.root.config(menu=menubar)

        #------------------------------------------------------------------------
        #create user input frame
        #------------------------------------------------------------------------
        user_input_frame = LabelFrame(self.root)
        user_input_frame.pack(side=LEFT, fill="y")

        #------------------------------------------------------------------------
        #Frame filter_type-------------------------------------------------------
        #------------------------------------------------------------------------
        filter_type_frame = LabelFrame(user_input_frame,
                                       text="Filter type",
                                       width=20,
                                       height=15)
        filter_type_frame.pack(side=TOP, fill="x")

        # filter-type drop-down menu
        self.filter_type_name = StringVar()
        self.filter_type_name.set("Filter type")  # default value
        filter_type_menu = OptionMenu(filter_type_frame, self.filter_type_name,
                                      *self.filter_type_list)
        filter_type_menu.pack(side=TOP, fill="x")

        # filter_type confirm button
        filter_type_set_button = Button(filter_type_frame,
                                        text="Set filter type",
                                        command=self.set_filter_type)
        filter_type_set_button.pack(side=TOP)

        #------------------------------------------------------------------------
        #Frame plantilla---------------------------------------------------------
        #------------------------------------------------------------------------
        self.template_parameters_frame = LabelFrame(user_input_frame,
                                                    text="Plantilla",
                                                    width=20,
                                                    height=15)
        self.template_parameters_frame.pack(side=TOP, fill="x")

        #todos los parametros para el template
        self.template_parameters_input = {
            "wa": [],
            "wp": [],
            "Aa": [],
            "Ap": [],
            "w0": [],
            "BWp": [],
            "BWa": [],
            "tau": [],
            "tol": [],
            "wrg": []
        }

        #entries para los parametros del templates
        for key in self.template_parameters_input:
            self.template_parameters_input[key].append(
                StringVar())  #template_parameters_input[key][0]
            self.template_parameters_input[key].append(
                Frame(self.template_parameters_frame)
            )  #template_parameters_input[key][1]
            self.template_parameters_input[key].append(
                Entry(self.template_parameters_input[key][1],
                      width=30,
                      textvariable=self.template_parameters_input[key][0],
                      state='disabled'))
            self.template_parameters_input[key][2].pack(side=RIGHT)
            Label(self.template_parameters_input[key][1],
                  text=key).pack(side=RIGHT)
            self.template_parameters_input[key][1].pack(side=TOP, anchor=NE)

        #desnormalizacion con sliders
        desnorm_input = Frame(self.template_parameters_frame)
        self.desnorm = StringVar()
        desnorm_scale = Scale(desnorm_input,
                              from_=0,
                              to_=100,
                              orient=HORIZONTAL,
                              variable=self.desnorm)
        desnorm_scale.pack(side=RIGHT)
        desnormLabel = Label(desnorm_input, text="Desnormalizacion")
        desnormLabel.pack(side=RIGHT, fill=X)
        desnorm_input.pack(anchor=NW)

        #Qmax
        qmax_input_frame = Frame(self.template_parameters_frame)
        self.qmax_value = StringVar()

        qmax_label = Label(qmax_input_frame, text="Q max:")
        self.qmax_input = Entry(qmax_input_frame,
                                textvariable=self.qmax_value,
                                width=5,
                                state='disabled')

        qmax_label.pack(side=LEFT)
        self.qmax_input.pack(side=LEFT)

        qmax_input_frame.pack(side=TOP, pady=2)

        #setemo modo de n
        self.n_options_name = StringVar()
        self.n_options_list = ["N libre", "N min y max", "N fijo"]
        self.n_options_name.set(self.n_options_list[0])
        n_options_menu = OptionMenu(self.template_parameters_frame,
                                    self.n_options_name,
                                    *self.n_options_list,
                                    command=self.n_mode_cb)
        n_options_menu.pack(side=TOP)

        #nmin y nmax
        nmaxmin_input_frame = Frame(self.template_parameters_frame)

        self.nmax_value = StringVar()
        self.nmin_value = StringVar()

        self.nmax_input = Entry(nmaxmin_input_frame,
                                textvariable=self.nmax_value,
                                width=5,
                                state='disabled')
        self.nmin_input = Entry(nmaxmin_input_frame,
                                textvariable=self.nmin_value,
                                width=5,
                                state='disabled')

        nmaxmin_label = Label(nmaxmin_input_frame, text="Rango N:")
        nmaxmin_separator = Label(nmaxmin_input_frame, text=" - ")

        nmaxmin_label.pack(side=LEFT)
        self.nmin_input.pack(side=LEFT)
        nmaxmin_separator.pack(side=LEFT)
        self.nmax_input.pack(side=LEFT)

        nmaxmin_input_frame.pack(side=TOP, pady=2)

        #n fijo
        nfijo_input_frame = Frame(self.template_parameters_frame)
        self.nfijo_value = StringVar()

        nfijo_label = Label(nfijo_input_frame, text="N fijo:")
        self.nfijo_input = Entry(nfijo_input_frame,
                                 textvariable=self.nfijo_value,
                                 width=5,
                                 state='disabled')

        nfijo_label.pack(side=LEFT)
        self.nfijo_input.pack(side=LEFT)

        nfijo_input_frame.pack(side=TOP, pady=2)

        self.approximation_type_name = StringVar()
        self.approximation_type_name.set("Approximation type")  # default value
        self.approximation_type_menu = OptionMenu(
            self.template_parameters_frame, self.approximation_type_name,
            *self.approximation_type_list)
        self.approximation_type_menu.pack(side=TOP, fill="x")

        self.template_parameters_set_button = Button(
            user_input_frame,
            text="Calculate new filter",
            command=self.calculate_new_filter_cb)
        self.template_parameters_set_button.pack()

        #------------------------------------------------------------------------
        toolbar = Frame(self.root)

        #todos los posibles graficos
        self.filter_plots_info = {
            "Mag": [],
            "Ate": [],
            "Pha": [],
            "Pha ret": [],
            "PZ": [],
            "Step": [],
            "Imp": []
        }

        #entries para los parametros del templates
        for key in self.filter_plots_info:
            #            self.filter_plots_info[key].append(Button(toolbar, text=key, command=locals()[key]()))
            #            self.filter_plots_info[key][0].pack(side=LEFT,padx=2,pady=2)
            print(key)

            # self.template_parameters_input[key].append(StringVar())                           #template_parameters_input[key][0]
            # self.template_parameters_input[key].append(Frame(template_parameters_frame))      #template_parameters_input[key][1]
            # self.template_parameters_input[key].append(Entry(self.template_parameters_input[key][1], width = 30, textvariable=self.template_parameters_input[key][0], state='disabled'))
            # self.template_parameters_input[key][2].pack(side=RIGHT)
            # Label(self.template_parameters_input[key][1], text=key).pack(side=RIGHT)
            # self.template_parameters_input[key][1].pack(side=TOP, anchor = NE)

        #parametros de los graficos
        self.normalizacion = StringVar()
        self.unidades = StringVar()
        self.db_veces = StringVar()
        self.current_plot = StringVar()

        #posibles valores para los parametros anteriores, el primero de la lista es el default
        self.normalizacion_list = ["Desnormalizado", "Normalizado"]
        self.unidades_list = ["Hz", "rad/s"]
        self.db_veces_list = ["dB", "Veces"]
        self.current_plot_list = self.m.get_available_plots()

        #valores default
        self.normalizacion.set(self.normalizacion_list[0])
        self.unidades.set(self.unidades_list[0])
        self.db_veces.set(self.db_veces_list[0])
        self.current_plot.set(self.current_plot_list[0])

        #creo los drop-down de los parametros
        normalizacion_input = OptionMenu(toolbar, self.normalizacion,
                                         *self.normalizacion_list)
        unidades_input = OptionMenu(toolbar, self.unidades,
                                    *self.unidades_list)
        db_veces_input = OptionMenu(toolbar, self.db_veces,
                                    *self.db_veces_list)
        current_plot_input = OptionMenu(toolbar, self.current_plot,
                                        *self.current_plot_list)

        normalizacion_input.pack(side=TOP, pady=2, fill='x')
        unidades_input.pack(side=TOP, pady=2, fill='x')
        db_veces_input.pack(side=TOP, pady=2, fill='x')
        current_plot_input.pack(side=TOP, pady=2, fill='x')

        #-----------
        #-----------
        #-----------
        self.existing_filters_frame = LabelFrame(toolbar,
                                                 text="Filtros existentes",
                                                 width=20)
        self.existing_filters_frame.pack(side=TOP, fill="x")

        #obtener de rochi
        self.filters = []
        self.filters_input = []

        stage_2_button = Button(toolbar,
                                text="Seleccionados a etapa 2",
                                command=self.stage_2_cb)
        stage_2_button.pack(side=BOTTOM, fill='x')

        delete_filters_button = Button(toolbar,
                                       text="Borrar deseleccionados",
                                       command=self.delete_unselected_cb)
        delete_filters_button.pack(side=BOTTOM, fill='x')

        Button(toolbar, text="Plot", command=self.plot).pack()

        toolbar.pack(side=RIGHT, fill=Y)
        graph = Canvas(self.root)
        graph.pack(side=TOP, fill=BOTH, expand=True, padx=2, pady=4)
        #-------------------------------------------------------------------------------

        f = Figure()
        self.axis = f.add_subplot(111)
        self.sys = signal.TransferFunction([1], [1, 1])
        self.w, self.mag, self.phase = signal.bode(self.sys)
        self.stepT, self.stepMag = signal.step(self.sys)
        self.impT, self.impMag = signal.impulse(self.sys)

        self.dataPlot = FigureCanvasTkAgg(f, master=graph)
        self.dataPlot.draw()
        self.dataPlot.get_tk_widget().pack(side=TOP, fill=BOTH, expand=True)
        nav = NavigationToolbar2Tk(self.dataPlot, self.root)
        nav.update()
        self.dataPlot._tkcanvas.pack(side=TOP, fill=X, expand=True)
        # self.plotMag()
        #-------------------------------------------------------------------------------
        self.root.mainloop()
Example #27
0
    def __init__(self, parent):
        ttk.Frame.__init__(self, parent)

        frameScanControl = ttk.Frame(self)
        frameScanControl.pack(side='bottom')

        optionListScanDirection = [
            'Up', 'Down', 'Clockwise', 'Counterclockwise'
        ]
        ''' Variables '''
        varScanStartAzimuth = tk.StringVar()
        varScanStartElevation = tk.StringVar()
        varScanDirection = tk.StringVar()
        varScanAmount = tk.StringVar()
        ''' Widgets '''
        # Label
        labelScanStartAzimuth = ttk.Label(frameScanControl,
                                          text='Start Azimuth:')
        labelScanStartElevation = ttk.Label(frameScanControl,
                                            text='Start Elevation:')
        labelScanDirection = ttk.Label(frameScanControl, text='Direction:')
        labelScanAmount = ttk.Label(frameScanControl, text='Amount:')
        labelScanMessage = ttk.Label(frameScanControl, text='Ready to Scan')

        # Entry
        entryScanStartAzimuth = ttk.Entry(frameScanControl,
                                          textvariable=varScanStartAzimuth)
        entryScanStartElevation = ttk.Entry(frameScanControl,
                                            textvariable=varScanStartElevation)
        entryScanAmount = ttk.Entry(frameScanControl,
                                    textvariable=varScanAmount)

        # OptionMenu
        optionMenuScanDirection = ttk.OptionMenu(frameScanControl,
                                                 varScanDirection,
                                                 optionListScanDirection[0],
                                                 *optionListScanDirection)

        # Button
        buttonScan = ttk.Button(
            frameScanControl,
            text='Scan',
            command=lambda: cmdScan(varScanStartAzimuth.get(
            ), varScanStartElevation.get(), varScanDirection.get(),
                                    varScanAmount.get(), labelScanMessage))

        # Other
        # progressBar = ttk.Progressbar(frameScanControl, orient='horizontal', length=100, mode='determinate').grid(
        # row=2, column=0, columnspan=5, sticky='nsew') sep = ttk.Separator(frameConnection, orient='horizontal')
        # sep.grid(row=2, column=0, columnspan=2, sticky='we')
        ''' Grid Layout '''
        # Label
        labelScanStartAzimuth.grid(row=0, column=0, sticky='nsew')
        labelScanStartElevation.grid(row=1, column=0, sticky='nsew')
        labelScanDirection.grid(row=0, column=2, sticky='nsew')
        labelScanAmount.grid(row=1, column=2, sticky='nsew')
        labelScanMessage.grid(row=2, column=0, columnspan=5)

        # Entry
        entryScanStartAzimuth.grid(row=0, column=1)
        entryScanStartElevation.grid(row=1, column=1)
        entryScanAmount.grid(row=1, column=3)

        # OptionMenu
        optionMenuScanDirection.grid(row=0, column=3, sticky='nsew')

        # Button
        buttonScan.grid(row=0, column=4, rowspan=2)
        ''' Graph '''
        x = np.arange(0.0, 2.0, 0.01)
        y = 1 + np.sin(2 * np.pi * x)

        figureScan = plt.figure()

        plotScan = figureScan.add_subplot(111)
        plotScan.plot(x, y, '.-')

        plotScan.set_title('Yeet!')
        plotScan.set_xlabel(r'Azimuth ($^\circ$)')
        plotScan.set_ylabel(r'Power ($\mu$W)')

        canvasScan = FigureCanvasTkAgg(figureScan, self)
        canvasScan.draw()
        canvasScan.get_tk_widget().pack(side=tk.BOTTOM,
                                        fill=tk.BOTH,
                                        expand=True,
                                        anchor=tk.S)

        toolbarScan = NavigationToolbar2Tk(canvasScan, self)
        toolbarScan.update()
        # Replacing .tkcanvas with .get_tk_widget seems to "just work" (TM) - JA 2020/04/04
        # canvasScan.tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=True, anchor=tk.S)
        canvasScan.get_tk_widget().pack(side=tk.TOP,
                                        fill=tk.BOTH,
                                        expand=True,
                                        anchor=tk.S)
Example #28
0
        # print 'h %s '%c_height
        # print 'w %s ' %c_width

        pix_per_inch = self.winfo_fpixels('1i')
        fig.set_size_inches(0.8*c_width/pix_per_inch,0.65*c_height/pix_per_inch)
        # print fig.get_size_inches()
        canvas = FigureCanvasTkAgg(fig, master=figure_frame)
        canvas.draw()
        canvas.mpl_connect('pick_event', on_pick)
        canvas.mpl_connect('motion_notify_event', on_move)
        canvas.mpl_connect('button_release_event', on_release)
        canvas.mpl_connect('scroll_event', on_scroll)
        # canvas.get_tk_widget().pack(side=TOP, fill=BOTH, expand=False)
        # canvas.get_tk_widget().grid(row=0,  sticky='nsew')
        # self.ctoolbar = NavigationToolbar2Tk(canvas, toolbar_frame)
        self.ctoolbar = NavigationToolbar2Tk(canvas, toolbar_frame)
        self.ctoolbar.update()
        canvas._tkcanvas.pack(side=TOP, fill=BOTH, expand=False)
        # canvas._tkcanvas.grid(row=0,  sticky='nsew')
        # figure_frame.grid(row=0,  sticky='nsew')
        # toolbar_frame.grid(row=1,  sticky='nsew')
        figure_frame.pack(side=TOP, fill=BOTH, expand=False)
        toolbar_frame.pack(side=BOTTOM, fill=BOTH, expand=True)


    def load_project(self, pid):
        try:
            projectpath = self.projects_mem[pid]['path']
            if projectpath.split('.')[-1] != 'pyd':
                print 'Warning! Are you sure this project was saved correctly? The file\'s extension is not *.pyd.'
            with open(projectpath, "rb") as f: