当前位置: 首页>>代码示例>>Python>>正文


Python FigureCanvasGTKAgg.set_size_request方法代码示例

本文整理汇总了Python中matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg.set_size_request方法的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasGTKAgg.set_size_request方法的具体用法?Python FigureCanvasGTKAgg.set_size_request怎么用?Python FigureCanvasGTKAgg.set_size_request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg的用法示例。


在下文中一共展示了FigureCanvasGTKAgg.set_size_request方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: recreate_canvas

# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg import set_size_request [as 别名]
 def recreate_canvas(self, fig):
     canvas = FigureCanvas(fig)
     canvas.set_size_request(450, 200)
     if self.canvas_frame.get_child():
         self.canvas_frame.remove(self.canvas_frame.get_child())
     self.canvas_frame.add(canvas)
     canvas.show()
开发者ID:schlamar,项目名称:sitforc,代码行数:9,代码来源:gui.py

示例2: visualize

# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg import set_size_request [as 别名]
def visualize(*args, **kwargs):
    """
    Method that does all magic to to with GTK.

    All arguments passed to grapher.matplot.Graph
    """

    logger.debug('Spawning a GTK window')
    win = gtk.Window()
    win.connect('destroy', lambda x: gtk.main_quit())
    win.set_default_size(800,500)
    win.set_title('BounceItBaby visualizer')

    sw = gtk.ScrolledWindow()
    win.add(sw)
    # TODO: allow arrow/hjkl buttons to scroll
    sw.set_policy(hscrollbar_policy=gtk.POLICY_ALWAYS,
                  vscrollbar_policy=gtk.POLICY_AUTOMATIC)

    logger.debug('Building the Figure from data')
    figure = Graph(*args, **kwargs)
    canvas = FigureCanvas(figure)
    # If time scale is 20 times longer than number of actors, make it 20 times
    # wider than it is tall.
    canvas.set_size_request(int(400 / figure.axes[0].get_data_ratio()), 400)
    sw.add_with_viewport(canvas)

    logger.debug('Displaying GTK window!')
    win.show_all()
    gtk.main()
开发者ID:xim,项目名称:bounceitbaby,代码行数:32,代码来源:gtk_grapher.py

示例3: __init__

# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg import set_size_request [as 别名]
    def __init__(self):
        print 'test'
        self.win = gtk.Window()
        #win.connect("destroy", lambda x: gtk.main_quit())
        self.win.connect("delete-event", self.hideinsteadofdelete)
        self.win.set_default_size(400,300)
        self.win.set_title("Embedding in GTK")

        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)

        sw = gtk.ScrolledWindow()
        self.win.add (sw)
        # A scrolled window border goes outside the scrollbars and viewport
        sw.set_border_width (10)
        # policy: ALWAYS, AUTOMATIC, NEVER
        sw.set_policy (hscrollbar_policy=gtk.POLICY_AUTOMATIC,
                       vscrollbar_policy=gtk.POLICY_ALWAYS)

        canvas = FigureCanvas(f)  # a gtk.DrawingArea
        canvas.set_size_request(800,600)
        sw.add_with_viewport (canvas)

        self.win.show_all()
        gtk.main()
开发者ID:badbytes,项目名称:pymeg,代码行数:30,代码来源:gtkpylab.py

示例4: __init__

# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg import set_size_request [as 别名]
    def __init__(self):
        
        self._gladefile = "neuronview.glade"

        self._builder = gtk.Builder()
        self._builder.add_from_file(self._gladefile)
        self._builder.connect_signals(self)

        self._win = self._builder.get_object("mainwindow")
        self._win.resize(900, 700)

        box = self._builder.get_object("box5")
        self._stimulatordictview = DictView()
        self._builder.get_object("scrolledwindow2").add(self._stimulatordictview)

        box = self._builder.get_object("box4")
        self._neurondictview = DictView()
        self._builder.get_object("scrolledwindow3").add(self._neurondictview)

        self.populate_comboboxes()

        self._figure = Figure(figsize=(5,4), dpi=100)
        canvas = FigureCanvas(self._figure)
        canvas.set_size_request(200, 250)
        canvas.show()

        box = self._builder.get_object("box3")
        bg_style = box.get_style().bg[gtk.STATE_NORMAL]
        gtk_color = (bg_style.red_float, bg_style.green_float, bg_style.blue_float)
        self._figure.set_facecolor(gtk_color)
        box.pack_start(canvas)

        self._win.show()
        gtk.main()
