Exemplo n.º 1
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)
Exemplo n.º 2
0
 def __init__(self, data_source):
     years    = mdates.YearLocator(2)   # every year
     months   = mdates.MonthLocator()  # every month
     yearsFmt = mdates.DateFormatter('%y')
     
     dt_list, ssn_list = data_source.get_plotting_data()
     
     self.figure = Figure(figsize=(12,8), dpi=72)   
     self.figure.patch.set_facecolor('white')
     self.figure.subplots_adjust(bottom=0.2)
     self.axis = self.figure.add_subplot(111) 
     self.axis.plot_date(dt_list, ssn_list, '-', lw=2)
     self.axis.axvline(date.today(), color='r')
     
     # format the ticks
     self.axis.xaxis.set_major_locator(years)
     self.axis.xaxis.set_major_formatter(yearsFmt)
     
     self.axis.grid(True)
     
     # rotates and right aligns the x labels, and moves the bottom of the
     # axes up to make room for them
     # The following line currently breaks voacapgui if the thumbnail is 
     # inserted into a panel
     # self.figure.autofmt_xdate(rotation=90)
     
     self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea   
Exemplo n.º 3
0
	def __init__(self):
		self.gladefile = "attenuation_calc.glade"
		windowname = "MainWindow"
		self.wTree=gtk.glade.XML(self.gladefile, windowname)

		dic = { "on_GetDataButton_clicked" : self.button1_clicked,
			"on_SaveImageMenuItem_activate" : self.save_image,
			"on_ExportMenuItem_activate" : self.save_data,
			"on_MainWindow_destroy" : (gtk.main_quit) ,
			"on_QuitMenuItem_activate" : (gtk.main_quit),
			"on_about_menuitem_activate" : self.about }

		self.wTree.signal_autoconnect(dic)

		self.figure = Figure(figsize=(6,4), dpi=72)
		self.axis = self.figure.add_subplot(111)
		self.axis.set_xlabel('Energies')
		self.axis.set_ylabel('Attenuation Length (microns)')
		self.axis.set_title('Attenuation Lengths vs Energy')
		self.axis.grid(True)
		self.canvas = FigureCanvasGTK(self.figure)
		self.canvas.show()
		self.graphview = self.wTree.get_widget("vbox1")
		self.graphview.pack_start(self.canvas,True,True)
		#self.graphview.pack_start(self.canvas,True,True)

		self.wTree.get_widget(windowname).maximize()

		self.E = {}
		self.attlen = {}

		return
Exemplo n.º 4
0
    def displayGraph(self, xaxis, yaxis, hist):

        if (hist == None):
            return

        try:
            dialog = gtk.Window()
            figure = Figure(figsize=(6, 4), dpi=72)
            axis = figure.add_subplot(111)
            canvas = FigureCanvasGTK(figure)  # a gtk.DrawingArea
            canvas.show()
            dialog.add(canvas)

            # empty axis if neccesary, and reset title and stuff
            axis.clear()
            axis.set_xlabel(xaxis)
            axis.set_ylabel(yaxis)

            if len(hist) > 1:
                axis.plot(hist[0], 'r')
                axis.plot(hist[1], 'g')
                axis.plot(hist[2], 'b')
            else:
                axis.plot(hist[0], 'r')

            dialog.show()

        except ValueError:
            sys.exit(1)
Exemplo n.º 5
0
    def __init__(self,
                 type=PointType.Default,
                 title='',
                 xupper=1.0,
                 yupper=1.0,
                 xlower=0,
                 ylower=0,
                 xlabel='',
                 ylabel='',
                 grid=True):

        self.type = type
        self.model = None
        self.figure = Figure()
        self.axis = self.figure.add_subplot(111)
        self.axis.set_title(title)
        self.axis.set_xlabel(xlabel)
        self.axis.set_ylabel(ylabel)
        self.axis.grid(grid)
        self.axis.set_xbound(xlower, xupper)
        self.axis.set_ybound(ylower, yupper)
        self.axis.set_autoscale_on(False)
        self.canvas = FigureCanvasGTK(self.figure)
        self.line, = self.axis.plot([], [])
        self.axis.set_position([0.15, 0.1, 0.80, 0.85])
        # There seems no better way to animate matplotlib figures
        # than having a separate periodic refresh which calls
        # a synchronous draw on the canvas
        self.cid = gobject.timeout_add(200, self.expose_event)
