def plot(self,plot,backend_name=const.DEFAULT_BACKEND): logger.debug("Backend name is %s" % backend_name) if backend_name == 'gnuplot/x11': backend = self.project.request_backend('gnuplot/x11', plot=plot) backend.draw() return # TODO: open Gnuplot window # add_subwindow # match_subwindow # request_subwindow # evtl. schon als ToolWindow ??? # window = self.window.subwindow_match( \ # (lambda win: isinstance(win, GnuplotWindow) and \ # win.project == self.project and \ # win.plot == plot) ) # if window is None: # window = GnuplotWindow(self, project=self.project, plot=plot) # self.window.subwindow_add( window ) elif backend_name == 'matplotlib': # # as widget # widget = self.window.find_plotwidget(project=self.project,plot=plot) # if widget is None: # widget = MatplotlibWidget(self, project=self.project, plot=plot) # self.window.add_plotwidget(widget) # widget.show() # as window window = self.window.subwindow_match( \ (lambda win: isinstance(win, MatplotlibWindow) \ and win.get_project() == self.project \ and win.get_plot() == plot) ) if window is None: window = MatplotlibWindow(self, project=self.project, plot=plot) ##window.set_transient_for(self.window) self.window.subwindow_add(window) window.show() window.present() else: raise RuntimeError("Unknown backend %s" % backend_name)
def plot(self,plot,backend_name='matplotlib'): logger.debug("Backend name is %s" % backend_name) if backend_name == 'gnuplot/x11': backend = self.project.request_backend('gnuplot/x11', plot=plot) backend.draw() return # TODO: open Gnuplot window # add_subwindow # match_subwindow # request_subwindow # evtl. schon als Toolbox ??? # window = self.window.subwindow_match( \ # (lambda win: isinstance(win, GnuplotWindow) and \ # win.project == self.project and \ # win.plot == plot) ) # if window is None: # window = GnuplotWindow(self, project=self.project, plot=plot) # self.window.subwindow_add( window ) elif backend_name == 'matplotlib': # # as widget # widget = self.window.find_plotwidget(project=self.project,plot=plot) # if widget is None: # widget = MatplotlibWidget(self, project=self.project, plot=plot) # self.window.add_plotwidget(widget) # widget.show() # as window window = self.window.subwindow_match( \ (lambda win: isinstance(win, MatplotlibWindow) \ and win.get_project() == self.project \ and win.get_plot() == plot) ) if window is None: window = MatplotlibWindow(self, project=self.project, plot=plot) ##window.set_transient_for(self.window) self.window.subwindow_add(window) # TESTING # Of course, the toolbox might decide to not use the backend, # e.g. if there is an 'auto' button and it is not pressed. So I will # need to change that then. window.connect("focus-in-event", (lambda a,b: self.window.toolbox.set_backend(window.get_backend()))) window.show() window.present() else: raise RuntimeError("Unknown backend %s" % backend_name)