开发者ID:JanneM,项目名称:nest-simulator,代码行数:36,代码来源:neuronview.py

示例5: WidgetsWrapper

# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg import set_size_request [as 别名]
class WidgetsWrapper(object):
    def __init__(self):
        self.widgets = gtk.glade.XML('mpl_with_glade.glade')
        self.widgets.signal_autoconnect(GladeHandlers.__dict__)

        self['windowMain'].connect('destroy', lambda x: gtk.main_quit())
        self['windowMain'].move(10, 10)
        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 = FigureCanvas(self.figure)  # a gtk.DrawingArea
        self.canvas.show()
        self.canvas.set_size_request(600, 400)
        self.canvas.set_events(
            gtk.gdk.BUTTON_PRESS_MASK |
            gtk.gdk.KEY_PRESS_MASK |
            gtk.gdk.KEY_RELEASE_MASK
            )
        self.canvas.set_flags(gtk.HAS_FOCUS | gtk.CAN_FOCUS)
        self.canvas.grab_focus()

        def keypress(widget, event):
            print('key press')

        def buttonpress(widget, event):
            print('button press')

        self.canvas.connect('key_press_event', keypress)
        self.canvas.connect('button_press_event', buttonpress)

        def onselect(xmin, xmax):
            print(xmin, xmax)

        span = SpanSelector(self.axis, onselect, 'horizontal', useblit=False,
                            rectprops=dict(alpha=0.5, facecolor='red'))

        self['vboxMain'].pack_start(self.canvas, True, 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, True, True)

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

    def __getitem__(self, key):
        return self.widgets.get_widget(key)
开发者ID:4over7,项目名称:matplotlib,代码行数:61,代码来源:mpl_with_glade.py

示例6: FigureWidget

# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg import set_size_request [as 别名]
class FigureWidget(gtk.ScrolledWindow):
    def __init__(self, figure):
        super(FigureWidget, self).__init__()
        self.set_border_width(10)
        self.set_policy(hscrollbar_policy=gtk.POLICY_AUTOMATIC,
            vscrollbar_policy=gtk.POLICY_ALWAYS)
        self.canvas = FigureCanvas(figure)
        self.canvas.set_size_request(500, 100)
        self.add_with_viewport(self.canvas)
开发者ID:matze,项目名称:af,代码行数:11,代码来源:ui.py

示例7: __init__

# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg import set_size_request [as 别名]
 def __init__(self, win, size, show_labels=True):
     fig = Figure(figsize=(size, size))
     canvas = FigureCanvas(fig)  # a gtk.DrawingArea
     canvas.set_size_request(500, 500)
     toolbar = NavigationToolbar(canvas, win)
     self.vbox = gtk.VBox()
     self.vbox.pack_start(canvas)
     self.vbox.pack_start(toolbar, False, False)
     self.fig = fig
     self.show_labels = show_labels
     self.eventfiles = {}
开发者ID:taldcroft,项目名称:cygob2_imgview,代码行数:13,代码来源:imgview.py

示例8: create_figure

# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg import set_size_request [as 别名]
def create_figure(quotes):

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

  a = f.add_subplot(111)
  canvas = FigureCanvas(f)  # a gtk.DrawingArea
  canvas.set_size_request(800,300)

  a.xaxis_date()
  
  finance.candlestick(a, quotes, width=0.5)

  return f
开发者ID:JamesValero,项目名称:yjl,代码行数:15,代码来源:matplotlib_cursor.py

示例9: __init__

# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg import set_size_request [as 别名]
	def __init__(self):
		self.gladefile='./lvshort2.glade'
		self.wTree = gtk.glade.XML(self.gladefile)
		dic={"on_start_clicked":self.dynamics,"on_mainwin_destroy":gtk.main_quit}
		self.wTree.signal_autoconnect(dic)
		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)
#		a.plot(t,s)
		canvas = FigureCanvas(self.f)  # a gtk.DrawingArea
		canvas.set_size_request(600,400)
		self.wTree.get_widget("sw").add_with_viewport(canvas)
		toolbar = NavigationToolbar(canvas, self.wTree.get_widget("mainwin"))
		self.wTree.get_widget("vbox1").pack_start(toolbar,False,False)

		print 'added'
		self.wTree.get_widget("mainwin").show_all()