Exemplo n.º 6
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()
Exemplo n.º 7
0
 def update_uttview(self):
     utt = self.corpusview.current_utt
     origspeech_specfig = Figure(dpi=72)
     origspeech_specplot = origspeech_specfig.add_subplot(111)
     origspeech_specplot.specgram(utt["waveform"].samples, Fs=utt["waveform"].samplerate, NFFT=128, noverlap=64)
     origspeech_speccanvas = FigureCanvasGTK(origspeech_specfig)
     framecontents = self.frame_specutt.get_children()
     if framecontents:
         self.frame_specutt.remove(framecontents[0])
     self.frame_specutt.add(origspeech_speccanvas)
     self.entry_transcription.set_text(self.corpusview.transcriptions[self.corpusview.worklist[self.corpusview.current_index][0]])
     self.entry_comment.set_text(self.corpusview.comments[self.corpusview.worklist[self.corpusview.current_index][0]])
     self.buttonbox_words = gtk.HButtonBox()
     words = utt.get_relation("Word").as_list()
     for i, word in enumerate(words):
         button = gtk.Button()
         button.wordindex = i
         button.connect("clicked", self.change_wordview)
         button.set_label(word["name"])
         self.buttonbox_words.pack_end(button)
     framecontents = self.frame_words.get_children()
     if framecontents:
         self.frame_words.remove(framecontents[0])
     self.frame_words.add(self.buttonbox_words)
     self.table_utt.show_all()
     self.update_wordview()
Exemplo n.º 8
0
    def __init__(self,):
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.connect("destroy", self.pgquit)
        self.window.set_title("Plot window")
        self.window.set_border_width(5)
        self.window.set_default_size(800,600)

        self.table = gtk.Table(10,4, True)
        self.window.add(self.table)
        self.table.show()

        # ==========================================
        self.figure = Figure(figsize=(6,4), dpi=72)
        self.axis   = self.figure.add_subplot(111)
        self.axis.set_title('tip-tilt log plotter for Pyramid')
        self.axis.set_xlabel('Iteration')
        self.axis.set_ylabel('Tip-Tilt residual (micron)')
        self.axis.set_ylim([-80.0, 80.0])
        self.axis.set_ylim([-0.35, 0.35])
        self.axis.grid(True)
        x = np.arange(100)
        self.axis.plot(x)
        self.axis.plot(x)
        self.canvas = FigureCanvasGTK(self.figure)
        self.canvas.show()
        self.table.attach(self.canvas, 0, 4, 0,9)
        # ==========================================


        butt = gtk.Button("START")
        butt.connect("clicked", self.b_clicked1)
        self.table.attach(butt, 0, 1, 9, 10)
        butt.show()

        self.butt = gtk.Button("STOP")
        self.butt.connect("clicked", self.b_clicked2)        
        self.table.attach(self.butt, 1, 2, 9, 10)
        self.butt.show()

        #self.lbl = gtk.Label("ExpTime:")
        #self.butt.connect("clicked", self.b_clicked3)        
        #self.table.attach(self.lbl, 2, 3, 9, 10)
        #self.lbl.show()

        self.lbl_tint = gtk.Label("")
        self.table.attach(self.lbl_tint, 3, 4, 9, 10)
        self.lbl_tint.show()

        # ----------------
        self.window.show()
