Exemplo n.º 1
0
    def createThemesMenu(self, menu):
        submenu = MfxMenu(menu, label=n_("Set t&heme"))

        try:
            from ttkthemes import themed_style
            style_path = themed_style.ThemedStyle(self.top)
        except ImportError:
            style_path = ttk.Style(self.top)
        all_themes = list(style_path.theme_names())

        all_themes.sort()
        #
        tn = {
            'alt': n_('Alt/Revitalized'),
            'itft1': n_('ITFT1'),
            'scidblue': n_('Scid Blue'),
            'scidgreen': n_('Scid Green'),
            'scidgrey': n_('Scid Grey'),
            'scidmint': n_('Scid Mint'),
            'scidpink': n_('Scid Pink'),
            'scidpurple': n_('Scid Purple'),
            'scidsand': n_('Scid Sand'),
            'winnative': n_('Windows Native'),
            'winxpblue': n_('Windows XP Blue'),
            'xpnative': n_('XP Native'),
        }
        for t in all_themes:
            try:
                n = tn[t]
            except KeyError:
                n = t.capitalize()
            submenu.add_radiobutton(label=n,
                                    variable=self.tkopt.theme,
                                    value=t,
                                    command=self.mOptTheme)
Exemplo n.º 2
0
def set_theme(app, top, theme):
    # set theme
    style = ttk.Style(top)
    try:
        style.theme_use(theme)
    except Exception:
        print_err(_('invalid theme name: ') + theme)
        style.theme_use(app.opt.default_tile_theme)
Exemplo n.º 3
0
    def createStyles(self):
        self._style = ttk.Style(master=self)

        self._fonts = {}
        self._fonts['ThumbListFont'] = tkFont.Font(family='Consolas', size=9)

        self._style.configure('ThumbList.Treeview',
                              font=self._fonts['ThumbListFont'],
                              foreground='#555555')
Exemplo n.º 4
0
 def _createChartInit(self, text):
     frame = ttk.LabelFrame(self.right_frame, text=text)
     frame.pack(side='top', fill='both', expand=False, padx=20, pady=10)
     style = ttk.Style(self.parent)
     fg = style.lookup('.', 'foreground') or None  # use default if fg == ''
     bg = style.lookup('.', 'background') or None
     self.fg = fg
     #
     w, h = self.tab_x[-1], max(self.tab_y[-1], self.oval_height+40)
     c = tkinter.Canvas(frame, width=w, height=h,
                        bg=bg, highlightthickness=0)
     c.pack(fill='both', expand=True)
     self.canvas = c
Exemplo n.º 5
0
def set_theme(app, top, theme):
    # set
    try:
        from ttkthemes import themed_style
        style = themed_style.ThemedStyle(top)
    except ImportError:
        style = ttk.Style(top)

    try:
        style.theme_use(theme)
    except Exception:
        print_err(_('invalid theme name: ') + theme)
        style.theme_use(app.opt.default_tile_theme)
Exemplo n.º 6
0
    def __init__(self, parent, title, app, player, gameid, **kw):

        kw = self.initKw(kw)
        title = _('Statistics')
        MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)

        self.font = app.getFont('default')
        self.tkfont = tkinter_font.Font(parent, self.font)
        self.font_metrics = self.tkfont.metrics()
        style = ttk.Style(parent)
        heading_font = style.lookup('Heading', 'font')  # treeview heading
        self.heading_tkfont = tkinter_font.Font(parent, heading_font)

        self.selected_game = None

        top_frame, bottom_frame = self.createFrames(kw)
        notebook = ttk.Notebook(top_frame)
        notebook.pack(expand=True, fill='both', padx=10, pady=10)

        self.notebook_tabs = []

        single_frame = SingleGameFrame(self, notebook, app, player, gameid)
        notebook.add(single_frame, text=_('Current game'))
        self.notebook_tabs.append(single_frame._w)

        all_frame = AllGamesFrame(self, notebook, app, player)
        notebook.add(all_frame, text=_('All games'))
        self.all_games_frame = all_frame
        self.notebook_tabs.append(all_frame._w)

        top_frame = TopFrame(self, notebook, app, player, gameid)
        notebook.add(top_frame, text=TOP_TITLE)
        self.notebook_tabs.append(top_frame._w)

        if player is not None:
            progr_frame = ProgressionFrame(self, notebook, app, player, gameid)
            notebook.add(progr_frame, text=_('Progression'))
            self.notebook_tabs.append(progr_frame._w)

        if StatsDialog.SELECTED_TAB < len(self.notebook_tabs):
            notebook.select(StatsDialog.SELECTED_TAB)
        bind(notebook, '<<NotebookTabChanged>>', self.tabChanged)
        # notebook.enableTraversal()
        self.notebook = notebook

        focus = self.createButtons(bottom_frame, kw)
        self.tabChanged()               # configure buttons state
        self.mainloop(focus, kw.timeout)
