コード例 #1
0
ファイル: testboxes.py プロジェクト: romed/python-gtkextra2
    def __init__(self):
        gtk.Window.__init__(self)
        self.set_title("GtkPlotBox Demo")
        self.set_size_request(550, 360)

        scrollwin = gtk.ScrolledWindow()
        scrollwin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.add(scrollwin)

        self.canvas = canvas = gtkextra.PlotCanvas(gtkextra.PLOT_LETTER_W,
                                                   gtkextra.PLOT_LETTER_H)
        canvas.plot_canvas_set_flags(gtkextra.PLOT_CANVAS_DND_FLAGS)
        scrollwin.add_with_viewport(canvas)

        plot = gtkextra.Plot()
        plot.resize(width=0.5, height=0.25)
        plot.set_range(-1.0, 1.0, -1.0, 1.4)
        plot.legends_move(0.51, 0.05)
        plot.set_legends_border(gtkextra.PLOT_BORDER_NONE,
                                gtkextra.PLOT_BORDER_NONE)
        plot.axis_hide_title(gtkextra.PLOT_AXIS_TOP)
        plot.axis_show_ticks(gtkextra.PLOT_AXIS_BOTTOM, 15, 3)
        plot.axis_set_ticks(gtkextra.PLOT_AXIS_X, 1.0, 1)
        plot.axis_set_ticks(gtkextra.PLOT_AXIS_Y, 1.0, 1)
        plot.x0_set_visible(gtk.TRUE)
        plot.y0_set_visible(gtk.TRUE)
        canvas.add_plot(plot, 0.15, 0.06)

        self.build_example1(plot)

        self.show_all()
コード例 #2
0
    def __init__(self):
        gtk.Window.__init__(self)
        self.set_title("GtkPlot Real Time Demo")
        self.set_size_request(550, 600)

        colormap = self.get_colormap()
        red = colormap.alloc_color("red")
        light_blue = colormap.alloc_color("light blue")
        light_yellow = colormap.alloc_color("light yellow")
        white = colormap.alloc_color("white")

        scrollwin = gtk.ScrolledWindow()
        scrollwin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.add(scrollwin)

        self.canvas = canvas = gtkextra.PlotCanvas(gtkextra.PLOT_LETTER_W,
                                                   gtkextra.PLOT_LETTER_H)
        canvas.set_background(light_blue)
        scrollwin.add_with_viewport(canvas)

        plot = gtkextra.Plot(width=0.65, height=0.45)
        plot.set_background(light_yellow)
        plot.legends_set_attributes(None, 0, None, white)
        plot.set_range(0.0, 20.0, 0.0, 1.0)
        plot.axis_set_ticks(gtkextra.PLOT_AXIS_X, 2.0, 1)
        plot.axis_set_ticks(gtkextra.PLOT_AXIS_Y, 0.1, 1)
        plot.axis_set_labels_style(gtkextra.PLOT_AXIS_TOP,
                                   gtkextra.PLOT_LABEL_FLOAT, 0)
        plot.axis_set_labels_style(gtkextra.PLOT_AXIS_BOTTOM,
                                   gtkextra.PLOT_LABEL_FLOAT, 0)
        plot.axis_set_visible(gtkextra.PLOT_AXIS_TOP, gtk.TRUE)
        plot.axis_set_visible(gtkextra.PLOT_AXIS_RIGHT, gtk.TRUE)
        plot.grids_set_visible(gtk.TRUE, gtk.TRUE, gtk.TRUE, gtk.TRUE)
        plot.axis_hide_title(gtkextra.PLOT_AXIS_TOP)
        plot.axis_hide_title(gtkextra.PLOT_AXIS_RIGHT)
        plot.axis_set_title(gtkextra.PLOT_AXIS_LEFT, "Intensity")
        plot.axis_set_title(gtkextra.PLOT_AXIS_BOTTOM, "Point")
        plot.set_legends_border(gtkextra.PLOT_BORDER_SHADOW, 3)
        plot.legends_move(0.60, 0.10)
        canvas.add_plot(plot, 0.15, 0.15)

        canvas.put_text(0.45, 0.05, "Times-BoldItalic", 20, 0, None, None,
                        gtk.TRUE, gtk.JUSTIFY_CENTER, "Iterator Demo")

        mask = gtkextra.PLOT_DATA_X | gtkextra.PLOT_DATA_Y | gtkextra.PLOT_DATA_LABELS
        data = gtkextra.PlotData(self.iterator, 20, mask)
        data.show_labels(gtk.TRUE)
        plot.add_data(data)
        data.set_legend("Iterator")
        data.set_symbol(gtkextra.PLOT_SYMBOL_DIAMOND,
                        gtkextra.PLOT_SYMBOL_OPAQUE, 10, 2, red, red)
        data.set_line_attributes(gtkextra.PLOT_LINE_SOLID, 0, 0, 1, red)

        self.show_all()
