Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Private Attributes
tkinter.ttk.Style Class Reference
Inheritance diagram for tkinter.ttk.Style:
Inheritance graph
[legend]
Collaboration diagram for tkinter.ttk.Style:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def configure
def map
def lookup
def layout
def element_create
def element_names
def element_options
def theme_create
def theme_settings
def theme_names
def theme_use

Public Attributes

 master
 tk
_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Static Private Attributes

string _name = "ttk::style"

Detailed Description

Manipulate style database.

Definition at line 369 of file ttk.py.


Constructor & Destructor Documentation

def tkinter.ttk.Style.__init__ (   self,
  master = None 
)

Definition at line 374 of file ttk.py.

00374 
00375     def __init__(self, master=None):
00376         master = setup_master(master)
00377 
00378         if not getattr(master, '_tile_loaded', False):
00379             # Load tile now, if needed
00380             _load_tile(master)
00381 
00382         self.master = master
00383         self.tk = self.master.tk
00384 

Here is the call graph for this function:

Here is the caller graph for this function:


Member Function Documentation

def tkinter.ttk.Style.configure (   self,
  style,
  query_opt = None,
  kw 
)
Query or sets the default value of the specified option(s) in
style.

Each key in kw is an option and each value is either a string or
a sequence identifying the value for that option.

Definition at line 385 of file ttk.py.

00385 
00386     def configure(self, style, query_opt=None, **kw):
00387         """Query or sets the default value of the specified option(s) in
00388         style.
00389 
00390         Each key in kw is an option and each value is either a string or
00391         a sequence identifying the value for that option."""
00392         if query_opt is not None:
00393             kw[query_opt] = None
00394         return _val_or_dict(kw, self.tk.call, self._name, "configure", style)
00395 

Here is the call graph for this function:

def tkinter.ttk.Style.element_create (   self,
  elementname,
  etype,
  args,
  kw 
)
Create a new element in the current theme of given etype.

Definition at line 467 of file ttk.py.

00467 
00468     def element_create(self, elementname, etype, *args, **kw):
00469         """Create a new element in the current theme of given etype."""
00470         spec, opts = _format_elemcreate(etype, False, *args, **kw)
00471         self.tk.call(self._name, "element", "create", elementname, etype,
00472             spec, *opts)
00473 

Here is the call graph for this function:

Returns the list of elements defined in the current theme.

Definition at line 474 of file ttk.py.

00474 
00475     def element_names(self):
00476         """Returns the list of elements defined in the current theme."""
00477         return self.tk.call(self._name, "element", "names")
00478 

def tkinter.ttk.Style.element_options (   self,
  elementname 
)
Return the list of elementname's options.

Definition at line 479 of file ttk.py.

00479 
00480     def element_options(self, elementname):
00481         """Return the list of elementname's options."""
00482         return self.tk.call(self._name, "element", "options", elementname)
00483 

def tkinter.ttk.Style.layout (   self,
  style,
  layoutspec = None 
)
Define the widget layout for given style. If layoutspec is
omitted, return the layout specification for given style.

layoutspec is expected to be a list or an object different than
None that evaluates to False if you want to "turn off" that style.
If it is a list (or tuple, or something else), each item should be
a tuple where the first item is the layout name and the second item
should have the format described below:

LAYOUTS

    A layout can contain the value None, if takes no options, or
    a dict of options specifying how to arrange the element.
    The layout mechanism uses a simplified version of the pack
    geometry manager: given an initial cavity, each element is
    allocated a parcel. Valid options/values are:

side: whichside
    Specifies which side of the cavity to place the
    element; one of top, right, bottom or left. If
    omitted, the element occupies the entire cavity.

sticky: nswe
    Specifies where the element is placed inside its
    allocated parcel.

children: [sublayout... ]
    Specifies a list of elements to place inside the
    element. Each element is a tuple (or other sequence)
    where the first item is the layout name, and the other
    is a LAYOUT.

Definition at line 424 of file ttk.py.

00424 
00425     def layout(self, style, layoutspec=None):
00426         """Define the widget layout for given style. If layoutspec is
00427         omitted, return the layout specification for given style.
00428 
00429         layoutspec is expected to be a list or an object different than
00430         None that evaluates to False if you want to "turn off" that style.
00431         If it is a list (or tuple, or something else), each item should be
00432         a tuple where the first item is the layout name and the second item
00433         should have the format described below:
00434 
00435         LAYOUTS
00436 
00437             A layout can contain the value None, if takes no options, or
00438             a dict of options specifying how to arrange the element.
00439             The layout mechanism uses a simplified version of the pack
00440             geometry manager: given an initial cavity, each element is
00441             allocated a parcel. Valid options/values are:
00442 
00443                 side: whichside
00444                     Specifies which side of the cavity to place the
00445                     element; one of top, right, bottom or left. If
00446                     omitted, the element occupies the entire cavity.
00447 
00448                 sticky: nswe
00449                     Specifies where the element is placed inside its
00450                     allocated parcel.
00451 
00452                 children: [sublayout... ]
00453                     Specifies a list of elements to place inside the
00454                     element. Each element is a tuple (or other sequence)
00455                     where the first item is the layout name, and the other
00456                     is a LAYOUT."""
00457         lspec = None
00458         if layoutspec:
00459             lspec = _format_layoutlist(layoutspec)[0]
00460         elif layoutspec is not None: # will disable the layout ({}, '', etc)
00461             lspec = "null" # could be any other word, but this may make sense
00462                            # when calling layout(style) later
00463 
00464         return _list_from_layouttuple(
00465             self.tk.call(self._name, "layout", style, lspec))
00466 

