Example #1
0
def create_configuration_ui(main_switcher):
    """Creates ConfigureWidget UI."""

    def create_toolbar_container(name, show_tabs=False, width=82, height=480):
        """Creates toolbar container."""

        container = gtk.Notebook()
        container.set_show_tabs(show_tabs)
        container.set_size_request(width, height)
        container.set_name(name)
        return container

    toplevel_table = gtk.Table(rows=1, columns=2)
    toolbar_container = create_toolbar_container('toolbar_container')
    toolbar_table = gtk.Table(rows=5, columns=1, homogeneous=True)
    general_settings_button = widgets.create_radio_button(None, \
        'config_toolbar_general_settings_button', None, width=80, height=80)
    skin_settings_button = widgets.create_radio_button(general_settings_button,
        'config_toolbar_skin_settings_button', None, width=80, height=80)
    tts_settings_button = widgets.create_radio_button(general_settings_button,
        'config_toolbar_tts_settings_button', None, width=80, height=80)
    menu_button = widgets.create_button('main_menu_button', None)
    mode_settings_switcher = gtk.Notebook()
    mode_settings_switcher.set_show_tabs(False)
    mode_settings_switcher.set_show_border(False)
    mode_settings_switcher.set_name('config_mode_settings_switcher')
    general_settings_table = gtk.Table(rows=2, columns=1, homogeneous=True)
    general_settings_table.set_row_spacings(10)
    directories_table = gtk.Table(rows=2, columns=1, homogeneous=True)
    directories_table.set_row_spacings(12)
    sounddir_box = gtk.VBox()
    sounddir_box.set_spacing(1)
    sounddir_label_container = gtk.HBox()
    sounddir_label = gtk.Label('  Sound directory:')
    sounddir_label.set_name('white_label')
    sounddir_container = gtk.Frame()
    sounddir_container.set_name('html_container')
    sounddir_entry = gtk.Entry()
    sounddir_entry.set_name('entry_widget')
    imagedir_box = gtk.VBox()
    imagedir_box.set_spacing(1)
    imagedir_label_container = gtk.HBox()
    imagedir_label = gtk.Label('  Image directory:')
    imagedir_label.set_name('white_label')
    imagedir_container = gtk.Frame()
    imagedir_container.set_name('html_container')
    imagedir_entry = gtk.Entry()
    imagedir_entry.set_name('entry_widget')
    checkboxes_box = gtk.VBox(homogeneous=True)
    checkboxes_box.set_spacing(12)
    fullscreen_table = gtk.Table(rows=1, columns=2)
    fullscreen_table.set_col_spacings(10)
    fullscreen_checkbox = gtk.ToggleButton()
    fullscreen_checkbox.set_size_request(64, 64)
    fullscreen_checkbox.set_name('config_checkbox')
    fullscreen_label = gtk.Label('Start in Fullscreen mode')
    fullscreen_label.set_name('white_label')
    start_with_review_table = gtk.Table(rows=1, columns=2)
    start_with_review_table.set_col_spacings(10)
    start_with_review_checkbox = gtk.ToggleButton()
    start_with_review_checkbox.set_size_request(64, 64)
    start_with_review_checkbox.set_name('config_checkbox')
    start_with_review_label = gtk.Label('Open Review mode at startup')
    start_with_review_label.set_name('white_label')
    skin_settings_table = gtk.Table(rows=1, columns=1)
    font_size_table = gtk.Table(rows=1, columns=3)
    font_size_example_container = gtk.Frame()
    font_size_example_container.set_size_request(-1, 140)
    font_size_example_container.set_name('html_container')
    font_size = widgets.create_gtkhtml()
    font_size_decrease_button = widgets.create_button('down_arrow', None,
        width=64, height=64)
    font_size_increase_button = widgets.create_button('up_arrow', None, 
        width=64, height=64)
    tts_settings_table = gtk.Table(rows=2, columns=1, homogeneous=True)
    tts_settings_table1 = gtk.Table(rows=2, columns=1, homogeneous=True)
    tts_settings_table1.set_row_spacings(10)
    tts_lang_table = gtk.Table(rows=1, columns=3)
    tts_lang_container = widgets.create_button('labels_container', 
        width=-1, height=60)
    tts_lang_label = gtk.Label('default')
    tts_lang_label.set_name('config_tts_label')
    tts_lang_prev_button = widgets.create_button('main_menu_button', None)
    tts_lang_next_button = widgets.create_button('right_arrow', None)
    tts_voice_table = gtk.Table(rows=1, columns=3)
    tts_voice_container = widgets.create_button('labels_container', 
        width=-1, height=60)
    tts_voice_label = gtk.Label('Male')
    tts_voice_label.set_name('config_tts_label')
    tts_voice_prev_button = widgets.create_button('main_menu_button', \
        None)
    tts_voice_next_button = widgets.create_button('right_arrow', None)
    tts_settings_table2 = gtk.Table(rows=2, columns=1, homogeneous=True)
    tts_settings_table2.set_row_spacings(10)
    tts_speed_box = gtk.VBox()
    tts_speed_box.set_spacing(10)
    tts_speed_label_box = gtk.HBox()
    tts_speed_label = gtk.Label('Speed:')
    tts_speed_label.set_name('config_scrollbar_label')
    tts_speed_scrollbar = gtk.HScrollbar()
    tts_speed_scrollbar.set_adjustment(gtk.Adjustment(lower=30, upper=200))
    tts_speed_scrollbar.set_increments(step=1, page=10)
    tts_speed_scrollbar.set_update_policy(gtk.UPDATE_CONTINUOUS)
    tts_speed_scrollbar.set_name('config_scrollbar')
    tts_pitch_box = gtk.VBox()
    tts_pitch_box.set_spacing(10)
    tts_pitch_label_box = gtk.HBox()
    tts_pitch_label = gtk.Label('Pitch:')
    tts_pitch_label.set_name('config_scrollbar_label')
    tts_pitch_scrollbar = gtk.HScrollbar()
    tts_pitch_scrollbar.set_update_policy(gtk.UPDATE_CONTINUOUS)
    tts_pitch_scrollbar.set_adjustment(gtk.Adjustment(lower=0, upper=100))
    tts_pitch_scrollbar.set_increments(step=1, page=10)
    tts_pitch_scrollbar.set_name('config_scrollbar')
    # packing widgets
    toolbar_table.attach(general_settings_button, 0, 1, 0, 1, \
        xoptions=gtk.SHRINK, yoptions=gtk.EXPAND)
    toolbar_table.attach(skin_settings_button, 0, 1, 1, 2, \
        xoptions=gtk.SHRINK, yoptions=gtk.EXPAND)
    toolbar_table.attach(tts_settings_button, 0, 1, 2, 3, \
        xoptions=gtk.SHRINK, yoptions=gtk.EXPAND)
    toolbar_table.attach(menu_button, 0, 1, 4, 5, \
        xoptions=gtk.SHRINK, yoptions=gtk.EXPAND)
    toolbar_container.add(toolbar_table)
    toplevel_table.attach(toolbar_container, 0, 1, 0, 1, \
        xoptions=gtk.SHRINK, yoptions=gtk.SHRINK|gtk.EXPAND|gtk.FILL)
    imagedir_container.add(imagedir_entry)
    imagedir_label_container.pack_start(imagedir_label, expand=False, 
        fill=False)
    imagedir_box.pack_start(imagedir_label_container)
    imagedir_box.pack_end(imagedir_container)
    sounddir_container.add(sounddir_entry)
    sounddir_label_container.pack_start(sounddir_label, expand=False, \
        fill=False)
    sounddir_box.pack_start(sounddir_label_container)
    sounddir_box.pack_end(sounddir_container)
    directories_table.attach(sounddir_box, 0, 1, 0, 1, xpadding=14, \
        xoptions=gtk.EXPAND|gtk.FILL|gtk.SHRINK, \
        yoptions=gtk.EXPAND|gtk.SHRINK)
    directories_table.attach(imagedir_box, 0, 1, 1, 2, xpadding=14, \
        xoptions=gtk.EXPAND|gtk.FILL|gtk.SHRINK, \
        yoptions=gtk.EXPAND|gtk.SHRINK)
    start_with_review_table.attach(start_with_review_checkbox, 0, 1, 0, 1, \
        xoptions=gtk.SHRINK, yoptions=gtk.EXPAND|gtk.FILL)
    start_with_review_table.attach(start_with_review_label, 1, 2, 0, 1, \
        xoptions=gtk.FILL, yoptions=gtk.EXPAND|gtk.FILL)
    fullscreen_table.attach(fullscreen_checkbox, 0, 1, 0, 1, \
        xoptions=gtk.SHRINK, yoptions=gtk.EXPAND|gtk.SHRINK)
    fullscreen_table.attach(fullscreen_label, 1, 2, 0, 1, \
        xoptions=gtk.FILL, yoptions=gtk.EXPAND|gtk.FILL)
    checkboxes_box.pack_start(fullscreen_table)
    checkboxes_box.pack_end(start_with_review_table)
    general_settings_table.attach(directories_table, 0, 1, 0, 1, \
        xoptions=gtk.EXPAND|gtk.FILL|gtk.SHRINK, ypadding=10, 
        yoptions=gtk.EXPAND|gtk.FILL|gtk.SHRINK)
    general_settings_table.attach(checkboxes_box, 0, 1, 1, 2, \
        xoptions=gtk.EXPAND|gtk.FILL|gtk.SHRINK, xpadding=13, \
        yoptions=gtk.EXPAND|gtk.SHRINK)
    mode_settings_switcher.append_page(general_settings_table)
    font_size_example_container.add(font_size)
    font_size_table.attach(font_size_decrease_button, 0, 1, 0, 1, \
        xoptions=gtk.SHRINK, yoptions=gtk.EXPAND)
    font_size_table.attach(font_size_example_container, 1, 2, 0, 1, \
        xoptions=gtk.EXPAND|gtk.FILL, xpadding=14, \
        yoptions=gtk.EXPAND|gtk.FILL|gtk.SHRINK)
    font_size_table.attach(font_size_increase_button, 2, 3, 0, 1, \
        xoptions=gtk.SHRINK, yoptions=gtk.EXPAND)
    skin_settings_table.attach(font_size_table, 0, 1, 0, 1, \
        xoptions=gtk.EXPAND|gtk.FILL|gtk.SHRINK, yoptions=gtk.EXPAND)
    mode_settings_switcher.append_page(skin_settings_table)
    tts_voice_container.add(tts_voice_label)
    tts_voice_table.attach(tts_voice_prev_button, 0, 1, 0, 1, \
        xoptions=gtk.SHRINK, yoptions=gtk.EXPAND)
    tts_voice_table.attach(tts_voice_container, 1, 2, 0, 1, \
        xoptions=gtk.EXPAND|gtk.FILL, yoptions=gtk.SHRINK)
    tts_voice_table.attach(tts_voice_next_button, 2, 3, 0, 1, \
        xoptions=gtk.SHRINK, yoptions=gtk.EXPAND)
    tts_lang_container.add(tts_lang_label)
    tts_lang_table.attach(tts_lang_prev_button, 0, 1, 0, 1, \
        xoptions=gtk.SHRINK, yoptions=gtk.EXPAND)
    tts_lang_table.attach(tts_lang_container, 1, 2, 0, 1, \
        xoptions=gtk.EXPAND|gtk.FILL, yoptions=gtk.SHRINK)
    tts_lang_table.attach(tts_lang_next_button, 2, 3, 0, 1, \
        xoptions=gtk.SHRINK, yoptions=gtk.EXPAND)
    tts_speed_label_box.pack_start(tts_speed_label, expand=False, fill=False)
    tts_speed_box.pack_start(tts_speed_label_box, expand=False, fill=False)
    tts_speed_box.pack_end(tts_speed_scrollbar)
    tts_pitch_label_box.pack_start(tts_pitch_label, expand=False, fill=False)
    tts_pitch_box.pack_start(tts_pitch_label_box, expand=False, fill=False)
    tts_pitch_box.pack_end(tts_pitch_scrollbar)
    tts_settings_table2.attach(tts_speed_box, 0, 1, 0, 1, \
        xoptions=gtk.EXPAND|gtk.FILL|gtk.SHRINK, \
        yoptions=gtk.EXPAND|gtk.FILL|gtk.SHRINK)
    tts_settings_table2.attach(tts_pitch_box, 0, 1, 1, 2, \
        xoptions=gtk.EXPAND|gtk.FILL|gtk.SHRINK, \
        yoptions=gtk.EXPAND|gtk.FILL|gtk.SHRINK)
    tts_settings_table1.attach(tts_lang_table, 0, 1, 0, 1, \
        xoptions=gtk.EXPAND|gtk.FILL|gtk.SHRINK, \
        yoptions=gtk.EXPAND|gtk.FILL|gtk.SHRINK)
    tts_settings_table1.attach(tts_voice_table, 0, 1, 1, 2, \
        xoptions=gtk.EXPAND|gtk.FILL|gtk.SHRINK, \
        yoptions=gtk.EXPAND|gtk.FILL|gtk.SHRINK)
    tts_settings_table.attach(tts_settings_table1, 0, 1, 0, 1, \
        xoptions=gtk.EXPAND|gtk.FILL|gtk.SHRINK, \
        yoptions=gtk.EXPAND|gtk.FILL|gtk.SHRINK)
    tts_settings_table.attach(tts_settings_table2, 0, 1, 1, 2, \
        xoptions=gtk.EXPAND|gtk.FILL|gtk.SHRINK, \
        yoptions=gtk.EXPAND|gtk.FILL|gtk.SHRINK)
    mode_settings_switcher.append_page(tts_settings_table)
    toplevel_table.attach(mode_settings_switcher, 1, 2, 0, 1, \
        xoptions=gtk.EXPAND|gtk.FILL|gtk.SHRINK, xpadding = 14, \
        yoptions=gtk.EXPAND|gtk.FILL|gtk.SHRINK, ypadding=14)
    toplevel_table.show_all()
    return main_switcher.append_page(toplevel_table), tts_settings_button, \
        general_settings_button, skin_settings_button, mode_settings_switcher,\
        fullscreen_checkbox, start_with_review_checkbox, imagedir_entry, \
        sounddir_entry, tts_voice_label, tts_pitch_label, tts_lang_label, \
        tts_speed_label, tts_speed_scrollbar, tts_pitch_scrollbar, font_size, \
        tts_lang_prev_button, tts_lang_next_button, menu_button, \
        font_size_decrease_button, font_size_increase_button, \
        tts_voice_prev_button, tts_voice_next_button