开发者ID:debsankha,项目名称:bedtime-programming,代码行数:20,代码来源:visual-lotka-matplot.py

示例10: __init__

# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg import set_size_request [as 别名]
    def __init__(self, toolBoxWidgets=None, title="GTK Gui Plot", scaling=True, *args, **kwargs):
        if not toolBoxWidgets:
            toolBoxWidgets = []
        super(GuiWithCanvasAndToolbar, self).__init__(*args, **kwargs)
        self.connect("destroy", lambda x: gtk.main_quit())
        self.set_default_size(1100, 600)
        self.set_title(title)

        table = gtk.Table(1, 2, False)

        self.figures = []
        self.y_max = float("-inf")
        self.x_max = float("-inf")
        self.y_min = float("inf")
        self.x_min = float("inf")
        self.fig = Figure(figsize=(8, 6), dpi=100)
        self.ax = self.fig.add_subplot(111)
        canvas = FigureCanvas(self.fig)
        canvas.set_size_request(800, 600)
        canvas.mpl_connect('button_press_event', self.handle_click)

        table.attach(canvas, 0, 1, 0, 1)

        toolbox = gtk.Table(len(toolBoxWidgets) + 1, 1, False)
        i = 0
        for widget in toolBoxWidgets:
            toolbox.attach(widget, 0, 1, i, i + 1)
            i += 1

        label = gtk.Label("SimGUI")
        toolbox.attach(label, 0, 1, i, i + 1)

        table.attach(toolbox, 1, 2, 0, 1)

        self.canvas = canvas
        canvas.draw()
        self.update_figures()

        self.add(table)
        self.scaling = scaling
开发者ID:salceson,项目名称:geometria,代码行数:42,代码来源:gui_with_canvas_and_toolbar.py

示例11: make_fig

# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg import set_size_request [as 别名]
 def make_fig(title = None):
     '''
     Create a figure window with a single set of axes and a single main subplot.
     Returns the axes of the main subplot
     '''
     global all_sub_figures
     if title == None:
         title = "Untitled Figure {0}".format(len(all_sub_figures)+1)
     dialog = gtk.Dialog(title, win, gtk.DIALOG_DESTROY_WITH_PARENT)
     dialog.set_default_size(500,400)
     fig = matplotlib.figure.Figure()
     axes = fig.add_subplot(111)
     #axes.invert_yaxis()
     #axes.autoscale()
     canvas = FigureCanvasGTKAgg(fig)  # a gtk.DrawingArea
     canvas.set_size_request(300,300)
     dialog.vbox.pack_start(canvas, expand=True)
     toolbar = NavigationToolbar2GTKAgg(canvas, dialog)
     dialog.vbox.pack_start(toolbar, False, False)
     dialog.show_all()
     canvas.draw()
     fig.prev_child_count = 0
     all_sub_figures.append(fig)
     return axes
开发者ID:bradenmacdonald,项目名称:astrocube,代码行数:26,代码来源:astrocubeview.py

示例12: init

# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg import set_size_request [as 别名]
	def init(self):
		print "INIT!!"

		self.emesh_editor=electrical_mesh_editor()
		self.emesh_editor.init()

		self.fig = Figure(figsize=(5,4), dpi=100)
		self.ax1=None
		self.show_key=True
		self.hbox=gtk.HBox()
		self.edit_list=[]
		self.line_number=[]
		gui_pos=0

		gui_pos=gui_pos+1

		self.draw_graph()
		canvas = FigureCanvas(self.fig)  # a gtk.DrawingArea
		#canvas.set_background('white')
		#canvas.set_facecolor('white')
		canvas.figure.patch.set_facecolor('white')
		canvas.set_size_request(500, 150)
		canvas.show()

		tooltips = gtk.Tooltips()

		toolbar = gtk.Toolbar()
		#toolbar.set_orientation(gtk.ORIENTATION_VERTICAL)
		toolbar.set_style(gtk.TOOLBAR_ICONS)
		toolbar.set_size_request(-1, 50)

		tool_bar_pos=0
		save = gtk.ToolButton(gtk.STOCK_SAVE)
		tooltips.set_tip(save, "Save image")
		save.connect("clicked", self.callback_save)
		toolbar.insert(save, tool_bar_pos)
		tool_bar_pos=tool_bar_pos+1

		hide_key = gtk.ToolButton(gtk.STOCK_INFO)
		tooltips.set_tip(hide_key, "Hide key")
		hide_key.connect("clicked", self.callback_hide_key)
		toolbar.insert(hide_key, tool_bar_pos)
		tool_bar_pos=tool_bar_pos+1

		image = gtk.Image()
   		image.set_from_file(os.path.join(get_image_file_path(),"play.png"))
		save = gtk.ToolButton(image)
		tooltips.set_tip(save, "Run simulation")
		save.connect("clicked", self.run_simulation)
		toolbar.insert(save, tool_bar_pos)
		tool_bar_pos=tool_bar_pos+1

		plot_toolbar = NavigationToolbar(canvas, self)
		plot_toolbar.show()
		box=gtk.HBox(True, 1)
		box.set_size_request(500,-1)
		box.show()
		box.pack_start(plot_toolbar, True, True, 0)
		tb_comboitem = gtk.ToolItem();
		tb_comboitem.add(box);
		tb_comboitem.show()
		toolbar.insert(tb_comboitem, tool_bar_pos)
		tool_bar_pos=tool_bar_pos+1

		sep = gtk.SeparatorToolItem()
		sep.set_draw(False)
		sep.set_expand(True)
		toolbar.insert(sep, tool_bar_pos)
		sep.show()
		tool_bar_pos=tool_bar_pos+1

		help = gtk.ToolButton(gtk.STOCK_HELP)
		toolbar.insert(help, tool_bar_pos)
		help.connect("clicked", self.callback_help)
		help.show()
		tool_bar_pos=tool_bar_pos+1

		toolbar.show_all()
		window_main_vbox=gtk.VBox()
		window_main_vbox.pack_start(toolbar, False, True, 0)
		#self.attach(toolbar, 0, 1, 0, 1)
		tool_bar_pos=tool_bar_pos+1


		self.hbox.pack_start(canvas, True, True, 0)
	
		self.emesh_editor.show()
		self.hbox.pack_start(self.emesh_editor, True, True, 0)
		self.emesh_editor.mesh_dump_ctl.connect("update", self.callback_update)
		window_main_vbox.add(self.hbox)

		self.add(window_main_vbox)
		self.set_title("Electrical Mesh Editor - (www.opvdm.com)")
		self.set_icon_from_file(os.path.join(get_image_file_path(),"mesh.png"))
		self.connect("delete-event", self.callback_close)
		self.set_position(gtk.WIN_POS_CENTER)
开发者ID:roderickmackenzie,项目名称:opvdm,代码行数:98,代码来源:emesh.py

示例13: Iverplot_window

# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg import set_size_request [as 别名]
class Iverplot_window (object):
    """
    Iverplot_window---main Iverplot GUI object

    Parameters
    -----------

    Notes
    ------

    """
    def __init__ (self):
        self.builder = gtk.Builder ()
        self.builder.add_from_file ('iverplot.glade')
        self.builder.connect_signals (self)
        self.window = self.builder.get_object ('main_window')

        # add matplotlib figure canvas
        w,h = self.window.get_size ()
        self.fig = Figure (figsize=(6,4))
        self.canvas = FigureCanvas (self.fig)  # a gtk.DrawingArea
        self.canvas.set_size_request (w-150,-1)

        vbox = gtk.VBox()
        toolbar = NavigationToolbar (self.canvas, self.window)
        vbox.pack_start (self.canvas, True, True)
        vbox.pack_start (toolbar, False, False)

        # a little hacky for packing hpane with figure canvas first then tool
        # bar---not sure if glade is to blame---first, remove tool_vbox then
        # repack
        plot_hpaned = self.builder.get_object ('plot_hpaned')
        self.tool_vbox = self.builder.get_object ('tool_vbox')
        plot_hpaned.remove (self.tool_vbox)

        #plot_hpaned.pack1 (self.canvas, resize=True, shrink=False)
        plot_hpaned.pack1 (vbox, resize=True, shrink=False)
        plot_hpaned.pack2 (self.tool_vbox)

        # data
        self.uvclog = None
        self.lcmlog = None

        # plot limits
        self.xlimits = [None,None]
        self.xlimits_abs = [None,None]

        # add single plot item
        self.plotdex = {}
        self.plot_items = []
        self.plot_items.append (Plot_item (self.tool_vbox,
            self.on_plot_item_selected, self.uvclog, self.lcmlog))
        self.update_subplots ()

        # setwin
        self.setwin = None

        # set some defaults
        self.cd_saveas = os.getcwd ()
        self.cd_open = os.getcwd ()

        self.window.show_all ()

    def on_setwin_clicked (self, widget):
        if self.setwin is None: 
            self.setwin = Setwin (self.canvas, self.fig, self.on_setwin_complete)

    def on_setwin_complete (self, xmin, xmax):
        self.xlimits = [xmin,xmax]
        for p in self.plot_items:
            ax = self.fig.axes[self.plotdex[p]]
            p.plot_type.set_limits (ax, *self.xlimits)
        self.canvas.draw ()
        self.setwin = None

    def on_setwin_reset (self, widget):
        if not self.setwin is None: return
        self.xlimits = [x for x in self.xlimits_abs]
        for p in self.plot_items:
            ax = self.fig.axes[self.plotdex[p]]
            p.plot_type.set_limits (ax, *self.xlimits)
        self.canvas.draw ()

    def update_subplots (self):
        self.fig.clear ()
        n = len (self.plot_items)
        for i,p in enumerate (self.plot_items):
            p.plot_type.uvclog = self.uvclog
            p.plot_type.lcmlog = self.lcmlog
            ax = self.fig.add_subplot (n,1,i+1)
            p.plot_type.plot (ax, *self.xlimits)
            self.plotdex[p] = i
        self.canvas.draw ()

    def on_plot_item_selected (self, combo, item):
        ax = self.fig.axes[self.plotdex[item]]
        item.plot_type.plot (ax, *self.xlimits)
        self.canvas.draw ()

    def update_window (self):
