Metadata-Version: 2.2
Name: ascii_designer
Version: 1.0.0
Summary: Builds dialogs from ASCII art definition.
Author-email: Johannes Loehnert <loehnert.kde@gmx.de>
License: Copyright 2018 J. Löhnert
        
        Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
        
Project-URL: Homepage, http://github.com/loehnertj/ascii_designer
Project-URL: Repository, http://github.com/loehnertj/ascii_designer
Project-URL: Documentation, https://ascii-designer.readthedocs.io/
Project-URL: Issues, http://github.com/loehnertj/ascii_designer/issues
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: User Interfaces
Requires-Python: >3.7
Description-Content-Type: text/x-rst
License-File: LICENSE
Provides-Extra: qtsupport
Requires-Dist: qtpy; extra == "qtsupport"

ASCII Designer
==============

A library that:

* creates GUI from ASCII-art (with well-defined syntax)
* maps widgets to virtual class attributes
* relieves 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 in ``AutoFrame``. The 
  ``f_show`` call triggers rendering of the form. All the reserved attributes 
  are prepended with ``f_`` to get out of your way when subclassing.
* There is a **well-defined syntax** for 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 the **header row** with the pipe characters. The 
  minus sign denotes stretching columns. (The ``<`` / ``>`` chars are just 
  decoration.)
* **Column-span** is easily done by having not-a-space underneath the pipe 
  symbol. **Row-span** can also be done by prepending subsequent cells with a 
  ``{`` character.
* **Anchoring** is 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 IDs** are automatically generated by lowercasing and whitelisting the 
  captions.
* If a method exists with the same name as a widget id, it is **automatically 
  bound** to the usually-wanted event (click in case of button, value-changed in 
  case of basically anything else). Oh, and ``close`` and ``quit`` are already 
  there for your convenience.
* Otherwise, you can retrieve and set the widget's value by using its id like
  a class **attribute**.
* ``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 using ``form["widget_id"]`` (or 
  ``form.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.
    

INSTALLATION
------------
::

    pip install ascii_designer
    
Requirements: Python >= 3, ``attrs``. To use the Qt toolkit you need ``qtpy``.
    
    
DOCUMENTATION
-------------

Please proceed to http://ascii_designer.readthedocs.io/en/latest/index.html

LICENCSE
--------

MIT License: https://github.com/loehnertj/ascii_designer/blob/master/LICENSE
    
TODO
----

Alpha-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.