コード例 #3
0
ファイル: testpixmap.py プロジェクト: romed/python-gtkextra2
    def __init__(self):
        gtk.Window.__init__(self)
        self.set_title = ("GtkPlot3D Demo")
        self.set_size_request(550, 650)

        colormap = self.get_colormap()

        self.canvas = canvas = gtkextra.PlotCanvas(gtkextra.PLOT_LETTER_W,
                                                   gtkextra.PLOT_LETTER_H)
        canvas.plot_canvas_set_flags(gtkextra.PLOT_CANVAS_DND_FLAGS)
        self.add(canvas)

        plot = gtkextra.Plot(width=0.5, height=0.25)
        plot.set_range(0.0, 1.0, 0.0, 1.4)
        plot.legends_move(0.5, 0.05)
        plot.set_legends_border(0, 0)
        plot.axis_hide_title(gtkextra.PLOT_AXIS_TOP)
        plot.axis_show_ticks(gtkextra.PLOT_AXIS_BOTTOM, 15, 3)
        plot.axis_set_ticks(gtkextra.PLOT_AXIS_X, 1.0, 1)
        plot.axis_set_ticks(gtkextra.PLOT_AXIS_Y, 1.0, 1)
        plot.axis_set_visible(gtkextra.PLOT_AXIS_TOP, gtk.TRUE)
        plot.axis_set_visible(gtkextra.PLOT_AXIS_RIGHT, gtk.TRUE)
        plot.x0_set_visible(gtk.TRUE)
        plot.y0_set_visible(gtk.TRUE)
        canvas.add_plot(plot, 0.15, 0.06)

        px1 = [0., 0.2, 0.4, 0.6, 0.8, 1.0]
        py1 = [.2, .4, .5, .35, .30, .40]
        px2 = [.0, .2, .4, .6, .8, 1.0]
        py2 = [.12, .22, .27, .12, .52, .62]

        (pixmap, mask) = gtk.gdk.pixmap_colormap_create_from_xpm_d(
            None, colormap, None, self.cloud_xpm)
        data = gtkextra.PlotPixmap(pixmap, mask)
        data.set_points(x=px1, y=py1)
        data.set_legend("Pixmap 1")
        plot.add_data(data)

        (pixmap, mask) = gtk.gdk.pixmap_colormap_create_from_xpm_d(
            None, colormap, None, self.suncloud_xpm)

        data = gtkextra.PlotPixmap(pixmap, mask)
        data.set_points(x=px2, y=py2)
        data.set_legend("Pixmap 2")
        plot.add_data(data)

        self.show_all()

        try:
            canvas.export_ps("demopixmap.ps")
            print "Wrote demopixmap.ps"
        except:
            pass
コード例 #4
0
 def new_layer(self, canvas):
     self.nlayers = self.nlayers + 1
     button = gtk.ToggleButton(str(self.nlayers))
     button.set_size_request(20, 20)
     canvas.put(button, (self.nlayers - 1) * 20, 0)
     #button.connect("toggled", self.activate_plot, canvas) #FIXME
     plot = gtkextra.Plot()
     plot.resize(0.5, 0.25)
     self.buttons.append(button)
     self.plots.append(plot)
     button.set_active(True)
     return plot
