tkgen package

Submodules

tkgen.form module

Implement the form generation.

class tkgen.form.CollectionInput(parent, schema, pipe)

Bases: _CollectionInput

A special widget for inputing elements to a collection.

class tkgen.form.FormFactory

Bases: Visitor

The main factory.

Implemented as a pyskema.visitor.Visitor, it builds the tree of nodes from the schema and seam the network of pipes through.

classmethod make_toplevel(schema, callback, *, Window=<class 'tkinter.Tk'>, title=None, init_data=None)

Main constructor, it does the boring work.

Boring work:

  • setup and wire the buttons

  • create the main window

  • (optional) set the window title

  • build the form and add it into a scollable container

  • (optional) inject initial data

Parameters:
  • schema – the pyskema schema.

  • callback – the callback that should treat the data at the end.

  • Window – (kw only, tkinter.Tk) the main window class.

  • title – (kw only, None) a title for the window.

  • init_data – (kw only, None) the initial data to inject in the form.

visit_atom(atom, parent, pipe, *args)

Visit an pyskema.schema.Atom instance.

visit_collection(collection, parent, pipe, *args)

Visit a pyskema.schema.Collection instance.

visit_map(map_, parent, pipe, *args)

Visit a pyskema.schema.Map instance.

visit_record(rec, parent, pipe, *args)

Visit a pyskema.schema.Record instance.

visit_tuple(tup, parent, pipe, *args)

Visit a pyskema.schema.Tuple instance.

visit_union(union, parent, pipe, *args)

Visit an pyskema.schema.Union instance.

class tkgen.form.MapInput(parent, schema, pipe)

Bases: _CollectionInput

A special widget for inputing named elements to a map.

add_item(data)
prepare_data(name, data)
pull()
push(data)
class tkgen.form.ScrollingFrame(*args, **kwargs)

Bases: Frame

A frame that encapsulate a scrollable content.

canvas_config(event)
frame_config(event)
scroll_canvas(event)
tkgen.form.make_form(schema, callback, *, Window=<class 'tkinter.Tk'>, title=None, init_data=None)

Build of form window from a schema. See FormFactory.make_toplevel().

tkgen.tooltip module

An implementation of a tooltip buble for documenting elements of forms.

class tkgen.tooltip.Semaphore

Bases: object

A semaphore letting several tooltips synchronising themself.

hold(ident)
release(ident)
request(ident)
class tkgen.tooltip.Tooltip(widget, *, bg='#FFFFEA', pad=(5, 3, 5, 3), text='widget info', waittime=200, wraplength=250, sem=<tkgen.tooltip.Semaphore object>)

Bases: object

Create a floating tooltip next to the attached widget.

Credits:

  • Originally written by vegaseat on 2014.09.09 (blog post).

  • Modified to include a delay time by Victor Zaccardo on 2016.03.25 (stackoverflow answer 1).

  • Modified by Alberto Vassena on 2016.11.05 (stackoverflow answer 2):

    • to correct extreme right and extreme bottom behavior,

    • to stay inside the screen whenever the tooltip might go out on the top but still the screen is higher than the tooltip,

    • to use the more flexible mouse positioning,

    • to add customizable background color, padding, waittime and wraplength on creation

  • Modified to fix a scheduling bug by Erik Bethke on 2016.12.29 (stackoverflow answer 3).

  • Modified by Théo Cavignac to prevent more than one visible tooltip at a time, causing superpositions of tooltips in complex widget tree, on 2022.09.04 (in tkgen sources).

Tested on Archlinux (kernel 6.2.2), running Python 3.10.9

hide()
onEnter(event=None)
onLeave(event=None)
schedule()
show()
unschedule()

Module contents

A simple way of generating Tkinter forms from structured data.