import enum
import sys
+import types
import _tkinter # If this fails your Python may not be configured for Tk
TclError = _tkinter.TclError
from tkinter.constants import *
import re
-
wantobjects = 1
TkVersion = float(_tkinter.TK_VERSION)
root.mainloop()
+__all__ = [name for name, obj in globals().items()
+ if not name.startswith('_') and not isinstance(obj, types.ModuleType)
+ and name not in {'wantobjects'}]
+
if __name__ == '__main__':
_test()
from tkinter.commondialog import Dialog
+__all__ = ["Chooser", "askcolor"]
+
#
# color chooser class
# written by Fredrik Lundh, May 1997
#
-from tkinter import *
+__all__ = ["Dialog"]
+
+from tkinter import Frame
class Dialog:
- command = None
+ command = None
def __init__(self, master=None, **options):
- self.master = master
+ self.master = master
self.options = options
if not master and options.get('parent'):
self.master = options['parent']
# dialog.py -- Tkinter interface to the tk_dialog script.
-from tkinter import *
-from tkinter import _cnfmerge
+from tkinter import _cnfmerge, Widget, TclError, Button, Pack
+
+__all__ = ["Dialog"]
DIALOG_ICON = 'questhead'
"""
-
import tkinter
+__all__ = ["dnd_start", "DndHandler"]
+
# The factory function
directory dialogue available in Tk 8.3 and newer.
These interfaces were written by Fredrik Lundh, May 1997.
"""
+__all__ = ["FileDialog", "LoadFileDialog", "SaveFileDialog",
+ "Open", "SaveAs", "Directory",
+ "askopenfilename", "asksaveasfilename", "askopenfilenames",
+ "askopenfile", "askopenfiles", "asksaveasfile", "askdirectory"]
-from tkinter import *
+import fnmatch
+import os
+from tkinter import (
+ Frame, LEFT, YES, BOTTOM, Entry, TOP, Button, Tk, X,
+ Toplevel, RIGHT, Y, END, Listbox, BOTH, Scrollbar,
+)
from tkinter.dialog import Dialog
from tkinter import commondialog
-import os
-import fnmatch
-
dialogstates = {}
# written by Fredrik Lundh, February 1998
#
-__version__ = "0.9"
-
import itertools
import tkinter
+__version__ = "0.9"
+__all__ = ["NORMAL", "ROMAN", "BOLD", "ITALIC",
+ "nametofont", "Font", "families", "names"]
# weight/slant
NORMAL = "normal"
from tkinter.commondialog import Dialog
+__all__ = ["showinfo", "showwarning", "showerror",
+ "askquestion", "askokcancel", "askyesno",
+ "askyesnocancel", "askretrycancel"]
+
#
# constants
Place methods are redirected to the Frame widget however.
"""
-__all__ = ['ScrolledText']
-
from tkinter import Frame, Text, Scrollbar, Pack, Grid, Place
from tkinter.constants import RIGHT, LEFT, Y, BOTH
+__all__ = ['ScrolledText']
+
class ScrolledText(Text):
def __init__(self, master=None, **kw):
class MiscTest(AbstractTkTest, unittest.TestCase):
+ def test_all(self):
+ self.assertIn("Widget", tkinter.__all__)
+ # Check that variables from tkinter.constants are also in tkinter.__all__
+ self.assertIn("CASCADE", tkinter.__all__)
+ self.assertIsNotNone(tkinter.CASCADE)
+ # Check that sys, re, and constants are not in tkinter.__all__
+ self.assertNotIn("re", tkinter.__all__)
+ self.assertNotIn("sys", tkinter.__all__)
+ self.assertNotIn("constants", tkinter.__all__)
+ # Check that an underscored functions is not in tkinter.__all__
+ self.assertNotIn("_tkerror", tkinter.__all__)
+ # Check that wantobjects is not in tkinter.__all__
+ self.assertNotIn("wantobjects", tkinter.__all__)
+
def test_repr(self):
t = tkinter.Toplevel(self.root, name='top')
f = tkinter.Frame(t, name='child')
Shane Hathaway
Michael Haubenwallner
Janko Hauser
+Flavian Hautbois
Rycharde Hawkes
Ben Hayden
Jochen Hayek
--- /dev/null
+Make `from tkinter import *` import only the expected objects.
\ No newline at end of file