MCPcopy Index your code
hub / github.com/python/cpython / Style

Class Style

Lib/tkinter/ttk.py:346–507  ·  view source on GitHub ↗

Manipulate style database.

Source from the content-addressed store, hash-verified

344
345
346class Style(object):
347 """Manipulate style database."""
348
349 _name = "ttk::style"
350
351 def __init__(self, master=None):
352 master = setup_master(master)
353 self.master = master
354 self.tk = self.master.tk
355
356
357 def configure(self, style, query_opt=None, **kw):
358 """Query or sets the default value of the specified option(s) in
359 style.
360
361 Each key in kw is an option and each value is either a string or
362 a sequence identifying the value for that option."""
363 if query_opt is not None:
364 kw[query_opt] = None
365 result = _val_or_dict(self.tk, kw, self._name, "configure", style)
366 if result or query_opt:
367 return result
368
369
370 def map(self, style, query_opt=None, **kw):
371 """Query or sets dynamic values of the specified option(s) in
372 style.
373
374 Each key in kw is an option and each value should be a list or a
375 tuple (usually) containing statespecs grouped in tuples, or list,
376 or something else of your preference. A statespec is compound of
377 one or more states and then a value."""
378 if query_opt is not None:
379 result = self.tk.call(self._name, "map", style, '-%s' % query_opt)
380 return _list_from_statespec(self.tk.splitlist(result))
381
382 result = self.tk.call(self._name, "map", style, *_format_mapdict(kw))
383 return {k: _list_from_statespec(self.tk.splitlist(v))
384 for k, v in _splitdict(self.tk, result).items()}
385
386
387 def lookup(self, style, option, state=None, default=None):
388 """Returns the value specified for option in style.
389
390 If state is specified it is expected to be a sequence of one
391 or more states. If the default argument is set, it is used as
392 a fallback value in case no specification for option is found."""
393 state = ' '.join(state) if state else ''
394
395 return self.tk.call(self._name, "lookup", style, '-%s' % option,
396 state, default)
397
398
399 def layout(self, style, layoutspec=None):
400 """Define the widget layout for given style. If layoutspec is
401 omitted, return the layout specification for given style.
402
403 layoutspec is expected to be a list or an object different than

Callers 2

__init__Method · 0.90
__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…