Esempio n. 1
0
    def test_map_custom_copy(self):
        style = self.style

        curr_theme = self.style.theme_use()
        self.addCleanup(self.style.theme_use, curr_theme)
        for theme in self.style.theme_names():
            self.style.theme_use(theme)
            for name in CLASS_NAMES:
                default = style.map(name)
                if not default:
                    continue
                with self.subTest(theme=theme, name=name):
                    if support.verbose >= 2:
                        print('map', theme, name, default)
                    if (theme in ('vista', 'xpnative')
                            and sys.getwindowsversion()[:2] == (6, 1)):
                        # Fails on the Windows 7 buildbot
                        continue
                    newname = f'C.{name}'
                    self.assertEqual(style.map(newname), {})
                    style.map(newname, **default)
                    if theme == 'alt' and name == '.' and get_tk_patchlevel() < (8, 6, 1):
                        default['embossed'] = [('disabled', '1')]
                    self.assertEqual(style.map(newname), default)
                    for key, value in default.items():
                        self.assertEqual(style.map(newname, key), value)
Esempio n. 2
0
 def test_paneconfigure_width(self):
     p, b, c = self.create2()
     self.check_paneconfigure(p,
                              b,
                              'width',
                              10,
                              10,
                              stringify=get_tk_patchlevel() < (8, 5, 11))
     self.check_paneconfigure_bad(p, b, 'width',
                                  'bad screen distance "badValue"')
Esempio n. 3
0
 def test_tabs(self):
     widget = self.create()
     if get_tk_patchlevel() < (8, 5, 11):
         self.checkParam(widget, "tabs", (10.2, 20.7, "1i", "2i"), expected=("10.2", "20.7", "1i", "2i"))
     else:
         self.checkParam(widget, "tabs", (10.2, 20.7, "1i", "2i"))
     self.checkParam(widget, "tabs", "10.2 20.7 1i 2i", expected=("10.2", "20.7", "1i", "2i"))
     self.checkParam(widget, "tabs", "2c left 4c 6c center", expected=("2c", "left", "4c", "6c", "center"))
     self.checkInvalidParam(
         widget, "tabs", "spam", errmsg='bad screen distance "spam"', keep_orig=tcl_version >= (8, 5)
     )
Esempio n. 4
0
 def test_tabs(self):
     widget = self.create()
     if get_tk_patchlevel() < (8, 5, 11):
         self.checkParam(widget, 'tabs', (10.2, 20.7, '1i', '2i'),
             expected=('10.2', '20.7', '1i', '2i'))
     else:
         self.checkParam(widget, 'tabs', (10.2, 20.7, '1i', '2i'))
     self.checkParam(widget, 'tabs', '10.2 20.7 1i 2i', expected=('10.2',
         '20.7', '1i', '2i'))
     self.checkParam(widget, 'tabs', '2c left 4c 6c center', expected=(
         '2c', 'left', '4c', '6c', 'center'))
     self.checkInvalidParam(widget, 'tabs', 'spam', errmsg=
         'bad screen distance "spam"', keep_orig=tcl_version >= (8, 5))
Esempio n. 5
0
 def test_tabs(self):
     widget = self.create()
     if get_tk_patchlevel() < (8, 5, 11):
         self.checkParam(widget, 'tabs', (10.2, 20.7, '1i', '2i'),
                         expected=('10.2', '20.7', '1i', '2i'))
     else:
         self.checkParam(widget, 'tabs', (10.2, 20.7, '1i', '2i'))
     self.checkParam(widget, 'tabs', '10.2 20.7 1i 2i',
                     expected=('10.2', '20.7', '1i', '2i'))
     self.checkParam(widget, 'tabs', '2c left 4c 6c center',
                     expected=('2c', 'left', '4c', '6c', 'center'))
     self.checkInvalidParam(widget, 'tabs', 'spam',
                            errmsg='bad screen distance "spam"',
                            keep_orig=tcl_version >= (8, 5))
Esempio n. 6
0
# Common tests for test_tkinter/test_widgets.py and test_ttk/test_widgets.py

import unittest
import sys
import tkinter
from tkinter.ttk import setup_master, Scale
from tkinter.test.support import (tcl_version, requires_tcl, get_tk_patchlevel,
                                  pixels_conv, tcl_obj_eq)
import test.support

noconv = False
if get_tk_patchlevel() < (8, 5, 11):
    noconv = str

pixels_round = round
if get_tk_patchlevel()[:3] == (8, 5, 11):
    # Issue #19085: Workaround a bug in Tk
    # http://core.tcl.tk/tk/info/3497848
    pixels_round = int

_sentinel = object()


class AbstractWidgetTest:
    _conv_pixels = staticmethod(pixels_round)
    _conv_pad_pixels = None
    wantobjects = True

    def setUp(self):
        self.root = setup_master()
        self.scaling = float(self.root.call('tk', 'scaling'))
Esempio n. 7
0
 def test_paneconfigure_width(self):
     p, b, c = self.create2()
     self.check_paneconfigure(p, b, 'width', 10, 10,
                              stringify=get_tk_patchlevel() < (8, 5, 11))
     self.check_paneconfigure_bad(p, b, 'width',
                                  'bad screen distance "badValue"')
Esempio n. 8
0
# Common tests for test_tkinter/test_widgets.py and test_ttk/test_widgets.py

import unittest
import sys
import tkinter
from tkinter.ttk import setup_master, Scale
from tkinter.test.support import (tcl_version, requires_tcl, get_tk_patchlevel,
                                  pixels_conv, tcl_obj_eq)
import test.support


noconv = False
if get_tk_patchlevel() < (8, 5, 11):
    noconv = str

pixels_round = round
if get_tk_patchlevel()[:3] == (8, 5, 11):
    # Issue #19085: Workaround a bug in Tk
    # http://core.tcl.tk/tk/info/3497848
    pixels_round = int


_sentinel = object()

class AbstractWidgetTest:
    _conv_pixels = staticmethod(pixels_round)
    _conv_pad_pixels = None
    wantobjects = True

    def setUp(self):
        self.root = setup_master()
Esempio n. 9
0
 def test_from(self):
     widget = self.create()
     conv = False if get_tk_patchlevel() >= (8, 6, 10) else float_round
     self.checkFloatParam(widget, 'from', 100, 14.9, 15.1, conv=conv)