#.........这里部分代码省略.........
开发者ID:jmwalls,项目名称:iverplot,代码行数:103,代码来源:iverplot.py

示例14: __init__

# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg import set_size_request [as 别名]
    def __init__(self, data=None, orient="LPS", overlay=None, colormap=cm.gray, pixdim=None):

        ##
        import sys

        print sys.argv
        if data == None:
            try:
                fn = sys.argv[1]
                from mri import img

                data = img.read(fn)
            except AttributeError:
                print "not passing data arg"
                pass

        try:
            data.qform
            print "think its a nifti volume"
            nim = data
            mrdata = nim.data
            print shape(mrdata)
            pixdim = nim.voxdim[::-1]

        except AttributeError:
            if pixdim != None:
                print "using user supplied pixeldimensions", pixdim
            else:
                print "probably not a nifti volume. using voxel units instead of actual distance units"
                pixdim = [1.0, 1.0, 1.0]
                # unitless
            mrdata = data
        ##

        self.win = gtk.Window()
        # win.connect("destroy", lambda x: gtk.main_quit())
        self.win.connect("delete-event", self.hideinsteadofdelete)
        self.win.set_default_size(600, 600)
        self.win.set_title("Embedding in GTK")

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

        fig = figure()  # figsize=(5,4), dpi=100)
        # subplots_adjust(left=.15, bottom=.15,right=1, top=.95,wspace=.25, hspace=.35)
        # a = fig.add_subplot(111)
        # t = arange(0.0,3.0,0.01)
        # s = sin(2*pi*t)
        # a.plot(t,s)
        # a.plot(data)

        ax1 = fig.add_subplot(221)
        # axis('off')
        # colorbar(fig,ax=ax1)
        xlabel("Anterior (A->P 1st Dim)")
        ylabel("Right (R->L 2nd Dim)")
        ax2 = fig.add_subplot(222)
        # axis('off')
        xlabel("Inferior (I->S Dim)")
        ylabel("Anterior (A->P 1st Dim)")
        ax3 = fig.add_subplot(223)
        # axis('off')
        xlabel("Infererior (I->S 3rd dim)")
        ylabel("Right (R->L 2nd Dim)")
        coord = fig.add_subplot(224)
        axis("off")
        tracker = IndexTracker(mrdata, ax1, ax2, ax3, colormap, pixdim, overlay, coord)
        # fig.canvas.mpl_connect('scroll_event', tracker.onscroll)
        cid = connect("button_press_event", tracker.click)

        print ("something")

        sw = gtk.ScrolledWindow()
        vbox.pack_start(sw)
        # self.win.add (sw)
        ## A scrolled window border goes outside the scrollbars and viewport
        sw.set_border_width(10)
        # policy: ALWAYS, AUTOMATIC, NEVER
        sw.set_policy(hscrollbar_policy=gtk.POLICY_AUTOMATIC, vscrollbar_policy=gtk.POLICY_ALWAYS)

        canvas = FigureCanvas(fig)  # a gtk.DrawingArea
        ##vbox.pack_start(canvas)
        canvas.set_size_request(300, 200)
        sw.add_with_viewport(canvas)
        canvas.draw()

        # manager = get_current_fig_manager()
        ## you can also access the window or vbox attributes this way
        # toolbar = manager.toolbar

        ##vbox.pack_start(canvas)
        # toolbar = NavigationToolbar(canvas, self.win)
        ##vbox.pack_start(toolbar, False, False)
        # show()
        # print tracker
        #
        # fig.show()
        self.win.show_all()
