Example #1
0
    def open(self, desktop=None):
        """
        Open a dialogue box (dialog) using a program appropriate to the desktop
        environment in use.

        If the optional 'desktop' parameter is specified then attempt to use
        that particular desktop environment's mechanisms to open the dialog
        instead of guessing or detecting which environment is being used.

        Suggested values for 'desktop' are "standard", "KDE", "GNOME",
        "Mac OS X", "Windows".

        The result of the dialogue interaction may be a string indicating user
        input (for Input, Password, Menu, Pulldown), a list of strings
        indicating selections of one or more items (for RadioList, CheckList),
        or a value indicating true or false (for Question, Warning, Message,
        Error).

        Where a string value may be expected but no choice is made, an empty
        string may be returned. Similarly, where a list of values is expected
        but no choice is made, an empty list may be returned.
        """

        # Decide on the desktop environment in use.

        desktop_in_use = use_desktop(desktop)

        # Get the program.

        try:
            program = self.commands[desktop_in_use]
        except KeyError:
            raise (
                OSError,
                "Desktop '%s' not supported (no known dialogue box command could be suggested)"
                % desktop_in_use)

        # The handler is one of the functions communicating with the subprocess.
        # Some handlers return boolean values, others strings.

        handler, options = self.info[program]

        cmd = [program]
        for option in options:
            if isinstance(option, str):
                cmd.append(option)
            else:
                value = getattr(self, option.name, None)
                cmd += option.convert(value, program)

        return handler(cmd, 0)
Example #2
0
def root(desktop=None):
    """
    Return the root window for the current desktop. If the optional 'desktop'
    parameter is specified then attempt to use that particular desktop
    environment's mechanisms to look for windows.
    """

    # NOTE: The desktop parameter is currently ignored and X11 is tested for
    # NOTE: directly.

    if _is_x11():
        return Window(None)
    else:
        raise OSError, "Desktop '%s' not supported" % use_desktop(desktop)
Example #3
0
    def open(self, desktop=None):

        """
        Open a dialogue box (dialog) using a program appropriate to the desktop
        environment in use.

        If the optional 'desktop' parameter is specified then attempt to use
        that particular desktop environment's mechanisms to open the dialog
        instead of guessing or detecting which environment is being used.

        Suggested values for 'desktop' are "standard", "KDE", "GNOME",
        "Mac OS X", "Windows".

        The result of the dialogue interaction may be a string indicating user
        input (for Input, Password, Menu, Pulldown), a list of strings
        indicating selections of one or more items (for RadioList, CheckList),
        or a value indicating true or false (for Question, Warning, Message,
        Error).

        Where a string value may be expected but no choice is made, an empty
        string may be returned. Similarly, where a list of values is expected
        but no choice is made, an empty list may be returned.
        """

        # Decide on the desktop environment in use.

        desktop_in_use = use_desktop(desktop)

        # Get the program.

        try:
            program = self.commands[desktop_in_use]
        except KeyError:
            raise(OSError, "Desktop '%s' not supported (no known dialogue box command could be suggested)" % desktop_in_use)

        # The handler is one of the functions communicating with the subprocess.
        # Some handlers return boolean values, others strings.

        handler, options = self.info[program]

        cmd = [program]
        for option in options:
            if isinstance(option, str):
                cmd.append(option)
            else:
                value = getattr(self, option.name, None)
                cmd += option.convert(value, program)

        return handler(cmd, 0)
def root(desktop=None):

    """
    Return the root window for the current desktop. If the optional 'desktop'
    parameter is specified then attempt to use that particular desktop
    environment's mechanisms to look for windows.
    """

    # NOTE: The desktop parameter is currently ignored and X11 is tested for
    # NOTE: directly.

    if _is_x11():
        return Window(None)
    else:
        raise OSError, "Desktop '%s' not supported" % use_desktop(desktop)
Example #5
0
 def open(self, desktop=None):
     desktop_in_use = use_desktop(desktop)
     try:
         program = self.commands[desktop_in_use]
     except KeyError:
         raise OSError("Desktop '%s' not supported (no known dialogue box command could be suggested)" % desktop_in_use)
     handler, options = self.info[program]
     cmd = [program]
     for option in options:
         if isinstance(option, str):
             cmd.append(option)
         else:
             value = getattr(self, option.name, None)
             cmd += option.convert(value, program)
     return handler(cmd, 0)
Example #6
0
def list(desktop=None):
    """
    Return a list of windows for the current desktop. If the optional 'desktop'
    parameter is specified then attempt to use that particular desktop
    environment's mechanisms to look for windows.
    """

    # NOTE: The desktop parameter is currently ignored and X11 is tested for
    # NOTE: directly.

    if _is_x11():
        s = _readfrom(_get_x11_vars() + "xlsclients -a -l", shell=1)
        prefix = "Window "
        prefix_end = len(prefix)
        handles = []

        for line in s.split("\n"):
            if line.startswith(prefix):
                handles.append(line[prefix_end:-1])  # NOTE: Assume ":" at end.
    else:
        raise OSError, "Desktop '%s' not supported" % use_desktop(desktop)

    return [Window(handle) for handle in handles]
Example #7
0
def list(desktop=None):

    """
    Return a list of windows for the current desktop. If the optional 'desktop'
    parameter is specified then attempt to use that particular desktop
    environment's mechanisms to look for windows.
    """

    # NOTE: The desktop parameter is currently ignored and X11 is tested for
    # NOTE: directly.

    if _is_x11():
        s = _readfrom(_get_x11_vars() + "xlsclients -a -l", shell=1)
        prefix = "Window "
        prefix_end = len(prefix)
        handles = []

        for line in s.split("\n"):
            if line.startswith(prefix):
                handles.append(line[prefix_end:-1]) # NOTE: Assume ":" at end.
    else:
        raise OSError, "Desktop '%s' not supported" % use_desktop(desktop)

    return [Window(handle) for handle in handles]
Example #8
0
def root(desktop=None):
    if _is_x11():
        return Window(None)
    else:
        raise OSError("Desktop '%s' not supported" % use_desktop(desktop))