コード例 #1
0
ファイル: ui.py プロジェクト: choiwoo/cs419-f15-group2
def build_home_tab(parent):
    '''
    Builds "Home" tab subtree of widgets

    Parameters:
        parent (Widget): Parent widget of tab subtree

    Returns:
        Widget: Subtree of widgets
    '''
    home = Tab('Home', parent, ord('h'))
    home.resize(height = 22)

    title = Text('Title', home, style = 'title')
    title.add_raw(title_string)
    title.resize(48, 14)
    title.align('CENTER')
    title.offset(0, 3)

    translator = DatasigTranslator(home)
    translator.map_output('UI_PROMPT_CONFIRM')

    form = Form(
        translator,
        prompt = 'Are you sure you want to exit?',
        sigconfirm = signals.Signal('UI_EXIT')
    )

    translator = DatasigTranslator(form)
    translator.map_output('UI_SUBMIT')

    exit = Button('Exit', translator, ord('e'))
    exit.align('CENTER')
    exit.offset(0, 18)

    return home
コード例 #2
0
ファイル: ui.py プロジェクト: choiwoo/cs419-f15-group2
def build_database_tab(parent):
    '''
    Builds "Database" tab subtree of widgets

    Parameters:
        parent (Widget): Parent widget of tab subtree

    Returns:
        Widget: Subtree of widgets
    '''
    database = Tab('Database', parent, ord('d'))
    database.resize(height = 22)
    database_group = database.content_region

    translator = DatasigTranslator(database_group)
    translator.map_input('UI_DATABASE_LIST', databases = 'options')
    translator.map_output('DB_SET_DATABASE', option = 'database')
    translator.map_request('DB_LIST_DATABASES')

    database_list = SelectField('Database List', translator, ord('d'))
    database_list.auto_expand()
    database_list.resize(width = 30)
    database_list.align('CENTER')
    database_list.linked_label.embellish(suffix = ': ').to_center(cross = True).shift(-1)

    tab_group = database.content_region.scale(height = -3).offset(y = 3)

    import_tab = VertTab('Import', tab_group, ord('i'))
    export_tab = VertTab('Export', tab_group, ord('e'))

    import_tab_group = import_tab.content_region
    export_tab_group = export_tab.content_region

    translator = DatasigTranslator(import_tab_group)
    translator.map_output('DB_IMPORT_DATABASE')

    form = Form(
        translator,
        pathname = '', filename = '', clean = False
    )

    translator = DatasigTranslator(form)
    translator.map_output('DATASIG_OUT', text = 'pathname')

    import_path = TextField('Path', translator, ord('p'))
    import_path.scale(width = -12).offset(x = 12)
    import_path.linked_label.embellish(suffix = ': ').to_center(cross = True).shift(-1)

    translator = DatasigTranslator(form)
    translator.map_output('DATASIG_OUT', text = 'filename')

    import_file = TextField('Filename', translator, ord('f'))
    import_file.scale(width = -12).offset(12, 3)
    import_file.linked_label.embellish(suffix = ': ').to_center(cross = True).shift(-1)

    translator = DatasigTranslator(form)
    translator.map_output('DATASIG_OUT', enabled = 'clean')

    overwrite = FlipSwitch('Overwrite Existing', translator, ord('o'))
    overwrite.offset(32, 6)
    overwrite.linked_label.embellish(suffix = ': ').to_center(cross = True).shift(-1)

    translator = DatasigTranslator(form)
    translator.map_output('UI_SUBMIT')

    import_button = Button('Import', translator, ord('i'))
    import_button.offset(12, 10)

    translator = DatasigTranslator(export_tab_group)
    translator.map_output('DB_EXPORT_DATABASE')

    form = Form(
        translator,
        pathname = '', filename = '', plain = False, schema = False
    )

    translator = DatasigTranslator(form)
    translator.map_output('DATASIG_OUT', text = 'pathname')

    export_path = TextField('Path', translator, ord('p'))
    export_path.scale(width = -12).offset(x = 12)
    export_path.linked_label.embellish(suffix = ': ').to_center(cross = True).shift(-1)

    translator = DatasigTranslator(form)
    translator.map_output('DATASIG_OUT', text = 'filename')

    export_file = TextField('Filename', translator, ord('f'))
    export_file.scale(width = -12).offset(12, 3)
    export_file.linked_label.embellish(suffix = ': ').to_center(cross = True).shift(-1)

    translator = DatasigTranslator(form)
    translator.map_output('DATASIG_OUT', enabled = 'plain')

    plaintext = FlipSwitch('Plain Text', translator, ord('t'))
    plaintext.offset(24, 6)
    plaintext.linked_label.embellish(suffix = ': ').to_center(cross = True).shift(-1)

    translator = DatasigTranslator(form)
    translator.map_output('DATASIG_OUT', enabled = 'schema')

    schema_only = FlipSwitch('Schema Only', translator, ord('s'))
    schema_only.offset(50, 6)
    schema_only.linked_label.embellish(suffix = ': ').to_center(cross = True).shift(-1)

    translator = DatasigTranslator(form)
    translator.map_output('UI_SUBMIT')

    export_button = Button('Export', translator, ord('e'))
    export_button.offset(12, 10)

    return database
