Exemplo n.º 1
0
    def add_figure_canvas(self, w=700, h=500):
        """Note: this method assumed self.main_hbox is already
        defined.  A figure canvas with a toolbar at the bottom is
        added to self.main_hbox."""
        self.fig = Figure(figsize=(8,6), dpi=100)
        self.ax = self.fig.add_subplot(111)
        t = arange(0.0,3.0,0.01)
        s = sin(2*pi*t)
        self.ax.plot(t,s)

        self.figcanvas = FigureCanvas(self.fig)  # a gtk.DrawingArea
        self.figcanvas.show()
        self.canvas_vbox = gtk.VBox()
        toolbar = NavigationToolbar(self.figcanvas, self.window)
        #toolbar.set_size_request(-1,50)
        self.figcanvas.set_size_request(w,h)
        toolbar.set_size_request(w,50)
        toolbar.show()
        self.canvas_vbox.pack_start(self.figcanvas)#, expand=True, \
            #fill=True, padding=5)
        self.canvas_vbox.pack_start(toolbar, False)#, False)#, padding=5)
        self.main_hbox.pack_start(self.canvas_vbox)#, expand=True, \
Exemplo n.º 2
0
buttons['Save'] = gtk.ToolButton(gtk.STOCK_SAVE_AS)
buttons['ReMesh'] = gtk.Button("ReMesh")
buttons['MachDown'] = gtk.ToolButton(gtk.STOCK_GO_BACK)
buttons['MachDisp'] = gtk.Button("")
buttons['MachUp'] = gtk.ToolButton(gtk.STOCK_GO_FORWARD)
buttons['ReDown'] = gtk.ToolButton(gtk.STOCK_GO_BACK)
buttons['ReDisp'] = gtk.Button("")
buttons['ReUp'] = gtk.ToolButton(gtk.STOCK_GO_FORWARD)
buttons['NEDown'] = gtk.ToolButton(gtk.STOCK_GO_BACK)
buttons['NEDisp'] = gtk.Button("")
buttons['NEUp'] = gtk.ToolButton(gtk.STOCK_GO_FORWARD)

fig = Figure()
canvas = FigureCanvas(fig)  # a gtk.DrawingArea
nav = NavigationToolbar(canvas, win)
nav.set_size_request(250, 35);

sep = [gtk.SeparatorToolItem() for i in range(10)]

