Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Quick and Dirty GUI Applications using GUIDeFATE

66 views

Published on

Perl modules to get a GUI up in minutes. The world's easiest GUI Designer....GUIDeFATE

Published in: Software
  • Be the first to comment

  • Be the first to like this

Quick and Dirty GUI Applications using GUIDeFATE

  1. 1. Quick and Dirty GUI Applications (and why you should make them) Saif Ahmed (SAIFTYNET)
  2. 2. Saif Ahmed Orthopaedic Surgeon Interests include:- (Tissue Engineering) (Electronics) (Robotics) (Programming) Introduction
  3. 3. %Contents=( Context => "Brief insight into TE", # Tissue Engineering n=5 GUIDeFATE => "Quick and dirty GUI" , # One way to do it n=18 SIMPLE => "End-user = Developer",# If there is time n=2 Soapbox => "Putting world right" , # Old fart talk n=2 Conclusion => undef, );
  4. 4. Context
  5. 5. Tissue Engineering Organisms are made of many organs, made of many tissues, made of many cells supported by matrices. Living structures are made of tissues...a structure made of cells and a scaffold holding them together. Cells need oxygen, nutrients and electrolytes to function delivered by a perfusion system So mixing cells, matrix and a blood supply produces living tissue….simple, eh?
  6. 6. Brief Overview of How Others Do It Tissue culture is easy: Organ culture is difficult In an organ diverse specialised cells are distributed in geographically distinct locations in a matrix providing mechanical support, in a biologically well maintained and perfused environment. Bioprinters exist. Expensive, proprietary, do not work. Generated tissue needs to be kept in a sterile climate controlled environment. Usually the entire printing device integrates with the build environment
  7. 7. The IntraCavity Bio Matrix 3D Printer. Open Source 3D printer capable of constructing a living tissue engineered inside a cavity within a narrow neck. Cheap, novel, reduced dependencies Most parts 3D printed To be driven using a Perl application:- ● Convert raster shape to vector voxels ● Translate polar geometry into cartesian coordinates for Extruder positioning ● Control flow rate and composition ● Generate the G-code and upload ...via a Real-Time embedded system for actuator control (like conventional Desktop 3d printers) (Help wanted)
  8. 8. The software interface The positioning electronics and the hardware=easy, doable, being refined. Control software objectives : - ● Usable interface for non-programmers ○ Everybody want applications to “just work” ● Abstraction and Algorithmic transformation ● Motion simulation ● Decomposition of printer mechanical actions ● G-Code generation ● Testing with final device
  9. 9. Visualisation is critical for 3D development Need to be able to simulate motion to make sure algorithms are right Need to visualise that motion Need End-user to be able make fine adjustments without reprogramming Need to make the tools accessible for non programmers Need to make it programmable for non-programmers Need to learn A Lot Of Things... ….but I AM OLD
  10. 10. Diversion into Interface Development by a naive developer
  11. 11. Making Perl GUI Applications Modules exist for multiple desktop interfaces Wx, Multiplatform, QT4 (not installable from CPAN) GTK Win32 (Platform constrained) Tk (Dated looks) Design tools exist to make things less complicated: e.g. wxGlade, Glade, Qt designer. Each only work with one interface, each with a significant learning curve. BUT it isn’t as easy as it should be “Wx not easily installable in some systems, and in versions of Perl after 5.16” “QT5 depends on Perl to build, but does not provide Perl API” “Tk works but looks ugly” “Use Inline Python for a GUI in Perl” “Info on Perl GUI development is illusive or old”
  12. 12. Too much effort, too much to learn I tried... Too many Toolkits (wx, Tk, Qt, etc) Too many paradigms for interacting with GUI Too many widget types Too many options for each widget type Even if it works on one platform, no assurance it will work for others...dependencies can not always be met. Diversity of platform and interface makes it easier to avoid the Desktop altogether … back to the drawing board
  13. 13. How I do it ...it is probably not the best way to do things ...it is one way to do things ...it may not work for everybody ...it may be coded better Invitation to constructively criticise Why I did it this way Do not have surplus time and energy Fading memory and learning capacity Others need to read/adapt my code Apps to be usable by non-coders TIMTOWDI
  14. 14. Graphical User Interface Design From A Text Editor +-------------------------------------------+ |T The Plants List App | +M------------------------------------------+ | {Refresh Data} dd/mm/yy | | [ ] {Search} | | {Angiosperms } 000 {Gymnosperms} 000 | | {Pteridophytes} 000 {Bryophytes } 000 | | No item on list | | +T-----------------+ +I--------------+ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +------------------+ +---------------+ | | {<} { Explore } {>} { Upload Photo } | | 0000 of 0000 | | www.theplantlist.org wikipedia.org | +-------------------------------------------+ Perl is good at parsing textual data
  15. 15. GUIDeFATE- the world simplest GUI designer Design Specifications ● No tools = Nothing external to learn ● Backend agnostic = Users choose what toolkit is installed or can be installed. Platform unconstrained ● Visual development = easy for a newbie ● Embedded = visible in the program code ● Few widgets = sacrifice capability for convenience Downside...programmed by an amateur
  16. 16. Designed in a Text Editor use GUIDeFATE; # create textual representation my $window=<<END; +----------------+ |T Window Title | +----------------+ | | | Hello World | | | +----------------+ END # Convert to a GUI and then start it my $gui=GUIDeFATE->new($window); $gui->MainLoop; The window design is obvious from the code in monospace font Looks roughly similar in multiple backends Supports Wx, Qt, GTK, TK, Win32, HTML
  17. 17. Only one object….the GUI Frame GUIDeFATE.pm ● Imports frame object from GFwx, GFtk etc ● Parses textual representation: convert() ○ To create a list discovered widgets ○ Allocate sequential Internal IDs ○ Add these objects to the frame ○ Optionally generate developer assistance ● Return the Frame object if ((!$target)||($target=~/^wx/i)){ $target="wx"; die "Failed to load Wx backend: $@" unless eval {require GFwx} ; GFwx->import; convert($textGUI,$assist); return GFwx->new(); } The Frame Object is defined in GFWx, GFtk etc Offers only a few methods: - ● Set, get and append values ● Open file selector and dialog box ● MainLoop Invocation my $gui=GUIDeFATE->new($window,$backend,$assist); my $frame=$gui->getFrame|| $gui; $gui->MainLoop;
  18. 18. Options my $gui=GUIDeFATE->new($window,$backend,$assist); $window contains the textual representation string $backend (optional) contains one of “wx”, “gtk”, “qt”, “tk”, (“html” or “web” experimental options exist as well) $assist (optional) contains one of : ● “q” for quiet…(default), ● “v” for verbose...prints to console each widget identified… ● ”a” for autogenerate… generates a perl - file containing a list of empty subroutines, referring to functions called for user interaction
  19. 19. Another example GUI string +------------------------+ |T Calculator | +M-----------------------+ | [ ] | | {sqr}{pi }{ C }{AC } | | { 1 }{ 2 }{ 3 }{ + } | | { 4 }{ 5 }{ 6 }{ - } | | { 7 }{ 8 }{ 9 }{ * } | | { . }{ 0 }{ = }{ / } | | made with GUIdeFATE | | and happy things | +------------------------+
  20. 20. Other widgets…(very few widgets currently, more may eventually follow) Buttons {label} Input box [default text] Combobox ^combo^ ImageBox +I-----------+ |Image.path | | | | | | | +------------+ TextArea +T-----------+ |content | | | | | | | +------------+
  21. 21. Example...Logo to SVG convertor my $window=<<END; +------------------------------------------------------------------------------+ |T LOGO to SVG convertor | +M-----------------------------------------------------------------------------+ |{Draw}{Logs} {Zoom in }{Zoom out}{Zoom All}{<}{^}{v}{>}{Center all}{AC}{Reset}| |+T---------------------++I---------------------------------------------------+| ||# Simple Logo ||simplelogo.svg || || || || || || || || || || || || || || || || || || || || || || || || || || || || || || || || || || || || || || || || |+----------------------+| || |[ ]+----------------------------------------------------+| +------------------------------------------------------------------------------+ Menu -File --New --Open --Save Script --Quit -Image36 --Draw --Save SVG --Save PNG -Examples --Star --Spiral --Flower --About END
  22. 22. Example...A Simple Game my $window=<<END; +------------------------------------------------+ |T Rock Paper Scissors Lizard Spock | +------------------------------------------------+ | | | Play Rock Paper +I------+ | | Scissors Lizard |rock.bm| | | Spock. Click |p | | | any button to +-------+ | | play { Rock } | | | | +I------+ +I------+ | | |Spock.j| +I------+ |paper.j| | | |pg | |sister.| |pg | | | +-------+ |jpg | +-------+ | | { Spock } +-------+ { Paper } | | I am ready | | | | +I------+ +I------+ | | |Lizard.| |scissor| | | |jpg | |s.jpg | | | +-------+ +-------+ | | {Lizard } {Scissrs} | | | +------------------------------------------------+ END
  23. 23. Example...The Executioner my $window=<<END; +--------------------------------------+ |T Executioner | +M-------------------------------------+ | ^bends ^ Options ^optns^ | | {Calculator } | | {Rock Paper Scissors Lizard Spock} | | {GUI Gnuplotter } | | { Text editor } | | {Image Magick GUI } | | { Executioner (this) } | | [ ]{Execute } | +--------------------------------------+ bends=$backends optns=Quiet,Verbose,Assist,Debug END
  24. 24. Convert to a Web Application? my $gui=GUIDeFATE->new($window, “web”);
  25. 25. Convert something useful into easily usable e.g. GUI interface for Gnuplot or ImageMagick Can create an interface with an editor panel Include help and example in the menu Load, Edit, Save, Export etc without needing console
  26. 26. Duck-tape the Internet to the Desktop Connect to Internet Databases and harvests data and present to the user as needed. This searches all known plants from ThePlantList.org creating a local cache, then searches wikipedia for the plants and if an image found, saves a copy
  27. 27. The Transformative Effect of Adding a Desktop GUI ● Transforms workflow ● Immediate visual feedback of yields ● Able to identify needs and address wishlist quickly ● Using a instant GUI frees programming time to enhance your utility rather than focus on the interface ● Can make legacy console applications interact with a modern UI The web browser has been Perl’s principle GUI. Not appropriate for all scenarios Unnecessarily narrows scope Screenshot application
  28. 28. End-user Programmability
  29. 29. Simple Integratable Modular Programming Language Experiment ● Customisable sequential task processing from a script. ● Generate visual output, simulating programmed motion ● Don’t know graphics programming ○ but can understand SVG ○ → SimpleLOGO ● Able to display code, outputs, and debugging information on GUI ● Perl makes script parsing easy
  30. 30. Soap Box - Vanishing Languages Goal of Perl "to make the easy things easy, and the hard things possible" (1) “the power of a programming language is not what it lets you do, but what it lets you do easily” (2) Larry Wall
  31. 31. “When I were a lad...” Perl is clearly good language for ● Command line tools ● Sysadmin tools ● CGI, Webapps ● Bioinformatics ● (? Desktop utilities) Learn a system, and code it, all the tricks and nuances, etc Admire skills of fellow coders Do a few snippets of code Feel good about yourself Which later becomes obsolete… But Perl seemed, no IS, different...
  32. 32. Perl Super Powers ● CPAN Modules for every task ● Text processing and RegExp power ● Performance ● One-liners ● Do more with fewer lines of code Paradox... Perl utilities often serve large numbers of people behind other more visible interfaces Webapps, websites, server management etc Being robust, reliable and low maintenance, the work is invisible Invisible Power Tends to Vanish (and no-one notices)
  33. 33. Make Perl Applications Visible- Use a GUI Accessibility Usefulness Simplicity Intuitiveness Modern interface paradigms Sensory stimulus (Multimedia yields) Unconstrained by OS, Graphical Toolkit or network So … Make Desktop Perl applications
  34. 34. Conclusion It is not enough for a programming language to make hard things possible, Hard things should be made easy too… It is not enough for a program to be usable by its developer Usefulness is defined by the effort required of any user to reach a desired result Concentrating on niche server-side, headless and console bound operations limits a language or an application. It should not be difficult to expand scope of any application to be delivered from the Desktop as well.

×