コード例 #5
0
    def __init__(self):
        gtk.Window.__init__(self)
        self.set_title("GtkPlotFlux Demo")
        self.set_size_request(550, 340)

        colormap = self.get_colormap()
        red = colormap.alloc_color("red")

        scrollwin = gtk.ScrolledWindow()
        scrollwin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.add(scrollwin)

        self.canvas = canvas = gtkextra.PlotCanvas(gtkextra.PLOT_LETTER_W,
                                                   gtkextra.PLOT_LETTER_H)
        canvas.plot_canvas_set_flags(gtkextra.PLOT_CANVAS_DND_FLAGS)
        canvas.connect("select_item", self.select_item)
        scrollwin.add_with_viewport(canvas)

        plot = gtkextra.Plot()
        plot.resize(width=0.5, height=0.25)
        plot.set_range(-1.0, 1.0, -1.0, 1.4)
        plot.legends_move(0.51, 0.05)
        plot.set_legends_border(0, 0)
        plot.axis_hide_title(gtkextra.PLOT_AXIS_TOP)
        plot.axis_show_ticks(gtkextra.PLOT_AXIS_BOTTOM, 15, 3)
        plot.axis_set_ticks(gtkextra.PLOT_AXIS_X, 1.0, 1)
        plot.axis_set_ticks(gtkextra.PLOT_AXIS_Y, 1.0, 1)
        plot.axis_set_visible(gtkextra.PLOT_AXIS_TOP, gtk.TRUE)
        plot.axis_set_visible(gtkextra.PLOT_AXIS_RIGHT, gtk.TRUE)
        plot.x0_set_visible(gtk.TRUE)
        plot.y0_set_visible(gtk.TRUE)
        canvas.add_plot(plot, 0.15, 0.06)

        px1 = [0., 0.2, 0.4, 0.6, 0.8, 1.0]
        py1 = [.2, .4, .5, .35, .30, .40]
        px2 = [.12, .22, .27, .12, .052, .42]
        py2 = [.0, .05, .12, .22, .16, .1]

        data = gtkextra.PlotFlux()
        data.set_points(x=px1, y=py1, dx=px2, dy=py2)
        data.set_symbol(gtkextra.PLOT_SYMBOL_CIRCLE,
                        gtkextra.PLOT_SYMBOL_OPAQUE, 10, 2, red, red)
        data.set_line_attributes(gtkextra.PLOT_LINE_NONE, 0, 0, 1, red)
        data.set_legend("Flux")
        plot.add_data(data)

        self.show_all()
コード例 #6
0
    def __init__(self):
        gtk.Window.__init__(self)
        self.set_title("Bubbles Demo")
        self.set_size_request(550, 650)
        self.connect("destroy", lambda win: gtk.main_quit())

        colormap = self.get_colormap()
        blue = colormap.alloc_color("blue")

        scrollwin = gtk.ScrolledWindow()
        scrollwin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.add(scrollwin)

        self.canvas = canvas = gtkextra.PlotCanvas(gtkextra.PLOT_LETTER_W,
                                                   gtkextra.PLOT_LETTER_H)
        canvas.plot_canvas_set_flags(gtkextra.PLOT_CANVAS_DND_FLAGS)
        scrollwin.add_with_viewport(canvas)

        plot = gtkextra.Plot(width=0.5, height=0.25)
        plot.legends_move(0.05, 0.05)
        plot.set_legends_border(0, 0)
        plot.axis_hide_title(gtkextra.PLOT_AXIS_TOP)
        plot.axis_show_ticks(gtkextra.PLOT_AXIS_BOTTOM, 15, 3)
        plot.axis_set_visible(gtkextra.PLOT_AXIS_TOP, gtk.TRUE)
        plot.axis_set_visible(gtkextra.PLOT_AXIS_RIGHT, gtk.TRUE)
        plot.grids_set_visible(gtk.TRUE, gtk.TRUE, gtk.TRUE, gtk.TRUE)
        canvas.add_plot(plot, 0.15, 0.06)

        px1 = [0., 0.1, 0.2, 0.3, 0.4, 0.5, .6, .7, .8, .9]
        py1 = [.2, .4, .5, .35, .30, .40, .45, .56, .76, .87]
        pa1 = [.12, .22, .27, .12, .052, .12, .045, .214, .123, .088]
        pda1 = [.132, .23, .432, .34, .46, .56, .785, .76, .86, .89]

        data = gtkextra.PlotData()
        data.set_points(x=px1, y=py1, a=pa1, da=pda1)
        data.set_symbol(gtkextra.PLOT_SYMBOL_CIRCLE,
                        gtkextra.PLOT_SYMBOL_OPAQUE, 10, 2, blue, blue)
        data.set_line_attributes(gtkextra.PLOT_LINE_NONE, 0, 0, 1, blue)
        data.set_legend("Bubbles")
        data.gradient_set_visible(gtk.TRUE)
        plot.add_data(data)

        self.show_all()