开发者ID:neurodebian,项目名称:pymeg,代码行数:100,代码来源:viewmri_gtk.py

示例15: MainView

# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg import set_size_request [as 别名]
class MainView(BasePlotView, gtk.Frame):
    """
    A Gtk Frame based plotting widget for dreampy
    that contains additional tool bar items for printing
    and adding notes
    """
    def __init__(self, win, **kwargs):
        gtk.Frame.__init__(self)
        BasePlotView.__init__(self, **kwargs)
        self.win = win
        self.title = None

        #Put some stuff
        # self.suppress_header = kwargs.get('suppress_header', False)
        # self.suppress_title = kwargs.get('suppress_title', False)
        # self.suppress_legend = kwargs.get('suppress_legend', False)
        self.vbox = gtk.VBox(False, 0)
        self.add(self.vbox)
        self.sw = gtk.ScrolledWindow()
        self.sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.vbox.pack_start(self.sw, True, True, 0)
        self.sw.show()
        self.f = Figure(figsize=(5,4), dpi=100)
        self.canvas = FigureCanvas(self.f)  # a gtk.DrawingArea
        self.canvas.set_size_request(400,300)
        self.sw.add_with_viewport (self.canvas)
        self.canvas.show_all()
        self.toolbar = NavToolBar(self.canvas, self.win)
        self.vbox.pack_start(self.toolbar, False, False)
        self.toolbar.show()
        self.vbox.show()
        # self.autoscale = True
        # self.xmin = None
        # self.xmax = None
        # self.ymin = None
        # self.ymax = None
        # self.image = None
        # self.hold_plot = False
        # self.keyid = None
        # self.filter = None
        # self.labelsize = 8
        # self.titlesize = 10
        # self.ticklabelsize = 8
        # self.ticklabelweight = 'normal'
        # self.labelweight = 'bold'
        # self.titleweight = 'bold'
        # self.legendsize = 8
        # self.legendweight = 'normal'
        # self.hdrlabelsize = 9
        # self.hdrlabelweight = 'normal'
        # self.cur_axname = None
        self.refresh_canvas()
        self.show_all()
        #self.gtk_catchup()
        
    def gtk_catchup(self):
        gtk.gdk.threads_enter()
        while gtk.events_pending():
            gtk.main_iteration()
        gtk.gdk.threads_leave()        
        
    def create_arrow_button(self, arrow_type, shadow_type):
        button = gtk.Button()
        self.arrow = gtk.Arrow(arrow_type, shadow_type)
        button.add(self.arrow)
        button.show()
        self.arrow.show()
        return button

    def list_widgets_turnoff(self):
        self.left_button.set_sensitive(False)
        self.right_button.set_sensitive(False)
        self.ignore_button.set_sensitive(False)        
        #if self.keyid:
        #    self.canvas.disconnect(self.keyid)


    def disconnect_event(self, sig):
        if self.canvas:
            self.canvas.mpl_disconnect(sig)

    def connect_event(self, eventname, eventfunc):
        if self.canvas:
            self.canvas.set_flags(gtk.CAN_FOCUS)  #to grab focus for keystrokes
            self.canvas.grab_focus()    #to grab focus for keystrokes
            return self.canvas.mpl_connect(eventname, eventfunc)

    def redraw_plot(self):
        if self.hold_plot is False:
            if hasattr(self.canvas, 'show_all'):
                self.canvas.show_all()
            self.canvas.draw()
        self.gtk_catchup()
开发者ID:gopastro,项目名称:pyphamas,代码行数:95,代码来源:plots.py


注:本文中的matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg.set_size_request方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。