Tkinter gui representation
Homepage Repository PyPI Python
pip install tkml==0.5
Library to build Tkinter structures from YAML descriptions.
It requires PyYAML 3.12.
import tkml
...
with open(filename) as fp:
toplevel = tkml.load_fp(fp)
There is a fixtures factory too:
import tkml
# With no arguments, it assumes fixtures/ subdirectory neighbor to current script
loader = tkml.fixtures()
toplevel = loader('my-app.yaml')
tkml.load_fp()
:
fp: io.TextBase
: file pointer to YAML filemaster: tkinter.Misc
: parent widgetuse_tix: bool
: use or not tix
– defaults to falsecontext
: context to ctx[]
, argparse.Namespace
,
collections.namedtuple
, or dict
tkml.fixtures()
:
origin: str
: the directory containing the YAML files, defaults to
subdirectory fixtures/
neighbor to the script calling the factoryLoader function returned by tkml.fixtures()
:
fixture: str
: YAML file name under fixtures directorymaster: tkinter.Misc
: parent widgetuse_tix: bool
: use or not tix
– defaults to falsecontext
: context to ctx[]
, argparse.Namespace
,
collections.namedtuple
, or dict
tk:
children:
- frame:
children:
- frame:
children:
- label:
text: _(word-to-search)
pack:
anchor: nw
side: left
expand: false
- entry:
pack:
anchor: ne
side: right
fill: x
expand: true
bind:
<Return>: ctx[search]
focus: null
pack:
anchor: n
fill: x
expand: true
- button:
text: _(search)
command: ctx[search]
pack:
anchor: s
expand: false
- scrolled-text:
call/set_text:
- ctx[set_text]
- "!self"
wrap: word
pack:
anchor: s
fill: both
expand: true
pack:
fill: both
expand: true
#
# Calls after tree is built:
#
option-add:
- "*tearOff"
- false
# call/* call the CAR (a callable) with CDR as parameters
call/set_entry:
- ctx[set_entry]
- "!frame.!frame.!entry"
ctx[*]
gets a key from the context._(*)
is the gettext
function.!self
is the current widget.!frame.frame2
is the second frame from inside de first frame at top.This library is under 3-Clause BSD License.
You can read the copying text here.