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 | |
| 8 | from _tkinter import TclError |
Guilherme Polo | 9de29af | 2009-01-28 20:40:48 +0000 | [diff] [blame] | 9 | from tkinter import ttk |
| 10 | from tkinter.test import runtktests |
Antoine Pitrou | 560f9da | 2011-01-04 00:24:03 +0000 | [diff] [blame] | 11 | from tkinter.test.support import get_tk_root |
Guilherme Polo | 9de29af | 2009-01-28 20:40:48 +0000 | [diff] [blame] | 12 | |
| 13 | try: |
| 14 | ttk.Button() |
| 15 | except TclError as msg: |
| 16 | # assuming ttk is not available |
Benjamin Peterson | e549ead | 2009-03-28 21:42:05 +0000 | [diff] [blame] | 17 | raise unittest.SkipTest("ttk not available: %s" % msg) |
Guilherme Polo | 9de29af | 2009-01-28 20:40:48 +0000 | [diff] [blame] | 18 | |
| 19 | def test_main(enable_gui=False): |
| 20 | if enable_gui: |
| 21 | if support.use_resources is None: |
| 22 | support.use_resources = ['gui'] |
| 23 | elif 'gui' not in support.use_resources: |
| 24 | support.use_resources.append('gui') |
| 25 | |
Antoine Pitrou | 560f9da | 2011-01-04 00:24:03 +0000 | [diff] [blame] | 26 | try: |
| 27 | support.run_unittest( |
| 28 | *runtktests.get_tests(text=False, packages=['test_ttk'])) |
| 29 | finally: |
| 30 | get_tk_root().destroy() |
Guilherme Polo | 9de29af | 2009-01-28 20:40:48 +0000 | [diff] [blame] | 31 | |
| 32 | if __name__ == '__main__': |
| 33 | test_main(enable_gui=True) |