• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1import unittest
2from test import support
3
4# Skip this test if _tkinter wasn't built.
5support.import_module('_tkinter')
6
7# Skip test if tk cannot be initialized.
8support.requires('gui')
9
10import tkinter
11from _tkinter import TclError
12from tkinter import ttk
13from tkinter.test import runtktests
14
15root = None
16try:
17    root = tkinter.Tk()
18    button = ttk.Button(root)
19    button.destroy()
20    del button
21except TclError as msg:
22    # assuming ttk is not available
23    raise unittest.SkipTest("ttk not available: %s" % msg)
24finally:
25    if root is not None:
26        root.destroy()
27    del root
28
29def test_main():
30    support.run_unittest(
31            *runtktests.get_tests(text=False, packages=['test_ttk']))
32
33if __name__ == '__main__':
34    test_main()
35