本文整理汇总了Python中matplotlib.backends.backend_gtkagg.NavigationToolbar2GTKAgg.show方法的典型用法代码示例。如果您正苦于以下问题:Python NavigationToolbar2GTKAgg.show方法的具体用法?Python NavigationToolbar2GTKAgg.show怎么用?Python NavigationToolbar2GTKAgg.show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_gtkagg.NavigationToolbar2GTKAgg
的用法示例。
在下文中一共展示了NavigationToolbar2GTKAgg.show方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: WidgetsWrapper
# 需要导入模块: from matplotlib.backends.backend_gtkagg import NavigationToolbar2GTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.NavigationToolbar2GTKAgg import show [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)
示例2: add_figure_canvas
# 需要导入模块: from matplotlib.backends.backend_gtkagg import NavigationToolbar2GTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.NavigationToolbar2GTKAgg import show [as 别名]
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, \
示例3: PlotViewer
# 需要导入模块: from matplotlib.backends.backend_gtkagg import NavigationToolbar2GTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.NavigationToolbar2GTKAgg import show [as 别名]
class PlotViewer(gtk.VBox):
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 ()
def __on_legend_toggled (self, button):
for pd in self.plots:
pd.plotter.setLegend (button.get_active ())
def __updateChildren (self):
count = 0
for axes in self.figure.get_axes ():
visible = axes.get_visible ()
if axes.get_visible ():
count += 1
if count == 0:
count = 1
nr = 1
for axes in self.figure.get_axes ():
axes.change_geometry (count, 1, nr)
if axes.get_visible ():
if nr < count:
nr += 1
else:
axes.set_position ((0, 0, 1e-10, 1e-10)) # Hack to prevent the invisible axes from getting mouse events
self.figure.canvas.draw ()
self.__updateGraph ()
def __updateGraph (self):
for pd in self.plots:
if pd.axes.get_visible ():
#start = time ()
pd.plotter.plot (self.pol, self.pol2)
#print "Plot ", pd.plotter.description, " needed ", time () - start
def __updateInfo (self, i, arg):
#print i, arg
self.__infos[i] = arg
s = ''
for info in self.__infos:
if info is not None:
if s != '':
s += ' '
s += info
for handler in self.handlers:
handler (s)
def __updatePos (self, i, arg):
if arg == None and self.__posi != i:
return
self.__posi = i
j = 0
for pd in self.plots:
if i != j:
pd.plotter.updateCPos (arg)
j += 1
def onUpdateInfo (self, handler):
#.........这里部分代码省略.........
示例4: init
# 需要导入模块: from matplotlib.backends.backend_gtkagg import NavigationToolbar2GTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.NavigationToolbar2GTKAgg import show [as 别名]
def init(self):
self.fig = Figure(figsize=(5,4), dpi=100)
self.ax1=None
self.show_key=True
self.hbox=gtk.HBox()
self.exe_command = get_exe_command()
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.callback_refresh)
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
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.attach(canvas, 1, 3, 0, 1)
vbox = gtk.VBox(False, 2)
#spacer
label=gtk.Label(" \n\n ")
#self.attach(label, 4, 5, 1, 2,gtk.SHRINK ,gtk.SHRINK)
vbox.pack_start(label, False, False, 0)
label.show()
hbox = gtk.HBox(False, 2)
hbox.show()
self.hbox.pack_start(vbox, False, False, 0)
#self.attach(vbox, 3, 4, 0, 1,gtk.SHRINK ,gtk.SHRINK)
vbox.show()
window_main_vbox.add(self.hbox)
#.........这里部分代码省略.........
示例5: init
# 需要导入模块: from matplotlib.backends.backend_gtkagg import NavigationToolbar2GTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.NavigationToolbar2GTKAgg import show [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)
示例6: init
# 需要导入模块: from matplotlib.backends.backend_gtkagg import NavigationToolbar2GTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.NavigationToolbar2GTKAgg import show [as 别名]
def init(self,index):
self.index=index
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
self.list=[]
self.load_data()
self.update_scan_tokens()
gui_pos=gui_pos+1
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)
self.store = self.create_model()
treeview = gtk.TreeView(self.store)
treeview.show()
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
add_section = gtk.ToolButton(gtk.STOCK_ADD)
tooltips.set_tip(add_section, _("Add section"))
add_section.connect("clicked", self.callback_add_section,treeview)
toolbar.insert(add_section, tool_bar_pos)
tool_bar_pos=tool_bar_pos+1
add_section = gtk.ToolButton(gtk.STOCK_CLEAR)
tooltips.set_tip(add_section, _("Delete section"))
add_section.connect("clicked", self.callback_remove_item,treeview)
toolbar.insert(add_section, tool_bar_pos)
tool_bar_pos=tool_bar_pos+1
move_down = gtk.ToolButton(gtk.STOCK_GO_DOWN)
tooltips.set_tip(move_down, _("Move down"))
move_down.connect("clicked", self.callback_move_down,treeview)
toolbar.insert(move_down, tool_bar_pos)
tool_bar_pos=tool_bar_pos+1
image = gtk.Image()
image.set_from_file(os.path.join(get_image_file_path(),"start.png"))
start = gtk.ToolButton(image)
tooltips.set_tip(start, _("Simulation start frequency"))
start.connect("clicked", self.callback_start_fx,treeview)
toolbar.insert(start, tool_bar_pos)
tool_bar_pos=tool_bar_pos+1
plot_toolbar = NavigationToolbar(self.fig.canvas, self)
plot_toolbar.show()
box=gtk.HBox(True, 1)
box.set_size_request(300,-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()
self.pack_start(toolbar, False, True, 0)
self.pack_start(toolbar, True, True, 0)
tool_bar_pos=tool_bar_pos+1
#.........这里部分代码省略.........
示例7: __init__
# 需要导入模块: from matplotlib.backends.backend_gtkagg import NavigationToolbar2GTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.NavigationToolbar2GTKAgg import show [as 别名]
class MainWindow:
OPTICAL_FLOW_BLOCK_WIDTH = 8
OPTICAL_FLOW_BLOCK_HEIGHT = 8
OPTICAL_FLOW_RANGE_WIDTH = 8 # Range to look outside of a block for motion
OPTICAL_FLOW_RANGE_HEIGHT = 8
PROCESSED_FRAME_DIFF = 1
# Classes of pixel in GrabCut algorithm
GC_BGD = 0 # background
GC_FGD = 1 # foreground
GC_PR_BGD = 2 # most probably background
GC_PR_FGD = 3 # most probably foreground
# GrabCut algorithm flags
GC_INIT_WITH_RECT = 0
GC_INIT_WITH_MASK = 1
GC_EVAL = 2
#---------------------------------------------------------------------------
def __init__( self, options, bagFilename = None ):
self.options = options
self.scriptPath = os.path.dirname( __file__ )
self.image = None
self.frameIdx = 0
self.workerThread = None
self.numFramesProcessed = 0
self.graphCanvas = None
self.graphNavToolbar = None
self.PROCESSED_FRAME_DIFF = int( self.options.frameSkip )
# Setup the GUI
builder = gtk.Builder()
builder.add_from_file( self.scriptPath + "/GUI/ObjectDetectorExplorer.glade" )
self.window = builder.get_object( "winMain" )
self.comboOutput_1_Mode = builder.get_object( "comboOutput_1_Mode" )
self.comboOutput_2_Mode = builder.get_object( "comboOutput_2_Mode" )
self.vboxGraphs = builder.get_object( "vboxGraphs" )
dwgInput = builder.get_object( "dwgInput" )
dwgOutput_1 = builder.get_object( "dwgOutput_1" )
dwgOutput_2 = builder.get_object( "dwgOutput_2" )
self.dwgInputDisplay = Display( dwgInput )
self.dwgOutput_1_Display = Display( dwgOutput_1 )
self.dwgOutput_2_Display = Display( dwgOutput_2 )
self.sequenceControls = builder.get_object( "sequenceControls" )
self.sequenceControls.setNumFrames( 1 )
self.sequenceControls.setOnFrameIdxChangedCallback( self.onSequenceControlsFrameIdxChanged )
builder.connect_signals( self )
#updateLoop = self.update()
#gobject.idle_add( updateLoop.next )
self.window.show()
if bagFilename != None:
self.tryToLoadBagFile( bagFilename )
#---------------------------------------------------------------------------
def onWinMainDestroy( self, widget, data = None ):
gtk.main_quit()
#---------------------------------------------------------------------------
def main( self ):
# All PyGTK applications must have a gtk.main(). Control ends here
# and waits for an event to occur (like a key press or mouse event).
gtk.gdk.threads_init()
gtk.main()
#---------------------------------------------------------------------------
def isCurFrameReady( self ):
return self.frameIdx < self.numFramesProcessed
#---------------------------------------------------------------------------
def setFrameIdx( self, frameIdx ):
frameReady = frameIdx < self.numFramesProcessed
if frameReady or frameIdx == 0:
self.frameIdx = frameIdx
self.updateDisplay()
else:
# Try to reset to current frame index
if self.isCurFrameReady():
self.sequenceControls.setFrameIdx( self.frameIdx )
else:
self.sequenceControls.setFrameIdx( 0 )
#---------------------------------------------------------------------------
def updateDisplay( self ):
if self.isCurFrameReady():
self.dwgInputDisplay.setImageFromOpenCVMatrix( self.inputImageList[ self.frameIdx ] )
#.........这里部分代码省略.........
示例8: __init__
# 需要导入模块: from matplotlib.backends.backend_gtkagg import NavigationToolbar2GTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.NavigationToolbar2GTKAgg import show [as 别名]
def __init__(self):
self.debug = 0
self.test = RTP.Motor_PD_Control_Test(kp=2, kd=0.07)
# create a new window
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
# When the window is given the "delete_event" signal (this is given
# by the window manager, usually by the "close" option, or on the
# titlebar), we ask it to call the delete_event () function
# as defined above. The data passed to the callback
# function is NULL and is ignored in the callback function.
self.window.connect("delete_event", self.delete_event)
# Here we connect the "destroy" event to a signal handler.
# This event occurs when we call gtk_widget_destroy() on the window,
# or if we return FALSE in the "delete_event" callback.
self.window.connect("destroy", self.destroy)
# Sets the border width of the window.
self.window.set_border_width(10)
# Creates a new button with the label "Hello World".
self.swept_sine_button = gtk.Button("Swept Sine")
self.step_button = gtk.Button("Step Response")
self.reset_button = gtk.Button("Reset Theta")
self.return_button = gtk.Button("Return to 0")
self.sys_check_button = gtk.Button("System Check")
self.ol_step_button = gtk.Button("OL Step")
#self.vib_check = gtk.CheckButton(label="Use Vibration Suppression", \
# use_underline=False)
self.vib_on_radio = gtk.RadioButton(None, "On")
self.vib_off_radio = gtk.RadioButton(self.vib_on_radio, "Off")
#button.connect("toggled", self.callback, "radio button 2")
self.vib_off_radio.set_active(True)
vib_label = gtk.Label("Vibration Suppression")
ol_label = gtk.Label("OL Step Response")
ol_hbox = gtk.HBox(homogeneous=False)
amp_label = gtk.Label("amp:")
dur_label = gtk.Label("duration:")
self.ol_amp_entry = gtk.Entry()
self.ol_amp_entry.set_max_length(7)
self.ol_amp_entry.set_text("150")
Entry_width = 50
self.ol_amp_entry.set_size_request(Entry_width,-1)
self.dur_entry = gtk.Entry()
self.dur_entry.set_max_length(7)
self.dur_entry.set_text("300")
self.dur_entry.set_size_request(Entry_width,-1)
ol_hbox.pack_end(self.ol_amp_entry, False)
ol_hbox.pack_end(amp_label, False)
#ol_hbox.pack_start(amp_label, False)
#ol_hbox.pack_start(self.ol_amp_entry, False)
ol_dur_box = gtk.HBox(homogeneous=False)
ol_dur_box.pack_end(self.dur_entry, False)
ol_dur_box.pack_end(dur_label, False)
#Fixed Sine Controls
self.fs_amp_entry = gtk.Entry()
self.fs_amp_entry.set_max_length(7)
self.fs_amp_entry.set_size_request(Entry_width, -1)
self.fs_amp_entry.set_text("5")
self.fs_freq_entry = gtk.Entry()
self.fs_freq_entry.set_max_length(7)
self.fs_freq_entry.set_size_request(Entry_width, -1)
self.fs_freq_entry.set_text("0.5")
self.fs_dur_entry = gtk.Entry()
self.fs_dur_entry.set_max_length(7)
self.fs_dur_entry.set_size_request(Entry_width, -1)
self.fs_dur_entry.set_text("300")
fs_label = gtk.Label('Fixed Sine')
fs_amp_label = gtk.Label("amp (counts):")
fs_freq_label = gtk.Label("freq (Hz):")
fs_dur_label = gtk.Label("duration:")
fsvbox = gtk.VBox(homogeneous=False, spacing=5)
fsvbox.show()
fsvbox.pack_start(fs_label)
fshbox1 = gtk.HBox(homogeneous=False)
fshbox1.pack_end(self.fs_amp_entry, False)
fshbox1.pack_end(fs_amp_label, False)
fsvbox.pack_start(fshbox1, False)
fshbox2 = gtk.HBox(homogeneous=False)
fshbox2.pack_end(self.fs_freq_entry, False)
fshbox2.pack_end(fs_freq_label, False)
fsvbox.pack_start(fshbox2, False)
fshbox3 = gtk.HBox(homogeneous=False)
fshbox3.pack_end(self.fs_dur_entry, False)
fshbox3.pack_end(fs_dur_label, False)
fsvbox.pack_start(fshbox3, False)
self.fixed_sine_button = gtk.Button("Fixed Sine")
fsvbox.pack_start(self.fixed_sine_button, False)
#ol_dur_box.pack_start(dur_label, False)
#ol_dur_box.pack_start(self.dur_entry, False)
sep0 = gtk.HSeparator()
sep1 = gtk.HSeparator()
sep2 = gtk.HSeparator()
sep3 = gtk.HSeparator()
#.........这里部分代码省略.........
示例9: __init__
# 需要导入模块: from matplotlib.backends.backend_gtkagg import NavigationToolbar2GTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.NavigationToolbar2GTKAgg import show [as 别名]
#.........这里部分代码省略.........
# Create the matplotlib graph
self.figure = Figure( figsize=(8,6), dpi=72 )
self.axisX = self.figure.add_subplot( 311 )
self.axisY = self.figure.add_subplot( 312 )
self.axisROC = self.figure.add_subplot( 313 )
self.canvas = None # Wait for GUI to be created before creating canvas
self.navToolbar = None
# Setup the GUI
builder = gtk.Builder()
builder.add_from_file( self.scriptPath + "/GUI/OpticalFlowExplorer.glade" )
self.dwgCameraImage = builder.get_object( "dwgCameraImage" )
self.window = builder.get_object( "winMain" )
self.vboxMain = builder.get_object( "vboxMain" )
self.hboxWorkArea = builder.get_object( "hboxWorkArea" )
self.adjTestPointX = builder.get_object( "adjTestPointX" )
self.adjTestPointY = builder.get_object( "adjTestPointY" )
self.adjTestPointX.set_upper( self.MAX_TEST_POINT_X )
self.adjTestPointY.set_upper( self.MAX_TEST_POINT_Y )
self.sequenceControls = builder.get_object( "sequenceControls" )
self.sequenceControls.setNumFrames( len( self.inputSequence.cameraImages ) )
self.sequenceControls.setOnFrameIdxChangedCallback( self.onSequenceControlsFrameIdxChanged )
self.setFrameIdx( 0 )
self.processOpticalFlowData()
builder.connect_signals( self )
updateLoop = self.update()
gobject.idle_add( updateLoop.next )
self.window.show()
self.window.maximize()
#---------------------------------------------------------------------------
def onWinMainDestroy( self, widget, data = None ):
gtk.main_quit()
#---------------------------------------------------------------------------
def main( self ):
# All PyGTK applications must have a gtk.main(). Control ends here
# and waits for an event to occur (like a key press or mouse event).
gtk.main()
#---------------------------------------------------------------------------
def processOpticalFlowData( self ):
testX = int( self.adjTestPointX.get_value() )
testY = int( self.adjTestPointY.get_value() )
regSeq = self.regularisedInputSequence
corSeq = self.crossCorrelatedSequence
# Normalise the data ready for display
normalisedServoAngleData = Utils.normaliseSequence( regSeq.regularServoAngleData )
normalisedOpticalFlowDataX = Utils.normaliseSequence( regSeq.regularOpticalFlowArrayX[ testY ][ testX ] )
normalisedOpticalFlowDataY = Utils.normaliseSequence( regSeq.regularOpticalFlowArrayY[ testY ][ testX ] )
numCorrelationChannels = len( corSeq.correlationChannels )
# Plot graphs
self.axisX.clear()
self.axisX.plot( regSeq.regularSampleTimes, normalisedServoAngleData )
self.axisX.plot( regSeq.regularSampleTimes, normalisedOpticalFlowDataX )
示例10: __init__
# 需要导入模块: from matplotlib.backends.backend_gtkagg import NavigationToolbar2GTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.NavigationToolbar2GTKAgg import show [as 别名]
class HurricaneUI:
def __init__(self):
gladefile = "HurricaneUI.glade"
builder = gtk.Builder()
builder.add_from_file(gladefile)
self.window = builder.get_object("mainWindow")
builder.connect_signals(self)
self.figure = Figure(figsize=(10,10), dpi=75)
self.axis = self.figure.add_subplot(111)
self.lat = 50
self.lon = -100
self.globe= globDisp.GlobeMap(self.axis, self.lat, self.lon)
self.canvas = FigureCanvasGTK(self.figure)
self.canvas.show()
self.canvas.set_size_request(500,500)
self.globeview = builder.get_object("map")
self.globeview.pack_start(self.canvas, True, True)
self.navToolbar = NavigationToolbar(self.canvas, self.globeview)
self.navToolbar.lastDir = '/var/tmp'
self.globeview.pack_start(self.navToolbar)
self.navToolbar.show()
self.gridcombo = builder.get_object("gridsize")
cell=gtk.CellRendererText()
self.gridcombo.pack_start(cell,True)
self.gridcombo.add_attribute(cell, 'text', 0)
#self.gridcombo.set_active(2)
# read menu configuration
self.gridopt = builder.get_object("gridopt").get_active()
self.chkDetected = builder.get_object("detectedopt")
self.detectedopt = self.chkDetected.get_active()
self.chkHurricane = builder.get_object("hurricaneopt")
self.hurricaneopt = self.chkHurricane.get_active()
model = builder.get_object("liststore1")
index = self.gridcombo.get_active()
self.gridsize = model[index][0]
radio = [ r for r in builder.get_object("classifieropt1").get_group() if r.get_active() ][0]
self.sClassifier = radio.get_label()
self.start = builder.get_object("startdate")
self.end = builder.get_object("enddate")
self.chkUndersample = builder.get_object("undersample")
self.chkGenKey = builder.get_object("genKey")
# disable unimplemented classifier selection
builder.get_object("classifieropt2").set_sensitive(False)
builder.get_object("classifieropt3").set_sensitive(False)
builder.get_object("classifieropt4").set_sensitive(False)
self.btnStore = builder.get_object("store")
self.datapath = 'GFSdat'
self.trackpath = 'tracks'
builder.get_object("btnDatapath").set_current_folder(self.datapath)
builder.get_object("btnTrackpath").set_current_folder(self.trackpath)
self.btnDetect = builder.get_object("detect")
# current operation status
self.stormlocs = None
self.detected = None
self.clssfr = None
# for test drawing functions
if os.path.exists('demo.detected'):
with open('demo.detected','r') as f:
self.detected = pickle.load(f)
self.stormlocs = pickle.load(f)
self.chkHurricane.set_label(str(self.stormlocs.shape[0])+" Hurricanes")
self.chkDetected.set_label(str(self.detected.shape[0])+" Detected")
self.setDisabledBtns()
# draw Globe
self.drawGlobe()
def setDisabledBtns(self):
self.chkDetected.set_sensitive(self.detected!=None)
self.chkHurricane.set_sensitive(self.stormlocs!=None)
self.btnStore.set_sensitive(self.clssfr!=None)
self.btnDetect.set_sensitive(self.clssfr!=None)
def drawGlobe(self):
self.globe.drawGlobe(self.gridsize, self.gridopt)
if self.hurricaneopt : self.globe.drawHurricanes(self.stormlocs)
if self.detectedopt : self.globe.fillGrids(self.detected)
def main(self):
self.window.show_all()
gtk.main()
def redraw(self):
self.axis.cla()
self.drawGlobe()
#.........这里部分代码省略.........