Esempio n. 1
0
class WidgetsWrapper:
    def __init__(self):
        self.widgets = gtk.glade.XML('mpl_with_glade.glade')
        self.widgets.signal_autoconnect(GladeHandlers.__dict__)

        self.figure = Figure(figsize=(8,6), dpi=72)
        self.axis = self.figure.add_subplot(111)
        
        t = arange(0.0,3.0,0.01)
        s = sin(2*pi*t)
        self.axis.plot(t,s)
        self.axis.set_xlabel('time (s)')
        self.axis.set_ylabel('voltage')

        self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea
        self.canvas.show()
        self['vboxMain'].pack_start(self.canvas, gtk.TRUE, gtk.TRUE)
        self['vboxMain'].show()
        
        # below is optional if you want the navigation toolbar
        self.navToolbar = NavigationToolbar(self.canvas, self['windowMain'])
        self.navToolbar.lastDir = '/var/tmp/'
        self['vboxMain'].pack_start(self.navToolbar)
        self.navToolbar.show()

        sep = gtk.HSeparator()
        sep.show()
        self['vboxMain'].pack_start(sep, gtk.TRUE, gtk.TRUE)


        self['vboxMain'].reorder_child(self['buttonClickMe'],-1)

    def __getitem__(self, key):
        return self.widgets.get_widget(key)
Esempio n. 2
0
    def __init__(self):
        self.widgets = gtk.glade.XML('mpl_with_glade.glade')
        self.widgets.signal_autoconnect(GladeHandlers.__dict__)

        self.figure = Figure(figsize=(8, 6), dpi=72)
        self.axis = self.figure.add_subplot(111)

        t = arange(0.0, 3.0, 0.01)
        s = sin(2 * pi * t)
        self.axis.plot(t, s)
        self.axis.set_xlabel('time (s)')
        self.axis.set_ylabel('voltage')

        self.canvas = FigureCanvasGTK(self.figure)  # a gtk.DrawingArea
        self.canvas.show()
        self['vboxMain'].pack_start(self.canvas, gtk.TRUE, gtk.TRUE)
        self['vboxMain'].show()

        # below is optional if you want the navigation toolbar
        self.navToolbar = NavigationToolbar(self.canvas, self['windowMain'])
        self.navToolbar.lastDir = '/var/tmp/'
        self['vboxMain'].pack_start(self.navToolbar)
        self.navToolbar.show()

        sep = gtk.HSeparator()
        sep.show()
        self['vboxMain'].pack_start(sep, gtk.TRUE, gtk.TRUE)

        self['vboxMain'].reorder_child(self['buttonClickMe'], -1)
Esempio n. 3
0
    def __init__(self):
        gladefile = os.path.join(roslib.packages.get_pkg_dir('pplan'), "glade/pplan_gui.glade")
        self.windowname = "main_window"
        self.w_tree = gtk.glade.XML(gladefile, self.windowname)
        dic = {'on_main_window_destroy' : gtk.main_quit,
               'on_get_data_button_clicked' : self.get_data,
               'on_make_graph_button_clicked' : self.make_graph,
               'on_calc_kernel_button_clicked' : self.calc_kernel,
               'on_plan_path_button_clicked' : self.plan_path,
               }
        self.w_tree.signal_autoconnect(dic)

        main_window = self.w_tree.get_widget('main_window')
                                        
        # setup matplotlib stuff on first notebook page (empty graph)
        self.figure = Figure(figsize=(6,4), dpi=72)
        self.axis = self.figure.add_subplot(111)
        self.axis.set_xlabel('Longitude')
        self.axis.set_ylabel('Latitude')
        self.axis.set_title('')
        self.axis.grid(True)
        self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea
        self.canvas.show()
        self.graphview = self.w_tree.get_widget('vbox1')
        self.graphview.pack_start(self.canvas, True, True)
        self.nav_bar = NavigationToolbar(self.canvas, main_window)
        self.graphview.pack_start(self.nav_bar, False, True)

        run_dir = sys.argv[1]
        self.settings = pplan.PPlanSettings(run_dir)
        # initialize the data directory, if not done already
        self.store = ppas.Store(self.settings.data_dir)

        self.plot_graph()
        self.plot_path()
Esempio n. 4
0
 def _get_toolbar(self, canvas):
     # must be inited after the window, drawingArea and figure
     # attrs are set
     if matplotlib.rcParams['toolbar']=='classic':
         toolbar = NavigationToolbar (canvas, self.window)
     elif matplotlib.rcParams['toolbar']=='toolbar2':
         toolbar = NavigationToolbar2GTKAgg (canvas, self.window)
     else:
         toolbar = None
     return toolbar
Esempio n. 5
0
 def setupCanvas(self):
     self.f = Figure(figsize=(5, 4),
                     dpi=100,
                     subplotpars=SubplotParams(left=0.06,
                                               top=0.95,
                                               right=0.97,
                                               bottom=0.1))
     self.setupSubplots()
     self.canvas = FigureCanvas(self.f)
     #self.canvas.show()
     self.lower_vbox.pack_start(self.canvas)
     #self.canvas.get_tk_widget().pack(side=TOP, fill=BOTH, expand=1)
     self.toolbar = NavigationToolbar(self.canvas, self.window)
     self.lower_vbox.pack_start(self.toolbar, False, False)