Example #2
0
def create_review_ui(main_switcher):
    """Creates ReviewWidget UI."""

    def create_button(name, width=80, height=80):
        button = gtk.Button()
        button.set_size_request(width, height)
        button.set_name(name)
        return button

    toplevel_table = gtk.Table(rows=1, columns=3)
    # create containers
    toolbar_container = widgets.create_toolbar_container( \
        'review_toolbar_container')
    grades_container = widgets.create_toolbar_container('grades_container')
    widgets_table = gtk.Table(rows=2, columns=1)
    widgets_table.set_row_spacings(14)
    toolbar_table = gtk.Table(rows=5, columns=1, homogeneous=True)
    grades_table = gtk.Table(rows=6, columns=1, homogeneous=True)
    widgets_box = gtk.VBox(spacing=10)
    # create tags label
    tags_label = gtk.Label()
    tags_label.set_name('tags_label')
    tags_label.set_justify(gtk.JUSTIFY_LEFT)
    tags_label.set_single_line_mode(True)
    answer_container = gtk.Frame()
    answer_container.set_name('html_container')
    question_container = gtk.Frame()
    question_container.set_name('html_container')
    answer_text = widgets.create_gtkhtml()
    question_text = widgets.create_gtkhtml()
    # create toolbar buttons
    buttons = {}
    buttons[0] = create_button('review_toolbar_stat_current_card_button')
    buttons[1] = create_button('review_toolbar_tts_button')
    buttons[2] = create_button('review_toolbar_edit_card_button')
    buttons[3] = create_button('plus_button')
    buttons[4] = create_button('review_toolbar_delete_card_button')
    buttons[5] = create_button('main_menu_button')
    # create grades buttons
    grades = {}
    for num in range(6):
        grades[num] = create_button('grade%s' % num)
    # packing toolbar buttons
    for pos in buttons.keys():
        toolbar_table.attach(buttons[pos], 0, 1, pos, pos + 1, \
            xoptions=gtk.EXPAND, yoptions=gtk.EXPAND)
    toolbar_container.add(toolbar_table)
    # packing grades buttons
    for pos in grades.keys():
        grades_table.attach(grades[pos], 0, 1, 5 - pos, 6 - pos, \
            xoptions=gtk.EXPAND, yoptions=gtk.EXPAND)
    grades_container.add(grades_table)
    # packing other widgets
    toplevel_table.attach(toolbar_container, 0, 1, 0, 1, \
        xoptions=gtk.SHRINK, yoptions=gtk.SHRINK|gtk.EXPAND|gtk.FILL)
    toplevel_table.attach(grades_container, 3, 4, 0, 1, \
        xoptions=gtk.SHRINK, yoptions=gtk.SHRINK|gtk.EXPAND|gtk.FILL)
    question_container.add(question_text)
    answer_container.add(answer_text)
    widgets_box.pack_start(question_container)
    widgets_box.pack_end(answer_container)
    widgets_table.attach(tags_label, 0, 1, 0, 1, \
        xoptions=gtk.SHRINK, yoptions=gtk.SHRINK, xpadding=4)
    widgets_table.attach(widgets_box, 0, 1, 1, 2, \
        xoptions=gtk.SHRINK|gtk.FILL|gtk.EXPAND, \
        yoptions=gtk.SHRINK|gtk.FILL|gtk.EXPAND)
    toplevel_table.attach(widgets_table, 2, 3, 0, 1, ypadding=30,
        xoptions=gtk.SHRINK|gtk.EXPAND|gtk.FILL, \
        yoptions=gtk.SHRINK|gtk.EXPAND|gtk.FILL, xpadding=30)
    toplevel_table.show_all()
    return main_switcher.append_page(toplevel_table), buttons[1], buttons[2], \
        buttons[4], question_container, answer_container, question_text, \
        answer_text, grades_table, grades.values(), buttons.values(), tags_label
