Пример #1
0
def PackageSelector(ID=None, opts=[]):
    """

    Synopsis
    PackageSelector (  );

    Parameters

    """
    from ycp import PackageSelector, Term, Symbol
    ycp.widget_names()

    try:
        result = []
        if ID is not None:
            result.append(Term('id', ID))
        if opts is not None:
            for opt in opts:
                result.append(Term('opt', Symbol(opt)))
        result = tuple(result)

        return PackageSelector(*result)
    except Exception as e:
        traceback.print_exc()
        sys.exit(1)
Пример #2
0
def BarGraph(values, labels, ID=None, opts=[]):
    """Horizontal bar graph (optional widget)

    Synopsis
    BarGraph ( list values, list labels );

    Parameters
    list values

    Optional Arguments
    list labels
    """
    from ycp import BarGraph, Term, Symbol
    ycp.widget_names()

    try:
        result = []
        if ID is not None:
            result.append(Term('id', ID))
        if opts is not None:
            for opt in opts:
                result.append(Term('opt', Symbol(opt)))
        result.append(values)
        result.append(labels)
        result = tuple(result)

        return BarGraph(*result)
    except Exception as e:
        traceback.print_exc()
        sys.exit(1)
Пример #3
0
def HVCenter(child, pixmap=None, ID=None, opts=[]):
    """Layout alignment

    Synopsis
    HVCenter ( term child, string pixmap );

    Parameters
    term child  The contained child widget

    Optional Arguments
    background pixmap

    """
    from ycp import HVCenter, Term, Symbol
    ycp.widget_names()

    try:
        result = []
        if ID is not None:
            result.append(Term('id', ID))
        if opts is not None:
            for opt in opts:
                result.append(Term('opt', Symbol(opt)))
        result.append(child)
        if pixmap is not None:
            result.append(Term('BackgroundPixmap', pixmap))
        result = tuple(result)

        return HVCenter(*result)
    except Exception as e:
        traceback.print_exc()
        sys.exit(1)
Пример #4
0
def Node(label, expanded=False, children=[], ID=None):
    from ycp import Term
    ycp.widget_names()

    try:
        result = []
        if ID is not None:
            result.append(Term('id', ID))
        result.append(label)
        result.append(expanded)
        result.append(children)
        result = tuple(result)

        return Term('item', *result)
    except Exception as e:
        traceback.print_exc()
        sys.exit(1)
Пример #5
0
def ComboBox(label, items=[], ID=None, opts=[]):
    """drop-down list selection (optionally editable)

    Synopsis
    ComboBox ( string label, list items );

    Parameters
    string label

    Options
    editable  the user can enter any value.

    Optional Arguments
    list items  the items contained in the combo box

    """
    from ycp import ComboBox, Term, Symbol
    ycp.widget_names()

    try:
        result = []
        if ID is not None:
            result.append(Term('id', ID))
        if opts is not None:
            for opt in opts:
                result.append(Term('opt', Symbol(opt)))
        result.append(label)
        options = []
        for item in items:
            if type(item) is tuple:
                options.append(Term('item', *item))
            else:
                options.append(item)
        result.append(options)
        result = tuple(result)

        return ComboBox(*result)
    except Exception as e:
        traceback.print_exc()
        sys.exit(1)
Пример #6
0
def Empty():
    """

    Synopsis
    Empty (  );

    Parameters

    """
    from ycp import Term
    ycp.widget_names()

    try:
        return Term('Empty')
    except Exception as e:
        traceback.print_exc()
        sys.exit(1)
Пример #7
0
def Table(header, items=[], ID=None, opts=[]):
    """Multicolumn table widget

    Synopsis
    Table ( term header, list items );

    Parameters
    term header  the headers of the columns

    Optional Arguments
    list items  the items contained in the selection box

    """
    from ycp import Table, Term, Symbol
    ycp.widget_names()

    try:
        result = []
        if ID is not None:
            result.append(Term('id', ID))
        if opts is not None:
            for opt in opts:
                result.append(Term('opt', Symbol(opt)))
        header = tuple(header)
        result.append(Term('header', *header))
        contents = []
        for item in items:
            if type(item) is list:
                contents.append(Term('item', Term('id', item[0]), *(item[1])))
            else:
                contents.append(Term('item', *item))
        result.append(contents)
        result = tuple(result)

        return Table(*result)
    except Exception as e:
        traceback.print_exc()
        sys.exit(1)
Пример #8
0
 def SetFocus(ID):
     UI.SetFocus(Term('id', ID))
Пример #9
0
 def ReplaceWidget(ID, contents):
     UI.ReplaceWidget(Term('id', ID), contents)
Пример #10
0
 def QueryWidget(ID, symbol):
     return UI.QueryWidget(Term('id', ID), Symbol(symbol))