""" Central place for flags, variables, small utilities etc. that determine how Tk is used throughout IDLE. """ import tkinter # Should IDLE use themed-Tk widgets (ttk)? # Callers can set to False to force non-ttk widgets even when ttk is present. using_ttk = False # What windowing system are we using? windowing_system = None # will be set to 'aqua', 'win32', or 'x11' # Do we need to include a Sizegrip widget? Yes on some older systems. need_sizegrip = False # Cursor to use to indicate clickable things, like links - usually a hand clickable_cursor = None class Spinbox(tkinter.Spinbox): """ A ttk::spinbox was added in Tk 8.5.9; use it if present, otherwise use a spinbox. Note the two have different options and methods, so this only works for the basics. """ def __init__(self, master=None, cnf={}, **kw): hasTtkSpinbox = master and master.tk.call('info', 'commands', 'ttk::spinbox') base = 'ttk::spinbox' if hasTtkSpinbox else 'spinbox' Widget.__init__(self, master, base, cnf, kw) # Initialization our common variables; we need to start up a temporary # Tk instance to do so root = tkinter.Tk() # If this fails, no meaningful recovery try: from tkinter import ttk b = tkinter.ttk.Button(root) using_ttk = True except Exception: pass windowing_system = root.call('tk', 'windowingsystem') clickable_cursor = 'pointinghand' if windowing_system == 'aqua' else 'hand2' if windowing_system == 'aqua': import platform v, _, _ = platform.mac_ver() major, minor = v.split('.')[:2] if (int(major) == 10 and int(minor) < 7): need_sizegrip = True root.after_idle(root.destroy) # 'after' avoids some background errors