Example #3
0
def create_statistics_ui(main_switcher):
    """Creates MaemoStatisticsWidget UI."""

    toplevel_table = gtk.Table(rows=1, columns=2)
    toolbar_container = widgets.create_toolbar_container('toolbar_container')
    toolbar_table = gtk.Table(rows=5, columns=1, homogeneous=True)
    # create toolbar buttons
    current_card_button = widgets.create_radio_button(None, \
        'stat_toolbar_current_card_button', None, width=80, height=80)
    common_button = widgets.create_radio_button(current_card_button, \
        'stat_toolbar_common_stat_button', None, width=80, height=80)
    tags_button = widgets.create_radio_button(common_button, \
        'stat_toolbar_tags_stat_button', None, width=80, height=80)
    menu_button = widgets.create_button('main_menu_button', None)
    # create mode switcher
    mode_statistics_switcher = gtk.Notebook()
    mode_statistics_switcher.set_show_tabs(False)
    mode_statistics_switcher.set_show_border(False)
    mode_statistics_switcher.set_name('config_mode_settings_switcher')
    # packing toolbar buttons
    toolbar_table.attach(current_card_button,  0, 1, 0, 1, \
        xoptions=gtk.SHRINK, yoptions=gtk.EXPAND)
    toolbar_table.attach(common_button, 0, 1, 1, 2, \
        xoptions=gtk.SHRINK, yoptions=gtk.EXPAND)
    toolbar_table.attach(tags_button, 0, 1, 2, 3, \
        xoptions=gtk.SHRINK, yoptions=gtk.EXPAND)
    toolbar_table.attach(menu_button, 0, 1, 4, 5, \
        xoptions=gtk.SHRINK, yoptions=gtk.EXPAND)
    toolbar_container.add(toolbar_table)
    toplevel_table.attach(toolbar_container, 0, 1, 0, 1, \
        xoptions=gtk.SHRINK, yoptions=gtk.SHRINK|gtk.EXPAND|gtk.FILL)
    # create widgets for current card mode
    current_card_table = gtk.Table(rows=1, columns=1, homogeneous=False)
    current_card_frame = gtk.Frame()
    current_card_frame.set_name('html_container')
    current_card_eventbox = gtk.EventBox()
    current_card_eventbox.set_visible_window(True)
    current_card_eventbox.set_name('viewport_widget')
    current_card_scrolledwindow = gtk.ScrolledWindow()
    current_card_scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, \
        gtk.POLICY_AUTOMATIC)
    current_card_scrolledwindow.set_name('scrolled_window')
    current_card_html = widgets.create_gtkhtml()
    # packing widgets for current card mode
    current_card_table.attach(current_card_frame, 1, 2, 0, 1, \
        xoptions=gtk.SHRINK|gtk.EXPAND|gtk.FILL, \
        yoptions=gtk.SHRINK|gtk.EXPAND|gtk.FILL, \
        xpadding=30, ypadding=30)
    current_card_scrolledwindow.add(current_card_html)
    current_card_eventbox.add(current_card_scrolledwindow)
    current_card_frame.add(current_card_eventbox)
    mode_statistics_switcher.append_page(current_card_table)
    # create widgets for total cards mode
    total_card_table = gtk.Table(rows=1, columns=1, homogeneous=False)
    total_card_frame = gtk.Frame()
    total_card_frame.set_name('html_container')
    total_card_eventbox = gtk.EventBox()
    total_card_eventbox.set_visible_window(True)
    total_card_eventbox.set_name('viewport_widget')
    total_card_scrolledwindow = gtk.ScrolledWindow()
    total_card_scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, \
        gtk.POLICY_AUTOMATIC)
    total_card_scrolledwindow.set_name('scrolled_window')
    total_card_html = widgets.create_gtkhtml()
    # packing widgets for total cards mode
    total_card_table.attach(total_card_frame, 1, 2, 0, 1, \
        xoptions=gtk.SHRINK|gtk.EXPAND|gtk.FILL, \
        yoptions=gtk.SHRINK|gtk.EXPAND|gtk.FILL, \
        xpadding=30, ypadding=30)
    total_card_scrolledwindow.add(total_card_html)
    total_card_eventbox.add(total_card_scrolledwindow)
    total_card_frame.add(total_card_eventbox)
    mode_statistics_switcher.append_page(total_card_table)
    # create widgets for grades section
    tags_card_table = gtk.Table(rows=1, columns=1, homogeneous=False)
    tags_card_frame = gtk.Frame()
    tags_card_frame.set_name('html_container')
    tags_card_eventbox = gtk.EventBox()
    tags_card_eventbox.set_visible_window(True)
    tags_card_eventbox.set_name('viewport_widget')
    tags_card_scrolledwindow = gtk.ScrolledWindow()
    tags_card_scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, \
        gtk.POLICY_AUTOMATIC)
    tags_card_scrolledwindow.set_name('scrolled_window')
    tags_card_html = widgets.create_gtkhtml()
    # packing widgets for grades section
    tags_card_table.attach(tags_card_frame, 1, 2, 0, 1, \
        xoptions=gtk.SHRINK|gtk.EXPAND|gtk.FILL, \
        yoptions=gtk.SHRINK|gtk.EXPAND|gtk.FILL, \
        xpadding=30, ypadding=30)
    tags_card_scrolledwindow.add(tags_card_html)
    tags_card_eventbox.add(tags_card_scrolledwindow)
    tags_card_frame.add(tags_card_eventbox)
    mode_statistics_switcher.append_page(tags_card_table)
    # packing widgets
    toplevel_table.attach(mode_statistics_switcher, 1, 2, 0, 1, \
        xoptions=gtk.SHRINK|gtk.EXPAND|gtk.FILL, \
        yoptions=gtk.SHRINK|gtk.EXPAND|gtk.FILL)
    toplevel_table.show_all()
    return main_switcher.append_page(toplevel_table), \
        mode_statistics_switcher, menu_button, current_card_button, \
        common_button, tags_button, current_card_html, total_card_html, \
        tags_card_html
Example #4
0
def create_input_ui(main_switcher, theme_path):
    """Creates InputWidget UI."""

    def create_text_block(name):
        """Creates text field and text field container."""
        container = gtk.Frame()
        container.set_name("html_container")
        text_widget = gtk.TextView()
        text_widget.set_name(name)
        text_widget.set_justification(gtk.JUSTIFY_CENTER)
        text_widget.set_wrap_mode(gtk.WRAP_CHAR)
        return container, text_widget

    toplevel_table = gtk.Table(rows=1, columns=3)
    # create containers
    toolbar_container = widgets.create_toolbar_container("toolbar_container")
    toolbar_table = gtk.Table(rows=5, columns=1, homogeneous=True)
    grades_container = widgets.create_toolbar_container("grades_container")
    grades_table = gtk.Table(rows=6, columns=1, homogeneous=True)
    # create toolbar buttons
    card_type_button = widgets.create_button("undefined")
    content_button = widgets.create_button("undefined")
    tags_button = widgets.create_button("tags_button")
    menu_button = widgets.create_button("main_menu_button")
    # create sound button
    sound_container = gtk.Frame()
    sound_container.set_name("html_container")
    html = '<html><body><table align="center"><tr><td><img src=%s></td></tr>' "</table></body></html>" % os.path.join(
        theme_path, "note.png"
    )
    sound_button = widgets.create_gtkhtml(html)
    sound_container.add(sound_button)
    sound_box = gtk.VBox()
    sound_box.set_homogeneous(True)
    # create grades buttons
    grades = {}
    for num in range(6):
        grades[num] = widgets.create_button("grade%s" % num)
    # create text fields
    question_container, question_text = create_text_block("question_text")
    answer_container, answer_text = create_text_block("answer_text")
    foreign_container, foreign_text = create_text_block("foreign_text")
    pronunciation_container, pronunciation_text = create_text_block("pronunciation_text")
    translation_container, translation_text = create_text_block("translation_text")
    cloze_container, cloze_text = create_text_block("cloze_text")
    # create new tag elements
    tags_label = gtk.Label()
    tags_label.set_name("tags_label")
    tags_label.set_justify(gtk.JUSTIFY_LEFT)
    tags_label.set_single_line_mode(True)
    tags_layout = gtk.VBox(spacing=26)
    new_tag_box = gtk.HBox()
    new_tag_label = gtk.Label()
    new_tag_label.set_text("New tag: ")
    new_tag_label.set_name("white_label")
    new_tag_button = widgets.create_button("plus_button", width=60, height=60)
    new_tag_frame = gtk.Frame()
    new_tag_frame.set_name("html_container")
    new_tag_entry = gtk.Entry()
    new_tag_entry.set_name("entry_widget")
    # creates 'tags list' elements
    tags_frame = gtk.Frame()
    tags_frame.set_name("html_container")
    tags_eventbox = gtk.EventBox()
    tags_eventbox.set_visible_window(True)
    tags_eventbox.set_name("viewport_widget")
    tags_scrolledwindow = gtk.ScrolledWindow()
    tags_scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
    tags_scrolledwindow.set_name("scrolled_window")
    tags_viewport = gtk.Viewport()
    tags_viewport.set_name("viewport_widget")
    tags_viewport.set_shadow_type(gtk.SHADOW_NONE)
    tags_box = gtk.VBox()
    tags_box.set_homogeneous(True)
    # create other widgets
    two_sided_box = gtk.VBox(spacing=10)
    two_sided_box.set_homogeneous(True)
    three_sided_box = gtk.VBox(spacing=10)
    three_sided_box.set_homogeneous(True)
    cloze_box = gtk.VBox()
    widgets_table = gtk.Table(rows=2, columns=1)
    widgets_table.set_row_spacings(14)
    card_type_switcher = gtk.Notebook()
    card_type_switcher.set_show_tabs(False)
    card_type_switcher.set_show_border(False)
    # packing widgets
    toolbar_table.attach(card_type_button, 0, 1, 0, 1, xoptions=gtk.EXPAND, yoptions=gtk.EXPAND)
    toolbar_table.attach(content_button, 0, 1, 1, 2, xoptions=gtk.EXPAND, yoptions=gtk.EXPAND)
    toolbar_table.attach(tags_button, 0, 1, 2, 3, xoptions=gtk.EXPAND, yoptions=gtk.EXPAND)
    toolbar_table.attach(menu_button, 0, 1, 4, 5, xoptions=gtk.EXPAND, yoptions=gtk.EXPAND)
    toolbar_container.add(toolbar_table)
    # packing grades buttons
    for pos in grades.keys():
        grades_table.attach(grades[pos], 0, 1, 5 - pos, 6 - pos, xoptions=gtk.EXPAND, yoptions=gtk.EXPAND)
    grades_container.add(grades_table)
    # packing other widgets
    toplevel_table.attach(
        toolbar_container, 0, 1, 0, 1, xoptions=gtk.SHRINK, yoptions=gtk.SHRINK | gtk.EXPAND | gtk.FILL
    )
    toplevel_table.attach(
        grades_container, 3, 4, 0, 1, xoptions=gtk.SHRINK, yoptions=gtk.SHRINK | gtk.EXPAND | gtk.FILL
    )
    widgets_table.attach(tags_label, 0, 1, 0, 1, xoptions=gtk.SHRINK, yoptions=gtk.FILL, xpadding=4)
    widgets_table.attach(
        card_type_switcher,
        0,
        1,
        1,
        2,
        xoptions=gtk.SHRINK | gtk.FILL | gtk.EXPAND,
        yoptions=gtk.SHRINK | gtk.FILL | gtk.EXPAND,
    )
    card_type_switcher.append_page(two_sided_box)
    card_type_switcher.append_page(three_sided_box)
    card_type_switcher.append_page(cloze_box)
    card_type_switcher.append_page(tags_layout)
    question_container.add(question_text)
    sound_box.pack_start(sound_container)
    sound_box.pack_end(question_container)
    answer_container.add(answer_text)
    two_sided_box.pack_start(sound_box)
    two_sided_box.pack_end(answer_container)
    foreign_container.add(foreign_text)
    pronunciation_container.add(pronunciation_text)
    translation_container.add(translation_text)
    three_sided_box.pack_start(foreign_container)
    three_sided_box.pack_start(pronunciation_container)
    three_sided_box.pack_end(translation_container)
    cloze_container.add(cloze_text)
    cloze_box.pack_start(cloze_container)
    new_tag_frame.add(new_tag_entry)
    new_tag_box.pack_start(new_tag_label, expand=False, fill=False, padding=10)
    new_tag_box.pack_start(new_tag_frame, expand=True, fill=True, padding=10)
    new_tag_box.pack_end(new_tag_button, expand=False, fill=False)
    tags_viewport.add(tags_box)
    tags_scrolledwindow.add(tags_viewport)
    tags_eventbox.add(tags_scrolledwindow)
    tags_frame.add(tags_eventbox)
    tags_layout.pack_start(new_tag_box, expand=False, fill=False)
    tags_layout.pack_end(tags_frame, expand=True, fill=True)
    toplevel_table.attach(
        widgets_table,
        1,
        2,
        0,
        1,
        xoptions=gtk.SHRINK | gtk.EXPAND | gtk.FILL,
        xpadding=30,
        yoptions=gtk.SHRINK | gtk.EXPAND | gtk.FILL,
        ypadding=30,
    )
    toplevel_table.show_all()
    # hide necessary widgets
    sound_container.hide()
    return (
        main_switcher.append_page(toplevel_table),
        card_type_button,
        content_button,
        menu_button,
        tags_button,
        sound_button,
        question_text,
        answer_text,
        foreign_text,
        pronunciation_text,
        translation_text,
        cloze_text,
        new_tag_button,
        new_tag_entry,
        tags_box,
        card_type_switcher,
        sound_container,
        question_container,
        toolbar_container,
        grades,
        tags_label,
        tags_button,
    )
Example #5
0
def create_input_ui(main_switcher, theme_path):
    """Creates InputWidget UI."""

    def create_grade_button(name, width=80, height=80):
        button = gtk.Button()
        button.set_size_request(width, height)
        button.set_name(name)
        return button

    toplevel_table = gtk.Table(rows=1, columns=3)
    # create toolbar container
    toolbar_container = widgets.create_toolbar_container('toolbar_container')
    toolbar_table = gtk.Table(rows=5, columns=1, homogeneous=True)
    # create grades container
    grades_container = widgets.create_toolbar_container('grades_container')
    grades_table = gtk.Table(rows=6, columns=1, homogeneous=True)
    # create toolbar buttons
    card_type_button = gtk.Button()
    card_type_button.set_size_request(80, 80)
    content_button = gtk.Button()
    content_button.set_size_request(80, 80)
    menu_button = gtk.Button()
    menu_button.set_size_request(80, 80)
    menu_button.set_name('main_menu_button')
    widgets_table = gtk.Table(rows=2, columns=1)
    widgets_table.set_row_spacings(14)
    tags_button = gtk.Button()
    tags_button.set_size_request(80, 80)
    tags_button.set_name('tags_button')
    card_type_switcher = gtk.Notebook()
    card_type_switcher.set_show_tabs(False)
    card_type_switcher.set_show_border(False)
    two_sided_box = gtk.VBox(spacing=10)
    two_sided_box.set_homogeneous(True)
    # create sound button
    sound_container = gtk.Frame()
    sound_container.set_name('html_container')
    html = '<html><body><table align="center"><tr><td><img src=%s></td></tr>' \
        '</table></body></html>' % os.path.join(theme_path, "note.png")
    sound_button = widgets.create_gtkhtml(html)
    sound_container.add(sound_button)
    sound_box = gtk.VBox()
    sound_box.set_homogeneous(True)
    # create grades buttons
    grades = {}
    for num in range(6):
        grades[num] = create_grade_button('grade%s' % num)
    # create text fields
    question_container = gtk.Frame()
    question_container.set_name('html_container')
    question_text = gtk.TextView()
    question_text.set_name('question_text')
    question_text.set_justification(gtk.JUSTIFY_CENTER)
    question_text.set_wrap_mode(gtk.WRAP_WORD)
    answer_container = gtk.Frame()
    answer_container.set_name('html_container')
    answer_text = gtk.TextView()
    answer_text.set_name('answer_text')
    answer_text.set_justification(gtk.JUSTIFY_CENTER)
    answer_text.set_wrap_mode(gtk.WRAP_WORD)
    three_sided_box = gtk.VBox(spacing=10)
    foreign_container = gtk.Frame()
    foreign_container.set_name('html_container')
    foreign_text = gtk.TextView()
    foreign_text.set_name('foreign_text')
    foreign_text.set_justification(gtk.JUSTIFY_CENTER)
    foreign_text.set_wrap_mode(gtk.WRAP_WORD)
    pronunciation_container = gtk.Frame()
    pronunciation_container.set_name('html_container')
    pronunciation_text = gtk.TextView()
    pronunciation_text.set_name('pronunciation_text')
    pronunciation_text.set_justification(gtk.JUSTIFY_CENTER)
    pronunciation_text.set_wrap_mode(gtk.WRAP_WORD)
    translation_container = gtk.Frame()
    translation_container.set_name('html_container')
    translation_text = gtk.TextView()
    translation_text.set_name('translation_text')
    translation_text.set_justification(gtk.JUSTIFY_CENTER)
    translation_text.set_wrap_mode(gtk.WRAP_WORD)
    cloze_box = gtk.VBox()
    cloze_container = gtk.Frame()
    cloze_container.set_name('html_container')
    cloze_text = gtk.TextView()
    cloze_text.set_name('cloze_text')
    cloze_text.set_justification(gtk.JUSTIFY_CENTER)
    cloze_text.set_wrap_mode(gtk.WRAP_WORD)
    # create new tag elements
    tags_label = gtk.Label()
    tags_label.set_name('tags_label')
    tags_label.set_justify(gtk.JUSTIFY_LEFT)
    tags_label.set_single_line_mode(True)
    tags_layout = gtk.VBox(spacing=26)
    new_tag_box = gtk.HBox()
    new_tag_label = gtk.Label()
    new_tag_label.set_text('New tag: ')
    new_tag_label.set_name('white_label')
    new_tag_button = gtk.Button()
    new_tag_button.set_size_request(60, 60)
    new_tag_button.set_name('plus_button')
    new_tag_frame = gtk.Frame()
    new_tag_frame.set_name('html_container')
    new_tag_entry = gtk.Entry()
    new_tag_entry.set_name('entry_widget')
    # creates 'tags list' elements
    tags_frame = gtk.Frame()
    tags_frame.set_name('html_container')
    tags_eventbox = gtk.EventBox()
    tags_eventbox.set_visible_window(True)
    tags_eventbox.set_name('viewport_widget')
    tags_scrolledwindow = gtk.ScrolledWindow()
    tags_scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, \
        gtk.POLICY_AUTOMATIC)
    tags_scrolledwindow.set_name('scrolled_window')
    tags_viewport = gtk.Viewport()
    tags_viewport.set_name('viewport_widget')
    tags_viewport.set_shadow_type(gtk.SHADOW_NONE)
    tags_box = gtk.VBox()
    tags_box.set_homogeneous(True)
    # packing widgets
    toolbar_table.attach(card_type_button, 0, 1, 0, 1, \
        xoptions=gtk.EXPAND, yoptions=gtk.EXPAND)
    toolbar_table.attach(content_button, 0, 1, 1, 2, \
        xoptions=gtk.EXPAND, yoptions=gtk.EXPAND)
    toolbar_table.attach(tags_button, 0, 1, 2, 3, \
        xoptions=gtk.EXPAND, yoptions=gtk.EXPAND)
    toolbar_table.attach(menu_button, 0, 1, 4, 5, \
        xoptions=gtk.EXPAND, yoptions=gtk.EXPAND)
    toolbar_container.add(toolbar_table)
    # packing grades buttons
    for pos in grades.keys():
        grades_table.attach(grades[pos], 0, 1, 5 - pos, 6 - pos, \
            xoptions=gtk.EXPAND, yoptions=gtk.EXPAND)
    grades_container.add(grades_table)
    # packing other widgets
    toplevel_table.attach(toolbar_container, 0, 1, 0, 1, \
        xoptions=gtk.SHRINK, yoptions=gtk.SHRINK|gtk.EXPAND|gtk.FILL)
    toplevel_table.attach(grades_container, 3, 4, 0, 1, \
        xoptions=gtk.SHRINK, yoptions=gtk.SHRINK|gtk.EXPAND|gtk.FILL)
    widgets_table.attach(tags_label, 0, 1, 0, 1, \
        xoptions=gtk.SHRINK, yoptions=gtk.SHRINK, xpadding=4)
    widgets_table.attach(card_type_switcher, 0, 1, 1, 2, \
        xoptions=gtk.SHRINK|gtk.FILL|gtk.EXPAND, \
        yoptions=gtk.SHRINK|gtk.FILL|gtk.EXPAND)
    card_type_switcher.append_page(two_sided_box)
    card_type_switcher.append_page(three_sided_box)
    card_type_switcher.append_page(cloze_box)
    card_type_switcher.append_page(tags_layout)
    question_container.add(question_text)
    sound_box.pack_start(sound_container)
    sound_box.pack_end(question_container)
    answer_container.add(answer_text)
    two_sided_box.pack_start(sound_box)
    two_sided_box.pack_end(answer_container)
    foreign_container.add(foreign_text)
    pronunciation_container.add(pronunciation_text)
    translation_container.add(translation_text)
    three_sided_box.pack_start(foreign_container)
    three_sided_box.pack_start(pronunciation_container)
    three_sided_box.pack_end(translation_container)
    cloze_container.add(cloze_text)
    cloze_box.pack_start(cloze_container)
    new_tag_frame.add(new_tag_entry)
    new_tag_box.pack_start(new_tag_label, expand=False, fill=False, padding=10)
    new_tag_box.pack_start(new_tag_frame, expand=True, fill=True, padding=10)
    new_tag_box.pack_end(new_tag_button, expand=False, fill=False)
    tags_viewport.add(tags_box)
    tags_scrolledwindow.add(tags_viewport)
    tags_eventbox.add(tags_scrolledwindow)
    tags_frame.add(tags_eventbox)
    tags_layout.pack_start(new_tag_box, expand=False, fill=False)
    tags_layout.pack_end(tags_frame, expand=True, fill=True)
    toplevel_table.attach(widgets_table, 1, 2, 0, 1, \
        xoptions=gtk.SHRINK|gtk.EXPAND|gtk.FILL, xpadding=30, \
        yoptions=gtk.SHRINK|gtk.EXPAND|gtk.FILL, ypadding=30)
    toplevel_table.show_all()
    # hide necessary widgets
    sound_container.hide()
    return main_switcher.append_page(toplevel_table), card_type_button, \
        content_button, menu_button, tags_button, sound_button, question_text, \
        answer_text, foreign_text, pronunciation_text, translation_text, \
        cloze_text, new_tag_button, new_tag_entry, tags_box, \
        card_type_switcher, sound_container, question_container, \
        toolbar_container, grades, tags_label, tags_button