コード例 #7
0
    def __init__(self):
        #gtk.Window.__init__(self)
        self.__gobject_init__()
        self.set_title("GtkPlot Real Time Demo")
        self.set_size_request(550, 600)
        self.connect("destroy", self.quit)

        colormap = self.get_colormap()
        red = colormap.alloc_color("red")
        light_blue = colormap.alloc_color("light blue")
        light_yellow = colormap.alloc_color("light yellow")
        white = colormap.alloc_color("white")

        scrollwin = gtk.ScrolledWindow()
        scrollwin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.add(scrollwin)

        self.canvas = canvas = gtkextra.PlotCanvas(gtkextra.PLOT_LETTER_W, gtkextra.PLOT_LETTER_H)
        canvas.set_background(light_blue)
        canvas.connect("button_press_event", self.button_press_handler)
        scrollwin.add_with_viewport(canvas)

        plot = gtkextra.Plot()
        plot.resize(width=0.65, height=0.45)
        plot.set_background(light_yellow)
        plot.legends_set_attributes(None, 0, None, white)
        plot.set_legends_border(gtkextra.PLOT_BORDER_SHADOW, 3)
        plot.legends_move(0.60, 0.10)

        plot.set_range(0.0, 20.0, 0.0, 1.0)
        plot.set_ticks(gtkextra.PLOT_AXIS_X, 2, 1)
        plot.set_ticks(gtkextra.PLOT_AXIS_Y, .1, 1)

        axis_left = plot.get_axis(gtkextra.PLOT_AXIS_LEFT)
        axis_right = plot.get_axis(gtkextra.PLOT_AXIS_RIGHT)
        axis_top = plot.get_axis(gtkextra.PLOT_AXIS_TOP)
        axis_bottom = plot.get_axis(gtkextra.PLOT_AXIS_BOTTOM)
        axis_x = plot.get_axis(gtkextra.PLOT_AXIS_X)
        axis_y = plot.get_axis(gtkextra.PLOT_AXIS_Y)

        axis_top.set_labels_style(gtkextra.PLOT_LABEL_FLOAT, 0)
        axis_bottom.set_labels_style(gtkextra.PLOT_LABEL_FLOAT, 0)
        
        axis_top.set_visible(True)
        axis_right.set_visible(True)
        plot.grids_set_visible(True, True, True, True)
        
        axis_top.hide_title()
        axis_right.hide_title()
        axis_left.set_title("Intensity")
        axis_bottom.set_title("Time (s)")

        child = gtkextra.PlotCanvasPlot(plot)
        canvas.put_child(child, .15, .15, .80, .65);
        plot.show()

        child = gtkextra.PlotCanvasText("Times-BoldItalic", 20, 0, None, None, True, gtk.JUSTIFY_CENTER, "Real Time Demo")
        canvas.put_child(child, .45, .05, 0., 0.)

        data = gtkextra.PlotData()
        plot.add_data(data)
        data.show()
        data.set_legend("Random pulse")
        data.set_symbol(gtkextra.PLOT_SYMBOL_DIAMOND, gtkextra.PLOT_SYMBOL_OPAQUE, 10, 2, red, red)
        data.set_line_attributes(gtkextra.PLOT_LINE_SOLID, 0, 0, 1, red)
        
        plot.clip_data(True)

        canvas.paint()
        canvas.refresh()

        self.show_all()

        gobject.timeout_add(100, self.update, canvas, plot, data)
