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 | |
Ned Deily | 4143535 | 2011-07-03 21:56:48 -0700 | [diff] [blame] | 8 | # Skip test if tk cannot be initialized. |
Zachary Ware | ceced6b | 2014-05-02 10:51:07 -0500 | [diff] [blame] | 9 | support.requires('gui') |
Ned Deily | 4143535 | 2011-07-03 21:56:48 -0700 | [diff] [blame] | 10 | |
Zachary Ware | 7dc9dea | 2015-05-22 11:36:53 -0500 | [diff] [blame] | 11 | import tkinter |
R. David Murray | a21e4ca | 2009-03-31 23:16:50 +0000 | [diff] [blame] | 12 | from _tkinter import TclError |
Guilherme Polo | 9de29af | 2009-01-28 20:40:48 +0000 | [diff] [blame] | 13 | from tkinter import ttk |
| 14 | from tkinter.test import runtktests |
Guilherme Polo | 9de29af | 2009-01-28 20:40:48 +0000 | [diff] [blame] | 15 | |
Serhiy Storchaka | d00aff2 | 2014-08-24 09:07:47 +0300 | [diff] [blame] | 16 | root = None |
Guilherme Polo | 9de29af | 2009-01-28 20:40:48 +0000 | [diff] [blame] | 17 | try: |
Serhiy Storchaka | d00aff2 | 2014-08-24 09:07:47 +0300 | [diff] [blame] | 18 | root = tkinter.Tk() |
| 19 | button = ttk.Button(root) |
| 20 | button.destroy() |
| 21 | del button |
Guilherme Polo | 9de29af | 2009-01-28 20:40:48 +0000 | [diff] [blame] | 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) |
Serhiy Storchaka | d00aff2 | 2014-08-24 09:07:47 +0300 | [diff] [blame] | 25 | finally: |
| 26 | if root is not None: |
| 27 | root.destroy() |
| 28 | del root |
Guilherme Polo | 9de29af | 2009-01-28 20:40:48 +0000 | [diff] [blame] | 29 | |
Zachary Ware | 66f2928 | 2014-06-02 16:01:29 -0500 | [diff] [blame] | 30 | def test_main(): |
Serhiy Storchaka | d00aff2 | 2014-08-24 09:07:47 +0300 | [diff] [blame] | 31 | support.run_unittest( |
| 32 | *runtktests.get_tests(text=False, packages=['test_ttk'])) |
Guilherme Polo | 9de29af | 2009-01-28 20:40:48 +0000 | [diff] [blame] | 33 | |
| 34 | if __name__ == '__main__': |
Zachary Ware | 66f2928 | 2014-06-02 16:01:29 -0500 | [diff] [blame] | 35 | test_main() |