@@ -258,6 +258,55 @@ def test_element_create_image_errors(self):
258258 with self .assertRaisesRegex (TclError , 'bad option' ):
259259 style .element_create ('block2' , 'image' , image , spam = 1 )
260260
261+ def test_element_create_vsapi_1 (self ):
262+ style = self .style
263+ if 'xpnative' not in style .theme_names ():
264+ self .skipTest ("requires 'xpnative' theme" )
265+ style .element_create ('smallclose' , 'vsapi' , 'WINDOW' , 19 , [
266+ ('disabled' , 4 ),
267+ ('pressed' , 3 ),
268+ ('active' , 2 ),
269+ ('' , 1 )])
270+ style .layout ('CloseButton' ,
271+ [('CloseButton.smallclose' , {'sticky' : 'news' })])
272+ b = ttk .Button (self .root , style = 'CloseButton' )
273+ b .pack (expand = True , fill = 'both' )
274+ self .assertEqual (b .winfo_reqwidth (), 13 )
275+ self .assertEqual (b .winfo_reqheight (), 13 )
276+
277+ def test_element_create_vsapi_2 (self ):
278+ style = self .style
279+ if 'xpnative' not in style .theme_names ():
280+ self .skipTest ("requires 'xpnative' theme" )
281+ style .element_create ('pin' , 'vsapi' , 'EXPLORERBAR' , 3 , [
282+ ('pressed' , '!selected' , 3 ),
283+ ('active' , '!selected' , 2 ),
284+ ('pressed' , 'selected' , 6 ),
285+ ('active' , 'selected' , 5 ),
286+ ('selected' , 4 ),
287+ ('' , 1 )])
288+ style .layout ('Explorer.Pin' ,
289+ [('Explorer.Pin.pin' , {'sticky' : 'news' })])
290+ pin = ttk .Checkbutton (self .root , style = 'Explorer.Pin' )
291+ pin .pack (expand = True , fill = 'both' )
292+ self .assertEqual (pin .winfo_reqwidth (), 16 )
293+ self .assertEqual (pin .winfo_reqheight (), 16 )
294+
295+ def test_element_create_vsapi_3 (self ):
296+ style = self .style
297+ if 'xpnative' not in style .theme_names ():
298+ self .skipTest ("requires 'xpnative' theme" )
299+ style .element_create ('headerclose' , 'vsapi' , 'EXPLORERBAR' , 2 , [
300+ ('pressed' , 3 ),
301+ ('active' , 2 ),
302+ ('' , 1 )])
303+ style .layout ('Explorer.CloseButton' ,
304+ [('Explorer.CloseButton.headerclose' , {'sticky' : 'news' })])
305+ b = ttk .Button (self .root , style = 'Explorer.CloseButton' )
306+ b .pack (expand = True , fill = 'both' )
307+ self .assertEqual (b .winfo_reqwidth (), 16 )
308+ self .assertEqual (b .winfo_reqheight (), 16 )
309+
261310 def test_theme_create (self ):
262311 style = self .style
263312 curr_theme = style .theme_use ()
@@ -358,6 +407,39 @@ def test_theme_create_image(self):
358407
359408 style .theme_use (curr_theme )
360409
410+ def test_theme_create_vsapi (self ):
411+ style = self .style
412+ if 'xpnative' not in style .theme_names ():
413+ self .skipTest ("requires 'xpnative' theme" )
414+ curr_theme = style .theme_use ()
415+ new_theme = 'testtheme5'
416+ style .theme_create (new_theme , settings = {
417+ 'pin' : {
418+ 'element create' : ['vsapi' , 'EXPLORERBAR' , 3 , [
419+ ('pressed' , '!selected' , 3 ),
420+ ('active' , '!selected' , 2 ),
421+ ('pressed' , 'selected' , 6 ),
422+ ('active' , 'selected' , 5 ),
423+ ('selected' , 4 ),
424+ ('' , 1 )]],
425+ },
426+ 'Explorer.Pin' : {
427+ 'layout' : [('Explorer.Pin.pin' , {'sticky' : 'news' })],
428+ },
429+ })
430+
431+ style .theme_use (new_theme )
432+ self .assertIn ('pin' , style .element_names ())
433+ self .assertEqual (style .layout ('Explorer.Pin' ),
434+ [('Explorer.Pin.pin' , {'sticky' : 'nswe' })])
435+
436+ pin = ttk .Checkbutton (self .root , style = 'Explorer.Pin' )
437+ pin .pack (expand = True , fill = 'both' )
438+ self .assertEqual (pin .winfo_reqwidth (), 16 )
439+ self .assertEqual (pin .winfo_reqheight (), 16 )
440+
441+ style .theme_use (curr_theme )
442+
361443
362444if __name__ == "__main__" :
363445 unittest .main ()
0 commit comments