Guilherme Polo | 9de29af | 2009-01-28 20:40:48 +0000 | [diff] [blame] | 1 | import os |
R. David Murray | a21e4ca | 2009-03-31 23:16:50 +0000 | [diff] [blame] | 2 | import unittest |
| 3 | from test import support |
| 4 | |
| 5 | # Skip this test if _tkinter wasn't built. |
| 6 | support.import_module('_tkinter') |
| 7 | |
Terry Jan Reedy | 743c85a | 2013-03-16 02:37:06 -0400 | [diff] [blame] | 8 | # Make sure tkinter._fix runs to set up the environment |
| 9 | support.import_fresh_module('tkinter') |
| 10 | |
Ned Deily | 4143535 | 2011-07-03 21:56:48 -0700 | [diff] [blame] | 11 | # Skip test if tk cannot be initialized. |
| 12 | from tkinter.test.support import check_tk_availability |
| 13 | check_tk_availability() |
| 14 | |
R. David Murray | a21e4ca | 2009-03-31 23:16:50 +0000 | [diff] [blame] | 15 | from _tkinter import TclError |
Guilherme Polo | 9de29af | 2009-01-28 20:40:48 +0000 | [diff] [blame] | 16 | from tkinter import ttk |
| 17 | from tkinter.test import runtktests |
Antoine Pitrou | 560f9da | 2011-01-04 00:24:03 +0000 | [diff] [blame] | 18 | from tkinter.test.support import get_tk_root |
Guilherme Polo | 9de29af | 2009-01-28 20:40:48 +0000 | [diff] [blame] | 19 | |
| 20 | try: |
| 21 | ttk.Button() |
| 22 | except TclError as msg: |
| 23 | # assuming ttk is not available |
Benjamin Peterson | e549ead | 2009-03-28 21:42:05 +0000 | [diff] [blame] | 24 | raise unittest.SkipTest("ttk not available: %s" % msg) |
Guilherme Polo | 9de29af | 2009-01-28 20:40:48 +0000 | [diff] [blame] | 25 | |
| 26 | def test_main(enable_gui=False): |
| 27 | if enable_gui: |
| 28 | if support.use_resources is None: |
| 29 | support.use_resources = ['gui'] |
| 30 | elif 'gui' not in support.use_resources: |
| 31 | support.use_resources.append('gui') |
| 32 | |
Antoine Pitrou | 560f9da | 2011-01-04 00:24:03 +0000 | [diff] [blame] | 33 | try: |
| 34 | support.run_unittest( |
| 35 | *runtktests.get_tests(text=False, packages=['test_ttk'])) |
| 36 | finally: |
| 37 | get_tk_root().destroy() |
Guilherme Polo | 9de29af | 2009-01-28 20:40:48 +0000 | [diff] [blame] | 38 | |
| 39 | if __name__ == '__main__': |
| 40 | test_main(enable_gui=True) |