Exemplo n.º 9
0
    def __init__(self, filename=None, query=""):
        builder = gtk.Builder()
        builder.add_from_file(os.path.join(getdatapath(), "master_gui.ui"))
        self.root = builder.get_object('mainWin')
        builder.connect_signals(self)

        self.tlbStart = builder.get_object('tlbStart')
        self.tlbPause = builder.get_object('tlbPause')
        self.tlbStop = builder.get_object('tlbStop')
        self.statusbar = builder.get_object('statusbar1')
        self.imgQueryStatus = builder.get_object('imgQueryStatus')
        self.txtQueryQuery = builder.get_object('txtQueryQuery')

        self.graphContainer = builder.get_object('graphContainer')
        if matplotlib:
            # setup matplotlib stuff on first notebook page (empty graph)
            #self.figure = Figure(figsize=(6,4), dpi=72)
            self.figure = Figure()
            self.axis = self.figure.add_subplot(111)

            self.axis.set_xlabel('Time (secs.)')
            self.axis.set_ylabel('Size of waiting list')
            self.canvas = FigureCanvasGTK(self.figure)  # a gtk.DrawingArea
            self.canvas.show()
            self.graphContainer.pack_start(self.canvas, True, True)

            self.graph_lines = []
            self.graph_data = []
            for i in range(1, size):
                self.graph_lines += self.axis.plot([0])
                self.graph_data += [[0]]

            print self.graph_data
            print self.graph_lines

            self.axis.set_ylim(0, 100)
            self.axis.set_xlim(0, 10)

        self.root.show_all()
        self.running = False

        if filename:
            self.loadFile(filename)
        if query:
            self.txtQueryQuery.set_text(query)
            gobject.idle_add(self.on_start)
Exemplo n.º 10
0
def updt_plot(GUI):
    GUI.axis.lines.pop(0)
    GUI.axis.lines.pop(0)

    #GUI.axis.lines.pop(0)
    #GUI.axis.lines.pop(0)
    #GUI.axis.lines.pop(0)
    GUI.axis.plot(GUI.sig_x, 'b', label='tip')
    GUI.axis.plot(GUI.sig_y, 'r', label='tilt')

    GUI.axis.plot(GUI.sig_f, 'g', label='focus')
    #GUI.axis.lines.pop(0)

    #GUI.axis.plot(GUI.ave_a1, 'g', label='45a')
    #GUI.axis.plot(GUI.ave_a2, 'y', label='90a')

    GUI.canvas = FigureCanvasGTK(GUI.figure)
    GUI.canvas.show()
    GUI.table.attach(GUI.canvas, 0, 4, 0, 9)
Exemplo n.º 11
0
    def createProjectGraph(self, widget):

        while True:
            try:
                # empty axis if neccesary, and reset title and stuff
                self.axis.clear()
                self.axis.set_xlabel('Yepper')
                self.axis.set_ylabel('Flabber')
                self.axis.set_title('A Graph')
                self.axis.grid(True)

                # get data
                age = self.wTree.get_widget("entry2").get_text()
                size = self.wTree.get_widget("entry3").get_text()
                age != ""
                size != ""

                N = 1
                ind = arange(N)  # the x locations for the groups
                width = 0.35  # the width of the bars

                p1 = self.axis.bar(ind, int(age), width, color='r')
                p2 = self.axis.bar(ind + width, int(size), width, color='y')

                self.axis.legend((p1[0], p2[0]), ("Age", "Size"), shadow=True)
                #self.axis.set_xticks(ind+width, ('G1') )
                self.axis.set_xlim(-width, len(ind))

                self.canvas.destroy()
                self.canvas = FigureCanvasGTK(self.figure)  # a gtk.DrawingArea
                self.canvas.show()
                self.grahview = self.wTree.get_widget("vbox1")
                self.grahview.pack_start(self.canvas, True, True)
                break

            except ValueError:
                self.wDialog = gtk.glade.XML("project2.glade",
                                             "cannotCreateProjGraph")
                close = self.wDialog.get_widget("cannotCreateProjGraph")
                response = close.run()
                if response == gtk.RESPONSE_OK:
                    close.destroy()
                break
