Discussion:
How to access CrossSectionTool from ImageWidget?
Carlos Pascual
2011-07-18 17:42:54 UTC
Permalink
Hi,

I ran into the following problem: I want to show cross sections on an
ImageWidget (not an ImageDialog), so I create one and then call
register_all_image_tools() on it (which gives, among others, the cross section
tool).

But, although I can show the cross section panels via the context menu, I
cannot draw the shape for calculating the cross section.
If I was using an ImageDialog I would do it using the Cross Section button in
the toolbar.

In my case, I had to subclass ImageWidget and reimplement the
get_context_menu() method like this :

++++++++++++++++++++++++++++++++++++++
class MyImageWidget(ImageWidget):
(...)
def get_context_menu(self, plot=None):
menu = ImageWidget.get_context_menu(self, plot=plot)
tool = self.get_tool(CrossSectionTool)
menu.addAction(tool.action)
return menu
++++++++++++++++++++++++++++++++++++++

(this way I do not have to modify the guiqwt code itself)

But in my opinion it would be better if the following method was added to the
CrossSectionTool in the official guiqwt release :

++++++++++++++++++++++++++++++++++++
class CrossSectionTool(RectangularShapeTool):
(...)
def setup_context_menu(self, menu, plot):
menu.addAction(self.action)
++++++++++++++++++++++++++++++++++++
--
+----------------------------------------------------+
Carlos Pascual Izarra
Scientific Software Coordinator
Computing Division
Cells / Alba Synchrotron [http:/www.cells.es]
Carretera BP 1413 de Cerdanyola-Sant Cugat, Km. 3.3
E-08290 Cerdanyola del Valles (Barcelona), Spain
E-mail: cpascual-***@public.gmane.org
Phone: +34 93 592 4428
+----------------------------------------------------+
Loading...