Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
3-manifolds
GitHub Repository: 3-manifolds/Sage_macOS
Path: blob/main/Sage_base/sage/python/patches/tkinter.patch
242 views
1
diff -ru Orig/Lib/test/test_tkinter/test_misc.py Python-3.13.1/Lib/test/test_tkinter/test_misc.py
2
--- Orig/Lib/test/test_tkinter/test_misc.py 2024-12-03 11:59:52
3
+++ Python-3.13.1/Lib/test/test_tkinter/test_misc.py 2024-12-12 12:57:15
4
@@ -66,9 +66,10 @@
5
f.tk_busy_forget()
6
self.assertFalse(f.tk_busy_status())
7
self.assertFalse(f.tk_busy_current())
8
- with self.assertRaisesRegex(TclError, "can't find busy window"):
9
+ errmsg = r"can(no|')t find busy window.*"
10
+ with self.assertRaisesRegex(TclError, errmsg):
11
f.tk_busy_configure()
12
- with self.assertRaisesRegex(TclError, "can't find busy window"):
13
+ with self.assertRaisesRegex(TclError, errmsg):
14
f.tk_busy_forget()
15
16
@requires_tk(8, 6, 6)
17
@@ -87,7 +88,8 @@
18
self.assertEqual(f.tk_busy_configure('cursor')[4], 'heart')
19
20
f.tk_busy_forget()
21
- with self.assertRaisesRegex(TclError, "can't find busy window"):
22
+ errmsg = r"can(no|')t find busy window.*"
23
+ with self.assertRaisesRegex(TclError, errmsg):
24
f.tk_busy_cget('cursor')
25
26
def test_tk_setPalette(self):
27
diff -ru Orig/Lib/test/test_tkinter/test_widgets.py Python-3.13.1/Lib/test/test_tkinter/test_widgets.py
28
--- Orig/Lib/test/test_tkinter/test_widgets.py 2024-12-03 11:59:52
29
+++ Python-3.13.1/Lib/test/test_tkinter/test_widgets.py 2024-12-12 12:57:15
30
@@ -7,9 +7,13 @@
31
from test.test_tkinter.support import (requires_tk, tk_version,
32
get_tk_patchlevel, widget_eq,
33
AbstractDefaultRootTest)
34
+
35
from test.test_tkinter.widget_tests import (
36
- add_standard_options,
37
- AbstractWidgetTest, StandardOptionsTests, IntegerSizeTests, PixelSizeTests)
38
+ add_configure_tests,
39
+ AbstractWidgetTest,
40
+ StandardOptionsTests,
41
+ IntegerSizeTests,
42
+ PixelSizeTests)
43
44
requires('gui')
45
46
@@ -20,9 +24,17 @@
47
def float_round(x):
48
return float(round(x))
49
50
-
51
class AbstractToplevelTest(AbstractWidgetTest, PixelSizeTests):
52
- _conv_pad_pixels = False
53
+ if tk_version < (9, 0):
54
+ _no_round = {'padx', 'pady'}
55
+ else:
56
+ _no_round = {'borderwidth', 'height', 'highlightthickness', 'padx',
57
+ 'pady', 'width'}
58
+ if tk_version < (9, 0):
59
+ _clipped = {'highlightthickness'}
60
+ else:
61
+ _clipped = {'borderwidth', 'height', 'highlightthickness', 'padx',
62
+ 'pady', 'width'}
63
64
def test_configure_class(self):
65
widget = self.create()
66
@@ -58,7 +70,7 @@
67
self.assertEqual(widget2['visual'], 'default')
68
69
70
-@add_standard_options(StandardOptionsTests)
71
+@add_configure_tests(StandardOptionsTests)
72
class ToplevelTest(AbstractToplevelTest, unittest.TestCase):
73
OPTIONS = (
74
'background', 'backgroundimage', 'borderwidth',
75
@@ -101,7 +113,7 @@
76
self.assertEqual(widget2['use'], wid)
77
78
79
-@add_standard_options(StandardOptionsTests)
80
+@add_configure_tests(StandardOptionsTests)
81
class FrameTest(AbstractToplevelTest, unittest.TestCase):
82
OPTIONS = (
83
'background', 'backgroundimage', 'borderwidth',
84
@@ -109,12 +121,17 @@
85
'highlightbackground', 'highlightcolor', 'highlightthickness',
86
'padx', 'pady', 'relief', 'takefocus', 'tile', 'visual', 'width',
87
)
88
+ if tk_version < (9, 0):
89
+ _no_round = {'padx', 'pady'}
90
+ else:
91
+ _no_round = {'borderwidth', 'height', 'highlightthickness', 'padx',
92
+ 'pady', 'width'}
93
94
def create(self, **kwargs):
95
return tkinter.Frame(self.root, **kwargs)
96
97
98
-@add_standard_options(StandardOptionsTests)
99
+@add_configure_tests(StandardOptionsTests)
100
class LabelFrameTest(AbstractToplevelTest, unittest.TestCase):
101
OPTIONS = (
102
'background', 'borderwidth',
103
@@ -124,6 +141,11 @@
104
'labelanchor', 'labelwidget', 'padx', 'pady', 'relief',
105
'takefocus', 'text', 'visual', 'width',
106
)
107
+ if tk_version < (9, 0):
108
+ _no_round = {'padx', 'pady'}
109
+ else:
110
+ _no_round = {'borderwidth', 'height', 'highlightthickness', 'padx',
111
+ 'pady', 'width'}
112
113
def create(self, **kwargs):
114
return tkinter.LabelFrame(self.root, **kwargs)
115
@@ -141,15 +163,16 @@
116
self.checkParam(widget, 'labelwidget', label, expected='.foo')
117
label.destroy()
118
119
-
120
+# Label, Button, Checkbutton, Radiobutton, MenuButton
121
class AbstractLabelTest(AbstractWidgetTest, IntegerSizeTests):
122
- _conv_pixels = False
123
- _clip_highlightthickness = tk_version >= (8, 7)
124
- _clip_pad = tk_version >= (8, 7)
125
- _clip_borderwidth = tk_version >= (8, 7)
126
+ _rounds_pixels = False
127
+ if tk_version < (9, 0):
128
+ _clipped = {}
129
+ else:
130
+ _clipped = {'borderwidth', 'insertborderwidth', 'highlightthickness',
131
+ 'padx', 'pady'}
132
133
-
134
-@add_standard_options(StandardOptionsTests)
135
+@add_configure_tests(StandardOptionsTests)
136
class LabelTest(AbstractLabelTest, unittest.TestCase):
137
OPTIONS = (
138
'activebackground', 'activeforeground', 'anchor',
139
@@ -165,7 +188,7 @@
140
return tkinter.Label(self.root, **kwargs)
141
142
143
-@add_standard_options(StandardOptionsTests)
144
+@add_configure_tests(StandardOptionsTests)
145
class ButtonTest(AbstractLabelTest, unittest.TestCase):
146
OPTIONS = (
147
'activebackground', 'activeforeground', 'anchor',
148
@@ -186,7 +209,7 @@
149
self.checkEnumParam(widget, 'default', 'active', 'disabled', 'normal')
150
151
152
-@add_standard_options(StandardOptionsTests)
153
+@add_configure_tests(StandardOptionsTests)
154
class CheckbuttonTest(AbstractLabelTest, unittest.TestCase):
155
OPTIONS = (
156
'activebackground', 'activeforeground', 'anchor',
157
@@ -240,8 +263,7 @@
158
b2.deselect()
159
self.assertEqual(v.get(), 0)
160
161
-
162
-@add_standard_options(StandardOptionsTests)
163
+@add_configure_tests(StandardOptionsTests)
164
class RadiobuttonTest(AbstractLabelTest, unittest.TestCase):
165
OPTIONS = (
166
'activebackground', 'activeforeground', 'anchor',
167
@@ -264,7 +286,7 @@
168
self.checkParams(widget, 'value', 1, 2.3, '', 'any string')
169
170
171
-@add_standard_options(StandardOptionsTests)
172
+@add_configure_tests(StandardOptionsTests)
173
class MenubuttonTest(AbstractLabelTest, unittest.TestCase):
174
OPTIONS = (
175
'activebackground', 'activeforeground', 'anchor',
176
@@ -277,10 +299,11 @@
177
'takefocus', 'text', 'textvariable',
178
'underline', 'width', 'wraplength',
179
)
180
- _conv_pixels = round
181
- _clip_highlightthickness = True
182
- _clip_pad = True
183
- _clip_borderwidth = False
184
+ _rounds_pixels = (tk_version < (9, 0))
185
+ if tk_version < (9, 0):
186
+ _clipped = {'highlightthickness', 'padx', 'pady'}
187
+ else:
188
+ _clipped ={ 'insertborderwidth', 'highlightthickness', 'padx', 'pady'}
189
190
def create(self, **kwargs):
191
return tkinter.Menubutton(self.root, **kwargs)
192
@@ -298,7 +321,10 @@
193
widget = self.create()
194
image = tkinter.PhotoImage(master=self.root, name='image1')
195
self.checkParam(widget, 'image', image, conv=str)
196
- errmsg = 'image "spam" doesn\'t exist'
197
+ if tk_version < (9, 0):
198
+ errmsg = 'image "spam" doesn\'t exist'
199
+ else:
200
+ errmsg = 'image "spam" does not exist'
201
with self.assertRaises(tkinter.TclError) as cm:
202
widget['image'] = 'spam'
203
if errmsg is not None:
204
@@ -328,9 +354,15 @@
205
with self.assertRaisesRegex(TclError, r"^unknown option -image$"):
206
tkinter.OptionMenu(self.root, None, 'b', image='')
207
208
-
209
-@add_standard_options(IntegerSizeTests, StandardOptionsTests)
210
+@add_configure_tests(IntegerSizeTests, StandardOptionsTests)
211
class EntryTest(AbstractWidgetTest, unittest.TestCase):
212
+ _rounds_pixels = (tk_version < (9, 0))
213
+ if tk_version < (9, 0):
214
+ _clipped = {'highlightthickness'}
215
+ else:
216
+ _clipped = {'highlightthickness', 'borderwidth', 'insertborderwidth',
217
+ 'selectborderwidth'}
218
+
219
OPTIONS = (
220
'background', 'borderwidth', 'cursor',
221
'disabledbackground', 'disabledforeground',
222
@@ -355,16 +387,23 @@
223
def test_configure_insertborderwidth(self):
224
widget = self.create(insertwidth=100)
225
self.checkPixelsParam(widget, 'insertborderwidth',
226
- 0, 1.3, 2.6, 6, -2, '10p')
227
+ 0, 1.3, 2.6, 6, '10p')
228
+ self.checkParam(widget, 'insertborderwidth', -2)
229
# insertborderwidth is bounded above by a half of insertwidth.
230
- self.checkParam(widget, 'insertborderwidth', 60, expected=100//2)
231
+ expected = 100 // 2 if tk_version < (9, 0) else 60
232
+ self.checkParam(widget, 'insertborderwidth', 60, expected=expected)
233
234
def test_configure_insertwidth(self):
235
widget = self.create()
236
self.checkPixelsParam(widget, 'insertwidth', 1.3, 3.6, '10p')
237
- self.checkParam(widget, 'insertwidth', 0.1, expected=2)
238
- self.checkParam(widget, 'insertwidth', -2, expected=2)
239
- self.checkParam(widget, 'insertwidth', 0.9, expected=1)
240
+ if tk_version < (9, 0):
241
+ self.checkParam(widget, 'insertwidth', 0.1, expected=2)
242
+ self.checkParam(widget, 'insertwidth', -2, expected=2)
243
+ self.checkParam(widget, 'insertwidth', 0.9, expected=1)
244
+ else:
245
+ self.checkParam(widget, 'insertwidth', 0.1)
246
+ self.checkParam(widget, 'insertwidth', -2, expected=0)
247
+ self.checkParam(widget, 'insertwidth', 0.9)
248
249
def test_configure_invalidcommand(self):
250
widget = self.create()
251
@@ -422,7 +461,7 @@
252
widget.selection_adjust(0)
253
254
255
-@add_standard_options(StandardOptionsTests)
256
+@add_configure_tests(StandardOptionsTests)
257
class SpinboxTest(EntryTest, unittest.TestCase):
258
OPTIONS = (
259
'activebackground', 'background', 'borderwidth',
260
@@ -559,7 +598,7 @@
261
self.assertEqual(widget.selection_element(), "buttondown")
262
263
264
-@add_standard_options(StandardOptionsTests)
265
+@add_configure_tests(StandardOptionsTests)
266
class TextTest(AbstractWidgetTest, unittest.TestCase):
267
OPTIONS = (
268
'autoseparators', 'background', 'blockcursor', 'borderwidth',
269
@@ -574,6 +613,9 @@
270
'tabs', 'tabstyle', 'takefocus', 'undo', 'width', 'wrap',
271
'xscrollcommand', 'yscrollcommand',
272
)
273
+ _rounds_pixels = (tk_version < (9, 0))
274
+ _no_round = {'selectborderwidth'}
275
+ _clipped = {'highlightthickness'}
276
277
def create(self, **kwargs):
278
return tkinter.Text(self.root, **kwargs)
279
@@ -602,8 +644,10 @@
280
def test_configure_height(self):
281
widget = self.create()
282
self.checkPixelsParam(widget, 'height', 100, 101.2, 102.6, '3c')
283
- self.checkParam(widget, 'height', -100, expected=1)
284
- self.checkParam(widget, 'height', 0, expected=1)
285
+ self.checkParam(widget, 'height', -100,
286
+ expected=1 if tk_version < (9, 0) else -100)
287
+ self.checkParam(widget, 'height', 0,
288
+ expected=1 if tk_version < (9, 0) else 0 )
289
290
def test_configure_maxundo(self):
291
widget = self.create()
292
@@ -696,7 +740,7 @@
293
self.assertRaises(TypeError, widget.bbox, '1.1', 'end')
294
295
296
-@add_standard_options(PixelSizeTests, StandardOptionsTests)
297
+@add_configure_tests(PixelSizeTests, StandardOptionsTests)
298
class CanvasTest(AbstractWidgetTest, unittest.TestCase):
299
OPTIONS = (
300
'background', 'borderwidth',
301
@@ -710,8 +754,15 @@
302
'xscrollcommand', 'xscrollincrement',
303
'yscrollcommand', 'yscrollincrement', 'width',
304
)
305
-
306
- _conv_pixels = round
307
+ _rounds_pixels = True
308
+ if tk_version < (9, 0):
309
+ _noround = {}
310
+ _clipped = {'highlightthickness'}
311
+ else:
312
+ _no_round = {'borderwidth', 'height', 'highlightthickness', 'width',
313
+ 'xscrollincrement', 'yscrollincrement'}
314
+ _clipped = {'borderwidth', 'height', 'highlightthickness', 'width',
315
+ 'xscrollincrement', 'yscrollincrement'}
316
_stringify = True
317
318
def create(self, **kwargs):
319
@@ -953,7 +1004,7 @@
320
self.assertEqual(y2_2 - y1_2, y2_3 - y1_3)
321
322
323
-@add_standard_options(IntegerSizeTests, StandardOptionsTests)
324
+@add_configure_tests(IntegerSizeTests, StandardOptionsTests)
325
class ListboxTest(AbstractWidgetTest, unittest.TestCase):
326
OPTIONS = (
327
'activestyle', 'background', 'borderwidth', 'cursor',
328
@@ -965,6 +1016,11 @@
329
'selectmode', 'setgrid', 'state',
330
'takefocus', 'width', 'xscrollcommand', 'yscrollcommand',
331
)
332
+ _rounds_pixels = (tk_version < (9, 0))
333
+ if tk_version < (9, 0):
334
+ _clipped = {'highlightthickness'}
335
+ else:
336
+ _clipped = { 'borderwidth', 'highlightthickness', 'selectborderwidth'}
337
338
def create(self, **kwargs):
339
return tkinter.Listbox(self.root, **kwargs)
340
@@ -1091,7 +1147,7 @@
341
self.assertRaises(TclError, lb.get, 2.4)
342
343
344
-@add_standard_options(PixelSizeTests, StandardOptionsTests)
345
+@add_configure_tests(PixelSizeTests, StandardOptionsTests)
346
class ScaleTest(AbstractWidgetTest, unittest.TestCase):
347
OPTIONS = (
348
'activebackground', 'background', 'bigincrement', 'borderwidth',
349
@@ -1102,6 +1158,8 @@
350
'resolution', 'showvalue', 'sliderlength', 'sliderrelief', 'state',
351
'takefocus', 'tickinterval', 'to', 'troughcolor', 'variable', 'width',
352
)
353
+ _rounds_pixels = (tk_version < (9, 0))
354
+ _clipped = {'highlightthickness'}
355
default_orient = 'vertical'
356
357
def create(self, **kwargs):
358
@@ -1159,7 +1217,7 @@
359
conv=float_round)
360
361
362
-@add_standard_options(PixelSizeTests, StandardOptionsTests)
363
+@add_configure_tests(PixelSizeTests, StandardOptionsTests)
364
class ScrollbarTest(AbstractWidgetTest, unittest.TestCase):
365
OPTIONS = (
366
'activebackground', 'activerelief',
367
@@ -1170,7 +1228,14 @@
368
'repeatdelay', 'repeatinterval',
369
'takefocus', 'troughcolor', 'width',
370
)
371
- _conv_pixels = round
372
+ _rounds_pixels = True
373
+ if tk_version >= (9, 0):
374
+ _no_round = {'borderwidth', 'elementborderwidth', 'highlightthickness',
375
+ 'width'}
376
+ if tk_version < (9, 0):
377
+ _clipped = {'highlightthickness'}
378
+ else:
379
+ _clipped = {'borderwidth', 'highlightthickness', 'width'}
380
_stringify = True
381
default_orient = 'vertical'
382
383
@@ -1208,7 +1273,7 @@
384
self.assertRaises(TypeError, sb.set, 0.6, 0.7, 0.8)
385
386
387
-@add_standard_options(StandardOptionsTests)
388
+@add_configure_tests(StandardOptionsTests)
389
class PanedWindowTest(AbstractWidgetTest, unittest.TestCase):
390
OPTIONS = (
391
'background', 'borderwidth', 'cursor',
392
@@ -1219,6 +1284,15 @@
393
'sashcursor', 'sashpad', 'sashrelief', 'sashwidth',
394
'showhandle', 'width',
395
)
396
+ _rounds_pixels = True
397
+ if tk_version < (9, 0):
398
+ _no_round = {'handlesize', 'height', 'proxyborderwidth', 'sashwidth',
399
+ 'selectborderwidth', 'width'}
400
+ else:
401
+ _no_round = {'borderwidth', 'handlepad', 'handlesize', 'height',
402
+ 'proxyborderwidth', 'sashpad', 'sashwidth',
403
+ 'selectborderwidth', 'width'}
404
+ _clipped = {}
405
default_orient = 'horizontal'
406
407
def create(self, **kwargs):
408
@@ -1347,13 +1421,13 @@
409
410
def test_paneconfigure_padx(self):
411
p, b, c = self.create2()
412
- self.check_paneconfigure(p, b, 'padx', 1.3, 1)
413
+ self.check_paneconfigure(p, b, 'padx', 1.3, 1 if tk_version < (9, 0) else 1.3)
414
self.check_paneconfigure_bad(p, b, 'padx',
415
EXPECTED_SCREEN_DISTANCE_ERRMSG.format('badValue'))
416
417
def test_paneconfigure_pady(self):
418
p, b, c = self.create2()
419
- self.check_paneconfigure(p, b, 'pady', 1.3, 1)
420
+ self.check_paneconfigure(p, b, 'pady', 1.3, 1 if tk_version < (9, 0) else 1.3)
421
self.check_paneconfigure_bad(p, b, 'pady',
422
EXPECTED_SCREEN_DISTANCE_ERRMSG.format('badValue'))
423
424
@@ -1379,17 +1453,17 @@
425
EXPECTED_SCREEN_DISTANCE_OR_EMPTY_ERRMSG.format('badValue'))
426
427
428
-@add_standard_options(StandardOptionsTests)
429
+@add_configure_tests(StandardOptionsTests)
430
class MenuTest(AbstractWidgetTest, unittest.TestCase):
431
OPTIONS = (
432
'activebackground', 'activeborderwidth', 'activeforeground',
433
- 'activerelief',
434
- 'background', 'borderwidth', 'cursor',
435
+ 'activerelief', 'background', 'borderwidth', 'cursor',
436
'disabledforeground', 'font', 'foreground',
437
'postcommand', 'relief', 'selectcolor', 'takefocus',
438
'tearoff', 'tearoffcommand', 'title', 'type',
439
)
440
- _conv_pixels = False
441
+ _rounds_pixels = False
442
+ _clipped = {}
443
444
def create(self, **kwargs):
445
return tkinter.Menu(self.root, **kwargs)
446
@@ -1458,7 +1532,7 @@
447
self.assertEqual(str(m1.entrycget(1, 'variable')), str(v2))
448
449
450
-@add_standard_options(PixelSizeTests, StandardOptionsTests)
451
+@add_configure_tests(PixelSizeTests, StandardOptionsTests)
452
class MessageTest(AbstractWidgetTest, unittest.TestCase):
453
OPTIONS = (
454
'anchor', 'aspect', 'background', 'borderwidth',
455
@@ -1467,11 +1541,12 @@
456
'justify', 'padx', 'pady', 'relief',
457
'takefocus', 'text', 'textvariable', 'width',
458
)
459
- _conv_pad_pixels = False
460
- if tk_version >= (8, 7):
461
- _conv_pixels = False
462
- _clip_pad = tk_version >= (8, 7)
463
- _clip_borderwidth = tk_version >= (8, 7)
464
+ _rounds_pixels = (tk_version < (9, 0))
465
+ _no_round = {'padx', 'pady'}
466
+ if tk_version < (9, 0):
467
+ _clipped = {'highlightthickness'}
468
+ else:
469
+ _clipped = {'borderwidth', 'highlightthickness', 'padx', 'pady'}
470
471
def create(self, **kwargs):
472
return tkinter.Message(self.root, **kwargs)
473
@@ -1482,16 +1557,14 @@
474
475
def test_configure_padx(self):
476
widget = self.create()
477
- self.checkPixelsParam(widget, 'padx', 3, 4.4, 5.6, '12m',
478
- conv=self._conv_pad_pixels)
479
- expected = self._default_pixels if self._clip_pad else -2
480
+ self.checkPixelsParam(widget, 'padx', 3, 4.4, 5.6, '12m')
481
+ expected = -2 if tk_version < (9, 0) else self._default_pixels
482
self.checkParam(widget, 'padx', -2, expected=expected)
483
484
def test_configure_pady(self):
485
widget = self.create()
486
- self.checkPixelsParam(widget, 'pady', 3, 4.4, 5.6, '12m',
487
- conv=self._conv_pad_pixels)
488
- expected = self._default_pixels if self._clip_pad else -2
489
+ self.checkPixelsParam(widget, 'pady', 3, 4.4, 5.6, '12m')
490
+ expected = -2 if tk_version < (9, 0) else self._default_pixels
491
self.checkParam(widget, 'pady', -2, expected=expected)
492
493
def test_configure_width(self):
494
diff -ru Orig/Lib/test/test_tkinter/widget_tests.py Python-3.13.1/Lib/test/test_tkinter/widget_tests.py
495
--- Orig/Lib/test/test_tkinter/widget_tests.py 2024-12-03 11:59:52
496
+++ Python-3.13.1/Lib/test/test_tkinter/widget_tests.py 2024-12-12 12:57:15
497
@@ -6,17 +6,16 @@
498
pixels_conv, tcl_obj_eq)
499
import test.support
500
501
-
502
_sentinel = object()
503
504
+# Options which accept all values allowed by Tk_GetPixels
505
+# borderwidth = bd
506
+
507
class AbstractWidgetTest(AbstractTkTest):
508
- _default_pixels = '' if tk_version >= (9, 0) else -1 if tk_version >= (8, 7) else ''
509
- _conv_pixels = round
510
- _conv_pad_pixels = None
511
- _stringify = False
512
- _clip_highlightthickness = True
513
- _clip_pad = False
514
- _clip_borderwidth = False
515
+ _default_pixels = '' # Value for unset pixel options.
516
+ _rounds_pixels = True # True if some pixel options are rounded.
517
+ _no_round = {} # Pixel options which are not rounded nonetheless
518
+ _stringify = False # Whether to convert tuples to strings
519
_allow_empty_justify = False
520
521
@property
522
@@ -44,6 +43,9 @@
523
widget[name] = value
524
if expected is _sentinel:
525
expected = value
526
+ if name in self._clipped:
527
+ if not isinstance(expected, str):
528
+ expected = max(expected, 0)
529
if conv:
530
expected = conv(expected)
531
if self._stringify or not self.wantobjects:
532
@@ -140,14 +142,17 @@
533
errmsg = 'bad' + errmsg2
534
self.checkInvalidParam(widget, name, 'spam', errmsg=errmsg)
535
536
- def checkPixelsParam(self, widget, name, *values,
537
- conv=None, **kwargs):
538
- if conv is None:
539
- conv = self._conv_pixels
540
+ def checkPixelsParam(self, widget, name, *values, conv=None, **kwargs):
541
+ if not self._rounds_pixels or name in self._no_round:
542
+ conv = False
543
+ elif conv != str:
544
+ conv = round
545
for value in values:
546
expected = _sentinel
547
conv1 = conv
548
if isinstance(value, str):
549
+ if not getattr(self, '_converts_pixels', True):
550
+ conv1 = str
551
if conv1 and conv1 is not str:
552
expected = pixels_conv(value) * self.scaling
553
conv1 = round
554
@@ -172,8 +177,12 @@
555
def checkImageParam(self, widget, name):
556
image = tkinter.PhotoImage(master=self.root, name='image1')
557
self.checkParam(widget, name, image, conv=str)
558
+ if tk_version < (9, 0):
559
+ errmsg = 'image "spam" doesn\'t exist'
560
+ else:
561
+ errmsg = 'image "spam" does not exist'
562
self.checkInvalidParam(widget, name, 'spam',
563
- errmsg='image "spam" doesn\'t exist')
564
+ errmsg=errmsg)
565
widget[name] = ''
566
567
def checkVariableParam(self, widget, name, var):
568
@@ -215,31 +224,80 @@
569
print('%s.OPTIONS doesn\'t contain "%s"' %
570
(self.__class__.__name__, k))
571
572
+class PixelOptionsTests:
573
+ """Standard options that accept all formats acceptable to Tk_GetPixels.
574
575
-class StandardOptionsTests:
576
- STANDARD_OPTIONS = (
577
- 'activebackground', 'activeborderwidth', 'activeforeground', 'anchor',
578
- 'background', 'bitmap', 'borderwidth', 'compound', 'cursor',
579
- 'disabledforeground', 'exportselection', 'font', 'foreground',
580
- 'highlightbackground', 'highlightcolor', 'highlightthickness',
581
- 'image', 'insertbackground', 'insertborderwidth',
582
- 'insertofftime', 'insertontime', 'insertwidth',
583
- 'jump', 'justify', 'orient', 'padx', 'pady', 'relief',
584
- 'repeatdelay', 'repeatinterval',
585
- 'selectbackground', 'selectborderwidth', 'selectforeground',
586
- 'setgrid', 'takefocus', 'text', 'textvariable', 'troughcolor',
587
- 'underline', 'wraplength', 'xscrollcommand', 'yscrollcommand',
588
- )
589
+ In addition to numbers, these options can be set with distances
590
+ specified as a string consisting of a number followed by a single
591
+ character giving the unit of distance. The allowed units are:
592
+ millimeters ('m'), centimeters ('c'), inches ('i') or points ('p').
593
+ In Tk 9 a cget call for one of these options returns a Tcl_Obj of
594
+ type "pixels", whose string representation is the distance string
595
+ passed to configure.
596
+ """
597
+ PIXEL_OPTIONS = ('activeborderwidth', 'borderwidth', 'highlightthickness',
598
+ 'insertborderwidth', 'insertwidth', 'padx', 'pady', 'selectborderwidth')
599
600
- def test_configure_activebackground(self):
601
- widget = self.create()
602
- self.checkColorParam(widget, 'activebackground')
603
-
604
def test_configure_activeborderwidth(self):
605
widget = self.create()
606
self.checkPixelsParam(widget, 'activeborderwidth',
607
0, 1.3, 2.9, 6, -2, '10p')
608
609
+ def test_configure_borderwidth(self):
610
+ widget = self.create()
611
+ self.checkPixelsParam(widget, 'borderwidth',
612
+ 0, 1.3, 2.6, 6, '10p')
613
+ self.checkParam(widget, 'borderwidth', -2)
614
+ if 'bd' in self.OPTIONS:
615
+ self.checkPixelsParam(widget, 'bd', 0, 1.3, 2.6, 6, '10p')
616
+ self.checkParam(widget, 'bd', -2, expected=expected)
617
+
618
+ def test_configure_highlightthickness(self):
619
+ widget = self.create()
620
+ self.checkPixelsParam(widget, 'highlightthickness',
621
+ 0, 1.3, 2.6, 6, '10p')
622
+ self.checkParam(widget, 'highlightthickness', -2)
623
+
624
+ def test_configure_insertborderwidth(self):
625
+ widget = self.create()
626
+ self.checkPixelsParam(widget, 'insertborderwidth',
627
+ 0, 1.3, 2.6, 6, '10p')
628
+ self.checkParam(widget, 'insertborderwidth', -2)
629
+
630
+ def test_configure_insertwidth(self):
631
+ widget = self.create()
632
+ self.checkPixelsParam(widget, 'insertwidth', 1.3, 2.6, -2, '10p')
633
+
634
+ def test_configure_padx(self):
635
+ widget = self.create()
636
+ self.checkPixelsParam(widget, 'padx', 3, 4.4, 5.6, '12m')
637
+ self.checkParam(widget, 'padx', -2)
638
+
639
+ def test_configure_pady(self):
640
+ widget = self.create()
641
+ self.checkPixelsParam(widget, 'pady', 3, 4.4, 5.6, '12m')
642
+ self.checkParam(widget, 'pady', -2)
643
+
644
+ def test_configure_selectborderwidth(self):
645
+ widget = self.create()
646
+ self.checkPixelsParam(widget, 'selectborderwidth', 1.3, 2.6, -2, '10p')
647
+
648
+class StandardOptionsTests(PixelOptionsTests):
649
+
650
+ STANDARD_OPTIONS = ( 'activebackground', 'activeforeground',
651
+ 'anchor', 'background', 'bitmap', 'compound', 'cursor',
652
+ 'disabledforeground', 'exportselection', 'font', 'foreground',
653
+ 'highlightbackground', 'highlightcolor', 'image',
654
+ 'insertbackground', 'insertofftime', 'insertontime', 'jump',
655
+ 'justify', 'orient', 'relief', 'repeatdelay', 'repeatinterval',
656
+ 'selectbackground', 'selectforeground', 'setgrid', 'takefocus',
657
+ 'text', 'textvariable', 'troughcolor', 'underline', 'wraplength',
658
+ 'xscrollcommand', 'yscrollcommand', ) + PixelOptionsTests.PIXEL_OPTIONS
659
+
660
+ def test_configure_activebackground(self):
661
+ widget = self.create()
662
+ self.checkColorParam(widget, 'activebackground')
663
+
664
def test_configure_activeforeground(self):
665
widget = self.create()
666
self.checkColorParam(widget, 'activeforeground')
667
@@ -277,18 +335,6 @@
668
self.checkInvalidParam(widget, 'bitmap', 'spam',
669
errmsg='bitmap "spam" not defined')
670
671
- def test_configure_borderwidth(self):
672
- widget = self.create()
673
- self.checkPixelsParam(widget, 'borderwidth',
674
- 0, 1.3, 2.6, 6, '10p')
675
- expected = 0 if self._clip_borderwidth else -2
676
- self.checkParam(widget, 'borderwidth', -2, expected=expected,
677
- conv=self._conv_pixels)
678
- if 'bd' in self.OPTIONS:
679
- self.checkPixelsParam(widget, 'bd', 0, 1.3, 2.6, 6, '10p')
680
- self.checkParam(widget, 'bd', -2, expected=expected,
681
- conv=self._conv_pixels)
682
-
683
def test_configure_compound(self):
684
widget = self.create()
685
self.checkEnumParam(widget, 'compound',
686
@@ -312,8 +358,8 @@
687
'-Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*')
688
is_ttk = widget.__class__.__module__ == 'tkinter.ttk'
689
if not is_ttk:
690
- self.checkInvalidParam(widget, 'font', '',
691
- errmsg='font "" doesn\'t exist')
692
+ errmsg = 'font "" does ?n[o\']t exist'
693
+ self.checkInvalidParam(widget, 'font', '', errmsg=errmsg)
694
695
def test_configure_foreground(self):
696
widget = self.create()
697
@@ -329,14 +375,6 @@
698
widget = self.create()
699
self.checkColorParam(widget, 'highlightcolor')
700
701
- def test_configure_highlightthickness(self):
702
- widget = self.create()
703
- self.checkPixelsParam(widget, 'highlightthickness',
704
- 0, 1.3, 2.6, 6, '10p')
705
- expected = 0 if self._clip_highlightthickness else -2
706
- self.checkParam(widget, 'highlightthickness', -2, expected=expected,
707
- conv=self._conv_pixels)
708
-
709
def test_configure_image(self):
710
widget = self.create()
711
self.checkImageParam(widget, 'image')
712
@@ -345,11 +383,6 @@
713
widget = self.create()
714
self.checkColorParam(widget, 'insertbackground')
715
716
- def test_configure_insertborderwidth(self):
717
- widget = self.create()
718
- self.checkPixelsParam(widget, 'insertborderwidth',
719
- 0, 1.3, 2.6, 6, -2, '10p')
720
-
721
def test_configure_insertofftime(self):
722
widget = self.create()
723
self.checkIntegerParam(widget, 'insertofftime', 100)
724
@@ -358,10 +391,6 @@
725
widget = self.create()
726
self.checkIntegerParam(widget, 'insertontime', 100)
727
728
- def test_configure_insertwidth(self):
729
- widget = self.create()
730
- self.checkPixelsParam(widget, 'insertwidth', 1.3, 2.6, -2, '10p')
731
-
732
def test_configure_jump(self):
733
widget = self.create()
734
self.checkBooleanParam(widget, 'jump')
735
@@ -379,22 +408,6 @@
736
self.assertEqual(str(widget['orient']), self.default_orient)
737
self.checkEnumParam(widget, 'orient', 'horizontal', 'vertical')
738
739
- def test_configure_padx(self):
740
- widget = self.create()
741
- self.checkPixelsParam(widget, 'padx', 3, 4.4, 5.6, '12m',
742
- conv=self._conv_pad_pixels)
743
- expected = 0 if self._clip_pad else -2
744
- self.checkParam(widget, 'padx', -2, expected=expected,
745
- conv=self._conv_pad_pixels)
746
-
747
- def test_configure_pady(self):
748
- widget = self.create()
749
- self.checkPixelsParam(widget, 'pady', 3, 4.4, 5.6, '12m',
750
- conv=self._conv_pad_pixels)
751
- expected = 0 if self._clip_pad else -2
752
- self.checkParam(widget, 'pady', -2, expected=expected,
753
- conv=self._conv_pad_pixels)
754
-
755
@requires_tk(8, 7)
756
def test_configure_placeholder(self):
757
widget = self.create()
758
@@ -421,10 +434,6 @@
759
widget = self.create()
760
self.checkColorParam(widget, 'selectbackground')
761
762
- def test_configure_selectborderwidth(self):
763
- widget = self.create()
764
- self.checkPixelsParam(widget, 'selectborderwidth', 1.3, 2.6, -2, '10p')
765
-
766
def test_configure_selectforeground(self):
767
widget = self.create()
768
self.checkColorParam(widget, 'selectforeground')
769
@@ -534,6 +543,7 @@
770
771
772
class IntegerSizeTests:
773
+ """ Tests widgets which only accept integral width and height."""
774
def test_configure_height(self):
775
widget = self.create()
776
self.checkIntegerParam(widget, 'height', 100, -100, 0)
777
@@ -544,6 +554,7 @@
778
779
780
class PixelSizeTests:
781
+ """ Tests widgets which accept screen distances for width and height."""
782
def test_configure_height(self):
783
widget = self.create()
784
self.checkPixelsParam(widget, 'height', 100, 101.2, 102.6, -100, 0, '3c')
785
@@ -553,7 +564,7 @@
786
self.checkPixelsParam(widget, 'width', 402, 403.4, 404.6, -402, 0, '5i')
787
788
789
-def add_standard_options(*source_classes):
790
+def add_configure_tests(*source_classes):
791
# This decorator adds test_configure_xxx methods from source classes for
792
# every xxx option in the OPTIONS class attribute if they are not defined
793
# explicitly.
794
diff -ru Orig/Lib/test/test_ttk/test_style.py Python-3.13.1/Lib/test/test_ttk/test_style.py
795
--- Orig/Lib/test/test_ttk/test_style.py 2024-12-03 11:59:52
796
+++ Python-3.13.1/Lib/test/test_ttk/test_style.py 2024-12-12 12:57:15
797
@@ -205,7 +205,8 @@
798
style = self.style
799
with self.assertRaises(IndexError):
800
style.element_create('plain.newelem', 'from')
801
- with self.assertRaisesRegex(TclError, 'theme "spam" doesn\'t exist'):
802
+ with self.assertRaisesRegex(TclError,
803
+ 'theme "spam" (does not|doesn\'t) exist'):
804
style.element_create('plain.newelem', 'from', 'spam')
805
806
def test_element_create_image(self):
807
diff -ru Orig/Lib/test/test_ttk/test_widgets.py Python-3.13.1/Lib/test/test_ttk/test_widgets.py
808
--- Orig/Lib/test/test_ttk/test_widgets.py 2024-12-03 11:59:52
809
+++ Python-3.13.1/Lib/test/test_ttk/test_widgets.py 2024-12-12 13:00:29
810
@@ -8,7 +8,7 @@
811
from test.test_tkinter.support import (
812
AbstractTkTest, requires_tk, tk_version, get_tk_patchlevel,
813
simulate_mouse_click, AbstractDefaultRootTest)
814
-from test.test_tkinter.widget_tests import (add_standard_options,
815
+from test.test_tkinter.widget_tests import (add_configure_tests,
816
AbstractWidgetTest, StandardOptionsTests, IntegerSizeTests, PixelSizeTests)
817
818
requires('gui')
819
@@ -125,10 +125,11 @@
820
821
822
class AbstractToplevelTest(AbstractWidgetTest, PixelSizeTests):
823
- _conv_pixels = False
824
+ _rounds_pixels = False
825
+ _clipped = {}
826
827
828
-@add_standard_options(StandardTtkOptionsTests)
829
+@add_configure_tests(StandardTtkOptionsTests)
830
class FrameTest(AbstractToplevelTest, unittest.TestCase):
831
OPTIONS = (
832
'borderwidth', 'class', 'cursor', 'height',
833
@@ -140,7 +141,7 @@
834
return ttk.Frame(self.root, **kwargs)
835
836
837
-@add_standard_options(StandardTtkOptionsTests)
838
+@add_configure_tests(StandardTtkOptionsTests)
839
class LabelFrameTest(AbstractToplevelTest, unittest.TestCase):
840
OPTIONS = (
841
'borderwidth', 'class', 'cursor', 'height',
842
@@ -168,6 +169,8 @@
843
844
class AbstractLabelTest(AbstractWidgetTest):
845
_allow_empty_justify = True
846
+ _rounds_pixels = False
847
+ _clipped = {}
848
849
def checkImageParam(self, widget, name):
850
image = tkinter.PhotoImage(master=self.root, name='image1')
851
@@ -179,8 +182,11 @@
852
expected=('image1', 'active', 'image2'))
853
self.checkParam(widget, name, 'image1 active image2',
854
expected=('image1', 'active', 'image2'))
855
- self.checkInvalidParam(widget, name, 'spam',
856
- errmsg='image "spam" doesn\'t exist')
857
+ if tk_version < (9, 0):
858
+ errmsg = 'image "spam" doesn\'t exist'
859
+ else:
860
+ errmsg = 'image "spam" does not exist'
861
+ self.checkInvalidParam(widget, name, 'spam', errmsg=errmsg)
862
863
def test_configure_compound(self):
864
values = ('none', 'text', 'image', 'center', 'top', 'bottom', 'left', 'right')
865
@@ -196,7 +202,7 @@
866
self.checkParams(widget, 'width', 402, -402, 0)
867
868
869
-@add_standard_options(StandardTtkOptionsTests)
870
+@add_configure_tests(StandardTtkOptionsTests)
871
class LabelTest(AbstractLabelTest, unittest.TestCase):
872
OPTIONS = (
873
'anchor', 'background', 'borderwidth',
874
@@ -214,7 +220,7 @@
875
test_configure_justify = StandardOptionsTests.test_configure_justify
876
877
878
-@add_standard_options(StandardTtkOptionsTests)
879
+@add_configure_tests(StandardTtkOptionsTests)
880
class ButtonTest(AbstractLabelTest, unittest.TestCase):
881
OPTIONS = (
882
'class', 'command', 'compound', 'cursor', 'default',
883
@@ -239,7 +245,7 @@
884
self.assertTrue(success)
885
886
887
-@add_standard_options(StandardTtkOptionsTests)
888
+@add_configure_tests(StandardTtkOptionsTests)
889
class CheckbuttonTest(AbstractLabelTest, unittest.TestCase):
890
OPTIONS = (
891
'class', 'command', 'compound', 'cursor',
892
@@ -326,7 +332,7 @@
893
self.assertEqual(len(set(variables)), len(buttons), variables)
894
895
896
-@add_standard_options(IntegerSizeTests, StandardTtkOptionsTests)
897
+@add_configure_tests(IntegerSizeTests, StandardTtkOptionsTests)
898
class EntryTest(AbstractWidgetTest, unittest.TestCase):
899
OPTIONS = (
900
'background', 'class', 'cursor',
901
@@ -338,6 +344,8 @@
902
)
903
# bpo-27313: macOS Tk/Tcl may or may not report 'Entry.field'.
904
IDENTIFY_AS = {'Entry.field', 'textarea'}
905
+ _rounds_pixels = False
906
+ _clipped = {}
907
908
def setUp(self):
909
super().setUp()
910
@@ -371,8 +379,12 @@
911
self.assertRaises(tkinter.TclError, self.entry.bbox, None)
912
913
def test_identify(self):
914
+ if (tk_version >= (9, 0) and sys.platform == 'darwin'
915
+ and isinstance(self.entry, ttk.Combobox)):
916
+ self.skipTest('Test does not work on macOS Tk 9.')
917
+ # https://core.tcl-lang.org/tk/tktview/8b49e9cfa6
918
self.entry.pack()
919
- self.entry.update()
920
+ self.root.update()
921
922
self.assertIn(self.entry.identify(5, 5), self.IDENTIFY_AS)
923
self.assertEqual(self.entry.identify(-1, -1), "")
924
@@ -450,7 +462,7 @@
925
self.assertEqual(self.entry.state(), ())
926
927
928
-@add_standard_options(IntegerSizeTests, StandardTtkOptionsTests)
929
+@add_configure_tests(IntegerSizeTests, StandardTtkOptionsTests)
930
class ComboboxTest(EntryTest, unittest.TestCase):
931
OPTIONS = (
932
'background', 'class', 'cursor', 'exportselection',
933
@@ -479,11 +491,14 @@
934
x, y = width - 5, 5
935
if sys.platform != 'darwin': # there's no down arrow on macOS
936
self.assertRegex(self.combo.identify(x, y), r'.*downarrow\Z')
937
- self.combo.event_generate('<ButtonPress-1>', x=x, y=y)
938
+ self.combo.event_generate('<Button-1>', x=x, y=y)
939
self.combo.event_generate('<ButtonRelease-1>', x=x, y=y)
940
- self.combo.update_idletasks()
941
942
def test_virtual_event(self):
943
+ if (tk_version >= (9, 0) and sys.platform == 'darwin'
944
+ and isinstance(self.entry, ttk.Combobox)):
945
+ self.skipTest('Test does not work on macOS Tk 9.')
946
+ # https://core.tcl-lang.org/tk/tktview/8b49e9cfa6
947
success = []
948
949
self.combo['values'] = [1]
950
@@ -501,6 +516,10 @@
951
self.assertTrue(success)
952
953
def test_configure_postcommand(self):
954
+ if (tk_version >= (9, 0) and sys.platform == 'darwin'
955
+ and isinstance(self.entry, ttk.Combobox)):
956
+ self.skipTest('Test does not work on macOS Tk 9.')
957
+ # https://core.tcl-lang.org/tk/tktview/8b49e9cfa6
958
success = []
959
960
self.combo['postcommand'] = lambda: success.append(True)
961
@@ -576,12 +595,14 @@
962
combo2.destroy()
963
964
965
-@add_standard_options(IntegerSizeTests, StandardTtkOptionsTests)
966
+@add_configure_tests(IntegerSizeTests, StandardTtkOptionsTests)
967
class PanedWindowTest(AbstractWidgetTest, unittest.TestCase):
968
OPTIONS = (
969
'class', 'cursor', 'height',
970
'orient', 'style', 'takefocus', 'width',
971
)
972
+ _rounds_pixels = False
973
+ _clipped = {}
974
975
def setUp(self):
976
super().setUp()
977
@@ -712,7 +733,7 @@
978
self.assertIsInstance(self.paned.sashpos(0), int)
979
980
981
-@add_standard_options(StandardTtkOptionsTests)
982
+@add_configure_tests(StandardTtkOptionsTests)
983
class RadiobuttonTest(AbstractLabelTest, unittest.TestCase):
984
OPTIONS = (
985
'class', 'command', 'compound', 'cursor',
986
@@ -791,13 +812,14 @@
987
menu.destroy()
988
989
990
-@add_standard_options(StandardTtkOptionsTests)
991
+@add_configure_tests(StandardTtkOptionsTests)
992
class ScaleTest(AbstractWidgetTest, unittest.TestCase):
993
OPTIONS = (
994
'class', 'command', 'cursor', 'from', 'length',
995
'orient', 'state', 'style', 'takefocus', 'to', 'value', 'variable',
996
)
997
- _conv_pixels = False
998
+ _rounds_pixels = False
999
+ _clipped = {}
1000
default_orient = 'horizontal'
1001
1002
def setUp(self):
1003
@@ -899,7 +921,7 @@
1004
self.assertRaises(tkinter.TclError, self.scale.set, None)
1005
1006
1007
-@add_standard_options(StandardTtkOptionsTests)
1008
+@add_configure_tests(StandardTtkOptionsTests)
1009
class ProgressbarTest(AbstractWidgetTest, unittest.TestCase):
1010
OPTIONS = (
1011
'anchor', 'class', 'cursor', 'font', 'foreground', 'justify',
1012
@@ -907,7 +929,8 @@
1013
'mode', 'maximum', 'phase', 'text', 'wraplength',
1014
'style', 'takefocus', 'value', 'variable',
1015
)
1016
- _conv_pixels = False
1017
+ _rounds_pixels = False
1018
+ _clipped = {}
1019
_allow_empty_justify = True
1020
default_orient = 'horizontal'
1021
1022
@@ -952,24 +975,27 @@
1023
1024
@unittest.skipIf(sys.platform == 'darwin',
1025
'ttk.Scrollbar is special on MacOSX')
1026
-@add_standard_options(StandardTtkOptionsTests)
1027
+@add_configure_tests(StandardTtkOptionsTests)
1028
class ScrollbarTest(AbstractWidgetTest, unittest.TestCase):
1029
OPTIONS = (
1030
'class', 'command', 'cursor', 'orient', 'style', 'takefocus',
1031
)
1032
+ _rounds_pixels = False
1033
+ _clipped = {}
1034
default_orient = 'vertical'
1035
1036
def create(self, **kwargs):
1037
return ttk.Scrollbar(self.root, **kwargs)
1038
1039
1040
-@add_standard_options(StandardTtkOptionsTests)
1041
+@add_configure_tests(StandardTtkOptionsTests)
1042
class NotebookTest(AbstractWidgetTest, unittest.TestCase):
1043
OPTIONS = (
1044
'class', 'cursor', 'height', 'padding', 'style', 'takefocus', 'width',
1045
)
1046
- if tk_version >= (8, 7):
1047
- _conv_pixels = False
1048
+ _rounds_pixels = (tk_version < (9,0))
1049
+ _converts_pixels = False
1050
+ _clipped = {}
1051
1052
def setUp(self):
1053
super().setUp()
1054
@@ -987,14 +1013,14 @@
1055
if get_tk_patchlevel(self.root) < (8, 6, 15):
1056
self.checkIntegerParam(widget, 'height', 402, -402, 0)
1057
else:
1058
- self.checkPixelsParam(widget, 'height', '10c', 402, -402, 0, conv=False)
1059
+ self.checkPixelsParam(widget, 'height', '10c', 402, -402, 0)
1060
1061
def test_configure_width(self):
1062
widget = self.create()
1063
if get_tk_patchlevel(self.root) < (8, 6, 15):
1064
self.checkIntegerParam(widget, 'width', 402, -402, 0)
1065
else:
1066
- self.checkPixelsParam(widget, 'width', '10c', 402, -402, 0, conv=False)
1067
+ self.checkPixelsParam(widget, 'width', '10c', 402, -402, 0)
1068
1069
def test_tab_identifiers(self):
1070
self.nb.forget(0)
1071
@@ -1160,7 +1186,12 @@
1072
1073
self.nb.select(0)
1074
1075
- focus_identify_as = 'focus' if sys.platform != 'darwin' else ''
1076
+ if sys.platform == 'darwin':
1077
+ focus_identify_as = ''
1078
+ elif sys.platform == 'win32':
1079
+ focus_identify_as = 'focus'
1080
+ else:
1081
+ focus_identify_as = 'focus' if tk_version < (9,0) else 'padding'
1082
self.assertEqual(self.nb.identify(5, 5), focus_identify_as)
1083
simulate_mouse_click(self.nb, 5, 5)
1084
self.nb.focus_force()
1085
@@ -1193,7 +1224,7 @@
1086
self.assertEqual(self.nb.select(), str(self.child2))
1087
1088
1089
-@add_standard_options(IntegerSizeTests, StandardTtkOptionsTests)
1090
+@add_configure_tests(IntegerSizeTests, StandardTtkOptionsTests)
1091
class SpinboxTest(EntryTest, unittest.TestCase):
1092
OPTIONS = (
1093
'background', 'class', 'command', 'cursor', 'exportselection',
1094
@@ -1370,7 +1401,7 @@
1095
spin2.destroy()
1096
1097
1098
-@add_standard_options(StandardTtkOptionsTests)
1099
+@add_configure_tests(StandardTtkOptionsTests)
1100
class TreeviewTest(AbstractWidgetTest, unittest.TestCase):
1101
OPTIONS = (
1102
'class', 'columns', 'cursor', 'displaycolumns',
1103
@@ -1378,6 +1409,8 @@
1104
'style', 'takefocus', 'titlecolumns', 'titleitems',
1105
'xscrollcommand', 'yscrollcommand',
1106
)
1107
+ _rounds_pixels = False
1108
+ _clipped = {}
1109
1110
def setUp(self):
1111
super().setUp()
1112
@@ -1413,8 +1446,10 @@
1113
1114
def test_configure_height(self):
1115
widget = self.create()
1116
- self.checkPixelsParam(widget, 'height', 100, -100, 0, '3c', conv=False)
1117
- self.checkPixelsParam(widget, 'height', 101.2, 102.6, conv=False)
1118
+ self.checkPixelsParam(widget, 'height', 100, -100, 0, '3c',
1119
+ conv=False)
1120
+ self.checkPixelsParam(widget, 'height', 101.2, 102.6, '3c',
1121
+ conv=False)
1122
1123
def test_configure_selectmode(self):
1124
widget = self.create()
1125
@@ -1936,24 +1971,28 @@
1126
self.assertEqual(self.tv.tag_has('tag3'), ())
1127
1128
1129
-@add_standard_options(StandardTtkOptionsTests)
1130
+@add_configure_tests(StandardTtkOptionsTests)
1131
class SeparatorTest(AbstractWidgetTest, unittest.TestCase):
1132
OPTIONS = (
1133
'class', 'cursor', 'orient', 'style', 'takefocus',
1134
# 'state'?
1135
)
1136
+ _rounds_pixels = False
1137
+ _clipped = {}
1138
default_orient = 'horizontal'
1139
1140
def create(self, **kwargs):
1141
return ttk.Separator(self.root, **kwargs)
1142
1143
1144
-@add_standard_options(StandardTtkOptionsTests)
1145
+@add_configure_tests(StandardTtkOptionsTests)
1146
class SizegripTest(AbstractWidgetTest, unittest.TestCase):
1147
OPTIONS = (
1148
'class', 'cursor', 'style', 'takefocus',
1149
# 'state'?
1150
)
1151
+ _rounds_pixels = False
1152
+ _clipped = {}
1153
1154
def create(self, **kwargs):
1155
return ttk.Sizegrip(self.root, **kwargs)
1156
diff -ru Orig/Lib/tkinter/ttk.py Python-3.13.1/Lib/tkinter/ttk.py
1157
--- Orig/Lib/tkinter/ttk.py 2024-12-03 11:59:52
1158
+++ Python-3.13.1/Lib/tkinter/ttk.py 2024-12-12 12:57:15
1159
@@ -321,6 +321,8 @@
1160
elif hasattr(val, 'typename'): # some other (single) Tcl object
1161
val = _convert_stringval(val)
1162
1163
+ if isinstance(val, tuple) and len(val) == 0:
1164
+ return ''
1165
return val
1166
1167
def tclobjs_to_py(adict):
1168
diff -ru Orig/Modules/_tkinter.c Python-3.13.1/Modules/_tkinter.c
1169
--- Orig/Modules/_tkinter.c 2024-12-03 11:59:52
1170
+++ Python-3.13.1/Modules/_tkinter.c 2024-12-12 12:57:15
1171
@@ -325,6 +325,7 @@
1172
const Tcl_ObjType *ListType;
1173
const Tcl_ObjType *StringType;
1174
const Tcl_ObjType *UTF32StringType;
1175
+ const Tcl_ObjType *PixelType;
1176
} TkappObject;
1177
1178
#define Tkapp_Interp(v) (((TkappObject *) (v))->interp)
1179
@@ -637,6 +638,7 @@
1180
v->ListType = Tcl_GetObjType("list");
1181
v->StringType = Tcl_GetObjType("string");
1182
v->UTF32StringType = Tcl_GetObjType("utf32string");
1183
+ v->PixelType = Tcl_GetObjType("pixel");
1184
1185
/* Delete the 'exit' command, which can screw things up */
1186
Tcl_DeleteCommand(v->interp, "exit");
1187
@@ -1236,7 +1238,8 @@
1188
}
1189
1190
if (value->typePtr == tkapp->StringType ||
1191
- value->typePtr == tkapp->UTF32StringType)
1192
+ value->typePtr == tkapp->UTF32StringType ||
1193
+ value->typePtr == tkapp->PixelType)
1194
{
1195
return unicodeFromTclObj(tkapp, value);
1196
}
1197
1198