def updt_plot(GUI):
    GUI.axis.lines.pop(0)
    GUI.axis.lines.pop(0)

    #GUI.axis.lines.pop(0)
    #GUI.axis.lines.pop(0)
    #GUI.axis.lines.pop(0)
    GUI.axis.plot(GUI.sig_x, 'b', label='Oblique Astig')
    GUI.axis.plot(GUI.sig_y, 'r', label='Right Astig')
    GUI.axis.legend(loc=0)

    #GUI.axis.plot(GUI.sig_f, 'g', label='focus')
    #GUI.axis.lines.pop(0)

    #GUI.axis.plot(GUI.ave_a1, 'g', label='45a')
    #GUI.axis.plot(GUI.ave_a2, 'y', label='90a')

    GUI.canvas = FigureCanvasGTK(GUI.figure)
    GUI.canvas.show()
    GUI.table.attach(GUI.canvas, 0, 4, 0, 9)
Exemplo n.º 13
0
    def __init__(self):
        gladefile = "pygtk-matplotlib.glade"
        self.windowname = "main_window"
        self.wTree = gtk.glade.XML(gladefile, self.windowname)
        dic = {
            "on_main_window_destroy" : gtk.main_quit,
            "on_button1_clicked" : self.render_graph,
            #"on_button3_clicked" : self.fillTree,
            #"on_notebook1_switch_page" : self.selectNotebookPage,
            #"on_treeview1_button_press_event" : self.clickTree,
            #"on_button2_clicked" : self.createProjectGraph,
        }
        self.wTree.signal_autoconnect(dic)

        # setup matplotlib stuff on first notebook page (empty graph)
        self.figure = Figure(figsize=(6,4), dpi=72)
        self.axis = self.figure.add_subplot(1,1,1)
        self.axis.set_xlabel('Yepper')
        self.axis.set_ylabel('Flabber')
        self.axis.set_title('An Empty Graph')
        self.axis.grid(True)
        self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea
        self.canvas.show()
        # Adding matplotlib canvas to our window
        self.graphview = self.wTree.get_widget("main_vbox")
        self.graphview.pack_start(self.canvas, True, True)

        #self.listview = self.wTree.get_widget("treeview1")
        #self.listmodel = gtk.ListStore(str, int, int, str, str)
        #self.listview.set_model(self.listmodel)
        #renderer = gtk.CellRendererText()
        #column = gtk.TreeViewColumn("Name",renderer, text=0)
        #column.set_clickable(True)
        #column.set_sort_column_id(0)
        #column.connect("clicked", self.createDBGraph)
        #column.set_resizable(True)
        #self.listview.append_column(column)

        self.wTree.get_widget(self.windowname).show()
Exemplo n.º 14
0
	def button1_clicked(self,widget):
		self.graphview.remove(self.canvas) # important else they just get inserted again each time (not replaced)
		self.axis.cla()
		eltext = self.wTree.get_widget("ElementText").get_text()
		if eltext.find(',') == -1:
			el = self.wTree.get_widget("ElementText").get_text().split()
		else:
			el = self.wTree.get_widget("ElementText").get_text().split(',')		
		
		[self.E,self.attlen] = nx.calclengths(el)
		for e in self.attlen.keys():
			self.axis.loglog(self.E[e],self.attlen[e],label=e);
		self.axis.set_xlabel('Energy (MeV)')
		self.axis.set_ylabel('Attenuation Length (cm)')
		self.axis.set_title('Attenuation Lengths vs Energy')
		self.axis.legend(loc='lower right')
		self.axis.grid(True)
		self.canvas.destroy()
                self.canvas = FigureCanvasGTK(self.figure)
                self.canvas.show()
		self.graphview = self.wTree.get_widget("vbox1")
                self.graphview.pack_end(self.canvas, True, True)
