How to use the handprint.ui.UI.instance function in handprint

To help you get started, we’ve selected a few handprint examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github caltechlibrary / handprint / handprint / ui.py View on Github external
def inform(text, *args):
    '''Print an informational message to the user.  The 'text' can contain
    string format placeholders such as "{}", and the additional arguments in
    args are values to use in those placeholders.
    '''
    ui = UI.instance()
    if not ui.use_color():
        text = unstyled(text)
        args = [unstyled(x) for x in args]
    ui.inform(text, *args)
github caltechlibrary / handprint / handprint / ui.py View on Github external
def alert_fatal(text, *args, **kwargs):
    '''Print or display a message reporting a fatal error.  The keyword
    argument 'details' can be supplied to pass a longer explanation that will
    be displayed (when a GUI is being used) if the user presses the 'Help'
    button in the dialog.

    Note that when a GUI interface is in use, this method will cause the
    GUI to exit after the user clicks the OK button, so that the calling
    application can regain control and exit.
    '''
    ui = UI.instance()
    if not ui.use_color():
        text = unstyled(text)
        args = [unstyled(x) for x in args]
    ui.alert_fatal(text, *args, **kwargs)
github caltechlibrary / handprint / handprint / ui.py View on Github external
def warn(text, *args):
    '''Warn the user that something is not right.  This should be used in
    situations where the problem is not fatal nor will prevent continued
    execution.  (For problems that prevent continued execution, use the
    alert(...) method instead.)
    '''
    ui = UI.instance()
    if not ui.use_color():
        text = unstyled(text)
        args = [unstyled(x) for x in args]
    ui.warn(text, *args)
github caltechlibrary / handprint / handprint / ui.py View on Github external
def file_selection(type, purpose, pattern = '*'):
    '''Returns the file selected by the user.  The value of 'type' should be
    'open' if the reason for the request is to open a file for reading, and
    'save' if the reason is to save a file.  The argument 'purpose' should be
    a short text string explaining to the user why they're being asked for a
    file.  The 'pattern' is a file pattern expression of the kind accepted by
    wxPython FileDialog.
    '''
    ui = UI.instance()
    return ui.file_selection(type, purpose, pattern)
github caltechlibrary / handprint / handprint / ui.py View on Github external
def alert(text, *args):
    '''Alert the user to an error.  This should be used in situations where
    there is a problem that will prevent normal execution.
    '''
    ui = UI.instance()
    if not ui.use_color():
        text = unstyled(text)
        args = [unstyled(x) for x in args]
    ui.alert(text, *args)
github caltechlibrary / handprint / handprint / ui.py View on Github external
def confirm(question):
    '''Returns True if the user replies 'yes' to the 'question'.'''
    ui = UI.instance()
    return ui.confirm(question)
github caltechlibrary / handprint / handprint / ui.py View on Github external
def login_details(prompt, user, password):
    '''Asks the user for a login name and password.  The value of 'user' and
    'password' will be used as initial values in the dialog.
    '''
    ui = UI.instance()
    return ui.login_details(prompt, user, password)