Пример #1
0
    def run(self, funcs):
        UISequencer.funcs = funcs
        aliases = {
            'run%d' % i: Code(UISequencer.runner)
            for i in range(0, len(UISequencer.funcs))
        }

        sequence = {
            'run%d' % i: {
                Symbol('abort'):
                Symbol('abort'),
                Symbol('next'):
                'run%d' % (i + 1) if
                (i + 1) < len(UISequencer.funcs) else Symbol('abort')
            }
            for i in range(0, len(UISequencer.funcs))
        }
        sequence['ws_start'] = 'run0'

        Wizard.CreateDialog()

        ret = Sequencer.Run(aliases, sequence)

        UI.CloseDialog()
        return ret
Пример #2
0
def Tree(label, items, ID=None, opts=[]):
    """Scrollable tree selection

    Synopsis
    Tree ( string label );

    Parameters
    string label

    Options
    immediate  make `notify trigger immediately when the selected item changes

    Optional Arguments
    itemList items  the items contained in the tree

    """
    from ycp import Tree, 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)
        result.append(items)
        result = tuple(result)

        return Tree(*result)
    except Exception as e:
        traceback.print_exc()
        sys.exit(1)
Пример #3
0
def BusyIndicator(label, timeout=None, ID=None, opts=[]):
    """Graphical busy indicator

    Synopsis
    BusyIndicator ( string label, integer timeout );

    Parameters
    string label  the label describing the bar

    Optional Arguments
    integer timeout  the timeout in milliseconds until busy indicator changes to stalled state, 1000ms by default

    """
    from ycp import BusyIndicator, 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)
        if timeout:
            result.append(timeout)
        result = tuple(result)

        return BusyIndicator(*result)
    except Exception as e:
        traceback.print_exc()
        sys.exit(1)
Пример #4
0
def RichText(text, ID=None, opts=[]):
    """Static text with HTML-like formatting

    Synopsis
    RichText ( string text );

    Parameters
    string text

    Options
    plainText  don't interpret text as HTML
    autoScrollDown  automatically scroll down for each text change
    shrinkable  make the widget very small

    """
    from ycp import RichText, 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(text)
        result = tuple(result)

        return RichText(*result)
    except Exception as e:
        traceback.print_exc()
        sys.exit(1)
Пример #5
0
def ReplacePoint(child, ID=None, opts=[]):
    """Pseudo widget to replace parts of a dialog

    Synopsis
    ReplacePoint ( term child );

    Parameters
    term child  the child widget
    """
    from ycp import ReplacePoint, Term, Symbol
    ycp.widget_names()

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

        return ReplacePoint(*result)
    except Exception as e:
        traceback.print_exc()
        sys.exit(1)
Пример #6
0
def ButtonBox(buttons, ID=None, opts=[]):
    """Layout for push buttons that takes button order into account

    Synopsis
    ButtonBox ( term button1, term button2 );

    Parameters
    term buttons  list of PushButton items

    """
    from ycp import ButtonBox, 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.extend(buttons)
        result = tuple(result)

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

    Synopsis
    Top ( term child, string pixmap );

    Parameters
    term child  The contained child widget

    Optional Arguments
    background pixmap

    """
    from ycp import Top, 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 Top(*result)
    except Exception as e:
        traceback.print_exc()
        sys.exit(1)
Пример #8
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)
Пример #9
0
def Password(label, defaulttext=None, ID=None, opts=[]):
    """Input field

    Synopsis
    Password ( string label, string defaulttext );

    Parameters
    string label  the label describing the meaning of the entry

    Options
    shrinkable  make the input field very small

    Optional Arguments
    string defaulttext  The text contained in the text entry

    """
    from ycp import Password, 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)
        if defaulttext is not None:
            result.append(defaulttext)
        result = tuple(result)

        return Password(*result)
    except Exception as e:
        traceback.print_exc()
        sys.exit(1)
Пример #10
0
def Heading(label, ID=None, opts=[]):
    """Simple static text

    Synopsis
    Heading ( string label );

    Parameters
    string label

    Options
    outputField  make the label look like an input field in read-only mode
    boldFont  use a bold font

    """
    from ycp import Heading, 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)
        result = tuple(result)

        return Heading(*result)
    except Exception as e:
        traceback.print_exc()
        sys.exit(1)
Пример #11
0
def IntField(ID=None, opts=[]):
    """

    Synopsis
    IntField (  );

    Parameters

    """
    from ycp import IntField, 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 IntField(*result)
    except Exception as e:
        traceback.print_exc()
        sys.exit(1)
Пример #12
0
def Frame(label, child, ID=None, opts=[]):
    """Frame with label

    Synopsis
    Frame ( string label, term child );

    Parameters
    string label  title to be displayed on the top left edge
    term child  the contained child widget

    """
    from ycp import Frame, 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)
        result.append(child)
        result = tuple(result)

        return Frame(*result)
    except Exception as e:
        traceback.print_exc()
        sys.exit(1)
Пример #13
0
def DumbTab(tabs, contents, ID=None, opts=[]):
    """Simplistic tab widget that behaves like push buttons

    Synopsis
    DumbTab ( list tabs , term contents );

    Parameters
    list tabs  page headers
    term contents  page contents - usually a ReplacePoint
    """
    from ycp import DumbTab, Term, Symbol
    ycp.widget_names()

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

        return DumbTab(*result)
    except Exception as e:
        traceback.print_exc()
        sys.exit(1)
Пример #14
0
def PushButton(label, ID=None, opts=[]):
    """Perform action on click

    Synopsis
    PushButton ( string label );

    Parameters
    string label

    Options
    default  makes this button the dialogs default button
    helpButton  automatically shows topmost `HelpText
    okButton  assign the [OK] role to this button (see ButtonBox)
    cancelButton  assign the [Cancel] role to this button (see ButtonBox)
    applyButton  assign the [Apply] role to this button (see ButtonBox)
    customButton  override any other button role assigned to this button

    """
    from ycp import PushButton, 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)
        result = tuple(result)

        return PushButton(*result)
    except Exception as e:
        traceback.print_exc()
        sys.exit(1)
Пример #15
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)
Пример #16
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)
Пример #17
0
 def HasSpecialWidget(symbol):
     return UI.HasSpecialWidget(Symbol(symbol))
Пример #18
0
 def QueryWidget(ID, symbol):
     return UI.QueryWidget(Term('id', ID), Symbol(symbol))