I am currently working on a gtk / python interface for a modeling tool. I have everything that was planned, with one exception - I canβt figure out how to draw a color panel related to the plot that I am showing. I can get a color panel to display it just fine, if I donβt paste my story into the GTK window, but as soon as I embed it, the color screen disappears.
The corresponding rendering code (inside my guyth python object) is below ( init and render_domain functions). I am trying to display a colorbar, 3 lines from the bottom of the render_domain function. The color palette works fine (my data in the grid is properly colored), the actual color panel just appears, which is the problem. Thoughts?
class AppGui(object):
def __init__(self):
gladefile = "py_FD2D.glade"
self.windowname = "main_window"
self.builder = gtk.Builder()
self.builder.add_from_file(gladefile)
self.window = self.builder.get_object(self.windowname)
dic = {
"on_main_window_destroy" : self.quit,
"on_run_simulation_button_clicked" : self.run_simulation,
"on_play_button_clicked" : self.play_animation,
"on_play_slider_value_changed" : self.slider_changed,
"on_cap_pres_yn_changed" : self.cap_pres_menu_changed,
}
self.builder.connect_signals(dic)
self.figure = matplotlib.figure.Figure(figsize=(6,4), dpi=72)
self.axis = self.figure.add_subplot(1,1,1)
self.canvas = FigureCanvas(self.figure)
self.canvas.show()
self.toolbar = NavigationToolbar(self.canvas, self.window)
self.graphview = self.builder.get_object("plot_holder")
self.graphview.pack_start(self.canvas, True, True)
self.graphview.pack_start(self.toolbar, False, False)
self.FD = gcsmt.FD2D()
self.update_all()
self.render_domain()
self.builder.get_object(self.windowname).show()
self.stop_sim = False
def render_domain(self):
self.axis.clear()
self.axis.set_xlabel('Formation Width (meters)')
self.axis.set_ylabel('Formation Thickness (meters)')
self.axis.set_title('Formation Saturation')
self.msh = matplotlib.collections.QuadMesh(self.x_cells, self.y_cells, self.verts, True)
if self.FD.HasRun()==False:
self.msh.set_array(np.zeros(self.x_cells*self.y_cells))
else:
self.msh.set_array(np.array(self.FD.GetTimestepData(0)))
self.msh.set_clim(0.0, 1.0)
self.cax = self.axis.add_collection(self.msh)
self.axis.axis([0, self.x_max, 0, self.y_top])
plt.colorbar(self.cax)
self.toolbar.show()
self.canvas.draw()
Markd source
share