Exemplo n.º 7
0
def init_root_window(root, app):
    base_init_root_window(root, app)
    if TOOLKIT == 'gtk':
        pass
    elif USE_TILE:
        theme = app.opt.tile_theme
        style = ttk.Style(root)
        if theme not in ('winnative', 'xpnative'):
            color = style.lookup('.', 'background')
            if color:
                root.tk_setPalette(color)
            # root.option_add('*Menu.foreground', 'black')
            root.option_add('*Menu.activeBackground', '#08246b')
            root.option_add('*Menu.activeForeground', 'white')
        if theme == 'winnative':
            style.configure('Toolbutton', padding=2)
    else:
        # root.option_add(...)
        pass
Exemplo n.º 8
0
    def __init__(self, parent, title, app, player, **kw):

        self.font = app.getFont('default')
        self.tkfont = tkinter_font.Font(parent, self.font)
        style = ttk.Style(parent)
        heading_font = style.lookup('Heading', 'font')  # treeview heading
        self.heading_tkfont = tkinter_font.Font(parent, heading_font)
        self.font_metrics = self.tkfont.metrics()

        self.CHAR_H = self.font_metrics['linespace']
        self.CHAR_W = self.tkfont.measure('M')

        kw = self.initKw(kw)
        title = _('Log')
        MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)

        # self.selected_game = None

        top_frame, bottom_frame = self.createFrames(kw)
        notebook = ttk.Notebook(top_frame)
        notebook.pack(expand=True, fill='both', padx=10, pady=10)

        self.notebook_tabs = []

        full_frame = FullLogFrame(self, notebook, app, player)
        notebook.add(full_frame, text=_('Full log'))
        self.notebook_tabs.append(full_frame._w)

        session_frame = SessionLogFrame(self, notebook, app, player)
        notebook.add(session_frame, text=_('Session log'))
        self.notebook_tabs.append(session_frame._w)

        notebook.select(LogDialog.SELECTED_TAB)
        #  bind(notebook, '<<NotebookTabChanged>>', self.tabChanged)

        self.notebook = notebook

        focus = self.createButtons(bottom_frame, kw)
        # self.tabChanged()               # configure buttons state
        self.mainloop(focus, kw.timeout)
Exemplo n.º 9
0
 def createThemesMenu(self, menu):
     submenu = MfxMenu(menu, label=n_("Set t&heme"))
     all_themes = list(ttk.Style(self.top).theme_names())
     all_themes.sort()
     #
     tn = {
         'default': n_('Default'),
         'classic': n_('Classic'),
         'alt': n_('Revitalized'),
         'winnative': n_('Windows native'),
         'xpnative': n_('XP Native'),
         'aqua': n_('Aqua'),
     }
     for t in all_themes:
         try:
             n = tn[t]
         except KeyError:
             n = t.capitalize()
         submenu.add_radiobutton(label=n,
                                 variable=self.tkopt.theme,
                                 value=t,
                                 command=self.mOptTheme)
