def add_frame(self, triangle_key):
"""Add a ``ttk.Frame`` to the dialog and return it.
The frame will contain a label that displays a |triangle| when
the value of the variable from :meth:`get_var` is invalid. The
triangle label is packed with ``side='right'``.
For example, :meth:`add_checkbutton` works roughly like this::
frame = section.add_frame(key)
var = section.get_var(key, tkinter.BooleanVar)
ttk.Checkbutton(frame, text=text, variable=var).pack(side='left')
"""
frame = ttk.Frame(self.content_frame)
frame.pack(fill='x')
if triangle_key is not None:
errorvar = self._infos[triangle_key].errorvar
triangle_label = ttk.Label(frame)
triangle_label.pack(side='right')
def on_errorvar_changed(*junk):
if errorvar.get():
triangle_label['image'] = 'img_triangle'
else:
triangle_label['image'] = self._get_fake_triangle(frame)
errorvar.trace('w', on_errorvar_changed)
on_errorvar_changed()
return frame
评论列表
文章目录