[issue24750] IDLE: Cosmetic improvements for main window

Terry J. Reedy report at bugs.python.org
Sun Aug 2 22:59:43 CEST 2015


Terry J. Reedy added the comment:

Minor nit: you import 'ttkcompat' and add 'compat'.

On to the new 'compat': the only doc for .setup_master is the docstring
"If master is not None, itself is returned. If master is None,
    the default master is returned if there is one, otherwise a new
    master is created and returned."
So if master is always passed in, it seems that the call does nothing and could be removed.

._load_tile and ._tile_loaded have no doc. As near as I can tell from
>>> r = tk.Tk()
>>> s = ttk.Scrollbar(r)  # does not set ._tile_loaded on r
>>> ttk._load_tile(r)  # ditto, None returned
with 8.5, ._load_tile does nothing and ._tile_loaded is never set. They are only used for 8.4.  Correct?  If the tile extension is loaded, then use_ttk would be set to True.  Is the tile extension fully compatible with using ttk?

I would like compat.py to consist of an initialization functions that is called exactly once, always with a Tk(), to set globals in the module.

import tkinter as tk
from tkinter import ttk

def initialize(master, ttk_wanted=True): # untested
    globals use_ttk, Scrollbar, ...

    if not ttk_wanted:
        use_ttk = False
    else:
        try:
            ttk._load_tile(master)
        except tkinter.TclError:
            use_ttk = False
        else:
            use_ttk = True

    if use_ttk:
        from ttk import Scrollbar, ...
    else:
        from tk import Scroolbar, ...

Initialize would normally be called when Idle starts up.  ttk.wanted could make use_ttk a user option.  Initialize with ttk_wanted True/False would be used for testing.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24750>
_______________________________________


More information about the Python-bugs-list mailing list