Esempio n. 6
0
 def __init__(self, _components = None, _data=None):
     self.components = _components
     self.data = _data
     
     gtk.Window.__init__(self,gtk.WINDOW_TOPLEVEL)
     self.set_default_size(700,500)
     self.set_title("Choose components to use...")
     self.connect("delete_event", self.delete_event)
     self.connect("destroy", self.delete_event)
     
     self.vbox = gtk.VBox()
     self.add(self.vbox)
     self.f = Figure(figsize=(5,4), dpi=100, subplotpars=SubplotParams(left=0.06, top=0.95, right=0.97, bottom=0.1))
     self.setupSubplots()
     self.plotAll()
     self.canvas = FigureCanvas(self.f)
     self.canvas.mpl_connect('button_press_event', self.cb_canvas)
     self.vbox.pack_start(self.canvas)
     self.toolbar = NavigationToolbar( self.canvas, self.window )
     self.vbox.pack_start(self.toolbar, False, False)
     self.show_all()
Esempio n. 7
0
    def __init__(self, window=None, startGtk=0, dims=2):
        self.dims = dims
        self.data = numpy.zeros((10, 10), numpy.float32)
        self.data[:] = numpy.arange(10).astype(numpy.float32)
        self.deactivatefn = None  #this can be set by the caller, eg to turn off buttons...

        self.win = gtk.Window()
        self.win.connect("destroy", self.quit)
        self.win.set_default_size(400, 400)
        self.win.set_title("Window")
        self.cmap = colour.gray
        self.vbox = gtk.VBox()
        self.interpolation = "nearest"  #see pylab documantation for others.
        self.win.add(self.vbox)
        self.vbox.connect("button_press_event", self.buttonPress)
        self.fig = Figure(figsize=(5, 4), dpi=50)
        self.ax = self.fig.add_subplot(111)
        self.fig.subplots_adjust(right=0.99, left=0.08, bottom=0.05, top=0.99)
        #self.ax.imshow(self.data,interpolation=self.interpolation)
        #print type(fig),dir(ax),dir(fig)
        self.canvas = FigureCanvas(self.fig)  # a gtk.DrawingArea
        self.vbox.pack_start(self.canvas)
        self.toolbar = NavigationToolbar(self.canvas, self.win)
        self.vbox.pack_start(self.toolbar, False, False)
        self.mytoolbar = myToolbar(plotfn=self.plot)
        #self.toolbar.save_figure=self.mytoolbar.mysave
        self.vbox.pack_start(self.mytoolbar.toolbar, False, False)
        self.win.show_all()
        self.toolbar.hide()
        self.mytoolbar.toolbar.hide()
        self.active = 1  #will be set to zero once quit or window closed.
        self.toolbarVisible = 0
        self.startedGtk = 0
        self.update = 0
        #self.plot()
        if startGtk == 1 and gtk.main_level() == 0:
            self.startedGtk = 1
            thread.start_new_thread(gtk.main, ())
Esempio n. 8
0
win = gtk.Window()
win.set_title("Embedding in GTK")
win.connect("destroy", lambda x: gtk.main_quit())

vbox = gtk.VBox()
win.add(vbox)

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

ax.plot(t,s)

canvas = FigureCanvas(fig)  # a gtk.DrawingArea
vbox.pack_start(canvas)

toolbar = NavigationToolbar(canvas, win)
vbox.pack_start(toolbar, gtk.FALSE, gtk.FALSE)

win.show_all()
gtk.main()


def DataSet:
    def __init__():
        

def train_and_apply(modelfilename, trainset, 
Esempio n. 9
0
win = gtk.Window()
win.set_name("Embedding in GTK")
win.connect("destroy", gtk.mainquit)
win.set_border_width(5)

vbox = gtk.VBox(spacing=3)
win.add(vbox)
vbox.show()

fig = Figure(figsize=(5,4), dpi=100)

ax = fig.add_subplot(111)
t = arange(0.0,3.0,0.01)
s = sin(2*pi*t)

ax.plot(t,s)
ax.set_title('click on line or text')


canvas = PickerCanvas(fig)
canvas.show()
vbox.pack_start(canvas)

toolbar = NavigationToolbar(canvas, win)
toolbar.show()
vbox.pack_start(toolbar, gtk.FALSE, gtk.FALSE)


win.show()
gtk.mainloop()
Esempio n. 10
0

win = gtk.Window()
win.set_name("Embedding in GTK")
win.connect("destroy", gtk.mainquit)
win.set_border_width(5)

vbox = gtk.VBox(spacing=3)
win.add(vbox)
vbox.show()

fig = Figure(figsize=(5, 4), dpi=100)

ax = fig.add_subplot(111)
t = arange(0.0, 3.0, 0.01)
s = sin(2 * pi * t)

ax.plot(t, s)
ax.set_title('click on line or text')

canvas = PickerCanvas(fig)
canvas.show()
vbox.pack_start(canvas)

toolbar = NavigationToolbar(canvas, win)
toolbar.show()
vbox.pack_start(toolbar, gtk.FALSE, gtk.FALSE)

win.show()
gtk.mainloop()