本文整理汇总了Python中matplotlib.backends.backend_gtkagg.NavigationToolbar2GTKAgg类的典型用法代码示例。如果您正苦于以下问题:Python NavigationToolbar2GTKAgg类的具体用法?Python NavigationToolbar2GTKAgg怎么用?Python NavigationToolbar2GTKAgg使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NavigationToolbar2GTKAgg类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, window, movie_frames, movie_file_maker):
# set MPL NavigationToolbar
NavigationToolbar2GTKAgg.__init__(self, movie_frames.canvas, window)
# ===================================
# movie file maker
# ===================================
self.mfm = movie_file_maker
self.mfm.set_update_number_of_recorded_frames_function(self.update_saved_frames_numer)
# Make Movie Button -----------------
self.button_make_movie=gtk.ToolButton(gtk.STOCK_CDROM)
self.button_make_movie.set_tooltip_text("Make movie file")
# callback
self.button_make_movie.connect("clicked",self.make_movie_callback)
# pack button into tollbar
self.insert(gtk.SeparatorToolItem(),8)
self.insert(self.button_make_movie,9)
# -----------------------------------
# number of saved frames ------------
self.saved_frames_label=gtk.Label('0')
self.saved_frames_label.set_width_chars(4)
# hbox with labels
hbox=gtk.HBox()
hbox.pack_start(gtk.Label('recorded:'),False,padding=3)
hbox.pack_start(self.saved_frames_label,False)
# tool item -- wrapper for hbox
toolitem=gtk.ToolItem()
toolitem.add(hbox)
# pack them into tollbar
self.insert(toolitem,10)
self.insert(gtk.SeparatorToolItem(),11)
示例2: __init__
def __init__(self, canvas, window, steps):
NavigationToolbar2GTKAgg.__init__(self, canvas, window)
item = self.get_nth_item(8)
self.remove(item)
self.playbutton = PlayButton()
self.positionscale = PositionScale(steps)
self.savemoviebutton = gtk.ToolButton(gtk.STOCK_SAVE_AS)
self.insert(gtk.SeparatorToolItem(), 8)
self.insert(self.playbutton, 9)
self.insert(self.savemoviebutton, 10)
self.insert(self.positionscale, 11)
self.savemoviebutton.connect("clicked", self.handle_save_movie)
示例3: __init__
def __init__(self, cube, canvas, parent_window):
self.cube = cube
NavigationToolbar2GTKAgg.__init__(self, canvas, parent_window)
示例4: draw
def draw(self,widget, func):
win = gtk.Window()
win.connect("destroy", lambda x: gtk.main_quit())
win.set_default_size(800,600)
win.set_title("Chart statistiche PromoGest2")
vbox = gtk.VBox()
win.add(vbox)
sw = gtk.ScrolledWindow()
vbox.pack_start(sw, True, True, 0)
sw.set_border_width (10)
sw.set_policy (hscrollbar_policy=GTK_POLICYTYPE_AUTOMATIC,
vscrollbar_policy=GTK_POLICYTYPE_ALWAYS)
canvas = FigureCanvas(self.fig) # a gtk.DrawingArea
sw.add_with_viewport (canvas)
toolbar = NavigationToolbar(canvas, win)
toolbar.set_message(func)
vbox.pack_start(toolbar, False, False, 0)
win.set_modal(True)
win.set_transient_for(None)
win.show_all()
gtk.main()
示例5: WidgetsWrapper
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)
示例6: refreshGraphDisplay
def refreshGraphDisplay( self ):
# Remove existing graph items
if self.graphCanvas != None:
self.vboxGraphs.remove( self.graphCanvas )
self.graphCanvas.destroy()
self.graphCanvas = None
if self.graphNavToolbar != None:
self.vboxGraphs.remove( self.graphNavToolbar )
self.graphNavToolbar.destroy()
self.graphNavToolbar = None
# Draw the graphs
self.graphFigure = Figure( figsize=(8,6), dpi=72 )
self.graphAxis = self.graphFigure.add_subplot( 111 )
#self.graphAxis.plot( range( 1, len( self.maxMotionCounts )+1 ), self.maxMotionCounts )
diffs = [ 0 ] + [ self.leftMostMotionList[ i+1 ] - self.leftMostMotionList[ i ] for i in range( len( self.leftMostMotionList ) - 1 ) ]
#self.graphAxis.plot( range( 1, len( self.leftMostMotionList )+1 ), self.leftMostMotionList )
self.graphAxis.plot( range( 1, len( self.leftMostMotionList )+1 ), diffs )
# Build the new graph display
self.graphCanvas = FigureCanvas( self.graphFigure ) # a gtk.DrawingArea
self.graphCanvas.show()
self.graphNavToolbar = NavigationToolbar( self.graphCanvas, self.window )
self.graphNavToolbar.lastDir = '/var/tmp/'
self.graphNavToolbar.show()
# Show the graph
self.vboxGraphs.pack_start( self.graphNavToolbar, expand=False, fill=False )
self.vboxGraphs.pack_start( self.graphCanvas, True, True )
self.vboxGraphs.show()
self.vboxGraphs.show()
示例7: setup_plot
def setup_plot(self, plot_controller):
self.plot_controller = plot_controller
self["matplotlib_box"].add(self.plot_controller.canvas)
self["matplotlib_box"].show_all()
self.nav_toolbar = NavigationToolbar(self.plot_controller.canvas, self.get_top_widget())
self.nav_toolbar.set_name("navtoolbar")
self["navtoolbar"] = self.nav_toolbar
self["navtoolbar_box"].add(self.nav_toolbar)
示例8: make_toolbar
def make_toolbar(self):
toolbar = NavigationToolbar(self.canvas, self)
next = 8
toolitem = gtk.SeparatorToolItem()
toolitem.show()
toolbar.insert(toolitem, next); next+=1
toolitem.set_expand(False)
self.buttonFollowEvents = gtk.CheckButton ()
self.buttonFollowEvents.set_label('Auto')
self.buttonFollowEvents.show()
self.buttonFollowEvents.set_active(True)
toolitem = gtk.ToolItem()
toolitem.show()
#Rewriting this for the new gtk tooltips available in pygtk 2.12 and up
#toolitem.set_tooltip(
# toolbar.tooltips,
# 'Automatically update in response to selections in EEG', 'Private')
toolitem.set_tooltip_text('Automatically update in response to selections in EEG')
toolitem.add(self.buttonFollowEvents)
toolbar.insert(toolitem, next); next +=1
# XXX: only available in gtk 2.6
menu = gtk.MenuToolButton(gtk.STOCK_EDIT)
menu.show()
context = self.make_context_menu()
menu.set_menu(context)
#menu.set_tooltip(
# toolbar.tooltips,
# 'Set filter/detrend etc', 'Private')
menu.set_tooltip_text('Set filter/detrend etc')
toolbar.insert(menu, next); next+=1
toolitem = gtk.SeparatorToolItem()
toolitem.show()
toolbar.insert(toolitem, next)
toolitem.set_expand(False)
return toolbar
示例9: add_figure_canvas
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, \
示例10: _init_toolbar
def _init_toolbar(self):
NavigationToolbar._init_toolbar(self)
image = gtk.Image()
image.set_from_stock(gtk.STOCK_PRINT, 22)
tbutton = gtk.ToolButton(image, 'Print')
self.insert(tbutton, -1)
tbutton.connect('clicked', getattr(self, 'print_canvas'))
if not _new_tooltip_api:
tbutton.set_tooltip(self.tooltips, 'Print current view',
'Private')
else:
tbutton.set_tooltip_text('Print current view')
image = gtk.Image()
image.set_from_stock(edit_img, 22)
tbutton = gtk.ToolButton(image, 'Comments')
self.insert(tbutton, -1)
if not _new_tooltip_api:
tbutton.set_tooltip(self.tooltips, 'Insert Comment to Plot',
'Private')
else:
tbutton.set_tooltip_text('Insert Comment to Plot')
tbutton.connect('clicked', getattr(self,'insert_comments'))
self.show_all()
示例11: __init__
def __init__ (self, plotters, fields):
gtk.VBox.__init__ (self)
self.figure = mpl.figure.Figure ()
self.canvas = FigureCanvas (self.figure)
self.canvas.unset_flags (gtk.CAN_FOCUS)
self.canvas.set_size_request (600, 400)
self.pack_start (self.canvas, True, True)
self.canvas.show ()
self.navToolbar = NavigationToolbar (self.canvas, self.window)
#self.navToolbar.lastDir = '/tmp'
self.pack_start (self.navToolbar, False, False)
self.navToolbar.show ()
self.checkboxes = gtk.HBox (len (plotters))
self.pack_start (self.checkboxes, False, False)
self.checkboxes.show ()
self.pol = (1+0j, 0j)
self.pol2 = None
self.handlers = []
i = 0
self.plots = []
for plotterClass, default in plotters:
axes = self.figure.add_subplot (len (plotters), 1, i)
def makeUpdateInfo (i): return lambda s: self.__updateInfo (i, s)
def makeUpdatePos (i): return lambda s: self.__updatePos (i, s)
plotter = plotterClass (axes, fields, makeUpdateInfo (i), makeUpdatePos (i))
d = PlottedData (axes, plotter, default, self.__updateChildren)
self.checkboxes.pack_start (d.checkBox, False, False)
self.plots.append (d)
i += 1
self.__infos = [None] * len (self.plots)
self.__posi = None
self.legendBox = gtk.CheckButton ("Show legend")
self.legendBox.set_active (True)
self.legendBox.connect ("toggled", self.__on_legend_toggled)
self.checkboxes.pack_start (self.legendBox, False, False)
self.legendBox.show ()
self.__updateChildren ()
示例12: refreshGraphDisplay
def refreshGraphDisplay( self ):
if self.canvas != None:
self.hboxWorkArea.remove( self.canvas )
self.canvas.destroy()
self.canvas = None
if self.navToolbar != None:
self.vboxMain.remove( self.navToolbar )
self.navToolbar.destroy()
self.navToolbar = None
self.canvas = FigureCanvas( self.figure ) # a gtk.DrawingArea
self.canvas.show()
self.hboxWorkArea.pack_start( self.canvas, True, True )
self.hboxWorkArea.show()
# Navigation toolbar
self.navToolbar = NavigationToolbar( self.canvas, self.window )
self.navToolbar.lastDir = '/var/tmp/'
self.vboxMain.pack_start( self.navToolbar, expand=False, fill=False )
self.navToolbar.show()
self.vboxMain.show()
示例13: Figure
buttons['Open'] = gtk.ToolButton(gtk.STOCK_OPEN)
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)
示例14: show
def show(self):
try:
if not self.packed:
self.pack_start(self.canvas, expand=True)
toolbar = NavigationToolbar(self.canvas, self.get_parent_window())
next = 8
button = gtk.Button('Lin y')
button.show()
button2 = gtk.Button('Lin x')
button2.show()
# linear/log
def clicked(button):
self.adjust_axis_margins()
self.set_axis_labels()
self.color_labels()
self.canvas.draw_idle()
self.canvas.show()
if self.ax.get_yscale() == 'log':
button.set_label('Lin y')
self.ax.set_yscale('linear')
else:
button.set_label('Log y')
self.ax.set_yscale('log')
self.show()
def clicked2(button):
self.adjust_axis_margins()
self.set_axis_labels()
self.color_labels()
self.canvas.draw_idle()
self.canvas.show()
if self.ax.get_xscale() == 'log':
button.set_label('Lin x')
self.ax.set_xscale('linear')
else:
button.set_label('Log x')
self.ax.set_xscale('log')
self.show()
button.connect('clicked', clicked)
button2.connect('clicked', clicked2)
toolitem=gtk.ToolItem()
toolitem.show()
toolitem.add(button)
toolbar.insert(toolitem, next)
next +=1
toolitem2=gtk.ToolItem()
toolitem2.show()
toolitem2.add(button2)
toolbar.insert(toolitem2, next)
self.pack_start(toolbar, expand=False)
self.packed = True
super(Figure, self).show()
except Exception, e:
print 'Exception: ', e
raise
示例15: AppView
class AppView(BaseView, HasChildView, FormattedTitleView):
"""
The main application interface view.
Attributes:
project: the project view
specimen: the specimen view
markers: the markers view
phases: the phases view
atom_types: the atom_types view
statistics: the statistics view
mixtures: the mixtures view
"""
builder = resource_filename(__name__, "glade/application.glade")
top = "main_window"
title_format = "PyXRD - %s"
child_views = {
"project": ProjectView,
"specimen": SpecimenView,
"markers": EditMarkersView, # FIXME this should be part of the specimen view/controller code
"phases": ObjectListStoreView,
"atom_types": ObjectListStoreView,
# ("statistics": ???
"mixtures": ObjectListStoreView
}
widget_groups = {
'full_mode_only': [
"tbtn_edit_phases",
"tbtn_edit_atom_types",
"tbtn_edit_mixtures",
"tbtn_separator1",
"btn_sample",
"separator3",
"separator4",
"separator5",
"main_menu_item_edit_phases",
"main_menu_item_edit_atom_types",
"main_menu_item_edit_mixtures",
"navtoolbar"
]
}
# ------------------------------------------------------------
# Initialisation and other internals
# ------------------------------------------------------------
def __init__(self, *args, **kwargs):
super(AppView, self).__init__(*args, **kwargs)
# Setup about window:
def on_aboutbox_response(dialog, response, *args):
if response < 0:
dialog.hide()
dialog.emit_stop_by_name('response')
def on_aboutbox_close(widget, event=None):
self["about_window"].hide()
return gtk.TRUE
self["about_window"].set_version(settings.VERSION)
pixbuf = gtk.gdk.pixbuf_new_from_file(resource_filename(__name__, "icons/pyxrd.png")) # @UndefinedVariable
scaled_buf = pixbuf.scale_simple(212, 160, gtk.gdk.INTERP_BILINEAR) # @UndefinedVariable
self["about_window"].set_logo(scaled_buf)
self["about_window"].connect("response", on_aboutbox_response)
self["about_window"].connect("close", on_aboutbox_close)
self["about_window"].connect("delete_event", on_aboutbox_close)
self["main_window"].set_icon_list(*get_icon_list())
# self.set_layout_modes()
self.reset_all_views()
if not settings.DEBUG:
self.get_top_widget().maximize()
self.get_top_widget().show()
return
def setup_plot(self, plot_controller):
self.plot_controller = plot_controller
self["matplotlib_box"].add(self.plot_controller.canvas)
self["matplotlib_box"].show_all()
self.nav_toolbar = NavigationToolbar(self.plot_controller.canvas, self.get_top_widget())
self.nav_toolbar.set_name("navtoolbar")
self["navtoolbar"] = self.nav_toolbar
self["navtoolbar_box"].add(self.nav_toolbar)
def reset_child_view(self, view_name, class_type=None):
if getattr(self, view_name, None) is not None:
getattr(self, view_name).hide()
setattr(self, view_name, None)
if class_type == None:
class_type = self.child_views[view_name]
view = class_type(parent=self)
setattr(self, view_name, view)
view.set_layout_mode(self.current_layout_state)
#.........这里部分代码省略.........