Package: ascii-designer
A library that:creates GUI from ASCII-art (with well-defined syntax)maps widgets to virtual class attributesrelieves you from the boring parts of Form building while leaving you in
control.Did you ever design a form by scribbling something like this in your editor:Text to transform:   [ Text_      ]

Select transformation:

(x) Uppercase
( ) Lowercase
( ) Title-case

    [ OK ]            [ Cancel ]… and wished that you could be done with design and start coding? Wish no longer:from ascii_designer import AutoFrame

class TextTransformer(AutoFrame):
    f_body='''
                            |    <->       |
        Text to transform:   [ Text_      ]

        Select transformation:

        (x) Uppercase
        ( ) Lowercase
        ( ) Title-case

            [ OK ]            [ Cancel ]~

    '''
    def ok(self):
        text = self.text
        if self.uppercase:
            text = text.upper()
        elif self.lowercase:
            text = text.lower()
        elif self.titlecase:
            text = text.title()
        print(text)
        self.close()

    def cancel(self):
        self.close()

if __name__ == '__main__':
    TextTransformer().f_show()Some comments, incidentally highlighting the features of this library:As you probably guessed, all the magic happens inAutoFrame. Thef_showcall triggers rendering of the form. All the reserved attributes
are prepended withf_to get out of your way when subclassing.There is awell-defined syntaxfor how to get the usual widget types. In the
example you can find labels (plain text), a text box, radio buttons and normal
buttons.The columns are defined by theheader rowwith the pipe characters. The
minus sign denotes stretching columns. (The</>chars are just
decoration.)Column-spanis easily done by having not-a-space underneath the pipe
symbol.Row-spancan also be done by prepending subsequent cells with a{character.Anchoringis controlled by whether the cell is space-padded or not. For
example, the Text box stretches, while the cancel button is centered. The
tilde character can be used instead of a fragile trailing space.Widget IDsare automatically generated by lowercasing and whitelisting the
captions.If a method exists with the same name as a widget id, it isautomatically
boundto the usually-wanted event (click in case of button, value-changed in
case of basically anything else). Oh, andcloseandquitare already
there for your convenience.Otherwise, you can retrieve and set the widget’s value by using its id like
a classattribute.f_show()captures all the usual boilerplate and simply f***ing shows
the frame. It can be used for both the toplevel and additional frames.Also note how the class name automatically turned into the window title.
Override by setting.f_title.The created widgets are“raw”, native widgets. You can configure the toolkit
to use. Currently there is a Qt and a Tkinter implementation. The native
widget can accessed usingform["widget_id"](orform.f_controls["widget_id"]).The general philosophy is to not paint everything over with wrappers. Instead,
the library focuses on specific tasks - building the layout, event-/value
binding - and lets you do everything else with the API you know and (maybe) love.INSTALLATIONpip install ascii_designerRequirements: Python >= 3,attrs. To use the Qt toolkit you needqtpy.DOCUMENTATIONPlease proceed tohttp://ascii_designer.readthedocs.io/en/latest/index.htmlLICENCSEMIT License:https://github.com/loehnertj/ascii_designer/blob/master/LICENSETODOAlpha-state software, mostly working.Test coverage is lacking, politely spoken.This is a hobby project. If you need something quick, open an issue or send a pull request.