Exemplo n.º 10
0
def init_root_window(root, app):

    base_init_root_window(root, app)

    #         if TOOLKIT == 'tk':
    #             window.wm_iconbitmap("@"+filename)
    #             window.wm_iconmask("@"+filename)

    # root.self.wm_maxsize(9999, 9999) # unlimited
    if TOOLKIT == 'gtk':
        pass
    elif TOOLKIT == 'kivy':
        pass
    elif USE_TILE:
        f = os.path.join(app.dataloader.dir, 'tcl', 'menu8.4.tcl')
        if os.path.exists(f):
            try:
                root.tk.evalfile(f)
            except Exception:
                traceback.print_exc()
        f = 'clrpick8.5.tcl'
        f = os.path.join(app.dataloader.dir, 'tcl', f)
        if os.path.exists(f):
            try:
                root.tk.evalfile(f)
            except Exception:
                traceback.print_exc()
        f = 'fsdialog8.5.tcl'
        f = os.path.join(app.dataloader.dir, 'tcl', f)
        if os.path.exists(f):
            try:
                root.tk.evalfile(f)
            except Exception:
                traceback.print_exc()
            else:
                from six.moves import tkinter_tkfiledialog
                tkinter_tkfiledialog.Open.command = 'ttk::getOpenFile'
                tkinter_tkfiledialog.SaveAs.command = 'ttk::getSaveFile'
                tkinter_tkfiledialog.Directory.command = 'ttk::chooseDirectory'

        style = ttk.Style(root)
        color = style.lookup('.', 'background')
        if color:
            root.tk_setPalette(color)

        root.option_add('*Menu.borderWidth', 1, 60)
        root.option_add('*Menu.activeBorderWidth', 1, 60)
        color = style.lookup('.', 'background', ['active'])
        if color:
            root.option_add('*Menu.activeBackground', color, 60)

        root.option_add('*Listbox.background', 'white', 60)
        root.option_add('*Listbox.foreground', 'black', 60)
        root.option_add('*Text.background', 'white', 60)
        root.option_add('*Text.foreground', 'black', 60)
        root.option_add('*selectForeground', 'white', 60)
        root.option_add('*selectBackground', '#0a5f89', 60)
        root.option_add('*inactiveSelectBackground', '#0a5f89', 60)  # Tk-8.5

        color = style.lookup('TEntry', 'selectbackground', ['focus'])
        if color:
            root.option_add('*selectBackground', color, 60)
            root.option_add('*inactiveSelectBackground', color, 60)
        color = style.lookup('TEntry', 'selectforeground', ['focus'])
        if color:
            root.option_add('*selectForeground', color, 60)

        root.option_add('*selectBorderWidth', 0, 60)

        font = root.option_get('font', TITLE)
        if font:
            # use font from xrdb
            fn = get_font_name(font)
            if fn:
                # root.option_add('*font', font)
                style.configure('.', font=font)
                app.opt.fonts['default'] = fn
                # treeview heading
                f = root.tk.splitlist(root.tk.call('font', 'actual', fn))
                root.tk.call('font', 'configure', 'TkHeadingFont', *f)
        else:
            # use font from ttk settings
            font = style.lookup('.', 'font')
            if font:
                fn = get_font_name(font)
                if fn:
                    root.option_add('*font', font)
                    app.opt.fonts['default'] = fn
        if app.opt.tile_theme == 'clam':
            style.configure('TLabelframe',
                            labeloutside=False,
                            labelmargins=(8, 0, 8, 0))

    #
    else:
        root.option_add('*Entry.background', 'white', 60)
        root.option_add('*Entry.foreground', 'black', 60)
        root.option_add('*Listbox.background', 'white', 60)
        root.option_add('*Listbox.foreground', 'black', 60)
        root.option_add('*Text.background', 'white', 60)
        root.option_add('*Text.foreground', 'black', 60)
        root.option_add('*selectForeground', 'white', 60)
        root.option_add('*selectBackground', '#0a5f89', 60)
        root.option_add('*inactiveSelectBackground', '#0a5f89', 60)  # Tk-8.5
        root.option_add('*selectBorderWidth', 0, 60)
        # root.option_add('*borderWidth', '1', 50)
        # root.option_add('*Button.borderWidth', '1', 50)
        root.option_add('*Scrollbar.elementBorderWidth', 1, 60)
        root.option_add('*Scrollbar.borderWidth', 1, 60)
        root.option_add('*Menu.borderWidth', 1, 60)
        root.option_add('*Menu.activeBorderWidth', 1, 60)
        # root.option_add('*Button.HighlightBackground', '#595d59')
        # root.option_add('*Button.HighlightThickness', '1')
        font = root.option_get('font', TITLE)
        if font:
            fn = get_font_name(font)
            app.opt.fonts['default'] = fn
        else:
            root.option_add('*font', 'helvetica 12', 60)
            app.opt.fonts['default'] = ('helvetica', 12, 'roman', 'normal')