toolbar = gtk.HBox(False, 2)
toolbar.pack_start(buttons['New'], False, False, 0)
toolbar.pack_start(buttons['Open'], False, False, 0)
toolbar.pack_start(buttons['Save'], False, False, 0)
toolbar.pack_start(sep[0], False, False, 0)
toolbar.pack_start(nav, False, False, 0)
toolbar.pack_start(sep[1], False, False, 0)
toolbar.pack_start(combobox, False, False, 0)
toolbar.pack_start(sep[2], False, False, 0)
toolbar.pack_start(buttons['ReMesh'], False, False, 0)
toolbar.pack_start(sep[3], False, False, 0)
toolbar.pack_start(buttons['MachDown'], False, False, 0)
Exemplo n.º 3
0
    def __init__(self):
        self.debug = 0
        
        self.test = RTP.Motor_PD_Control_Test(kp=2, kd=0.07)

        # create a new window
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
    
        # When the window is given the "delete_event" signal (this is given
        # by the window manager, usually by the "close" option, or on the
        # titlebar), we ask it to call the delete_event () function
        # as defined above. The data passed to the callback
        # function is NULL and is ignored in the callback function.
        self.window.connect("delete_event", self.delete_event)
    
        # Here we connect the "destroy" event to a signal handler.  
        # This event occurs when we call gtk_widget_destroy() on the window,
        # or if we return FALSE in the "delete_event" callback.
        self.window.connect("destroy", self.destroy)
    
        # Sets the border width of the window.
        self.window.set_border_width(10)
    
        # Creates a new button with the label "Hello World".
        self.swept_sine_button = gtk.Button("Swept Sine")
        self.step_button = gtk.Button("Step Response")
        self.reset_button = gtk.Button("Reset Theta")
        self.return_button = gtk.Button("Return to 0")
        self.sys_check_button = gtk.Button("System Check")
        self.ol_step_button = gtk.Button("OL Step")
        
        #self.vib_check = gtk.CheckButton(label="Use Vibration Suppression", \
        #                                 use_underline=False)
        self.vib_on_radio = gtk.RadioButton(None, "On")
        self.vib_off_radio = gtk.RadioButton(self.vib_on_radio, "Off")
        #button.connect("toggled", self.callback, "radio button 2")
        self.vib_off_radio.set_active(True)
        vib_label = gtk.Label("Vibration Suppression")
        ol_label = gtk.Label("OL Step Response")
        ol_hbox = gtk.HBox(homogeneous=False)
        amp_label = gtk.Label("amp:")
        dur_label = gtk.Label("duration:")
        self.ol_amp_entry = gtk.Entry()
        self.ol_amp_entry.set_max_length(7)
        self.ol_amp_entry.set_text("150")
        Entry_width = 50
        self.ol_amp_entry.set_size_request(Entry_width,-1)
        self.dur_entry = gtk.Entry()
        self.dur_entry.set_max_length(7)
        self.dur_entry.set_text("300")
        self.dur_entry.set_size_request(Entry_width,-1)
        ol_hbox.pack_end(self.ol_amp_entry, False)
        ol_hbox.pack_end(amp_label, False)
        #ol_hbox.pack_start(amp_label, False)
        #ol_hbox.pack_start(self.ol_amp_entry, False)
        ol_dur_box = gtk.HBox(homogeneous=False)
        ol_dur_box.pack_end(self.dur_entry, False)
        ol_dur_box.pack_end(dur_label, False)
        
        #Fixed Sine Controls
        self.fs_amp_entry = gtk.Entry()
        self.fs_amp_entry.set_max_length(7)
        self.fs_amp_entry.set_size_request(Entry_width, -1)
        self.fs_amp_entry.set_text("5")
        self.fs_freq_entry = gtk.Entry()
        self.fs_freq_entry.set_max_length(7)
        self.fs_freq_entry.set_size_request(Entry_width, -1)
        self.fs_freq_entry.set_text("0.5")
        self.fs_dur_entry = gtk.Entry()
        self.fs_dur_entry.set_max_length(7)
        self.fs_dur_entry.set_size_request(Entry_width, -1)
        self.fs_dur_entry.set_text("300")
        fs_label = gtk.Label('Fixed Sine')
        fs_amp_label = gtk.Label("amp (counts):")
        fs_freq_label = gtk.Label("freq (Hz):")
        fs_dur_label = gtk.Label("duration:")
        fsvbox = gtk.VBox(homogeneous=False, spacing=5)
        fsvbox.show()
        fsvbox.pack_start(fs_label)
        fshbox1 = gtk.HBox(homogeneous=False)
        fshbox1.pack_end(self.fs_amp_entry, False)
        fshbox1.pack_end(fs_amp_label, False)
        fsvbox.pack_start(fshbox1, False)
        fshbox2 = gtk.HBox(homogeneous=False)
        fshbox2.pack_end(self.fs_freq_entry, False)
        fshbox2.pack_end(fs_freq_label, False)
        fsvbox.pack_start(fshbox2, False)
        fshbox3 = gtk.HBox(homogeneous=False)
        fshbox3.pack_end(self.fs_dur_entry, False)
        fshbox3.pack_end(fs_dur_label, False)
        fsvbox.pack_start(fshbox3, False)
        self.fixed_sine_button = gtk.Button("Fixed Sine")
        fsvbox.pack_start(self.fixed_sine_button, False)

        #ol_dur_box.pack_start(dur_label, False)
        #ol_dur_box.pack_start(self.dur_entry, False)
        sep0 = gtk.HSeparator()
        sep1 = gtk.HSeparator()
        sep2 = gtk.HSeparator()
        sep3 = gtk.HSeparator()
        sep4 = gtk.HSeparator()
        
        
        #self.button.set_size_request(30, 40)
    
        # When the button receives the "clicked" signal, it will call the
        # function hello() passing it None as its argument.  The hello()
        # function is defined above.
        self.swept_sine_button.connect("clicked", self.swept_sine_test, None)
        self.step_button.connect("clicked", self.step_test, None)
        self.reset_button.connect("clicked", self.reset_theta, None)
        self.return_button.connect("clicked", self.return_to_zero, None)
        self.sys_check_button.connect("clicked", self.system_check, None)
        self.ol_step_button.connect("clicked", self.run_ol_step, None)
        self.fixed_sine_button.connect("clicked", self.fixed_sine_test, None)    
        # This will cause the window to be destroyed by calling
        # gtk_widget_destroy(window) when "clicked".  Again, the destroy
        # signal could come from here, or the window manager.
        #self.button.connect_object("clicked", gtk.Widget.destroy, self.window)

        big_hbox = gtk.HBox()#homogeneous=False, spacing=5)
        button_vbox = gtk.VBox(homogeneous=False, spacing=5)
        #self.vbox1 = gtk.VBox(homogeneous=False, spacing=0)
        # This packs the button into the window (a GTK container).
        #self.window.add(self.button)

        button_vbox.pack_start(self.sys_check_button, False)
        button_vbox.pack_start(sep0, False)
        button_vbox.pack_start(self.swept_sine_button, False, False, 0)
        button_vbox.pack_start(sep1, False)
        button_vbox.pack_start(vib_label, False)
        #button_vbox.pack_start(self.vib_check, False)
        button_vbox.pack_start(self.vib_on_radio, False)
        button_vbox.pack_start(self.vib_off_radio, False)
        button_vbox.pack_start(sep2, False)
        button_vbox.pack_start(self.step_button, False, False, 0)
        button_vbox.pack_start(sep3, False)
        #Fixed Sine Stuff
        button_vbox.pack_start(fsvbox, False)
        button_vbox.pack_start(sep4, False)
        button_vbox.pack_start(ol_label, False)
        button_vbox.pack_start(ol_hbox, False)
        button_vbox.pack_start(ol_dur_box, False)
        button_vbox.pack_start(self.ol_step_button, False)
        button_vbox.pack_start(self.reset_button, False)
        button_vbox.pack_start(self.return_button, False)
        
        

        self.f = Figure(figsize=(5,4), dpi=100)
        self.ax = self.f.add_subplot(111)
        t = arange(0.0,3.0,0.01)
        s = sin(2*pi*t)
        self.ax.plot(t,s)

        self.figcanvas = FigureCanvas(self.f)  # a gtk.DrawingArea
        self.figcanvas.show()
        canvas_vbox = gtk.VBox()
        toolbar = NavigationToolbar(self.figcanvas, self.window)
        #toolbar.set_size_request(-1,50)
        self.figcanvas.set_size_request(600,300)
        toolbar.set_size_request(600,50)
        toolbar.show()
        big_hbox.pack_start(button_vbox, False, False, 0)
        canvas_vbox.pack_start(self.figcanvas)#, expand=True, \
                               #fill=True, padding=5)
        canvas_vbox.pack_start(toolbar, False)#, False)#, padding=5)
        big_hbox.pack_start(canvas_vbox)#, expand=True, \
                            #fill=True, padding=5)
        

        self.window.add(big_hbox)

        # The final step is to display this newly created widget.
        #self.button.show()

        #self.window.set_size_request(1000,800)

        self.window.set_title('RTP Motor GUI v. 1.0')
        # and the window
        #self.window.show()
        self.window.set_position(gtk.WIN_POS_CENTER)
        self.window.show_all()
