本文整理汇总了Python中matplotlib.backends.backend_gtk.FigureCanvasGTK.show方法的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasGTK.show方法的具体用法?Python FigureCanvasGTK.show怎么用?Python FigureCanvasGTK.show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_gtk.FigureCanvasGTK
的用法示例。
在下文中一共展示了FigureCanvasGTK.show方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: displayGraph
# 需要导入模块: from matplotlib.backends.backend_gtk import FigureCanvasGTK [as 别名]
# 或者: from matplotlib.backends.backend_gtk.FigureCanvasGTK import show [as 别名]
def displayGraph(self, xaxis, yaxis, hist):
if(hist == None):
return
try:
dialog = gtk.Window()
figure = Figure(figsize=(6,4), dpi=72)
axis = figure.add_subplot(111)
canvas = FigureCanvasGTK(figure) # a gtk.DrawingArea
canvas.show()
dialog.add(canvas)
# empty axis if neccesary, and reset title and stuff
axis.clear()
axis.set_xlabel(xaxis)
axis.set_ylabel(yaxis)
if len(hist) > 1:
axis.plot(hist[0], 'r')
axis.plot(hist[1], 'g')
axis.plot(hist[2], 'b')
else:
axis.plot(hist[0], 'r')
dialog.show()
except ValueError:
sys.exit(1)
示例2: __init__
# 需要导入模块: from matplotlib.backends.backend_gtk import FigureCanvasGTK [as 别名]
# 或者: from matplotlib.backends.backend_gtk.FigureCanvasGTK import show [as 别名]
class Onus:
def __init__(self):
#self.gladefile = "onus.glade"
self.gladefile = "../onus.glade"
self.wTree = gtk.glade.XML(self.gladefile, "mainWindow")
FILES = [ "../../0_10_0.TXT" ]
t = 0
time = []
heart_rate = []
step_count = []
activity = []
# Get the Data
for file in FILES:
infile = open(file,"r")
data_section = 0
while 1:
line = infile.readline()
if not line:
break
moment = line.split(",")
time.append( t )
t += 1
step_count.append( moment[0] )
heart_rate.append( moment[1] )
activity.append( moment[2] )
self.figure = Figure(figsize=(6,4), dpi=72)
self.axis = self.figure.add_subplot(111)
self.axis.set_xlabel('Time (minutes)')
self.axis.set_ylabel('Heart Rate (bpm)')
self.axis.set_title('Activity')
self.axis.grid(True)
self.axis.plot(time, heart_rate, time, step_count, time, activity)
self.axis.legend(["Heart Rate", "Step Count", "Activity"])
self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea
self.canvas.show()
self.graphview = self.wTree.get_widget("vbox2")
self.graphview.pack_start(self.canvas, True, True)
#Create our dictionay and connect it
dic = { "on_mainWindow_destroy" : gtk.main_quit, "on_connect" : self.on_connect, "on_import" : self.on_import }
self.wTree.signal_autoconnect(dic)
def on_connect(self, widget):
#dan = Fetch()
#.start()
self.statusbar1 = self.wTree.get_widget("statusbar1")
self.statusbar1.push(0, "Connected")
def on_import(self, widget):
self.statusbar1 = self.wTree.get_widget("statusbar1")
self.statusbar1.push(0, "Importing")
示例3: __init__
# 需要导入模块: from matplotlib.backends.backend_gtk import FigureCanvasGTK [as 别名]
# 或者: from matplotlib.backends.backend_gtk.FigureCanvasGTK import show [as 别名]
class MainWin:
def __init__(self):
# Le decimos a nuestro programa el nombre del archivo glade
self.widgets = gtk.glade.XML("interface.glade")
# Creamos un pequeño diccionario que contiene las señales definidas en
# glade y su respectivo método (o llamada)
signals = { "on_buttonIniciar_clicked" : self.on_buttonIniciar_clicked,
"on_about_dialog_clicked" : self.on_about_dialog_clicked,
"on_exit_clicked" : gtk.main_quit, # al presionar el boton salir, sale de la aplicacion
"gtk_main_quit" : gtk.main_quit } #
# Luego se auto-conectan las señales.
self.widgets.signal_autoconnect(signals)
# Nota: Otra forma de hacerlo es No crear el diccionario signals y
# solo usar "self.widgets.signal_autoconnect(self)" -->Ojo con el self
# Ahora obtenemos del archivo glade los widgets que vamos a utilizar
self.labelTiempo = self.widgets.get_widget("labelTiempo") #label de tiempo
self.buttonIniciar = self.widgets.get_widget("buttonIniciar") #boton iniciar
self.aboutDialog = self.widgets.get_widget("aboutDialog") #dialogo acerca de
#Definición del widget que manejará la gráfica
self.figure = Figure(figsize=(6,4), dpi=60)
self.axis = self.figure.add_subplot(111)
self.axis.set_xlabel('X')
self.axis.set_ylabel('Y')
self.axis.set_title('Graph')
self.axis.grid(True)
#Agregar la gráfica a la caja vertical
self.canvas = FigureCanvasGTK(self.figure)
self.canvas.show()
self.graphview = self.widgets.get_widget("matplot")
self.graphview.pack_start(self.canvas, True, True)
# Se definen los métodos, en este caso señales como "destroy" ya fueron
# definidas en el .glade, así solo se necesita definir "on_button1_clicked"
def on_about_dialog_clicked(self, widget):
#self.labelTiempo.set_text("Hola !")
self.aboutDialog.show()
def on_buttonIniciar_clicked(self, widget):
self.labelTiempo.set_text("Hola !")
示例4: Backend
# 需要导入模块: from matplotlib.backends.backend_gtk import FigureCanvasGTK [as 别名]
# 或者: from matplotlib.backends.backend_gtk.FigureCanvasGTK import show [as 别名]
class Backend( backend.Backend ):
def init(self):
self.layer_to_axes = {}
self.axes_to_layer = {}
self.layers_cache = [] # copy of self.plot.layers
self.layer_signals = {}
self.line_caches = {}
self.omaps = {}
def connect(self):
logger.debug("Opening matplotlib session.")
self.figure = Figure(dpi=100, facecolor="white") # figsize=(5,4), dpi=100)
self.canvas = FigureCanvas(self.figure)
self.canvas.show()
self.line_caches = {}
self.layer_to_axes.clear()
self.axes_to_layer.clear()
backend.Backend.connect(self)
logger.debug("Init finished")
def set(self, project,plot):
backend.Backend.set(self, project, plot)
if self.project is not None:
# TODO: connect to notify::layers of Plot
pass
def disconnect(self):
logger.debug("Closing matplotlib session.")
if not self.canvas is None:
self.canvas.destroy()
self.canvas = None
if not self.figure is None:
self.figure = None
backend.Backend.disconnect(self)
#----------------------------------------------------------------------
def arrange(self, rows=1, cols=1):
layers = self.plot.layers
n = len(layers)
if n > (rows*cols):
rows = int((rows*cols) / n) + 1
cols = rows * n
#raise ValueError("Not enough rows and cols for all layers!")
self.figure.clear()
self.figure.axes = []
self.layer_to_axes.clear()
self.axes_to_layer.clear()
self.layers_cache = []
for signal_list in self.layer_signals.itervalues():
for signal in signal_list:
Signals.disconnect(signal)
self.layer_signals = {}
j = 1
for layer in layers:
print "Setting up layer", layer
axes = self.figure.add_subplot("%d%d%d" % (rows,cols,j))
self.layer_to_axes[layer] = axes
self.axes_to_layer[axes] = layer
self.layers_cache.append(layer)
print "Connecting to notify of ", layer
self.layer_signals[layer] = \
[Signals.connect(layer, 'notify', self.on_update_layer),
Signals.connect(layer, 'notify::labels', self.on_update_labels)]
j += 1
def draw(self):
self.check_connection()
logger.debug("Matplotlib: draw()")
if self.plot.layers != self.layers_cache:
self.arrange()
self.omaps = {}
for layer in self.plot.layers:
self.update_layer(layer)
self.draw_canvas()
def draw_canvas(self):
#.........这里部分代码省略.........
示例5: ResultViewer
# 需要导入模块: from matplotlib.backends.backend_gtk import FigureCanvasGTK [as 别名]
# 或者: from matplotlib.backends.backend_gtk.FigureCanvasGTK import show [as 别名]
class ResultViewer(gtk.Window):
def __init__(self,modelf,paramsf,resultsf,auto_update = 1):
super(ResultViewer, self).__init__()
self.model_file = modelf if modelf!=None else "model.json"
self.param_file = paramsf
self.results_file = resultsf
self.connect("destroy", gtk.main_quit)
self.set_size_request(800, 600)
self.set_position(gtk.WIN_POS_CENTER)
self.vbox = gtk.VBox()
self.time = gtk.SpinButton()
self.time.set_numeric(True)
self.time.set_increments(1,1)
self.time.connect('value-changed', self.on_time_changed)
self.vbox.pack_start(self.time,False)
self.hbox = gtk.HPaned()
self.add(self.hbox)
self.graph = xdot.DotWidget()
self.hbox.pack1(self.graph,True)
self.set_focus(self.graph)
self.graph.connect('clicked', self.on_url_clicked)
self.current_node = None
self.hbox.pack2(self.vbox,True)
self.hbox.set_position(400)
self.init_chart()
if auto_update==1:
import gobject
gobject.timeout_add(500, self.update)
self.update()
else:
self.reload()
self.show_all()
def reload(self):
modelins = get_in_stream(self.model_file or "model.json")
parameterins = get_in_stream(self.param_file or "prm.json")
resultins = get_in_stream(self.results_file or "res.json")
self.model = json.load(modelins)
self.params = json.load(parameterins)
self.results = json.load(resultins)
modelins.close()
parameterins.close()
resultins.close()
self.set_title(self.model["properties"]["name"])
self.time.set_range(0,len(self.results)-1)
dotcode = generate_dot(self.model)
self.graph.set_dotcode(dotcode, filename='<stdin>')
self.draw_chart()
dotcode = generate_dot(self.model)
self.graph.set_dotcode(dotcode, filename='<stdin>')
self.graph.zoom_to_fit()
def update(self):
import os
import subprocess
if not hasattr(self, "last_mtime"):
self.last_mtime = None
current_mtime = os.stat(self.model_file).st_mtime
if current_mtime != self.last_mtime:
self.last_mtime = current_mtime
subprocess.call("make")
self.reload()
return True
def init_chart(self):
self.figure = Figure(figsize=(6,4), dpi=72)
self.axis = self.figure.add_subplot(111)
self.axis.grid(True)
self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea
self.canvas.show()
self.vbox.pack_start(self.canvas, True, True)
def on_url_clicked(self, widget, url, event):
self.current_node = url
self.draw_chart()
return True
def on_time_changed(self,widget):
self.draw_chart()
def draw_chart(self):
self.axis.clear()
if not (self.current_node is None):
setup_node_states(self.model["nodes"])
for n in self.model["nodes"]:
if n["id"] == self.current_node:
node = n
#.........这里部分代码省略.........
示例6: __init__
# 需要导入模块: from matplotlib.backends.backend_gtk import FigureCanvasGTK [as 别名]
# 或者: from matplotlib.backends.backend_gtk.FigureCanvasGTK import show [as 别名]
class JPlot:
"""Misspecification plot"""
def __init__(self, app):
#setup matplotlib stuff on first notebook page (empty graph)
self.app = app
# Plot defaults:
self.imp_col = '#dd2244'
self.nim_col = '#5533dd'
# Create figure
self.figure = Figure(figsize=(6,4), dpi=72)
self.axis = self.figure.add_subplot(111)
self.axis.set_xlabel('Modification index')
self.axis.set_ylabel('Power')
self.axis.set_title('Misspecifications')
try:
# omit missing observations
parameters = [par for par in self.app.get_parameters() if \
par.mi <99.0 and par.power < 1.0 and par.epc < 99.0]
self.mis = [par.mi for par in parameters]
self.names = [par.name for par in parameters]
self.powers = [par.power for par in parameters]
self.ids = ["%s in group %s" % (par.name, par.group) for par in parameters]
self.axis.scatter( self.mis, self.powers,
c = [par.epc > self.app.get_field_value('delta') \
and self.imp_col or self.nim_col for par in parameters],
linewidth=0, picker=30.0, vmin=self.imp_col,
vmax = self.nim_col,
)
self.axis.autoscale_view(True) #tight
self.axis.axvline(self.app.get_critical(),
color='#444444', linestyle='dashed')
self.axis.axhline( y=float(self.app.get_field_value('power')),
color='#444444', linestyle='dashed')
except AttributeError:
pass
self.draw()
def pick_handler(self, event):
'''What happens if the user clicks a point in the plot'''
index = event.ind[0]
label = self.ids[index]
sys.stderr.write('ind is %s'% index)
sys.stderr.write('mousover %s\n' % label)
x, y = self.mis[index], self.powers[index]
self.axis.text(x, y, label)
self.draw()
def draw(self):
'Draw or re-draw the plot, possibly showing some labels'
try: self.graphview.remove(self.canvas)
except: pass
self.canvas = FigureCanvasGTK(self.figure)
self.canvas.mpl_connect('pick_event', self.pick_handler)
self.canvas.show()
self.graphview = self.app.tree.get_widget("vbox_plot")
self.graphview.pack_start(self.canvas, True, True)
def reload(self):
'Completely redo the whole plot.'
self.graphview.remove(self.canvas)
self.__init__(self.app)
示例7: GuiGraphViewer
# 需要导入模块: from matplotlib.backends.backend_gtk import FigureCanvasGTK [as 别名]
# 或者: from matplotlib.backends.backend_gtk.FigureCanvasGTK import show [as 别名]
class GuiGraphViewer (threading.Thread):
def __init__(self, querylist, config, parent, debug=True):
"""Constructor for GraphViewer"""
self.sql = querylist
self.conf = config
self.debug = debug
self.parent = parent
#print "start of GraphViewer constructor"
self.db = Database.Database(self.conf, sql=self.sql)
filters_display = { "Heroes" : True,
"Sites" : True,
"Games" : True,
"Limits" : True,
"LimitSep" : True,
"LimitType" : True,
"Type" : False,
"UseType" : 'ring',
"Seats" : False,
"SeatSep" : False,
"Dates" : True,
"GraphOps" : True,
"Groups" : False,
"Button1" : True,
"Button2" : True
}
self.filters = Filters.Filters(self.db, self.conf, self.sql, display = filters_display)
self.filters.registerButton1Name(_("Refresh _Graph"))
self.filters.registerButton1Callback(self.generateGraph)
self.filters.registerButton2Name(_("_Export to File"))
self.filters.registerButton2Callback(self.exportGraph)
self.mainHBox = gtk.HBox(False, 0)
self.mainHBox.show()
self.leftPanelBox = self.filters.get_vbox()
self.hpane = gtk.HPaned()
self.hpane.pack1(self.leftPanelBox)
self.mainHBox.add(self.hpane)
# hierarchy: self.mainHBox / self.hpane / self.graphBox / self.canvas / self.fig / self.ax
self.graphBox = gtk.VBox(False, 0)
self.graphBox.show()
self.hpane.pack2(self.graphBox)
self.hpane.show()
self.fig = None
#self.exportButton.set_sensitive(False)
self.canvas = None
self.db.rollback()
def get_vbox(self):
"""returns the vbox of this thread"""
return self.mainHBox
#end def get_vbox
def clearGraphData(self):
try:
try:
if self.canvas:
self.graphBox.remove(self.canvas)
except:
pass
if self.fig != None:
self.fig.clear()
self.fig = Figure(figsize=(5,4), dpi=100)
if self.canvas is not None:
self.canvas.destroy()
self.canvas = FigureCanvas(self.fig) # a gtk.DrawingArea
except:
err = traceback.extract_tb(sys.exc_info()[2])[-1]
print _("Error:")+" "+err[2]+"("+str(err[1])+"): "+str(sys.exc_info()[1])
raise
def generateGraph(self, widget, data):
try:
self.clearGraphData()
sitenos = []
playerids = []
sites = self.filters.getSites()
heroes = self.filters.getHeroes()
siteids = self.filters.getSiteIds()
limits = self.filters.getLimits()
games = self.filters.getGames()
graphops = self.filters.getGraphOps()
names = ""
for i in ('show', 'none'):
if i in limits:
#.........这里部分代码省略.........
示例8: Backend
# 需要导入模块: from matplotlib.backends.backend_gtk import FigureCanvasGTK [as 别名]
# 或者: from matplotlib.backends.backend_gtk.FigureCanvasGTK import show [as 别名]
class Backend( backend.Plotter ):
def init(self):
# line_cache: key = id(Curve), value=mpl line object
self.line_cache = dict()
self.layer_to_axes = dict()
self.axes_to_layer = dict()
self.layers_cache = list() # copy of self.plot.layers
def connect(self):
logger.debug("Opening matplotlib session.")
self.figure = Figure(dpi=100, facecolor="white") # figsize=(5,4), dpi=100)
self.canvas = FigureCanvas(self.figure)
self.canvas.show()
self.line_cache.clear()
self.layer_to_axes.clear()
self.axes_to_layer.clear()
backend.Plotter.connect(self)
logger.debug("Init finished")
def disconnect(self):
logger.debug("Closing matplotlib session.")
if not self.canvas is None:
self.canvas.destroy()
self.canvas = None
if not self.figure is None:
self.figure = None
backend.Plotter.disconnect(self)
#----------------------------------------------------------------------
def arrange(self, rows=1, cols=1):
layers = self.plot.layers
n = len(layers)
if n > (rows*cols):
rows = int((rows*cols) / n) + 1
cols = rows * n
#raise ValueError("Not enough rows and cols for all layers!")
self.figure.clear()
self.figure.axes = []
self.layer_to_axes.clear()
self.axes_to_layer.clear()
self.layers_cache = list()
j = 1
for layer in layers:
print "Setting up layer", layer
axes = self.figure.add_subplot("%d%d%d" % (rows,cols,j))
self.layer_to_axes[layer] = axes
self.axes_to_layer[axes] = layer
self.layers_cache.append(layer)
j += 1
def draw_layer(self, layer, group_info):
ax = self.layer_to_axes[layer]
print "DRAWING AXES ", ax
ax.lines = []
line_cache = []
line_count = 0
last_cx = -1
# Default values come in two flavors:
# group-wise and single default values
group_colors = uwrap.get(layer, 'group_colors')
group_styles = uwrap.get(layer, 'group_styles')
group_markers = uwrap.get(layer, 'group_markers')
#default_color = 'r'
default_color = None
default_style = 'solid'
default_marker = 'None'
#:layer.visible
if uwrap.get(layer, 'visible') is False:
return
#:layer.title
title = uwrap.get(layer, 'title', None)
if title is not None:
ax.set_title(title)
#:layer.grid
grid = uwrap.get(layer, 'grid')
#.........这里部分代码省略.........
示例9: __init__
# 需要导入模块: from matplotlib.backends.backend_gtk import FigureCanvasGTK [as 别名]
# 或者: from matplotlib.backends.backend_gtk.FigureCanvasGTK import show [as 别名]
class GuiSessionViewer:
def __init__(self, config, querylist, mainwin, owner, debug=True):
self.debug = debug
self.conf = config
self.sql = querylist
self.window = mainwin
self.owner = owner
self.liststore = None
self.MYSQL_INNODB = 2
self.PGSQL = 3
self.SQLITE = 4
self.fig = None
self.canvas = None
self.ax = None
self.graphBox = None
# create new db connection to avoid conflicts with other threads
self.db = Database.Database(self.conf, sql=self.sql)
self.cursor = self.db.cursor
settings = {}
settings.update(self.conf.get_db_parameters())
settings.update(self.conf.get_import_parameters())
settings.update(self.conf.get_default_paths())
# text used on screen stored here so that it can be configured
self.filterText = {'handhead':_('Hand Breakdown for all levels listed above')}
filters_display = { "Heroes" : True,
"Sites" : True,
"Games" : True,
"Currencies": True,
"Limits" : True,
"LimitSep" : True,
"LimitType" : True,
"Type" : False,
"Seats" : True,
"SeatSep" : False,
"Dates" : True,
"Groups" : False,
"GroupsAll" : False,
"Button1" : True,
"Button2" : False
}
self.filters = Filters.Filters(self.db, self.conf, self.sql, display = filters_display)
self.filters.registerButton1Name("_Refresh")
self.filters.registerButton1Callback(self.refreshStats)
# ToDo: store in config
# ToDo: create popup to adjust column config
# columns to display, keys match column name returned by sql, values in tuple are:
# is column displayed, column heading, xalignment, formatting
self.columns = [ (1.0, "SID" )
, (1.0, "Hands" )
, (0.5, "Start" )
, (0.5, "End" )
, (1.0, "Rate" )
, (1.0, "Open" )
, (1.0, "Close" )
, (1.0, "Low" )
, (1.0, "High" )
, (1.0, "Range" )
, (1.0, "Profit")
]
self.detailFilters = [] # the data used to enhance the sql select
self.main_hbox = gtk.HPaned()
self.stats_frame = gtk.Frame()
self.stats_frame.show()
main_vbox = gtk.VPaned()
main_vbox.show()
self.graphBox = gtk.VBox(False, 0)
self.graphBox.set_size_request(400,400)
self.graphBox.show()
self.stats_vbox = gtk.VBox(False, 0)
self.stats_vbox.show()
self.stats_frame.add(self.stats_vbox)
self.main_hbox.pack1(self.filters.get_vbox())
self.main_hbox.pack2(main_vbox)
main_vbox.pack1(self.graphBox)
main_vbox.pack2(self.stats_frame)
self.main_hbox.show()
# make sure Hand column is not displayed
#[x for x in self.columns if x[0] == 'hand'][0][1] = False
# if DEBUG == False:
# warning_string = _("Session Viewer is proof of concept code only, and contains many bugs.\n")
# warning_string += _("Feel free to use the viewer, but there is no guarantee that the data is accurate.\n")
# warning_string += _("If you are interested in developing the code further please contact us via the usual channels.\n")
# warning_string += _("Thank you")
# self.warning_box(warning_string)
#.........这里部分代码省略.........
示例10: GuiSessionViewer
# 需要导入模块: from matplotlib.backends.backend_gtk import FigureCanvasGTK [as 别名]
# 或者: from matplotlib.backends.backend_gtk.FigureCanvasGTK import show [as 别名]
class GuiSessionViewer (threading.Thread):
def __init__(self, config, querylist, mainwin, debug=True):
self.debug = debug
self.conf = config
self.sql = querylist
self.liststore = None
self.MYSQL_INNODB = 2
self.PGSQL = 3
self.SQLITE = 4
self.fig = None
self.canvas = None
self.ax = None
self.graphBox = None
# create new db connection to avoid conflicts with other threads
self.db = Database.Database(self.conf, sql=self.sql)
self.cursor = self.db.cursor
settings = {}
settings.update(self.conf.get_db_parameters())
settings.update(self.conf.get_import_parameters())
settings.update(self.conf.get_default_paths())
# text used on screen stored here so that it can be configured
self.filterText = {'handhead':_('Hand Breakdown for all levels listed above')}
filters_display = { "Heroes" : True,
"Sites" : True,
"Games" : False,
"Limits" : False,
"LimitSep" : False,
"LimitType" : False,
"Type" : True,
"Seats" : False,
"SeatSep" : False,
"Dates" : True,
"Groups" : False,
"GroupsAll" : False,
"Button1" : True,
"Button2" : False
}
self.filters = Filters.Filters(self.db, self.conf, self.sql, display = filters_display)
self.filters.registerButton1Name("_Refresh")
self.filters.registerButton1Callback(self.refreshStats)
# ToDo: store in config
# ToDo: create popup to adjust column config
# columns to display, keys match column name returned by sql, values in tuple are:
# is column displayed, column heading, xalignment, formatting
self.columns = [ ("sid", True, "SID", 0.0, "%s")
, ("hand", False, "Hand", 0.0, "%s") # true not allowed for this line
, ("n", True, "Hds", 1.0, "%d")
, ("start", True, "Start", 1.0, "%d")
, ("end", True, "End", 1.0, "%d")
, ("hph", True, "Hands/h", 1.0, "%d")
, ("profit", True, "Profit", 1.0, "%s")
#, ("avgseats", True, "Seats", 1.0, "%3.1f")
#, ("vpip", True, "VPIP", 1.0, "%3.1f")
#, ("pfr", True, "PFR", 1.0, "%3.1f")
#, ("pf3", True, "PF3", 1.0, "%3.1f")
#, ("steals", True, "Steals", 1.0, "%3.1f")
#, ("saw_f", True, "Saw_F", 1.0, "%3.1f")
#, ("sawsd", True, "SawSD", 1.0, "%3.1f")
#, ("wtsdwsf", True, "WtSDwsF", 1.0, "%3.1f")
#, ("wmsd", True, "W$SD", 1.0, "%3.1f")
#, ("flafq", True, "FlAFq", 1.0, "%3.1f")
#, ("tuafq", True, "TuAFq", 1.0, "%3.1f")
#, ("rvafq", True, "RvAFq", 1.0, "%3.1f")
#, ("pofafq", False, "PoFAFq", 1.0, "%3.1f")
#, ("net", True, "Net($)", 1.0, "%6.2f")
#, ("bbper100", True, "BB/100", 1.0, "%4.2f")
#, ("rake", True, "Rake($)", 1.0, "%6.2f")
#, ("variance", True, "Variance", 1.0, "%5.2f")
]
self.stats_frame = None
self.stats_vbox = None
self.detailFilters = [] # the data used to enhance the sql select
#self.main_hbox = gtk.HBox(False, 0)
#self.main_hbox.show()
self.main_hbox = gtk.HPaned()
self.stats_frame = gtk.Frame()
self.stats_frame.show()
self.stats_vbox = gtk.VBox(False, 0)
self.stats_vbox.show()
self.stats_frame.add(self.stats_vbox)
# self.fillStatsFrame(self.stats_vbox)
#self.main_hbox.pack_start(self.filters.get_vbox())
#self.main_hbox.pack_start(self.stats_frame, expand=True, fill=True)
self.main_hbox.pack1(self.filters.get_vbox())
self.main_hbox.pack2(self.stats_frame)
self.main_hbox.show()
#.........这里部分代码省略.........
示例11: __init__
# 需要导入模块: from matplotlib.backends.backend_gtk import FigureCanvasGTK [as 别名]
# 或者: from matplotlib.backends.backend_gtk.FigureCanvasGTK import show [as 别名]
class BrachGUI:
def __init__(self):
self.lastUpdate = datetime.now()
self.thread = None
self.lastBest = None
self.builder = gtk.Builder()
self.builder.add_from_file(GUI_FILENAME)
# init default values (due to Glade 3.7 bug)
self.builder.get_object("input_Ax").set_value(brach.A[0])
self.builder.get_object("input_Ay").set_value(brach.A[1])
self.builder.get_object("input_Bx").set_value(brach.B[0])
self.builder.get_object("input_By").set_value(brach.B[1])
self.builder.get_object("input_population_size").set_value(brach.POPULATION_MAX)
self.builder.get_object("input_elitism").set_value(brach.ELITISM*100)
self.builder.get_object("input_points").set_value(brach.POINTS_INIT)
self.builder.get_object("input_crossover").set_value(brach.CROSSOVER*100)
self.builder.get_object("input_crossover_len").set_value(brach.CROSSOVER_LEN_MAX*100)
self.builder.get_object("input_mutation").set_value(brach.MUTATION*100)
self.builder.get_object("input_mutation_y").set_value(brach.MUTATION_Y*100)
self.builder.get_object("input_mutation_burst").set_value(brach.MUTATION_BURST*100)
# init the input_selection_type
selection_model = gtk.ListStore(str)
selection_model.append(["Tournament"])
selection_model.append(["Roulette"])
selection_box = self.builder.get_object("input_selection_type")
selection_box.set_model(selection_model)
cell = gtk.CellRendererText()
selection_box.pack_start(cell)
selection_box.add_attribute(cell,'text',0)
selection_box.set_active(0)
self.builder.get_object("button_save").set_sensitive(False)
self.running = False
# init graphs
self.fig_best = Figure(figsize=(400, 400))
self.fig_hist = Figure(figsize=(400, 200))
self.canvas_best = FigureCanvasGTK(self.fig_best)
self.canvas_hist = FigureCanvasGTK(self.fig_hist)
self.canvas_best.show()
self.canvas_hist.show()
self.hbox_best = self.builder.get_object("hbox_graph_best")
self.hbox_hist = self.builder.get_object("hbox_graph_hist")
self.hbox_best.pack_start(self.canvas_best, True, True)
self.hbox_hist.pack_start(self.canvas_hist, True, True)
# show window
self.builder.connect_signals(self)
window = self.builder.get_object('window_main')
window.set_title("Brachistochrone curve")
window.show()
def on_adjust_Ax_value_changed(self, widget, data=None):
brach.A[0] = widget.get_value()
if brach.A[0] >= brach.B[0]:
widget.set_value(brach.A[0]-0.1)
return True
def on_adjust_Ay_value_changed(self, widget, data=None):
brach.A[1] = widget.get_value()
if brach.A[1] < brach.B[1]:
widget.set_value(brach.A[1] + 0.1)
return True
def on_adjust_Bx_value_changed(self, widget, data=None):
brach.B[0] = widget.get_value()
if brach.B[0] <= brach.A[0]:
widget.set_value(brach.B[0] + 0.1)
return True
def on_adjust_By_value_changed(self, widget, data=None):
brach.A[1] = widget.get_value()
if brach.B[1] > brach.A[1]:
widget.set_value(brach.B[1] - 0.1)
return True
def on_input_population_size_value_changed(self, widget, data=None):
brach.POPULATION_MAX = widget.get_value_as_int()
return True
def on_input_elitism_value_changed(self, widget, data=None):
brach.ELITISM = widget.get_value()/100
return True
#.........这里部分代码省略.........
示例12: __init__
# 需要导入模块: from matplotlib.backends.backend_gtk import FigureCanvasGTK [as 别名]
# 或者: from matplotlib.backends.backend_gtk.FigureCanvasGTK import show [as 别名]
class appGui:
def __init__(self):
gladefile = "project2.glade"
self.windowname = "gtkbench"
self.wTree = gtk.glade.XML(gladefile, self.windowname)
self.win = self.wTree.get_widget("gtkbench")
self.win.maximize()
dic = {"on_window1_destroy" : gtk.main_quit,
"on_button1_clicked" : self.submitDB,
"on_button3_clicked" : self.fillTree,
"on_notebook1_switch_page" : self.selectNotebookPage,
"on_treeview1_button_press_event" : self.clickTree,
"on_button2_clicked" : self.createProjectGraph
}
self.wTree.signal_autoconnect(dic)
# start with database selection
self.wDialog = gtk.glade.XML("project2.glade", "dbSelector")
# setup matplotlib stuff on first notebook page (empty graph)
self.figure = Figure(figsize=(6,4), dpi=72)
self.axis = self.figure.add_subplot(111)
self.axis.set_xlabel('Yepper')
self.axis.set_ylabel('Flabber')
self.axis.set_title('An Empty Graph')
self.axis.grid(True)
self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea
self.canvas.show()
self.graphview = self.wTree.get_widget("vbox1")
self.graphview.pack_start(self.canvas, True, True)
# setup listview for database
self.listview = self.wTree.get_widget("treeview1")
self.listmodel = gtk.ListStore(str, int, int, str, str)
self.listview.set_model(self.listmodel)
renderer = gtk.CellRendererText()
column = gtk.TreeViewColumn("Name",renderer, text=0)
column.set_clickable(True)
column.set_sort_column_id(0)
column.connect("clicked", self.createDBGraph)
column.set_resizable(True)
self.listview.append_column(column)
#renderer = gtk.CellRendererText()
column = gtk.TreeViewColumn("Age",renderer, text=1)
column.set_clickable(True)
column.set_sort_column_id(1)
column.connect("clicked", self.createDBGraph)
column.set_resizable(True)
self.listview.append_column(column)
#self.listview.show()
column = gtk.TreeViewColumn("Shoesize",renderer, text=2)
column.set_clickable(True)
column.set_sort_column_id(2)
column.connect("clicked", self.createDBGraph)
column.set_resizable(True)
self.listview.append_column(column)
#self.listview.show()
column = gtk.TreeViewColumn("Created",renderer, text=3)
column.set_clickable(True)
column.set_sort_column_id(3)
column.connect("clicked", self.createDBGraph)
column.set_resizable(True)
self.listview.append_column(column)
#self.listview.show()
#renderer = gtk.CellRendererText()
column = gtk.TreeViewColumn("Updated",renderer, text=4)
column.set_clickable(True)
column.set_sort_column_id(4)
column.connect("clicked", self.createDBGraph)
column.set_resizable(True)
self.listview.append_column(column)
return
# callbacks.
def submitDB(self, widget):
while True:
try:
name = self.wTree.get_widget("entry1").get_text()
age = self.wTree.get_widget("entry2").get_text()
size = self.wTree.get_widget("entry3").get_text()
assert name != ""
assert age != ""
assert size != ""
dataUsr = name, age, size
sd = DBStuff.Eb_db(host, user, passwd, db)
sd.subMit(dataUsr)
break
except AssertionError:
self.wDialog = gtk.glade.XML("project2.glade", "dbWarningEmpty")
close = self.wDialog.get_widget("dbWarningEmpty")
#.........这里部分代码省略.........
示例13: __init__
# 需要导入模块: from matplotlib.backends.backend_gtk import FigureCanvasGTK [as 别名]
# 或者: from matplotlib.backends.backend_gtk.FigureCanvasGTK import show [as 别名]
class appgui:
def __init__(self):
self.gladefile = "attenuation_calc.glade"
windowname = "MainWindow"
self.wTree=gtk.glade.XML(self.gladefile, windowname)
dic = { "on_GetDataButton_clicked" : self.button1_clicked,
"on_SaveImageMenuItem_activate" : self.save_image,
"on_ExportMenuItem_activate" : self.save_data,
"on_MainWindow_destroy" : (gtk.main_quit) ,
"on_QuitMenuItem_activate" : (gtk.main_quit),
"on_about_menuitem_activate" : self.about }
self.wTree.signal_autoconnect(dic)
self.figure = Figure(figsize=(6,4), dpi=72)
self.axis = self.figure.add_subplot(111)
self.axis.set_xlabel('Energies')
self.axis.set_ylabel('Attenuation Length (microns)')
self.axis.set_title('Attenuation Lengths vs Energy')
self.axis.grid(True)
self.canvas = FigureCanvasGTK(self.figure)
self.canvas.show()
self.graphview = self.wTree.get_widget("vbox1")
self.graphview.pack_start(self.canvas,True,True)
#self.graphview.pack_start(self.canvas,True,True)
self.wTree.get_widget(windowname).maximize()
self.E = {}
self.attlen = {}
return
def about(self,widget):
print 'Hello World'
t = gtk.glade.XML(self.gladefile, "aboutdialog1")
about = t.get_widget("aboutdialog1")
about.run()
about.hide()
return
def button1_clicked(self,widget):
self.graphview.remove(self.canvas) # important else they just get inserted again each time (not replaced)
self.axis.cla()
eltext = self.wTree.get_widget("ElementText").get_text()
if eltext.find(',') == -1:
el = self.wTree.get_widget("ElementText").get_text().split()
else:
el = self.wTree.get_widget("ElementText").get_text().split(',')
[self.E,self.attlen] = nx.calclengths(el)
for e in self.attlen.keys():
self.axis.loglog(self.E[e],self.attlen[e],label=e);
self.axis.set_xlabel('Energy (MeV)')
self.axis.set_ylabel('Attenuation Length (cm)')
self.axis.set_title('Attenuation Lengths vs Energy')
self.axis.legend(loc='lower right')
self.axis.grid(True)
self.canvas.destroy()
self.canvas = FigureCanvasGTK(self.figure)
self.canvas.show()
self.graphview = self.wTree.get_widget("vbox1")
self.graphview.pack_end(self.canvas, True, True)
#self.graphview.pack_start(self.canvas, True, True)
#print dir(self.canvas)
def save_image(self,widget):
chooser = gtk.FileChooserDialog(title='Save File',action=gtk.FILE_CHOOSER_ACTION_SAVE,
buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK))
chooser.set_default_response(gtk.RESPONSE_OK)
response = chooser.run()
if response == gtk.RESPONSE_OK:
print chooser.get_filename()
self.figure.savefig(chooser.get_filename())
else:
print 'No files selected'
chooser.destroy()
def save_data(self,widget):
chooser = gtk.FileChooserDialog(title='Save File',action=gtk.FILE_CHOOSER_ACTION_SAVE,
buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK))
chooser.set_default_response(gtk.RESPONSE_OK)
response = chooser.run()
if response == gtk.RESPONSE_OK:
print chooser.get_filename()
filename = chooser.get_filename()
Eint = []
#.........这里部分代码省略.........
示例14: GuiGraphViewer
# 需要导入模块: from matplotlib.backends.backend_gtk import FigureCanvasGTK [as 别名]
# 或者: from matplotlib.backends.backend_gtk.FigureCanvasGTK import show [as 别名]
class GuiGraphViewer (threading.Thread):
def __init__(self, querylist, config, debug=True):
"""Constructor for GraphViewer"""
self.sql = querylist
self.conf = config
self.debug = debug
#print "start of GraphViewer constructor"
self.db = Database.Database(self.conf, sql=self.sql)
filters_display = { "Heroes" : True,
"Sites" : True,
"Games" : True,
"Limits" : True,
"LimitSep" : True,
"LimitType" : True,
"Type" : False,
"UseType" : 'ring',
"Seats" : False,
"SeatSep" : False,
"Dates" : True,
"Groups" : False,
"Button1" : True,
"Button2" : True
}
self.filters = Filters.Filters(self.db, self.conf, self.sql, display = filters_display)
self.filters.registerButton1Name("Refresh _Graph")
self.filters.registerButton1Callback(self.generateGraph)
self.filters.registerButton2Name("_Export to File")
self.filters.registerButton2Callback(self.exportGraph)
self.mainHBox = gtk.HBox(False, 0)
self.mainHBox.show()
self.leftPanelBox = self.filters.get_vbox()
self.hpane = gtk.HPaned()
self.hpane.pack1(self.leftPanelBox)
self.mainHBox.add(self.hpane)
# hierarchy: self.mainHBox / self.hpane / self.graphBox / self.canvas / self.fig / self.ax
self.graphBox = gtk.VBox(False, 0)
self.graphBox.show()
self.hpane.pack2(self.graphBox)
self.hpane.show()
self.fig = None
#self.exportButton.set_sensitive(False)
self.canvas = None
self.db.rollback()
def get_vbox(self):
"""returns the vbox of this thread"""
return self.mainHBox
#end def get_vbox
def clearGraphData(self):
try:
try:
if self.canvas:
self.graphBox.remove(self.canvas)
except:
pass
if self.fig != None:
self.fig.clear()
self.fig = Figure(figsize=(5,4), dpi=100)
if self.canvas is not None:
self.canvas.destroy()
self.canvas = FigureCanvas(self.fig) # a gtk.DrawingArea
except:
err = traceback.extract_tb(sys.exc_info()[2])[-1]
print "***Error: "+err[2]+"("+str(err[1])+"): "+str(sys.exc_info()[1])
raise
def generateGraph(self, widget, data):
try:
self.clearGraphData()
sitenos = []
playerids = []
sites = self.filters.getSites()
heroes = self.filters.getHeroes()
siteids = self.filters.getSiteIds()
limits = self.filters.getLimits()
games = self.filters.getGames()
for i in ('show', 'none'):
if i in limits:
limits.remove(i)
# Which sites are selected?
for site in sites:
if sites[site] == True:
#.........这里部分代码省略.........
示例15: __init__
# 需要导入模块: from matplotlib.backends.backend_gtk import FigureCanvasGTK [as 别名]
# 或者: from matplotlib.backends.backend_gtk.FigureCanvasGTK import show [as 别名]
class mainGUI:
#====================
#constructor
#====================
def __init__(self):
# Create main window
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.set_title("Dan's crazy gene regulation simulator")
self.window.set_border_width(2)
self.window.connect("delete_event",self.close)
#window size values
self.x_size = 640
self.y_size = 480
self.design_Window_Fraction_x = 1.0
self.design_Window_Fraction_y = 0.5
self.button_Window_Fraction_x = 0.1
self.button_Window_Fraction_y = 0.5
self.plot_Window_Fraction_x = 0.9
self.plot_Window_Fraction_y = 0.5
#divide up the window
self.main_Box = gtk.VBox(False,0)
self.window.add(self.main_Box)
#Setup circuit design area
self.setup_Design_Area(self.main_Box)
self.sub_Box = gtk.HBox(False,0)
self.main_Box.pack_start(self.sub_Box,True,True,0)
#Setup buttons
self.setup_Buttons(self.sub_Box)
self.setup_Plots(self.sub_Box)
self.sub_Box.show_all()
self.main_Box.show_all()
self.window.show_all()
#====================
#Init helpers
#====================
def setup_Design_Area(self,box):
self.design_Area = gtk.Fixed()
self.design_Area.set_size_request(int(self.design_Window_Fraction_x*self.x_size),
int(self.design_Window_Fraction_y*self.y_size))
self.design_Area.set_has_window(True)
box.pack_start(self.design_Area,True,True,0)
self.design_Area.show()
self.gene_Collection = Gene_Collection(self.design_Area)
self.design_Area.connect("button-press-event",self.create_Object,"")
def setup_Buttons(self,box):
self.button_Box = gtk.VBox(False,0)
self.button_Clear = gtk.Button("Clear")
self.button_Clear.connect("clicked",self.clear,"")
self.button_Clear.show()
self.button_Box.pack_start(self.button_Clear,True,True,0)
self.button_Go = gtk.Button("Go")
self.button_Go.connect("clicked",self.runSim,"")
self.button_Box.pack_start(self.button_Go,True,True,0)
self.button_Go.show()
self.button_Quit = gtk.Button("Quit")
self.button_Quit.connect("clicked",self.close,"")
self.button_Box.pack_start(self.button_Quit,True,True,0)
self.button_Quit.show()
self.button_Box.show()
box.add(self.button_Box)
def setup_Plots(self,box):
self.plot_Figure = Figure(figsize=(5,4), dpi=72)
self.plot = self.plot_Figure.add_subplot(111)
self.plot.plot(0,0,'-')
self.plot_Canvas = FigureCanvas(self.plot_Figure)
self.plot_Canvas.set_size_request(int(self.plot_Window_Fraction_x*self.x_size),
int(self.plot_Window_Fraction_y*self.y_size))
self.plot_Canvas.show()
box.add(self.plot_Canvas)
#====================
#Call backs
#====================
def close(self, widget, event, data=None):
gtk.main_quit()
return False
def clear(self, widget, event, data=None):
print "clear"
def runSim(self, widget, event, data=None):
print "sim"
if(self.gene_Collection.Build_Simulation()):
self.gene_Collection.Run_Simulation()
else:
#.........这里部分代码省略.........