Package: uielem
uielem - wrapper over Tkinter for more Pythonic UI buildingSometimes you just want to make a quick UI to make some visual task easier andTkinteris a fast UI toolkit that's packaged with Python since forever.uielemhopes to provide a more modern/Pythonic syntax for usingTkinter.A simple example:Beforefrom Tkinter import Tk, Frame, Label, Listbox, Button, mainloop

tkroot = Tk()
tkroot.title('Kanban')
frame = Frame(tkroot)
frame.pack()
board_frame = Frame(frame)
board_frame.pack(side='top')
for board_name in ["Todo", "Doing", "Done"]:
    inner_frame = Frame(board_frame)
    inner_frame.pack(side='left')
    label = Label(inner_frame, text=board_name)
    label.pack(side='top')
    listbox = Listbox(inner_frame)
    listbox.pack(side='top')
buttons_frame = Frame(frame)
buttons_frame.pack(side='top')
add_button = Button(buttons_frame, text='Add item', command=add)
add_button.pack(side='left')
remove_button = Button(buttons_frame, text='Remove item', command=remove)
remove_button.pack(side='left')

mainloop()Afterfrom uielem import UI, uidict
from Tkinter import Tk, Frame, Label, Listbox, Button

uiroot = UI(Tk, name='root', title='Kanban', children=[
           UI(Frame, packside='top', children=[
             UI(Frame, packside='left', name='boards', children=[
               UI(Frame, packside='top', children=[
                 UI(Label, text=board_name),
                 UI(Listbox, name=board_name.lower())])
               for board_name in ["Todo", "Doing", "Done"]]),
             UI(Frame, packside='left', children=[
               UI(Button, text='Add item', command=add),
               UI(Button, text='Remove item', command=remove), ])])])

uiroot.makeelem()
uidict["root"].mainloop()Installationpip install -r requirements.txtuielemdepends onundoable.Usage and featuresThe basic pattern is justUI(<tkinter elem>, <keyword arguments>, children=[<chidren>]).Keyword argumentspackside=sets the packing side for allchildren(contained in the element).defaulttext=for aTkinter.Entryset the initial text.on_*=sets an event callback (and_is replaced by-). So passingon_Button_3=funcis the same as runningelem.bind('<Button-3>', func)after creation.set_*=sets attribute values after creation. For exampleset_title=['title']has the same effect astitle='title'.Other non-special keyword arguments are passed through to the Tkinter element.Other featuresuidictcontains all named (name=something) elements for easy reference. Names must be globally unique (thinkidin SVG).To add and remove child elements from a container, treat it like a list (using.append,.insertand.remove).Children of the wrapper can be accessed by indexing (such asuiroot[0][1]).The wrapper can access the Tkinter object with the.elemattribute and the Tkinter object can access the wrapper with.ui.Alternate versionsuielemis now rather large so two lighter versions ofuielemare provided in thesummariesfolder but they may not always be up to date.simple_uielem.pyremoves some of the less used features like code generation.minimal_uielem.pyonly works with UIs generated once and never modified after that (like in the example) but is otherwise fully compatible. Also removes the dependency on undoable.They also serve as documentation foruielem's architecture/inner workings.