Exemplo n.º 4
0
buttons['Save'] = gtk.ToolButton(gtk.STOCK_SAVE_AS)
buttons['ReMesh'] = gtk.Button("ReMesh")
buttons['MachDown'] = gtk.ToolButton(gtk.STOCK_GO_BACK)
buttons['MachDisp'] = gtk.Button("")
buttons['MachUp'] = gtk.ToolButton(gtk.STOCK_GO_FORWARD)
buttons['ReDown'] = gtk.ToolButton(gtk.STOCK_GO_BACK)
buttons['ReDisp'] = gtk.Button("")
buttons['ReUp'] = gtk.ToolButton(gtk.STOCK_GO_FORWARD)
buttons['NEDown'] = gtk.ToolButton(gtk.STOCK_GO_BACK)
buttons['NEDisp'] = gtk.Button("")
buttons['NEUp'] = gtk.ToolButton(gtk.STOCK_GO_FORWARD)

fig = Figure()
canvas = FigureCanvas(fig)  # a gtk.DrawingArea
nav = NavigationToolbar(canvas, win)
nav.set_size_request(250, 35)

sep = [gtk.SeparatorToolItem() for i in range(10)]

toolbar = gtk.HBox(False, 2)
toolbar.pack_start(buttons['New'], False, False, 0)
toolbar.pack_start(buttons['Open'], False, False, 0)
toolbar.pack_start(buttons['Save'], False, False, 0)
toolbar.pack_start(sep[0], False, False, 0)
toolbar.pack_start(nav, False, False, 0)
toolbar.pack_start(sep[1], False, False, 0)
toolbar.pack_start(combobox, False, False, 0)
toolbar.pack_start(sep[2], False, False, 0)
toolbar.pack_start(buttons['ReMesh'], False, False, 0)
toolbar.pack_start(sep[3], False, False, 0)
toolbar.pack_start(buttons['MachDown'], False, False, 0)