本文整理汇总了Python中matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg.show方法的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasGTKAgg.show方法的具体用法?Python FigureCanvasGTKAgg.show怎么用?Python FigureCanvasGTKAgg.show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg
的用法示例。
在下文中一共展示了FigureCanvasGTKAgg.show方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: recreate_canvas
# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg import show [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()
示例2: __init__
# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg import show [as 别名]
class HelloMatplotlib:
def __init__(self):
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.connect("delete_event", self.delete_event)
self.window.connect("destroy", self.destroy)
self.window.set_size_request(400, 400)
self.window.set_border_width(10)
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)
self.canvas = FigureCanvas(f)
self.canvas.show()
self.window.add(self.canvas)
self.window.show()
def delete_event(self, widget, event, data=None):
gtk.main_quit()
def destroy(self, widget, data=None):
gtk.main_quit()
def main(self):
gtk.main()
示例3: __init__
# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg import show [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()
示例4: WidgetsWrapper
# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg 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)
示例5: graficar
# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg import show [as 别名]
def graficar(self, datos, datos1, titulo):
datos = datos # valores del tiempo de espera.
datos1 = datos1 # valores de tiempo de cpu, tiempo de llegada y numeró de procesos.
titulo = titulo
x1 = []
y1 = []
y2 = []
n = len(datos)
for i in xrange(n):
x1.append(datos1[i][0]) #Numero de proceso
y1.append(datos[i][1]) #Tiempo de espera
y2.append(datos1[i][1]) #tiempo de uso del cpu
self.win = gtk.Window()
self.win.set_default_size(600,480)
self.win.set_position(gtk.WIN_POS_CENTER)
self.win.set_title(titulo)
f = Figure(figsize=(5,4), dpi=100)
a = f.add_subplot(111)
a.plot(x1, y1, color='blue', label='(Procesos, Tiempo de espera)')
a.legend(loc = 2)
a.set_title(titulo, color='red', size=14)
a.set_xlabel(u'Número de procesos', color='red', size=14)
a.set_ylabel('Tiempo de espera ', color='red', size=14)
"""
# gráfica procesos vs tiempo de cpu
#g = Figure(figsize=(5,4), dpi=100)
b = f.add_subplot(111)
b.plot(x1, y2, color='red', label='(Procesos, Tiempo de CPU)')
b.set_xlabel(u'Número de procesos', color='red', size=14)
b.set_ylabel('Tiempo de CPU ', color='red', size=14)
"""
vbox = gtk.VBox(False, 5)
canvas = FigureCanvas(f)
canvas.show()
#canvas1 = FigureCanvas(g)
#canvas1.show()
vbox.pack_start(canvas, True, True, 0)
#vbox.pack_start(canvas1, True, True, 0)
cerrar = gtk.Button(stock=gtk.STOCK_CLOSE)
cerrar.connect("activate", self.close)
vbox.pack_start(cerrar, False, False, 0)
self.win.add(vbox)
self.win.show_all()
示例6: __init__
# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg import show [as 别名]
class aacxGui:
def __init__(self):
self.builder = gtk.Builder()
self.builder.add_from_file("aacx.ui")
self.window = self.builder.get_object("window1")
self.status = self.builder.get_object("statusbar1")
self.frmadj = self.builder.get_object("frame_adj")
self.about = gtk.AboutDialog()
self.about.set_name("AACX")
self.about.set_version("0.0.1")
self.about.set_copyright(u'Copyright © 2010 Alex Converse')
self.about.set_website("http://github.com/aconverse/aacx")
self.about.set_license("GPLv2+")
self.window.connect("destroy", gtk.main_quit)
signals = {
"on_file_quit_activate": gtk.main_quit,
"on_help_about_activate": self.show_about,
"on_frame_adj_value_changed": self.spinback,
}
self.builder.connect_signals(signals)
self.set_status_here("xxx")
self.hasplot = 0
def addplot(self, fig):
self.canvas = FigureCanvasGTKAgg(fig)
self.canvas.show()
v = self.builder.get_object("vbox1")
v.pack_start(self.canvas)
self.hasplot = 1
def redraw(self):
self.canvas.draw()
def show(self):
self.window.show()
def show_about(self, data):
self.about.run()
self.about.hide()
def set_status_here(self, text):
self.status.push(0, text)
def spinback(self, data):
spinback(int(data.get_value()), int(data.get_upper())+1)
def set_spinner(self, n):
self.frmadj.set_value(n)
def set_num_frames(self, n):
self.frmadj.set_upper(n-1)
示例7: __init__
# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg import show [as 别名]
def __init__(self, wTree, widget):
figure = Figure(figsize=(6,4), dpi=72)
axes = figure.add_subplot(1,1,1)
canvas = FigureCanvasGTKAgg(figure)
canvas.show()
canvas.mpl_connect('pick_event', self.pick_handler)
canvas.mpl_connect('motion_notify_event', self.motion_handler)
canvas.mpl_connect('button_release_event', self.release_handler)
canvas.mpl_connect('button_press_event', self.press_handler)
graphview = wTree.get_widget(widget)
graphview.add_with_viewport(canvas)
self.figure = figure
self.canvas = canvas
self.axes = axes
self.plot_line = self.axes.plot([], [], 'b-', animated=True)[0]
self.cursors = []
self.picked = None
self.data = []
示例8: get_ax
# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg import show [as 别名]
def get_ax(self, custom_location=None):
from matplotlib.figure import Figure
from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg as FigureCanvas
if custom_location:
widget = self.get_widget(custom_location)
else:
widget = self.get_widget_in_current_location(self)
if not widget or not widget.get_data('ax'):
#logging.debug('creating ax')
widget = gtk.Frame()
fig = Figure(dpi=100)
ax = fig.add_subplot(111)
ax.set_aspect('auto')
canvas = FigureCanvas(fig)
self.on_canvas_draw(canvas)
#canvas.mpl_connect('draw_event', self.on_canvas_draw)
canvas.show()
widget.add(canvas)
if custom_location:
services.add_widget(widget, custom_location)
else:
services.add_widget(widget, self.current_widget_locations[0])
widget.set_data('ax', ax)
return widget.get_data('ax')
示例9: DDTF
# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg import show [as 别名]
#.........这里部分代码省略.........
S11=abs(Sxx)**2
S12=abs(Sxy)**2
S13=abs(Sxz)**2
S21=abs(Syx)**2
S22=abs(Syy)**2
S23=abs(Syz)**2
S31=abs(Szx)**2
S32=abs(Szy)**2
S33=abs(Szz)**2
sumS = S11 + S12 + S13
sumS2 = S21 + S22 + S23
sumS3 = S31 + S32 + S33
NS11 = S11 / S11.max()
NS12 = S12 / sumS
NS13 = S13 / sumS
NS21 = S21 / sumS2
NS22 = S22 / S22.max()
NS23 = S23 / sumS2
NS31 = S31 / sumS3
NS32 = S32 / sumS3
NS33 = S33 / S33.max()
count += 1
ttle1='Spectrum el1'
ttle2=' el2 - . el1'
ttle3=' el3 - . el1'
ttle4=' el1 - . el2'
ttle5=' Spectrum el2'
ttle6=' el3 - . el2'
ttle7=' el1 - . el3'
ttle8='el2 - . el3'
ttle9='Spectrum el3'
# print "ns11 shape ", NS11.shape
# print "f shape ", f.shape
# print "f is: " , f
# print "step is: ", step
# print "shape x, y ", f[1:step/4].shape, NS11[1:step/4].shape
# plot.subplot(211)
# plot.axis([0, 60, 0, 1])
# print (NS12, NS13, NS21, NS22, NS23, NS31, NS32, NS33)
return (f ,step,NS11, NS12, NS13, NS21, NS22, NS23, NS31, NS32, NS33)
def delete_event(self, widget, event, data=None):
return False
def destroy(self,widget, data=None):
gtk.main_quit()
def __init__(self):
super(DDTF,self).__init__()
self.connect("delete_event", self.delete_event)
self.connect("destroy", self.destroy)
e1,e2,e3 = signal_gen.signal_gen(.2,.01,.001)
(f ,step,NS11, NS12, NS13, NS21, NS22, NS23, NS31, NS32, NS33) = self.ddtf(e1,e2,e3)
# gtk.Window.__init__(self)
self.fig = Figure(figsize = (20,15), dpi=72)
self.canvas = FigureCanvas(self.fig)
self.canvas.set_size_request(1800, 640)
t = np.arange(0.0,50.0, 0.01)
xlim = np.array([0,10])
self.axes = self.fig.add_axes([0.075, 0.25, 0.9, 0.725], axisbg='#FFFFCC')
self.axes.plot(t, np.sin(2*0.32*np.pi*t) * np.sin(2*2.44*np.pi*t) )
self.axes.set_xlim([0.0,10.0])
self.axes.set_xticklabels([])
self.axesSpec = self.fig.add_axes([0.075, 0.05, 0.9, 0.2])
t = self.axesSpec.text(
0.5, 0.5,
'Click on EEG channel for spectrogram (scroll mouse to expand)',
verticalalignment='center',
horizontalalignment='center',
)
t.set_transform(self.axes.transAxes)
self.axesSpec.set_xlim([0.0,10.0])
self.axesSpec.set_xticklabels([])
self.axesSpec.set_yticklabels([])
self.canvas.show()
self.show()
# self.axes.plot(f[step/4],NS11[:,0:step/4],'k')
# plot.plot([1,2,3,4])
# plot.show()
def main(self):
gtk.main()
示例10: __init__
# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg import show [as 别名]
class gui:
"""Main application class."""
def __init__(self):
self.builder=gtk.Builder()
self.dsizes=[]
self.builder.add_from_file("gladeb.glade")
myscreen=gtk.gdk.Screen()
self.screensize=(myscreen.get_width(),myscreen.get_height())
print self.screensize
dic={"mainwindowdestroy" : gtk.main_quit,"openwindow":self.openWindow, "closewindow":self.closeWindow, "devicenumchanged":self.changeDeviceNumber, "btnclicked":self.btnclicked, "fileset":self.fileSet, "mctoolbarbtn":self.mctoolbarClicked, "trkeypress":self.getKeyPress}
self.builder.connect_signals(dic)
#Initialise defaults
#Camera config window
self.devicenumcb = gtk.combo_box_new_text()
self.builder.get_object("combospace").add(self.devicenumcb)
self.builder.get_object("combospace").show_all()
self.devicenumcb.append_text('0')
self.devicenumcb.append_text('1')
self.devicenumcb.set_active(0)
self.devicenumcb.connect("changed", self.changeDeviceNumber)
self.figurecc=Figure()
self.axiscc=self.figurecc.add_subplot(111)
try:
self.cap = cv2.VideoCapture(self.devicenumcb.get_active())
except:
pass
self.pixelthreshold=0
#Monitor config window
self.tolerance=25
self.blocksize=7
self.d1size=(80,50)
self.d2size=None
self.builder.get_object("tolerance").set_text("25")
self.builder.get_object("blocksize").set_text("7")
self.builder.get_object("d1x").set_text("50")
self.builder.get_object("d1y").set_text("80")
self.figuremc=Figure()
self.axismc=self.figuremc.add_subplot(111)
self.figuretmc=Figure()
self.axistmc=self.figuretmc.add_subplot(111)
self.mcflipx=False
self.mcflipy=False
self.clickstate="none"
self.crop1=None
self.crop2=None
self.builder.get_object("tolerance").set_editable(True)
self.builder.get_object("blocksize").set_editable(True)
self.builder.get_object("d1x").set_editable(True)
self.builder.get_object("d1y").set_editable(True)
self.builder.get_object("d2x").set_editable(True)
self.builder.get_object("d2y").set_editable(True)
self.contours=[]
self.dlist=[]
self.trdlist=[]
self.figuretr=Figure()
self.axistr=self.figuretr.add_subplot(111)
self.trframe=0
self.trtotal=0
self.traindict={}
self.solsdict={}
#General functions
def fileSet(self, widget):
call=gtk.Buildable.get_name(widget)
if call=="monitorconfigloadfile":
self.loadMonitorImage(widget.get_filename())
elif call=="trainingfilechooser":
self.loadTrainingImage(widget.get_filename())
elif call=="testmcfile":
self.loadMonitorImage(widget.get_filename(), testmc=True)
def btnclicked(self, widget):
call=gtk.Buildable.get_name(widget)
if call=="resbtn":
self.setResolution()
elif call=="imagesavebtn":
fname=self.builder.get_object("imagesavetext").get_text()
if fname!="" and fname!=None:
self.saveImage(fname)
elif call=="videosavebtn":
fname=self.builder.get_object("videosavefile").get_text()
if fname!="" and fname!=None:
self.saveVideo(fname)
elif call=="setparameters":
self.setParameters()
elif call=="setdigits":
self.setDigitSizes()
elif call=="mcflipx":
if self.mcflipx==False:
self.mcflipx=True
else:
self.mcflipx=False
self.loadMonitorImage(self.builder.get_object("monitorconfigloadfile").get_filename())
elif call=="mcflipy":
#.........这里部分代码省略.........
示例11: init
# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg 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)
#.........这里部分代码省略.........
示例12: init
# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg 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)
示例13: init
# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg 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
#.........这里部分代码省略.........
示例14: __init__
# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg 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 ] )
#.........这里部分代码省略.........
示例15: __init__
# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg import show [as 别名]
class setup_gui:
def __init__(self):
self.builder = gtk.Builder()
self.builder.add_from_file(os.path.splitext(__file__)[0]+".glade")
self.window = self.builder.get_object("window1")
dic = {
"on_lpa_toggled" : self.set_lpa,
"on_rpa_toggled" : self.set_rpa,
"on_nas_toggled" : self.set_nas,
"gtk_widget_hide" : self.hideinsteadofdelete,
"on_menu_load_data_activate" : self.load_data,
"on_menu_load_channels_activate" : self.load_channel_positions,
"on_menuAbout_activate": self.show_aboutdialog,
"on_menu_coregister_toggled" : self.coregister_toggle,
"on_buttonsavecoreg_activate" : self.save_coregister_info,
#"test" : self.changed_cb,
}
self.builder.connect_signals(dic)
self.create_draw_frame('none')
#self.load_data(None)
def coregister_toggle(self,widget):
if widget.get_active() == True:
self.builder.get_object("hbuttonbox2").show()
else:
self.builder.get_object("hbuttonbox2").hide()
def show_aboutdialog(self,widget):
self.builder.get_object("aboutdialog1").show()
def load_data(self,widget):
chooser = gtk.FileChooserDialog(title=None,action=gtk.FILE_CHOOSER_ACTION_OPEN,
buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK))
filter = gtk.FileFilter()
filter.set_name('MRI files')
filter.add_pattern('*.img')
filter.add_pattern('*.nii*')
chooser.add_filter(filter)
chooser.run()
print chooser.get_filename(), 'selected'
fn = chooser.get_filename(); print type(fn);
chooser.destroy()
img = nibabel.load(fn)
self.fig.clf()
self.display(img)
def load_channel_positions(self,widget):
pass
def set_lpa(self,widget):
if widget.get_active() == True:
print 'adding circle', self.ind1, self.ind2, self.ind3
circle = Circle((self.ind3,self.ind2),radius=5,color='b',alpha=.75)#self.ind2,self.ind3), 5)
self.lpapatch = self.ax1.add_patch(circle)
self.lpa = copy(self.coordinates)
if widget.get_active() == False:
self.lpapatch.remove()
self.update()
def set_rpa(self,widget):
if widget.get_active() == True:
print 'adding circle', self.ind1, self.ind2, self.ind3
circle = Circle((self.ind3,self.ind2),radius=5,color='r',alpha=.75)#self.ind2,self.ind3), 5)
self.rpapatch = self.ax1.add_patch(circle)
self.rpa = copy(self.coordinates)
if widget.get_active() == False:
self.rpapatch.remove()
self.update()
def set_nas(self,widget):
if widget.get_active() == True:
print 'adding circle', self.ind1, self.ind2, self.ind3
circle = Circle((self.ind3,self.ind2),radius=5,color='g',alpha=.75)#self.ind2,self.ind3), 5)
self.naspatch = self.ax1.add_patch(circle)
self.nas = copy(self.coordinates)
if widget.get_active() == False:
self.naspatch.remove()
self.update()
def save_coregister_info(self,widget):
print 'current aux field in header',self.hdr['aux_file']
#filepath = os.path.splitext(self.img.file_map['header'].filename)[0]
try:
filepath = os.path.splitext(self.filename)[0]
except:
print 'Couldnt find filename for saving XFM, saving in current dir as MRI_XFM_DATA'
filepath = 'MRI_XFM_DATA'
coreg_dict = {'lpa': self.lpa,'rpa': self.rpa, 'nas':self.nas}
readwrite.writedata(coreg_dict, filepath)
def load_coregister_info(self, widget):
if os.path.isfile(filepath+'.pym') == True:
print('loading index points found in file',filepath+'.pym')
self.fiddata = readwrite.readdata(filepath+'.pym')
self.getfiducals(h)
#def test2(self,widget):
#.........这里部分代码省略.........