コード例 #3
0
ファイル: ui.py プロジェクト: choiwoo/cs419-f15-group2
def build_server_tab(parent):
    '''
    Builds "Server" tab subtree of widgets

    Parameters:
        parent (Widget): Parent widget of tab subtree

    Returns:
        Widget: Subtree of widgets
    '''
    offset = [0, 3]
    input_field_size = 30
    button_offset = 25

    server = Tab('Server', parent, ord('s'))
    server.resize(height = 22)

    translator = DatasigTranslator(server)
    translator.map_output('DB_CONNECT')

    form = Form(
        translator,
        hostname = None, port = None, username = None, password = None
    )

    translator = DatasigTranslator(form)
    translator.map_output('DATASIG_OUT', text = 'hostname')

    hostname = TextField('Host Name', translator, ord('h'))
    hostname.resize(width = input_field_size)
    hostname.align('CENTER')
    hostname.offset(*offset)
    hostname.linked_label.embellish(suffix = ': ').to_center(cross = True).shift(-1)

    translator = DatasigTranslator(form)
    translator.map_output('DATASIG_OUT', number = 'port')

    port = NumericField('Port Number', translator, ord('n'))
    port.resize(width = input_field_size)
    port.align('CENTER')
    port.move(y = 3)
    port.offset(*offset)
    port.linked_label.embellish(suffix = ': ').to_center(cross = True).shift(-1)

    translator = DatasigTranslator(form)
    translator.map_output('DATASIG_OUT', text = 'username')

    username = TextField('User Name', translator, ord('u'))
    username.resize(width = input_field_size)
    username.align('CENTER')
    username.move (y = 6)
    username.offset(*offset)
    username.linked_label.embellish(suffix = ': ').to_center(cross = True).shift(-1)

    translator = DatasigTranslator(form)
    translator.map_output('DATASIG_OUT', text = 'password')

    password = TextField('Password', translator, ord('p'))
    password.resize(width = input_field_size)
    password.align('CENTER')
    password.move (y = 9)
    password.offset(*offset)
    password.obscure()
    password.linked_label.embellish(suffix = ': ').to_center(cross = True).shift(-1)

    translator = DatasigTranslator(form)
    translator.map_output('UI_SUBMIT')

    offset[0] = button_offset
    connect = Button('Connect', translator, ord('c'))
    connect.move(y = 13)
    connect.offset(*offset)

    translator = DatasigTranslator(server)
    translator.map_output('DB_DISCONNECT')

    offset[0] += 16
    disconnect = Button('Disconnect', translator, ord('d'))
    disconnect.move(y = 13)
    disconnect.offset(*offset)

    return server