This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Graphics Agnostic Python (GAP)
Ti Leyon last edited by Ti Leyon
Graphics Agnostic Python (GAP)
GAP is a visual interface designer written in
Pythonthat produces complete python scripts with modern graphical interfaces. These scripts may be executed verbatim under all five major computing platforms (MS Windows, OS X, Linux, iOS an Android) with consistent look feel and functionality. GAP is a universal Rapid Application Development (RAD) environment for the
Pythonlanguage. A prospective user needs only grasp rudimentary concepts of modern user interface elements without any idea of the coding involved. The module and its output require kivy or the Pythonista UI in order to function.
GAP was designed with the utmost emphasis on simplicity. A three line instruction (displayed in the application's window) should be sufficient for a new user to start interacting with the environment then design and generate a full fledge application in minutes if not seconds.
GAP is composed of a virtual screen that occupies most of the surface of its window starting at the top left, a few buttons and text fields at the right of that virtual screen and three lines of instruction at the very bottom. The virtual screen is an exact replica of the one generated by its output with all its components properly scaled and positioned. The top five buttons create corresponding components at predefined positions and sizes. These components can be selected and dragged anywhere on the virtual screen. Their positions and sizes can be altered by changing the four text fields to a desired value then clicking or touching the
Modifybutton. A selected component can be removed with the
Savebutton will create a fully functional
Pythonscript named "gapout.py" that reflects perfectly the virtual screen and its elements. GAP will automatically define functions that are bound to every button in the interface. Users may modify these functions at will to adapt the script's functionality to their specific needs.
GAP is built using the
UniPAGe.pymodule. The application reads itself to isolate that module and use it to build its output. Therefore, they may be scaled according to a 4/3 ratio without distortion.
For more information about
UniPAGerefer to its repository or its thread on this forum.
GAP and UniPAGe are copyrighted materials of Ti Leyon (© 2017).
They are released under the Creative Commons Attribution-ShareAlike 4.0 International License
GAP constitutes another step into the unification of
Pythonista. However, it greatly simplifies, optimizes and accelerates the task of generating a GUI. Users can produce a complete application with a sophisticated interface in seconds from any device in which
Pythonista UIis available. Then they can just concentrate in customizing functionality by modifying the predefined functions bound to the buttons. By allowing them to do so GAP totally abstract these users from the intricacies of the underlying code.
On a technical point of view GAP further demonstrates the extraordinary affinity between
Pythonista UI. This is very fortunate for the roaming programmer which seems to be de rigueur these days. I should mention that
Scenewas not used in
Kivy. The basic touch event was overridden in both systems and the logic implemented from scratch. This project (yes it seems to have evolved into a real project now) has compelled me to investigate realms of
Pythonthat otherwise I would not get into. The need to create conditional classes brought me into the technicalities of the
superclass. Although that structure could have provided the mechanism for conditional classes, I found its implementation quite awkward, overcomplicated and definitely beyond the grasp of many potential users of the script. Therefore, I opted for the code to detect the operating environment and accordingly submit a specific type to the classes. GAP uses
UniPAGeto build its interface and introduces two new classes. The interesting part is that it uses the first one as a parent of the second when using
Kivywhile it turns it into a custom
Pythonistato catch the
Touchevents. That way it implements the exact same algorithm for manipulating the elements created in the virtual screen.
I do not use comments while coding, because doing so interferes with my concentration, and rarely add them afterward because it becomes a hassle. I understand that the script has grown way more complex than I expected when I started it. Therefore, if the reader has any question about the implementation or its logic do not hesitate to post it on this thread. I will do my best to address the issue. Below is the full implementation of GAP. You may copy it or retrieve it from
Github. If you elect to copy it make sure that your first line of code is the first comment line (The one with a lot of dashes). This is because GAP reads itself under whatever name you save the script so it can isolate the
UniPAGeportion to generate the output.
Edit: The script is way too long to be inserted in this post. Please retrieve it from GitHub here.
jmv38 last edited by jmv38
@tileyon thanks, nice work.
I would like a full_screen interface, would you consider adding this option? I can easily modify the code to add it in pythonista, but it wont work in kivy, and the size must be adjusted automatically too. And it seems your license does not allow me to change the code (or?).
zrzka last edited by
@jmv38 why do you think you can't change the code? Read https://creativecommons.org/licenses/by-sa/4.0/
jmv38 last edited by
@zrzka thanks for correcting my mistake.
Ti Leyon last edited by
@jmv38 the visual interface designer keeps all the screen elements in a variable called
widgets. That variable is always defined in the
__main__section of its output (
gapout.py) near the end of the script.
widgetsis a list of tuples that defines the parameters for the constituents of the interface. The first tuple represents the window size in the form of (width, height). You may change these parameters to whatever number you want and all the subviews will be scaled accordingly. Try to keep a 4/3 ratio between the width and the height to avoid distortion. If you set the tuple to (0, 0) GAP will automatically set the window to an
optimalsize according to the orientation in which you start the script. By the way you can do the same with GAP itself since it is also based on
Ti Leyon last edited by
Major enhancements to the Visual Interface Designer’s interface. Now you can change the sizes of a selected object by dragging on it with the mouse or finger. To do so you have to toggle the newly introduced
switchbuttons to the on state. This will prevent the component from moving and instead its dimensions will change with the dragging according to which switch is turned on. You can also change the name of the output file directly from GAP. The interfaces of files built with GAP can now be loaded and modified. This is almost "programming for the rest of us". Programming for the non techie on the go. If I can spare the time I will try to write a
MIT Scratchlike Python script to make it fully so.
gap21.pyto get the new features.
Below is a screenshot with a description of the new features.
Although GAP was developed manually using UniPAGe below is a screenshot of the script reading itself in an Android phone.
In a further release I will try to introduce a help screen at the first start up in a specific directory since the space for the three lines instruction is now taken.