Here is the call graph for this function:

def tkinter.ttk.Style.lookup (   self,
  style,
  option,
  state = None,
  default = None 
)
Returns the value specified for option in style.

If state is specified it is expected to be a sequence of one
or more states. If the default argument is set, it is used as
a fallback value in case no specification for option is found.

Definition at line 412 of file ttk.py.

00412 
00413     def lookup(self, style, option, state=None, default=None):
00414         """Returns the value specified for option in style.
00415 
00416         If state is specified it is expected to be a sequence of one
00417         or more states. If the default argument is set, it is used as
00418         a fallback value in case no specification for option is found."""
00419         state = ' '.join(state) if state else ''
00420 
00421         return self.tk.call(self._name, "lookup", style, '-%s' % option,
00422             state, default)
00423 

def tkinter.ttk.Style.map (   self,
  style,
  query_opt = None,
  kw 
)
Query or sets dynamic values of the specified option(s) in
style.

Each key in kw is an option and each value should be a list or a
tuple (usually) containing statespecs grouped in tuples, or list,
or something else of your preference. A statespec is compound of
one or more states and then a value.

Definition at line 396 of file ttk.py.

00396 
00397     def map(self, style, query_opt=None, **kw):
00398         """Query or sets dynamic values of the specified option(s) in
00399         style.
00400 
00401         Each key in kw is an option and each value should be a list or a
00402         tuple (usually) containing statespecs grouped in tuples, or list,
00403         or something else of your preference. A statespec is compound of
00404         one or more states and then a value."""
00405         if query_opt is not None:
00406             return _list_from_statespec(
00407                 self.tk.call(self._name, "map", style, '-%s' % query_opt))
00408 
00409         return _dict_from_tcltuple(
00410             self.tk.call(self._name, "map", style, *(_format_mapdict(kw))))
00411 

Here is the call graph for this function:

def tkinter.ttk.Style.theme_create (   self,
  themename,
  parent = None,
  settings = None 
)
Creates a new theme.

It is an error if themename already exists. If parent is
specified, the new theme will inherit styles, elements and
layouts from the specified parent theme. If settings are present,
they are expected to have the same syntax used for theme_settings.

Definition at line 484 of file ttk.py.

00484 
00485     def theme_create(self, themename, parent=None, settings=None):
00486         """Creates a new theme.
00487 
00488         It is an error if themename already exists. If parent is
00489         specified, the new theme will inherit styles, elements and
00490         layouts from the specified parent theme. If settings are present,
00491         they are expected to have the same syntax used for theme_settings."""
00492         script = _script_from_settings(settings) if settings else ''
00493 
00494         if parent:
00495             self.tk.call(self._name, "theme", "create", themename,
00496                 "-parent", parent, "-settings", script)
00497         else:
00498             self.tk.call(self._name, "theme", "create", themename,
00499                 "-settings", script)
00500 

Here is the call graph for this function:

Returns a list of all known themes.

Definition at line 513 of file ttk.py.

00513 
00514     def theme_names(self):
00515         """Returns a list of all known themes."""
00516         return self.tk.call(self._name, "theme", "names")
00517 

def tkinter.ttk.Style.theme_settings (   self,
  themename,
  settings 
)
Temporarily sets the current theme to themename, apply specified
settings and then restore the previous theme.

Each key in settings is a style and each value may contain the
keys 'configure', 'map', 'layout' and 'element create' and they
are expected to have the same format as specified by the methods
configure, map, layout and element_create respectively.

Definition at line 501 of file ttk.py.

00501 
00502     def theme_settings(self, themename, settings):
00503         """Temporarily sets the current theme to themename, apply specified
00504         settings and then restore the previous theme.
00505 
00506         Each key in settings is a style and each value may contain the
00507         keys 'configure', 'map', 'layout' and 'element create' and they
00508         are expected to have the same format as specified by the methods
00509         configure, map, layout and element_create respectively."""
00510         script = _script_from_settings(settings)
00511         self.tk.call(self._name, "theme", "settings", themename, script)
00512 

Here is the call graph for this function:

def tkinter.ttk.Style.theme_use (   self,
  themename = None 
)
If themename is None, returns the theme in use, otherwise, set
the current theme to themename, refreshes all widgets and emits
a <<ThemeChanged>> event.

Definition at line 518 of file ttk.py.

00518 
00519     def theme_use(self, themename=None):
00520         """If themename is None, returns the theme in use, otherwise, set
00521         the current theme to themename, refreshes all widgets and emits
00522         a <<ThemeChanged>> event."""
00523         if themename is None:
00524             # Starting on Tk 8.6, checking this global is no longer needed
00525             # since it allows doing self.tk.call(self._name, "theme", "use")
00526             return self.tk.eval("return $ttk::currentTheme")
00527 
00528         # using "ttk::setTheme" instead of "ttk::style theme use" causes
00529         # the variable currentTheme to be updated, also, ttk::setTheme calls
00530         # "ttk::style theme use" in order to change theme.
00531         self.tk.call("ttk::setTheme", themename)
00532 


Member Data Documentation

string tkinter.ttk.Style._name = "ttk::style" [static, private]

Definition at line 372 of file ttk.py.

Definition at line 381 of file ttk.py.

Definition at line 107 of file object.h.

struct _typeobject* _object::ob_type [inherited]

Definition at line 108 of file object.h.

Definition at line 382 of file ttk.py.


The documentation for this class was generated from the following file: