Beispiel #1
0
 def check_if_it_finished():
     if thread.is_alive():
         get_main_window().after(200, check_if_it_finished)
     else:
         actions.add_choice("Color Styles",
                            styles,
                            var=config.get_var('pygments_style'))
Beispiel #2
0
def setup():
    # TODO: loading the styles takes a long time on startup... try to
    # make it asynchronous without writing too complicated code?
    config = settings.get_section('General')
    actions.add_choice("Color Styles",
                       sorted(pygments.styles.get_all_styles()),
                       var=config.get_var('pygments_style'))
Beispiel #3
0
def test_add_choice(porcusession, action_path):
    assert actions.add_choice(action_path + '_',
                              ['a', 'b', 'c']).var.get() == 'a'
    assert actions.add_choice(action_path + '__',
                              ['a', 'b', 'c'], 'b').var.get() == 'b'

    with pytest.raises(ValueError):
        actions.add_choice(action_path, ['a', 'b', 'c'], 'd')

    var = tkinter.StringVar()
    var.set('d')
    with pytest.raises(ValueError):
        actions.add_choice(action_path, ['a', 'b', 'c'], var=var)

    var.set('c')
    with pytest.raises(ValueError):
        actions.add_choice(action_path, ['a', 'b', 'c'], 'd', var=var)

    # default and var: var should be set to the default
    action = actions.add_choice(action_path, ['a', 'b', 'c', 'd'], 'b',
                                var=var)
    assert action.var is var
    assert var.get() == 'b'

    with pytest.warns(RuntimeWarning):
        var.set('wat wat')
Beispiel #4
0
def setup():
    style = ttkthemes.ThemedStyle()

    # https://github.com/RedFantom/ttkthemes/issues/6
    # this does what style.theme_use() should do
    default_theme = style.tk.eval('return $ttk::currentTheme')

    config.add_option('ttk_theme', default_theme, reset=False)
    config.connect('ttk_theme', functools.partial(on_theme_changed, style))
    actions.add_choice("Ttk Themes", sorted(style.get_themes()),
                       var=config.get_var('ttk_theme'))
Beispiel #5
0
def setup():
    var = tkinter.StringVar()

    # this initial value isn't shown anywhere, it just needs to be set to
    # something to avoid an error in actions.add_choice
    var.set(filetypes.get_all_filetypes()[0].name)

    var.trace('w', functools.partial(var_value_to_tab, var))
    get_tab_manager().bind('<<NotebookTabChanged>>',
                           functools.partial(tab_filetype_to_var, var),
                           add=True)
    utils.bind_with_data(get_tab_manager(),
                         '<<NewTab>>',
                         functools.partial(on_new_tab, var),
                         add=True)

    actions.add_choice(
        'Filetypes',
        [filetype.name for filetype in filetypes.get_all_filetypes()],
        var=var,
        tabtypes=[tabs.FileTab])