Print

Print


(I'm circulating to the mailing list because this might be of more general
interest.)

Tim is best placed to tell you about the argServer.  But I can tell you
how to do things from the Python prompt (which is where I always play with
this kind of stuff).

At the Python prompt you have top, which is the top module widget, an
instance (the only instance) of AnalysisPopup:

  >>> top
  <ccpnmr.analysis.AnalysisPopup.AnalysisPopup instance at 0x9385abc>

From here you can navigate to everything.  If you need to get at a data
model object then top.project gives you the Project, and from there you
can get everything else:

  >>> top.project
  <memops.Implementation.Project id:154388500>

On the graphics side, every popup can also be obtained from top.  For
example, to get the graphics window popup with name "window1" you do:

  >>> top.getWindowPopup('window1')
  <ccpnmr.analysis.WindowPopup.WindowPopup instance at 0x965fd9c>

which gives an instance of WindowPopup and therefore also of WindowDraw
(WindowDraw is a superclass of WindowPopup, introduced so that PostScript,
etc., could use mostly the same drawing code as the on-screen code).

You can also get hold of the non-graphics popups using top.popups.  That
is a dictionary which includes both the graphics and non-graphics popups.
The key for a graphics popup is 'window_'+window_name and for a
non-graphics popup is defined in AnalysisPopup if you know where to look,
for example for the EditWindowPopup it is 'edit_window' (if you grep on
the popup name in AnalysisPopup.py you'll find the key).  So for example:

  >>> top.popups
  {'window_www_1': <ccpnmr.analysis.WindowPopup.WindowPopup instance at
0x9faa9a4>,
   'window_www_3': <ccpnmr.analysis.WindowPopup.WindowPopup
instance at 0x94d3994>,
   'window_www_2':
<ccpnmr.analysis.WindowPopup.WindowPopup instance at 0x9fa7054>,
   'window_www_5': <ccpnmr.analysis.WindowPopup.WindowPopup instance at
0x9398eac>,
   'window_window1': <ccpnmr.analysis.WindowPopup.WindowPopup
instance at 0x965fd9c>,
   'window_w':
<ccpnmr.analysis.WindowPopup.WindowPopup instance at 0x966c424>,
  'edit_strip': <ccpnmr.analysis.EditStripPopup.EditStripPopup instance at
0xa651fd4>,
  'window_www_4': <ccpnmr.analysis.WindowPopup.WindowPopup
instance at 0x9fb5524>,
  'new_window':
<ccpnmr.analysis.NewWindowPopup.NewWindowPopup instance at 0x97a01f4>,
  'window_window2': <ccpnmr.analysis.WindowPopup.WindowPopup instance at
0x962be44>}

In that example most of the popups are grahical ones but I also opened two
non-graphical ones.  The rule (so far) is that once a popup is created it
is not destroyed until the project is closed or you quit the program.  So
that list of top.popups gets longer and longer as you work.

  So if you do:

  >>> top.popups['new_window']
  <ccpnmr.analysis.NewWindowPopup.NewWindowPopup instance at 0x97a01f4>

you get hold of the NewWindowPopup instance.  For graphical popups I
would recommend using getWindowPopup() rather than popups (for one thing
you don't have to stick the extra 'window_' in front of the name).

One final hint.  If you have a graphical popup then you can get to the
data model object corresponding to this popup via popup.window.  This is a
ccpnmr.api.Analysis.SpectrumWindow object:

  >>> popup = top.getWindowPopup('window1')
  >>> popup
  <ccpnmr.analysis.WindowPopup.WindowPopup instance at 0x965fd9c>
  >>> popup.window
  <ccpnmr.Analysis.SpectrumWindow [1]>

Wayne

On Fri, 6 Aug 2004, Brian Smith wrote:

>
> I think I'm beginning to see the light.  Finally finding where
> SpectrumWindow was defined (ccpnmr.api.Analysis rather than
> ccpnmr.analysis.Analysis) helped.  So my question now is (I guess)?
>
> How can I navigate from a SpectrumWindow (returned by the argserver) to
> the WindowDraw class (or make WindowDraw methods/attribues work on my
> SpectrumWindow)?
>
> More generally, how does one extend an object?  RTFM is an acceptable
> answer here!
>
> Brian
>
> --
> Dr. Brian O. Smith ---------------------- B.Smith at bio.gla.ac.uk
>           Division of Biochemistry & Molecular Biology,
>               Institute Biomedical & Life Sciences,
> Joseph Black Building, University of Glasgow, Glasgow G12 8QQ, UK.
> Tel: 0141 330 5167/6459                         Fax: 0141 330 8640
>
>
>