blob: 462665db5f3e7512602d370a0740e6ee2f3134ec [file] [log] [blame]
R. David Murraya21e4ca2009-03-31 23:16:50 +00001import unittest
2from test import support
3
4# Skip this test if _tkinter wasn't built.
5support.import_module('_tkinter')
6
Ned Deily41435352011-07-03 21:56:48 -07007# Skip test if tk cannot be initialized.
Zachary Warececed6b2014-05-02 10:51:07 -05008support.requires('gui')
Ned Deily41435352011-07-03 21:56:48 -07009
Zachary Ware7dc9dea2015-05-22 11:36:53 -050010import tkinter
R. David Murraya21e4ca2009-03-31 23:16:50 +000011from _tkinter import TclError
Guilherme Polo9de29af2009-01-28 20:40:48 +000012from tkinter import ttk
13from tkinter.test import runtktests
Guilherme Polo9de29af2009-01-28 20:40:48 +000014
Serhiy Storchakad00aff22014-08-24 09:07:47 +030015root = None
Guilherme Polo9de29af2009-01-28 20:40:48 +000016try:
Serhiy Storchakad00aff22014-08-24 09:07:47 +030017 root = tkinter.Tk()
18 button = ttk.Button(root)
19 button.destroy()
20 del button
Guilherme Polo9de29af2009-01-28 20:40:48 +000021except TclError as msg:
22 # assuming ttk is not available
Benjamin Petersone549ead2009-03-28 21:42:05 +000023 raise unittest.SkipTest("ttk not available: %s" % msg)
Serhiy Storchakad00aff22014-08-24 09:07:47 +030024finally:
25 if root is not None:
26 root.destroy()
27 del root
Guilherme Polo9de29af2009-01-28 20:40:48 +000028
Zachary Ware66f29282014-06-02 16:01:29 -050029def test_main():
Serhiy Storchakad00aff22014-08-24 09:07:47 +030030 support.run_unittest(
31 *runtktests.get_tests(text=False, packages=['test_ttk']))
Guilherme Polo9de29af2009-01-28 20:40:48 +000032
33if __name__ == '__main__':
Zachary Ware66f29282014-06-02 16:01:29 -050034 test_main()