Exemplo n.º 15
0
    def createDBGraph(self, widget):
        self.axis.clear()
        self.axis.set_xlabel('Samples (n)')
        self.axis.set_ylabel('Value (-)')
        self.axis.set_title(
            'Another Graph (click on the columnheader to sort)')
        self.axis.grid(True)

        # get columns from listmodel
        age = []
        for row in self.listmodel:
            age.append(row[1])
        size = []
        for row in self.listmodel:
            size.append(row[2])

        # get number of rows
        N = len(age)

        ind = arange(N)  # the x locations for the groups
        width = 0.35  # the width of the bars
        p1 = self.axis.bar(ind, age, width, color='b')
        p2 = self.axis.bar(ind + width, size, width, color='r')
        # destroy graph if it already exists
        while True:
            try:
                self.canvas2.destroy()
                break
            except:
                print "nothing to destroy"
                break

        self.canvas2 = FigureCanvasGTK(self.figure)  # a gtk.DrawingArea
        self.canvas2.show()
        self.grahview = self.wTree.get_widget("vbox2")
        self.grahview.pack_start(self.canvas2, True, True)
Exemplo n.º 16
0
    def update_wordview(self):
        u = self.corpusview.current_utt
        words = u.get_relation("SylStructure").as_list()
        word = words[self.corpusview.current_wordindex]
        try:
            prevword = word.prev_item
            prevwordname = prevword["name"]
            origstartsample = u["waveform"].samplerate * prevword["start"]
            synthstartsample = u["lindists"]["utt"]["waveform"].samplerate * prevword["start"]
            prevwordpronun = self.corpusview.pronuns[self.corpusview.worklist[self.corpusview.current_index][0]][self.corpusview.current_wordindex-1]
        except TypeError:
            prevwordname = "NONE"
            origstartsample = 0
            synthstartsample = 0
            prevwordpronun = ""
        wordname = word["name"]
        wordpronun = self.corpusview.pronuns[self.corpusview.worklist[self.corpusview.current_index][0]][self.corpusview.current_wordindex]
        try:
            nextword = word.next_item
            nextwordname = nextword["name"]
            origendsample = u["waveform"].samplerate * nextword["end"]
            synthendsample = u["lindists"]["utt"]["waveform"].samplerate * nextword["end"]
            nextwordpronun = self.corpusview.pronuns[self.corpusview.worklist[self.corpusview.current_index][0]][self.corpusview.current_wordindex+1]
        except TypeError:
            nextwordname = "NONE"
            origendsample = len(u["waveform"].samples)
            synthendsample = len(u["waveform"].samples)
            nextwordpronun = ""
            
        self.label_word1.set_label(prevwordname)
        self.label_word2.set_label(wordname)
        self.label_word3.set_label(nextwordname)

        self.entry_word1.set_text(prevwordpronun)
        self.entry_word2.set_text(wordpronun)
        self.entry_word3.set_text(nextwordpronun)

        self.origwordcontextwav = Waveform()
        self.origwordcontextwav.samplerate = u["waveform"].samplerate
        self.origwordcontextwav.samples = u["waveform"].samples[origstartsample:origendsample]
        origwordcontext_specfig = Figure(dpi=72)
        origwordcontext_specplot = origwordcontext_specfig.add_subplot(111)
        origwordcontext_specplot.specgram(self.origwordcontextwav.samples,
                                          Fs=self.origwordcontextwav.samplerate,
                                          NFFT=128, noverlap=64,
                                          xextent=(0.0, self.origwordcontextwav.samplerate*len(self.origwordcontextwav.samples)))
        origwordcontext_speccanvas = FigureCanvasGTK(origwordcontext_specfig)
        framecontents = self.frame_wordspecorig.get_children()
        if framecontents:
            self.frame_wordspecorig.remove(framecontents[0])
        self.frame_wordspecorig.add(origwordcontext_speccanvas)

        self.synthwordcontextwav = Waveform()
        self.synthwordcontextwav.samplerate = u["lindists"]["utt"]["waveform"].samplerate
        self.synthwordcontextwav.samples = u["lindists"]["utt"]["waveform"].samples[synthstartsample:synthendsample] 
        synthwordcontext_specfig = Figure(dpi=72)
        synthwordcontext_specplot = synthwordcontext_specfig.add_subplot(111)
        synthwordcontext_specplot.specgram(self.synthwordcontextwav.samples,
                                           Fs=self.synthwordcontextwav.samplerate,
                                           NFFT=128, noverlap=64,
                                           xextent=(0.0, self.synthwordcontextwav.samplerate*len(self.synthwordcontextwav.samples)))
        synthwordcontext_speccanvas = FigureCanvasGTK(synthwordcontext_specfig)
        framecontents = self.frame_wordspecsynth.get_children()
        if framecontents:
            self.frame_wordspecsynth.remove(framecontents[0])
        self.frame_wordspecsynth.add(synthwordcontext_speccanvas)
       
        self.statusbar.push(0, "Item: %s/%s (Word index: %s)" % (self.corpusview.current_index + 1, len(self.corpusview.worklist), self.corpusview.current_wordindex))
        self.table_words.show_all()