コード例 #8
0
ファイル: testcontour.py プロジェクト: romed/python-gtkextra2
    def __init__(self, use_function =  1):
        gtk.Window.__init__(self)
        self.set_title("Contour Demo")
        self.set_size_request(550, 600)

        scale = 1.0
        scrollwin = gtk.ScrolledWindow()
        scrollwin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.add(scrollwin)

        self.canvas = canvas = gtkextra.PlotCanvas(gtkextra.PLOT_LETTER_W * scale, gtkextra.PLOT_LETTER_H * scale)
        canvas.plot_canvas_set_flags(gtkextra.PLOT_CANVAS_DND_FLAGS)
        scrollwin.add_with_viewport(canvas)

        plot = gtkextra.Plot3D(width=0.5, height=0.5)
        plot.axis_set_minor_ticks(gtkextra.PLOT_AXIS_X, 3)
        plot.axis_set_minor_ticks(gtkextra.PLOT_AXIS_Y, 3)
        plot.minor_grids_set_visible(gtk.FALSE, gtk.FALSE, gtk.FALSE)
        canvas.add_plot(plot, 0.16, 0.02)

        nx = 40
        ny = 40
        if use_function:
            surface = gtkextra.PlotCSurface(self.function)
            surface.set_xstep(1.0/nx)
            surface.set_ystep(1.0/ny)
        else:
            x=[]; y=[]; z=[]
            for ix in range(nx):
                for iy in range(ny):
                    x.append(ix/float(nx))
                    y.append(iy/float(ny))
                    z.append(self.function(x[-1], y[-1]))
            surface = gtkextra.PlotCSurface()
            surface.set_points(nx, ny, x=x, y=y, z=z)

        surface.set_legend("cos ((r-r\\s0\\N)\\S2\\N)")
        surface.set_gradient(0.2, 0.8, 6, 1)
        surface.set_lines_visible(gtk.FALSE)
        surface.set_transparent(gtk.FALSE)
        plot.add_data(surface)

        plot = gtkextra.Plot(width=0.4, height=0.4)
        plot.axis_set_minor_ticks(gtkextra.PLOT_AXIS_X, 1)
        plot.axis_set_minor_ticks(gtkextra.PLOT_AXIS_Y, 1)
        canvas.add_plot(plot, 0.26, 0.56)

        nx = 20
        ny = 20
        if use_function:
            surface = gtkextra.PlotCSurface(self.function)
            surface.set_xstep(1.0/nx)
            surface.set_ystep(1.0/ny)
        else:
            x=[]; y=[]; z=[]
            for ix in range(nx):
                for iy in range(ny):
                    x.append(ix/float(nx))
                    y.append(iy/float(ny))
                    z.append(self.function(x[-1], y[-1]))
            surface = gtkextra.PlotCSurface()
            surface.set_points(nx, ny, x=x, y=y, z=z)

        surface.set_legend("cos ((r-r\\s0\\N)\\S2\\N)")
        surface.set_gradient(0.2, 0.8, 6, 1)
        surface.set_grid_visible(gtk.FALSE)
        surface.set_transparent(gtk.FALSE)
        surface.set_projection(gtkextra.PLOT_PROJECT_FULL)
        plot.add_data(surface)

        canvas.export_ps("democsurface.ps", 0, 0, gtkextra.PLOT_LETTER)
        self.show_all()