Example #6
0
def create_about_ui(main_switcher, image_name):
    """Creates AboutWidget UI."""

    toplevel_table = gtk.Table(rows=1, columns=2)
    # create toolbar container
    toolbar_container = widgets.create_toolbar_container("three_button_container")
    toolbar_table = gtk.Table(rows=5, columns=1, homogeneous=True)
    # create mode switcher
    mode_switcher = gtk.Notebook()
    mode_switcher.set_show_tabs(False)
    mode_switcher.set_show_border(False)
    mode_switcher.set_name("config_mode_settings_switcher")
    # create toolbar elements
    about_button = widgets.create_radio_button(None, "help_toolbar_about_button", None, width=80, height=80)
    help_button = widgets.create_radio_button(about_button, "help_toolbar_help_button", None, width=80, height=80)
    menu_button = widgets.create_button("main_menu_button")
    info_container = gtk.Notebook()
    info_container.set_show_border(False)
    info_container.set_show_tabs(False)
    info_box = gtk.VBox()
    hbutton_box = gtk.HButtonBox()
    text_box = gtk.HBox()
    logo_box = gtk.HBox()
    label_left = gtk.Label()
    label_left.set_use_markup(True)
    label_left.set_markup(
        "<span foreground='white' size='small'><b>"
        "Developers:</b></span>\n<span foreground='white' size='small'>"
        "Max Usachev |</span> <span foreground='#299BFC' size='small'>"
        "[email protected]</span>\n<span foreground='white' size="
        "'small'>Ed Bartosh |</span> <span foreground='#299BFC' size="
        "'small'>[email protected]</span>\n<span foreground='white' "
        "size='small'>Vlad Vasiliev |</span> <span foreground='#299BFC' "
        "size='small'>[email protected]</span>\n\n<span foreground='white' "
        "size='small'><b>Designer:</b>\n</span><span foreground='white' "
        "size='small'>Andrew Zhilin |</span> <span foreground='#299BFC' "
        "size='small'>[email protected]</span>\n\n<span foreground="
        "'white' size='small'><b>Development team:</b></span>\n<span "
        "foreground='#299BFC' size='small'>[email protected]</span>"
    )
    label_right = gtk.Label()
    label_right.set_use_markup(True)
    label_right.set_markup(
        "<span foreground='white' size='small'><b>"
        "Special Thanks To:</b></span>\n<span foreground='white' size="
        "'small'>Peter Bienstman</span>\n<span foreground='#299BFC' size="
        "'small'>[email protected]</span>\n<span foreground="
        "'#299BFC' size='small'>http://www.mnemosyne-proj.org/</span>"
        "\n<span size='x-large'></span><span foreground='white' size="
        "'small'>\nGSoC 2009</span>\n<span foreground='#299BFC' size='"
        "small'>http://socghop.appspot.com/</span>\n\n<span size='x-large'>"
        "</span><span foreground='white' size='small'>\nMaemo community"
        "</span>\n<span foreground='#299BFC' size='small'>"
        "http://maemo.org/</span>"
    )
    logo = gtk.Image()
    logo.set_from_file(image_name)
    program_label = gtk.Label()
    program_label.set_justify(gtk.JUSTIFY_CENTER)
    program_label.set_use_markup(True)
    program_label.set_markup(
        "<span foreground='white' size='large'><b>"
        "Mnemosyne for Maemo</b></span>\n<span foreground='white' size="
        "'large'>version 2.0.0~beta11</span>"
    )
    # create help widgets
    help_table = gtk.Table(rows=1, columns=1, homogeneous=False)
    help_frame = gtk.Frame()
    help_frame.set_name("html_container")
    help_eventbox = gtk.EventBox()
    help_eventbox.set_visible_window(True)
    help_eventbox.set_name("viewport_widget")
    help_scrolledwindow = gtk.ScrolledWindow()
    help_scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
    help_scrolledwindow.set_name("scrolled_window")
    # help_html = widgets.create_gtkhtml(open(help_html).read())
    help_html = widgets.create_gtkhtml()
    # packing widgets
    logo_box.pack_start(logo, expand=False, fill=False, padding=10)
    logo_box.pack_end(program_label, expand=False, fill=False)
    hbutton_box.pack_start(logo_box)
    text_box.pack_start(label_left)
    text_box.pack_end(label_right)
    info_box.pack_start(hbutton_box, expand=False)
    info_box.pack_end(text_box)
    info_container.append_page(info_box)
    toolbar_table.attach(about_button, 0, 1, 1, 2, xoptions=gtk.EXPAND, yoptions=gtk.EXPAND)
    toolbar_table.attach(help_button, 0, 1, 0, 1, xoptions=gtk.EXPAND, yoptions=gtk.EXPAND)
    toolbar_table.attach(menu_button, 0, 1, 4, 5, xoptions=gtk.EXPAND, yoptions=gtk.EXPAND)
    toolbar_container.append_page(toolbar_table)
    toplevel_table.attach(
        toolbar_container, 0, 1, 0, 1, xoptions=gtk.SHRINK, yoptions=gtk.SHRINK | gtk.EXPAND | gtk.FILL
    )
    mode_switcher.append_page(info_container)
    help_table.attach(
        help_frame,
        1,
        2,
        0,
        1,
        xoptions=gtk.SHRINK | gtk.EXPAND | gtk.FILL,
        yoptions=gtk.SHRINK | gtk.EXPAND | gtk.FILL,
        xpadding=30,
        ypadding=30,
    )
    help_scrolledwindow.add(help_html)
    help_eventbox.add(help_scrolledwindow)
    help_frame.add(help_eventbox)
    mode_switcher.append_page(help_table)
    toplevel_table.attach(
        mode_switcher,
        1,
        2,
        0,
        1,
        xoptions=gtk.SHRINK | gtk.EXPAND | gtk.FILL,
        yoptions=gtk.SHRINK | gtk.EXPAND | gtk.FILL,
    )
    toplevel_table.show_all()
    return main_switcher.append_page(toplevel_table), mode_switcher, menu_button, about_button, help_button, help_html