Exemplo n.º 17
0
    def __init__(self):
        self.gladefile = "property_hist.glade"

        self.widgetsTree = gtk.glade.XML(self.gladefile)

        dic = {
            "new_bins_number_selected": self.new_bins_number_selected,
            "on_range_check_toggled": self.on_range_check_toggled,
            "on_min_cutoff_box_activate": self.on_min_cutoff_box_activate,
            "on_max_cutoff_box_activate": self.on_max_cutoff_box_activate,
            "on_cumulative_check_toggled": self.on_cumulative_check_toggled,
            "on_normalized_check_toggled": self.on_normalized_check_toggled,
            "on_log_check_toggled": self.on_log_check_toggled,
            "on_obj_combo_changed": self.on_obj_combo_changed,
            "on_save_file_clicked": self.on_save_file_clicked,
        }

        self.widgetsTree.signal_autoconnect(dic)

        self.window = self.widgetsTree.get_widget("property_hist")

        if (self.window):
            self.window.connect("destroy", self.close_app)

        # -- initialization
        self.bins = 50

        self.cumulative = False
        self.cumulative_check = self.widgetsTree.get_widget("cumulative_check")

        self.normalized = False
        self.normalized_check = self.widgetsTree.get_widget("normalized_check")

        self.log = False
        self.log_check = self.widgetsTree.get_widget("log_check")

        self.undefined_value = -99
        self.property_names = [
            "BIG_SOFT_DATA_CONT", "BIG_SOFT_IND_DATA", "SOME_OTHER_OBJECT"
        ]

        # objects initialization
        self.properties = []
        self.properties.append(
            load_property_python_hpgl(166,
                                      141,
                                      20,
                                      "GAUSSIAN_PROP.INC",
                                      intype=True))
        self.properties.append(
            load_property_python_hpgl(166,
                                      141,
                                      20,
                                      "BIG_SOFT_DATA_160_141_20.INC",
                                      intype=True))

        #default object is 0
        self.property = self.properties[0]
        self.property_name = self.property_names[0]
        self.property_defined_only = self.property[
            self.property != self.undefined_value]

        self.bins_editbox = self.widgetsTree.get_widget("bins_editbox")
        self.bins_editbox.insert_text(str(self.bins), position=0)

        # objects box
        cell = []
        self.object_box = gtk.ListStore(str)
        self.cb = self.widgetsTree.get_widget("obj_combo")
        self.cb.set_model(self.object_box)

        for k in xrange(len(self.property_names)):
            self.object_box.append([self.property_names[k]])
            cell.append(gtk.CellRendererText())
            self.cb.pack_start(cell[k])
            self.cb.add_attribute(cell[k], 'text', k)

        self.cb.set_active(0)

        # -- histogram drawing
        self.figure = Figure(figsize=(6, 4), dpi=72)
        self.axis = self.figure.add_subplot(111)
        self.axis.hist(self.property_defined_only,
                       bins=self.bins,
                       range=self.range,
                       normed=self.normalized,
                       cumulative=self.cumulative,
                       log=self.log)
        self.axis.set_xlabel('Values')
        self.axis.set_ylabel('Count')
        self.axis.set_title(self.property_names[self.cb.get_active()])
        self.axis.grid(True)
        self.canvas = FigureCanvasGTK(self.figure)  # a gtk.DrawingArea
        self.canvas.show()
        self.graphview = self.widgetsTree.get_widget("draw_area")
        self.graphview.pack_start(self.canvas, True, True)

        # range elements
        self.max_cutoff = self.widgetsTree.get_widget("max_cutoff_box")
        self.max_cutoff.hide()
        self.min_cutoff = self.widgetsTree.get_widget("min_cutoff_box")
        self.min_cutoff.hide()

        self.min_cutoff_text = self.widgetsTree.get_widget("min_cutoff_text")
        self.min_cutoff_text.hide()
        self.max_cutoff_text = self.widgetsTree.get_widget("max_cutoff_text")
        self.max_cutoff_text.hide()

        self.range_check = self.widgetsTree.get_widget("range_check")

        self.save_file = self.widgetsTree.get_widget("save_file")
        # statistic calculation
        self.init()

        self.window.show()
