blob: 490e72337f24c20576953e6fae72667ec5c17d85 [file] [log] [blame]
Guilherme Polo9de29af2009-01-28 20:40:48 +00001import os
R. David Murraya21e4ca2009-03-31 23:16:50 +00002import unittest
3from test import support
4
5# Skip this test if _tkinter wasn't built.
6support.import_module('_tkinter')
7
Ned Deily41435352011-07-03 21:56:48 -07008# Skip test if tk cannot be initialized.
Zachary Warececed6b2014-05-02 10:51:07 -05009support.requires('gui')
Ned Deily41435352011-07-03 21:56:48 -070010
Zachary Ware7dc9dea2015-05-22 11:36:53 -050011import tkinter
R. David Murraya21e4ca2009-03-31 23:16:50 +000012from _tkinter import TclError
Guilherme Polo9de29af2009-01-28 20:40:48 +000013from tkinter import ttk
14from tkinter.test import runtktests
Guilherme Polo9de29af2009-01-28 20:40:48 +000015
Serhiy Storchakad00aff22014-08-24 09:07:47 +030016root = None
Guilherme Polo9de29af2009-01-28 20:40:48 +000017try:
Serhiy Storchakad00aff22014-08-24 09:07:47 +030018 root = tkinter.Tk()
19 button = ttk.Button(root)
20 button.destroy()
21 del button
Guilherme Polo9de29af2009-01-28 20:40:48 +000022except TclError as msg:
23 # assuming ttk is not available
Benjamin Petersone549ead2009-03-28 21:42:05 +000024 raise unittest.SkipTest("ttk not available: %s" % msg)
Serhiy Storchakad00aff22014-08-24 09:07:47 +030025finally:
26 if root is not None:
27 root.destroy()
28 del root
Guilherme Polo9de29af2009-01-28 20:40:48 +000029
Zachary Ware66f29282014-06-02 16:01:29 -050030def test_main():
Serhiy Storchakad00aff22014-08-24 09:07:47 +030031 support.run_unittest(
32 *runtktests.get_tests(text=False, packages=['test_ttk']))
Guilherme Polo9de29af2009-01-28 20:40:48 +000033
34if __name__ == '__main__':
Zachary Ware66f29282014-06-02 16:01:29 -050035 test_main()