From 7008603df84f0ba868c14151939eae986cd1def0 Mon Sep 17 00:00:00 2001 From: Simon Poirier Date: Sun, 06 Dec 2009 22:56:25 +0000 Subject: inspect widgets through probe --- (limited to 'tutorius/propwidgets.py') diff --git a/tutorius/propwidgets.py b/tutorius/propwidgets.py index 7e78ba4..eb756fe 100644 --- a/tutorius/propwidgets.py +++ b/tutorius/propwidgets.py @@ -192,18 +192,22 @@ class PropWidget(object): Base Class for property editing widgets. Subclasses should implement create_widget, run_dialog and refresh_widget """ - def __init__(self, parent, edit_object, prop_name, changed_callback=None): + def __init__(self, parent, edit_object, prop_name, changed_callback=None, + probe_mgr=None): """Constructor @param parent parent widget @param edit_object TPropContainer being edited @param prop_name name of property being edited @param changed_callback optional callable to call on value changes + @type probe_mgr: ProbeMgr instance or None + @param probe_mgr: the probe manager to use to inspect activities """ self._parent = parent self._edit_object = edit_object self._propname = prop_name self._widget = None self._changed_cb = changed_callback + self._probe_mgr = probe_mgr ############################################################ # Begin Properties @@ -254,13 +258,14 @@ class PropWidget(object): return widget @classmethod - def run_dialog(cls, parent, obj_prop, propname): + def run_dialog(cls, parent, obj_prop, propname, probe_mgr=None): """ Class Method. Prompts the user for changing an object's property @param parent widget @param obj_prop TPropContainer to edit @param propname name of property to edit + @param probe_mgr a ProbeMgr instance for activity inspection """ raise NotImplementedError() @@ -318,13 +323,14 @@ class StringPropWidget(PropWidget): self.widget.get_buffer().set_text(str(self.obj_prop)) #unicode() ? @classmethod - def run_dialog(cls, parent, obj_prop, propname): + def run_dialog(cls, parent, obj_prop, propname, probe_mgr=None): """ Class Method. Prompts the user for changing an object's property @param parent widget @param obj_prop TPropContainer to edit @param propname name of property to edit + @param probe_mgr a ProbeMgr instance for activity inspection """ dlg = TextInputDialog(parent, text="Mandatory property", @@ -380,8 +386,8 @@ class UAMPropWidget(PropWidget): """Allows editing an UAM property with a widget chooser""" def _show_uam_chooser(self, widget): """show the UAM chooser""" - selector = WidgetSelector(self.parent) - self.obj_prop = selector.select() + evt = self._probe_mgr.create_event('FetchWidget') + self.obj_prop = evt.widaddr self.notify() def create_widget(self, init_value=None): @@ -401,17 +407,24 @@ class UAMPropWidget(PropWidget): self.widget.set_label(self.obj_prop) @classmethod - def run_dialog(cls, parent, obj_prop, propname): + def run_dialog(cls, parent, obj_prop, propname, probe_mgr=None): """ Class Method. Prompts the user for changing an object's property @param parent widget @param obj_prop TPropContainer to edit @param propname name of property to edit - """ - selector = WidgetSelector(parent) - value = selector.select() - setattr(obj_prop, propname, selector.select()) + @param probe_mgr a ProbeMgr instance for activity inspection + """ + if probe_mgr: + evt = probe_mgr.create_event('FetchWidget') + setattr(obj_prop, propname, evt.widaddr) + elif parent: + selector = WidgetSelector(parent) + value = selector.select() + setattr(obj_prop, propname, selector.select()) + else: + raise RuntimeError('No parent or probe_mgr passed for inspection.') class EventTypePropWidget(PropWidget): """Allows editing an EventType property""" @@ -422,13 +435,14 @@ class EventTypePropWidget(PropWidget): self.widget.set_text(str(self.obj_prop)) @classmethod - def run_dialog(cls, parent, obj_prop, propname): + def run_dialog(cls, parent, obj_prop, propname, probe_mgr=None): """ Class Method. Prompts the user for changing an object's property @param parent widget @param obj_prop TPropContainer to edit @param propname name of property to edit + @param probe_mgr a ProbeMgr instance for activity inspection """ try: dlg = SignalInputDialog(parent, @@ -478,12 +492,13 @@ class IntArrayPropWidget(PropWidget): children[i].set_text(str(value[i])) @classmethod - def run_dialog(cls, parent, obj_prop, propname): + def run_dialog(cls, parent, obj_prop, propname, probe_mgr=None): """ Class Method. Prompts the user for changing an object's property @param parent widget @param obj_prop TPropContainer to edit @param propname name of property to edit + @param probe_mgr a ProbeMgr instance for activity inspection """ pass -- cgit v0.9.1