示例#1
0
    def parse_one(self, toplevel, gobj):
        WidgetIntrospecter.parse_one(self, toplevel, gobj)

        # mark the object as "listened" to ensure we'll always
        # receive unique objects
        if gobj in self._listened_objects:
            return
        self._listened_objects.append(gobj)

        for object_type, event_types in self._event_types.items():
            if not isinstance(gobj, object_type):
                continue

            for event_type in event_types:
                # These 3 hacks should move into the event class itself
                if event_type == MenuItemActivateEvent:
                    if not isinstance(gobj.get_parent(), gtk.MenuBar):
                        continue
                elif event_type == ToolButtonReleaseEvent:
                    if not isinstance(gobj.get_parent(), gtk.ToolButton):
                        continue
                elif event_type == ButtonClickedEvent:
                    if isinstance(gobj.get_parent(), gtk.ToolButton):
                        continue
                if issubclass(event_type, SignalEvent):
                    self._listen_event(gobj, event_type)
示例#2
0
    def parse_one(self, toplevel, gobj):
        WidgetIntrospecter.parse_one(self, toplevel, gobj)

        # mark the object as "listened" to ensure we'll always
        # receive unique objects
        if gobj in self._listened_objects:
            return
        self._listened_objects.append(gobj)

        for object_type, event_types in self._event_types.items():
            if not isinstance(gobj, object_type):
                continue

            for event_type in event_types:
                # These 3 hacks should move into the event class itself
                if event_type == MenuItemActivateEvent:
                    if not isinstance(gobj.get_parent(), gtk.MenuBar):
                        continue
                elif event_type == ToolButtonReleaseEvent:
                    if not isinstance(gobj.get_parent(), gtk.ToolButton):
                        continue
                elif event_type == ButtonClickedEvent:
                    if isinstance(gobj.get_parent(), gtk.ToolButton):
                        continue
                if issubclass(event_type, SignalEvent):
                    self._listen_event(gobj, event_type)
示例#3
0
    def __init__(self, filename):
        """
        Create a new Recorder object.
        :param filename: name of the script
        """
        WidgetIntrospecter.__init__(self)
        self.register_event_handler()
        self.connect('window-removed', self.window_removed)

        self._filename = filename
        self._events = []
        self._listened_objects = []
        self._event_types = self._configure_event_types()
        self._args = None

        # This is sort of a hack, but there are no other realiable ways
        # of actually having something executed after the application
        # is finished
        atexit.register(self.save)

        # Register a hook that is called before normal delete-events
        # because if it's connected using a normal callback it will not
        # be called if the application returns True in it's signal handler.
        if add_emission_hook:
            add_emission_hook(gtk.Window, 'delete-event',
                              self._emission_window__delete_event)
示例#4
0
    def __init__(self, filename):
        """
        Create a new Recorder object.
        :param filename: name of the script
        """
        WidgetIntrospecter.__init__(self)
        self.register_event_handler()
        self.connect('window-removed', self.window_removed)

        self._filename = filename
        self._events = []
        self._listened_objects = []
        self._event_types = self._configure_event_types()
        self._args = None

        # This is sort of a hack, but there are no other realiable ways
        # of actually having something executed after the application
        # is finished
        atexit.register(self.save)

        # Register a hook that is called before normal delete-events
        # because if it's connected using a normal callback it will not
        # be called if the application returns True in it's signal handler.
        if add_emission_hook:
            add_emission_hook(gtk.Window, 'delete-event',
                              self._emission_window__delete_event)
示例#5
0
    def __init__(self, filename):
        self.parser = doctest.DocTestParser()
        self.retval = 0

        self._filename = filename
        self._default_duration = 0.01
        self._prompt = False
        self._interact = False
        self._pos = 0
        self._windows = {}
        self._ns = {}
        self._source_id = -1
        self._stmts = self.parser.get_examples(open(filename).read())
        self._checker = doctest.OutputChecker()
        # Create a fake output target for capturing doctest output.
        self._fakeout = _SpoofOut()
        self._stdout = sys.stdout
        self._options = (doctest.ELLIPSIS | doctest.REPORT_ONLY_FIRST_FAILURE
                         | doctest.REPORT_UDIFF)

        self._updateFile = False

        self._caughtExceptions = []  # list of (exception,traceback) pairs

        wi = WidgetIntrospecter()
        wi.register_event_handler()
        wi.connect('window-added', self._on_wi__window_added)
        wi.connect('window-removed', self._on_wi__window_removed)
示例#6
0
文件: runner.py 项目: vmware/weasel
    def __init__(self, filename):
        self.parser = doctest.DocTestParser()
        self.retval = 0

        self._filename = filename
        self._default_duration = 0.01
        self._prompt = False
        self._interact = False
        self._pos = 0
        self._windows = {}
        self._ns = {}
        self._source_id = -1
        self._stmts = self.parser.get_examples(open(filename).read())
        self._checker = doctest.OutputChecker()
        # Create a fake output target for capturing doctest output.
        self._fakeout = _SpoofOut()
        self._stdout = sys.stdout
        self._options = (doctest.ELLIPSIS |
                         doctest.REPORT_ONLY_FIRST_FAILURE |
                         doctest.REPORT_UDIFF)

        self._updateFile = False

        self._caughtExceptions = [] # list of (exception,traceback) pairs

        wi = WidgetIntrospecter()
        wi.register_event_handler()
        wi.connect('window-added', self._on_wi__window_added)
        wi.connect('window-removed', self._on_wi__window_removed)
示例#7
0
    def __init__(self, filename):
        self.parser = doctest.DocTestParser()
        self.retval = 0

        self._filename = filename
        self._pos = 0
        self._windows = {}
        self._ns = {}
        self._source_id = -1
        self._stmts = self.parser.get_examples(open(filename).read())
        self._checker = doctest.OutputChecker()
        # Create a fake output target for capturing doctest output.
        self._fakeout = _SpoofOut()
        self._options = doctest.ELLIPSIS | doctest.REPORT_ONLY_FIRST_FAILURE

        wi = WidgetIntrospecter()
        wi.register_event_handler()
        wi.connect('window-added', self._on_wi__window_added)
        wi.connect('window-removed', self._on_wi__window_removed)
示例#8
0
    def __init__(self, filename):
        self.parser = doctest.DocTestParser()
        self.retval = 0

        self._filename = filename
        self._pos = 0
        self._windows = {}
        self._ns = {}
        self._source_id = -1
        self._stmts = self.parser.get_examples(open(filename).read())
        self._checker = doctest.OutputChecker()
        # Create a fake output target for capturing doctest output.
        self._fakeout = _SpoofOut()
        self._options = doctest.ELLIPSIS | doctest.REPORT_ONLY_FIRST_FAILURE

        wi = WidgetIntrospecter()
        wi.register_event_handler()
        wi.connect('window-added', self._on_wi__window_added)
        wi.connect('window-removed', self._on_wi__window_removed)