Exemplo n.º 18
0
from matplotlib.figure import Figure

import gtk

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

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

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

a.plot(t, s)

canvas = FigureCanvasGTK(f)  # a gtk.DrawingArea
vbox.pack_start(canvas)

#button = gtk.Button('Quit')
#button.connect('clicked', lambda b: gtk.mainquit())
#button.show()
#vbox.pack_start(button)

win.show_all()
#gtk.mainloop()
gtk.main()
Exemplo n.º 19
0
    def __init__(self):
        gladefile = "project2.glade"
        self.windowname = "gtkbench"
        self.wTree = gtk.glade.XML(gladefile, self.windowname)
        self.win = self.wTree.get_widget("gtkbench")
        self.win.maximize()
        dic = {
            "on_window1_destroy": gtk.main_quit,
            "on_button1_clicked": self.submitDB,
            "on_button3_clicked": self.fillTree,
            "on_notebook1_switch_page": self.selectNotebookPage,
            "on_treeview1_button_press_event": self.clickTree,
            "on_button2_clicked": self.createProjectGraph
        }

        self.wTree.signal_autoconnect(dic)
        # start with database selection
        self.wDialog = gtk.glade.XML("project2.glade", "dbSelector")

        # 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('Yepper')
        self.axis.set_ylabel('Flabber')
        self.axis.set_title('An Empty Graph')
        self.axis.grid(True)

        self.canvas = FigureCanvasGTK(self.figure)  # a gtk.DrawingArea
        self.canvas.show()
        self.graphview = self.wTree.get_widget("vbox1")
        self.graphview.pack_start(self.canvas, True, True)

        # setup listview for database
        self.listview = self.wTree.get_widget("treeview1")
        self.listmodel = gtk.ListStore(str, int, int, str, str)
        self.listview.set_model(self.listmodel)

        renderer = gtk.CellRendererText()

        column = gtk.TreeViewColumn("Name", renderer, text=0)
        column.set_clickable(True)
        column.set_sort_column_id(0)
        column.connect("clicked", self.createDBGraph)
        column.set_resizable(True)
        self.listview.append_column(column)
        #renderer = gtk.CellRendererText()

        column = gtk.TreeViewColumn("Age", renderer, text=1)
        column.set_clickable(True)
        column.set_sort_column_id(1)
        column.connect("clicked", self.createDBGraph)
        column.set_resizable(True)
        self.listview.append_column(column)
        #self.listview.show()

        column = gtk.TreeViewColumn("Shoesize", renderer, text=2)
        column.set_clickable(True)
        column.set_sort_column_id(2)
        column.connect("clicked", self.createDBGraph)
        column.set_resizable(True)
        self.listview.append_column(column)
        #self.listview.show()

        column = gtk.TreeViewColumn("Created", renderer, text=3)
        column.set_clickable(True)
        column.set_sort_column_id(3)
        column.connect("clicked", self.createDBGraph)
        column.set_resizable(True)
        self.listview.append_column(column)
        #self.listview.show()
        #renderer = gtk.CellRendererText()

        column = gtk.TreeViewColumn("Updated", renderer, text=4)
        column.set_clickable(True)
        column.set_sort_column_id(4)
        column.connect("clicked", self.createDBGraph)
        column.set_resizable(True)
        self.listview.append_column(column)

        return