Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sun 21 Oct 2018, 15:32
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
IUP deb and pet packages for use with small Lua interpreter
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 2 [24 Posts]   Goto page: 1, 2 Next
Author Message
wiak

Joined: 11 Dec 2007
Posts: 957
Location: not Bulgaria

PostPosted: Wed 04 Apr 2018, 04:56    Post subject:  IUP deb and pet packages for use with small Lua interpreter
Subject description: Graphical toolkit compiled by me to use gtk2
 

IMPORTANT: See also post three of this thread for optional extension iupluacontrols module deb and dotpet downloads.
-----

Lots of learn Lua related links, tutorials, and IDE information, in these thread posts:

http://www.murga-linux.com/puppy/viewtopic.php?p=988625#988625

http://www.murga-linux.com/puppy/viewtopic.php?p=988238#988238

iuplua-core-xenialdog64-gtk2 64-bits deb package (size 344 KiBytes) for Xenial 64bits OS google drive download link here (IUPLUA has liberal tecgraf-MIT opensource licence so is fully GPL compatible). Just two small packages to install for sophisticated GUI programming environment (you will NOT need any devx to be loaded): i.e. apt-get install lua5.3 and then download and install uiplua-core deb package from google drive link here:

64-bit Deb on google-drive here:

https://drive.google.com/open?id=1ggyc3vVJLEBPkPlDorx8eAZE87_S5U2W

64-bit Dotpet on google-drive here:

A dotpet of iuplua-core, which I tested on Slacko64 v6.9.9.9 (kernel 4.9) here:

https://drive.google.com/open?id=1-CHe7rvJa1ccQL-BSXessBOfPzuMEmSh

That dotpet should also work in Puppy Xenial64 and Quirky Xenial64 and likely also fine for any 64-bit Artful or 64-bit Bionic builds.

Deb for xenialdog32/bionicdog32 and dotpet for 32bit Pups (slacko32 ver 6.9.9.9 should be okay as should XenialPup32 or Artful/BionicPup32 or any 32-bit version of Quirky Xerus). Won't work on slacko32 ver 6.3.2 cos too old libs and repository:

32-bit Deb on google-drive here:

https://drive.google.com/open?id=19UaHnEUSq3ZTt2PXYGGHknAPEGiRlUMI

32-bit Dotpet on google-drive here:

https://drive.google.com/open?id=1bYe_9YO9BaM9m8z7vdFfIX0atDbJndVf

For Puppy system use you first need to install Lua version 5.3.x from the Puppy Package Manager (IT HAS TO BE VERSION 5.3 FOR THIS IUPLUA LIBRARY). In Slacko64 ver. 6.9.9.9 that was from slackware 14.2 official repo. Note that in Puppy the command to run lua is 'lua' rather than the default 'lua5.3' in the Dogs.

Then simply try out the examples linked to in second post of this thread (explanation of howto run them given in detail below if you need it).

The above gtk2-compiled uiplua-core deb package along with official apt-get installed lua deb package (104 kB download; 379 kB installed) is all you need for programming basic (simple widgets) GUI apps and utilities in Lua script-interpreting programming language. Note that the alternative version of iuplua system libs provided on tecgraf iup download site (google it...) are compiled for gtk3. I have here recompiled for gtk2 in case more useful on Puppy/Dogs.

Lua with IUP is a very powerful GUI app-building combination, with a small install size. IUP offers far more functionality than gtkdialog or yad and I find it even easier to build GUIs with it than either of those others (just look at the dotlua scripts example code in the links provided in post two below...).

Lua itself is actually much easier to program in than in bash (though many on the forum are already quite fluent in bash of course so may doubt my statement...) and is actually a very full-featured, yet tiny, programming language (interpreter). You can also run bash commandline utilities (such as sed) from within Lua, and more particularly if you add-on a lua-module such as maybe lua-sh by Serge Zaitsev (google it later). Learning to program the GUI part is almost trivial (certainly easier than learning gtkdialog for the first time) - just run and then read the simple program examples in the second post of this thread to see how to do it. Later you'll want to learn a bit more Lua of course.

Lua used to be provided in some early Pups, by the way, in the form of Murga-Lua by John Murga, which was a (discontinued?) mod of Lua with bindings to modified FLTK graphical toolkit. However, IUP has the advantage of using native widgets (GTK in Linux and Windows API widgets in Windoze) rather than the unique widgets FLTK draws itself (which some say don't look good alongside native widgets). Note that you can also program your GUIs in C as an alternative to Lua, but, as I said above, with what is provided here, no devx is additionally required for Lua programming, and Lua is a logical simple-to-learn language for beginners too:

Serge wrote:
Lua is one of my favourite languages. It's tiny, it's fast, it has simple grammar and is very easy to learn.
...
I had an experience in the past when Bash script became hard to maintain. Then we moved to Lua, and it was a big relief. Logic became transparent, code became more readable. However, we had to wrap shell command invocations into hand-written functions to make them look nice. So I made a library that brings the joy of shell scripting into Lua.



INSTALLATION AND USAGE STEPS


If it's Puppy (xenial or bionic anyway), just install the dotpets, else if its a Dog:

1. Using IUPLUA via iuplua-core-xenialdog64-gtk2 installation only requires lua5.3 (104 kB download; 379 kB installed) to first be installed, which you can install on XenialDog with:

Code:
apt-get update && apt-get install lua5.3


IUPLUA also requires libfreetype runtime library to be installed and findable on your system, but that is already done in XenialDog pristine iso.EDIT: I have now tested on pristine XenialDog64 install and all worked fine.

2. Then install the attached iuplua-core-xenialdog64-gtk2 deb package (in pcmanfm on XenialDog you just need to right click it and choose to install.debs).

3. Running provided example lua scriptsE:

a. Links to a whole host of example scripts, that are tested as working with iuplua-core-xenialdog64-gtk2, are provided in the second post of this thread linked below along with some documentation for IUPLUA. Please let me know if any don't run afterall and I'll re-test:

http://www.murga-linux.com/puppy/viewtopic.php?p=987612#987612

Note that these example scripts just produce the sample GUIs - extra code would need to be added to them to complete their functionality.

To try these examples, simply click on the particular example link and the lua script text will appear in your webbrowser. Then save the page thus displayed, in any directory you like on your system, with the filename as provided at the end of the link (for example "alarm.lua"). To then run the example, simply open a terminal at the download directory and enter the command:

Code:
lua5.3 <filename> (e.g. lua5.3 alarm.lua)


b. Alternatively, you can edit the lua script (which is a simple text file) and insert the following line at the top of the script (assuming lua5.3 executable was installed in that path, which it was on XenialDog64):

Code:
#!/usr/bin/lua5.3


c. Save the edited file and then, make the script executable with:

Code:
chmod +x <filename>


d. Then you can just run the file from the terminal with command:

./<filename> (e.g. ./alarm.lua) just as you would were it an executable bash script... On my XenialDog64 system no exec nor lib paths environment variables needed to be changed.

That's it! Should hopefully all be working for simple GUI Lua programming now. What follows is for more complex GUI building and additional functionality, which will require additional iuplua modules to be installed as described.
----------

Note that the other more complex GUIs examples (yet still easy to program), such as matrix(*).lua, provided at:

https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/

generally 'require' the additional iup libraries provided by iupluacontrols-xenialdog64-gtk2_3.24_amd64, which I am providing as a single (399 KiBytes) deb package in post three below. Note that some of these other examples require even more iuplua library modules (such as libiup-plot.so and libiuplua-plot53.so for plotting graphs), some of which I will attach as deb packages to later posts.

Soonish/later, however, I want to create some examples that show how to interface with bash shell commands such as sed, and general shell pipeline commands so I can experiment with converting existing bash/gtkdialog scripts as exemplars of using Lua with IUP. I will also try to make XenialDog32 bit deb versions and also dotpets for Puppy Xenial sometime in nearish future, but any developer could probably easily manage to convert the attached deb packages to dotpets anyway (but for 32 bit systems, iuplua will need re-compiled so DO NOT attempt to use the 64 bit debs on 32 bit Linux...). Getting this far was a lot of work so I'm intending to take a bit of a rest just now albeit whilst continuing to play/experiment with this iuplua system... Wink

I also intend to make same gtk2-based IUPLUA packages for Ubuntu Bionic (debs and dotpets) some time after BIONIC becomes stable. I do not guarantee any support for other distributions or earlier Puppies at this stage. The usual disclaimers apply to what is provided.

Some of you may also be interested in seeing my murga-forum development thread for IUPLUA compiling/packaging here (which is basically a scratchpad of reminders for my own use):

http://www.murga-linux.com/puppy/viewtopic.php?t=113013

Regarding UIP and Lua more generally for bigger apps like painting/image-manipulation:

https://webserver2.tecgraf.puc-rio.br/iup/en/tutorial/tutorial4.html

http://compasstech.com.au/TNS_Authoring/Scripting/lua_tutorials.html

http://compasstech.com.au/TNS_Authoring/Scripting/script_tut7.html

wiak

Last edited by wiak on Sun 29 Apr 2018, 20:16; edited 30 times in total
Back to top
View user's profile Send private message 
wiak

Joined: 11 Dec 2007
Posts: 957
Location: not Bulgaria

PostPosted: Wed 04 Apr 2018, 04:56    Post subject: Example code and docs  

Some relevant IUP, CanvasDraw (cd), and Lua documents

https://sourceforge.net/projects/iup/files/3.24/Docs%20and%20Sources/iup-3.24_Docs.pdf/download
https://sourceforge.net/projects/canvasdraw/files/5.11.1/Docs%20and%20Sources/cd-5.11.1_Docs.pdf/download
http://www.lua.org/manual/5.3/manual.html
https://webserver2.tecgraf.puc-rio.br/iup/en/iuplua.html

Lightweight small footprint IDE for Lua programming:
https://studio.zerobrane.com/

Note that, once installed, the applications name is zbstudio. On my XenialDog64 system it installed into directory /usr/bin/zbstudio with its desktop file in "/usr/local/share/applications/ZeroBrance Studio"

IDE for Lua programming if you want it. The zbrane download actually comes with its own versions of lua but should set to the one you want to use, for example, /usr/bin/lua5.3. To do that, start zbstudio and Edit --> Preferences. In the resulting user.lua window add the code (seems to fix things to work using zbstudio IDE, but only just tested):

Code:
path.lua = '/usr/bin/lua5.3'


https://studio.zerobrane.com/doc-lua-quick-start-guide

Now I'm away to learn Lua programming with the above for creating the GUIs... Wink
-----------------------------

There follows links to example Lua scripts that should work with only lua5.3 and iuplua-core-xenialdog64-gtk2 deb package installed

Simplest way to run them is just to download them as a text file with same name as in link and run them from command line with lua5.3 interpreter. For example:

Code:
lua5.3 alarm.lua

lua5.3 getfile.lua

lua5.3 hbox.lua

lua5.3 menu.lua

lua5.3 sample.lua

lua5.3 tree1.lua

lua5.3 notepad.lua

etc...


These particular lua GUI scripts DO NOT 'require' installation of the iupluacontrols deb provided in my next thread post:

https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/alarm.lua
https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/button.lua
https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/console.lua
https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/dialog.lua
https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/filedlg.lua
https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/filedlg_preview.lua
https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/fill.lua
https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/fonts.lua
https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/frame.lua
https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/getfile.lua
https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/hbox.lua
https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/idle.lua
https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/image.lua
https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/item.lua
https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/label.lua
https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/list.lua
https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/listdialog.lua
https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/mdi1.lua
https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/mdi2.lua
https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/menu.lua
https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/message.lua
https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/message_clone.lua
https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/messagedlg.lua
https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/multiline.lua
https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/normalizer1.lua
https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/normalizer2.lua
https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/notepad.lua
https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/radio.lua
https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/sample.lua
https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/scanf.lua
https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/separator.lua
https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/submenu.lua
https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/text.lua
https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/text_highlight.lua
https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/timer.lua
https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/toggle.lua
https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/tray.lua
https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/tree1.lua
https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/tree2.lua
https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/tree3.lua
https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/tree_set_attrs.lua
https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/vbox.lua
https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/zbox.lua

wiak

Last edited by wiak on Thu 12 Apr 2018, 02:11; edited 8 times in total
Back to top
View user's profile Send private message 
wiak

Joined: 11 Dec 2007
Posts: 957
Location: not Bulgaria

PostPosted: Wed 04 Apr 2018, 04:56    Post subject: optional additional module iupluacontrols  

Optional additional module iupluacontrols

Note that the other more complex GUIs examples (yet still easy to program), such as matrix(*).lua, provided at:

https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/

generally 'require' the additional iup libraries provided by iupluacontrols-xenialdog64-gtk2_3.24_amd64, which I am for now providing as a single (399 KiBytes) XenialDog 64bit deb package and XenialPup dotpet via the following google-drive links:

Deb pkg for XenialDog64 (also worked on BionicDog64).

64-bit deb on google-drive here:

https://drive.google.com/open?id=1dfAWxGsHbEZJLeJTUtBHrW4zRtlGLI8k

Dotpet pkg tested on Slacko64 v6.9.9.9 and should work in Quirky Xenial, and probably any 64-bit Puppy Artful64 and Bionic64 if ever built.

64-bit dotpet on google-drive here:

https://drive.google.com/open?id=1sX4AV5nccHaQ8mhWnt2EV5XE_fVYabxh

32-bit Deb on google-drive here:

https://drive.google.com/open?id=1_NlIfmPZEmsOOnb3pCWTQitZ7bUAoxib

32-bit Dotpet on google-drive here:

https://drive.google.com/open?id=1uAVsHjkJSmA5a9LGkaTtlnB4GUYEwHOL

Above should work on Slacko32 ver 6.9.9.9 but not version 6.3.2. Should also work on 32-bit versions of XenialPup, ArtfulPup and BionicPup and on any 32-bit Quirky Xerus (if there is such a version).

wiak

Last edited by wiak on Tue 10 Apr 2018, 06:53; edited 10 times in total
Back to top
View user's profile Send private message 
wiak

Joined: 11 Dec 2007
Posts: 957
Location: not Bulgaria

PostPosted: Wed 04 Apr 2018, 04:56    Post subject:  

Some optional technical details relating to more advanced IUP GUI programming. Includes links to how to use IUP with not only Lua, but also with C, Perl, Ruby, Go, FreeBASIC, ScriptBASIC, Component Pascal, and more:

https://webserver2.tecgraf.puc-rio.br/iup/en/guide.html

In particular, note that the way the gtk dialog GUI is constructed is similar to Puppy's favourite old gtkdialog (vbox, hbox inside frames etc). Thankfully, IUP doesn't use pseudo xml constructs, however (which are easily messed-up, when doing by hand, and add a lot of bulk and indenting complexity):

Quote:
IUP controls are never positioned in a specific (x,y) coordinate inside the dialog. The positioning is always calculated dynamically from the abstract layout hierarchy. So get used to the IupFill, IupHbox and IupVbox controls that allows you to position the controls in the dialog.


wiak

Last edited by wiak on Wed 04 Apr 2018, 08:13; edited 6 times in total
Back to top
View user's profile Send private message 
wiak

Joined: 11 Dec 2007
Posts: 957
Location: not Bulgaria

PostPosted: Wed 04 Apr 2018, 04:57    Post subject:  

reserved
Back to top
View user's profile Send private message 
wiak

Joined: 11 Dec 2007
Posts: 957
Location: not Bulgaria

PostPosted: Wed 04 Apr 2018, 04:57    Post subject:  

reserved
Back to top
View user's profile Send private message 
wiak

Joined: 11 Dec 2007
Posts: 957
Location: not Bulgaria

PostPosted: Wed 04 Apr 2018, 05:09    Post subject: IUP deb packages for use with small Lua interpreter  

IUPLUA graphical toolkit programming environment deb files. This first release (GTK2 compilation) is for Ubuntu Xenial 64-bit system (such as XenialDog64). Whether it would work on any other recent 64-bit Linux system I do not know. I intend to compile 32-bit versions later and hopefully also produce some dotpets. Links to simple example GUI code is provided in second post of thread.

Find the small google-drive download near the top of the first post of this thread:

http://www.murga-linux.com/puppy/viewtopic.php?t=113082

wiak
Back to top
View user's profile Send private message 
Keef


Joined: 20 Dec 2007
Posts: 918
Location: Staffordshire

PostPosted: Wed 04 Apr 2018, 17:03    Post subject:  

This looks to be working well in Quirky Xerus64 - just had to install Lua 5.3 via petget. Tried a few of the examples and no problems so far.

I did try it on Fatdog also - it only has Lua 5.2 available but simple enough to download and compile 5.3. Had to manually install the deb, but got a 'undefined symbol' error.
uip.jpg
 Description   
 Filesize   92.45 KB
 Viewed   691 Time(s)

uip.jpg

Back to top
View user's profile Send private message 
wiak

Joined: 11 Dec 2007
Posts: 957
Location: not Bulgaria

PostPosted: Wed 04 Apr 2018, 17:50    Post subject:  

Keef wrote:
This looks to be working well in Quirky Xerus64 - just had to install Lua 5.3 via petget. Tried a few of the examples and no problems so far.

I did try it on Fatdog also - it only has Lua 5.2 available but simple enough to download and compile 5.3. Had to manually install the deb, but got a 'undefined symbol' error.


Thanks for the report Keef. Good to know it works on Quirky Xerus64. Later I plan to work on a compile-build system to make it easy for me to rebuild specifically for different platforms. Compiling iuplua proved very tricky for me first time round, but mainly because there were several dependency parts to it all. I was pleasantly surprised at how powerful just using the iup and iuplua libs (in core) proved to be in around half a MB compressed download total including Lua. I'm not myself a Lua programmer, but I now intend to learn - doesn't look too difficult.

Hopefully someone can try the existing debs on Xenial Pup too.

wiak

EDIT: Attached is a screenshot of one of IUPLUA examples running (notepad.lua).. Not a bad little lua text notebook written in only 164 lines of code. It isn't just a GUI in this example; it all actually works. Note that '--' signifies comment lines in Lua. You can get the extra HELP menu (and submenu) to display by deleting the shown -- comments in notebook.lua code shown below in iup.submenu{}, though there seems to be an error in that part of the code so probably why it is currently commented-out...
screenshot_notepad_lua_in_action.jpg
 Description   lua5.3 notebook.lua
 Filesize   60.1 KB
 Viewed   704 Time(s)

screenshot_notepad_lua_in_action.jpg

Back to top
View user's profile Send private message 
wiak

Joined: 11 Dec 2007
Posts: 957
Location: not Bulgaria

PostPosted: Thu 05 Apr 2018, 00:30    Post subject:  

Code:
apt-get update && apt-get install lua5.3

along with installing iuplua-core-xenialdog64-gtk2.deb

and (optionally): iupluacontrols-xenialdog64-gtk2.deb


Above also works fine with the examples from posts 2 and 3 above in BionicDog64. I am pretty the packages will also work fine in Puppy Xenial as long as Lua5.3 installed there via its package manager.

wiak
Back to top
View user's profile Send private message 
wiak

Joined: 11 Dec 2007
Posts: 957
Location: not Bulgaria

PostPosted: Thu 05 Apr 2018, 07:20    Post subject: IUPLUA dotpets for recent pups uploaded now
Subject description: to join the Dog debs
 

IUPLUA dotpets for iuplua-core-gtk2 and iupluacontrols-gtk2
have now been uploaded following some testing on Slacko64. Should work on XenialPup64, Quirky Xenial64 and any 64bit versions of Artful or Bionic I think.

See first post for some installation details concerning Lua itself (which needs to be installed too and it MUST BE Lua version 5.3.x).

Slacko64 lua5.3 (from slackware 14.2 repo) expected the iuplua libs to be in /usr/local/lib rather than /usr/lib/ so instead of requiring users to set PATH env variables to sort that out, I just added appropriate symlinks into the dotpets. From Keef's report above, probably won't work in FatDog64 without a recompile.

Any other reports of successes or failures would be appreciated. If enough interest I may compile 32bit versions though personally I always use 64bit Linux nowadays.

Regarding UIP and Lua more generally for bigger apps like painting/image-manipulation:

https://webserver2.tecgraf.puc-rio.br/iup/en/tutorial/tutorial4.html

http://compasstech.com.au/TNS_Authoring/Scripting/lua_tutorials.html

wiak
Back to top
View user's profile Send private message 
wiak

Joined: 11 Dec 2007
Posts: 957
Location: not Bulgaria

PostPosted: Tue 10 Apr 2018, 06:32    Post subject: 32bit iuplua dotpets now also provided above  

1. uiplua-core Debian package for 32-bit Xenial (also works on BionicDog32) also now added to first post of this thread.

2. Optional uipluacontrols Debian package for 32-bit XenialDog (also works on BionicDog32) also now added to third post of this thread.

3. uiplua-core Dotpet package for 32-bit XenialPup now added to first post of this thread. Should also work on 32-bit Bionic or Artful Pups and also in slacko32 ver 6.9.9.9 (but not, I think, in older slacko32 ver 6.3.2).

4. Optional uipluacontrols Dotpet package for 32-bit Xenial now added to third post of this thread. Should also work on 32-bit Bionic or Artful Pups and also in slacko32 ver 6.9.9.9 (but not, I think, in older slacko32 ver 6.3.2).

Again, these will only work with Lua version 5.3, which you need to download from package repository.

PLEASE NOTE WELL that I will only be providing these packages for a short time on my google-drive account, so get them while you can... If anyone has a reliable repository to store them for later, that would be good. They were quite tricky to compile so I'm unlikely to repeat that in a hurry.

EDIT: Also note, that more iuplua modules are available for the likes of matrixes, plotting graphs, handling images and so on. Let me know if you get into this and reach the stage when you want these. I currently have them all compiled, but not packaged, which would take me a lot of time so I'm not planning on that unless there is significant feedback and interest.

Lightweight small footprint IDE for Lua programming:
https://studio.zerobrane.com/

Note that, once installed, the applications name is zbstudio. On my XenialDog64 system it installed into directory /usr/bin/zbstudio with its desktop file in "/usr/local/share/applications/ZeroBrance Studio"

IDE for Lua programming if you want it. The zbrane download actually comes with its own versions of lua but should set to the one you want to use, for example, /usr/bin/lua5.3. To do that, start zbstudio and Edit --> Preferences. In the resulting user.lua window add the code (seems to fix things to work using zbstudio IDE, but only just tested):

Code:
path.lua = '/usr/bin/lua5.3'


https://studio.zerobrane.com/doc-lua-quick-start-guide

Now I'm away to learn Lua programming with the above for creating the GUIs... Wink
-----------------------------

Attempty to 'learn' Lua in 15 minutes:

http://tylerneylon.com/a/learn-lua/
https://gist.github.com/tylerneylon/5853042

https://webserver2.tecgraf.puc-rio.br/iup/en/tutorial/tutorial4.html

http://compasstech.com.au/TNS_Authoring/Scripting/lua_tutorials.html

https://www.lua.org/pil/contents.html

https://en.wikibooks.org/wiki/Lua_Programming

https://www.tutorialspoint.com/lua/index.htm

http://lua-users.org/lists/lua-l/2007-04/msg00085.html

https://stackoverflow.com/questions/9676113/lua-os-execute-return-value

https://stackoverflow.com/questions/tagged/lua

http://www.lua.org/lua-l.html

http://www.capgo.com/Resources/SoftwareDev/LuaShortRef51.pdf

https://foicica.com/lua/download/lua_quickref_excerpt.pdf

http://www.lua.org/manual/

http://notebook.kulchenko.com/programming/lua-good-different-bad-and-ugly-parts

https://www.youtube.com/watch?v=4NKMtazVNe8

https://www.youtube.com/watch?v=iMacxZQMPXs

https://www.youtube.com/watch?v=yI41OL0-DWM

https://www.youtube.com/watch?v=GVnIRt77ePk

https://www.youtube.com/watch?v=emnHx52S-Xk

Maybe not for beginners this one:

https://www.youtube.com/watch?v=S4eNl1rA1Ns

May or may not find the following useful:

https://github.com/zserge/luash
https://www.gammon.com.au/scripts/doc.php?lua=os.execute
https://github.com/torch/sys

The tecgraf iuplua examples again:

https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/

And maybe about time Puppy development work went truly 'Cutting Edge'. Check this out:

http://torch.ch/

wiak
Back to top
View user's profile Send private message 
wiak

Joined: 11 Dec 2007
Posts: 957
Location: not Bulgaria

PostPosted: Fri 13 Apr 2018, 09:56    Post subject: bash/yad GUI translated to IUP/Lua  

As I've said elsewhere in Announcements, I'm working on a translation of fredx181's gifenc-yad script into gifenc-iup.lua (just as a practice exemplar) and have basically completed the main gui part of the code as shown below (note that this is older version of gifenc-yad; it has had some extra functionality added since). Been too busy to complete everything today (maybe tomorrow) but thought I'd publish the current result at least. Obviously, next part is to interface to ffmpeg line, though I think I can do that with Lua5.3 io.popen command though I've yet to try that (and have never before programmed in Lua...). Most of the code here is from iup.Getparam() function example from tecgraf:

https://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/getparam.lua

Further info on iup.Getparam() function itself is here:

https://webserver2.tecgraf.puc-rio.br/iup/en/dlg/iupgetparam.html

Code:
-- gifenc-iup.lua
-- as yet incomplete translation of fredx181's gifenc-yad script

require( "iuplua" )

function param_action(dialog, param_index)
  if (param_index == iup.GETPARAM_OK) then
    print("OK")
  elseif (param_index == iup.GETPARAM_INIT) then
    print("Map")
  elseif (param_index == iup.GETPARAM_CANCEL) then
    print("Cancel")
  elseif (param_index == iup.GETPARAM_HELP) then
    print("Help")
--  elseif (param_index == 1) then
--    return 0
  else
    local param = iup.GetParamParam(dialog, param_index)
    print("PARAM"..param_index.." = "..param.value)
  end
  return 1
end

-- set initial values
SIZE = 100
START = 0
DURATION = 0 
pboolean = 1

ret, SIZE, START, DURATION, pboolean =
      iup.GetParam("GifenC-iuplua", param_action,
                  "Convert (portion of) short video to animated gif%t\n"..
                  "The new .gif will be in the same folder as the video%t\n"..
                  "   Please set the desired .gif size%t\n"..
                  "Size: %i[0,2000,10]\n"..
                  "   Set start time and duration: %t\n"..
                  "Start at (seconds): %r[0,20000,.01]\n"..
                  "Duration (seconds) (0=all): %r[0,20000,.01]\n"..
                  "Do not loop (just once): %b\n",
                  SIZE, START, DURATION, pboolean)
if (not ret) then
  return
end

if (iup.MainLoopLevel()==0) then
  iup.MainLoop()
end


Note that as the code stands above, the GUI will exit if Cancel button pressed, but not if OK button pressed.
Fred's complete gifenc-yad script follows for comparison purposes:

Code:
#!/bin/bash

if [ -z "$(which ffmpeg)" ]; then
yad --width=300 --title "No ffmpeg found" --center --text "  No ffmpeg found, please install ffmpeg  \n  Press Close to exit  " --button="gtk-close:0"
exit
fi

# ffmpeg -i try.mkv -vf "setpts=(1/6)*PTS" output.mp4

SETUP=`yad --width=400 --title="GifenC" --center --text=" Convert (portion of) short video to animated gif \n The new .gif will be in the same folder as the video \n     \tPlease set the desired .gif size" \
--window-icon="folder-system" --form  \
--field=" Size: :NUM" "100!20..2000!10" \
--field="     \tSet start time and duration: :LBL" "" \
--field=" Start at (seconds): :NUM" "0!0..20000!0.010!3" \
--field=" Duration (seconds) (0=all): :NUM" "0!0..20000!0.010!3" \
--field=" Do not loop (just once):CHK" "FALSE" \
--button="gtk-cancel:1" --button="gtk-ok:0"`
ret=$?
[[ $ret -ne 0 ]] && exit 1
echo $SETUP

export SIZE=$(echo $SETUP | cut -d "|" -f 1 | cut -f1 -d".")
export START=$(echo $SETUP | cut -d "|" -f 3)
export DUR=$(echo $SETUP | cut -d "|" -f 4)
export LOOP=$(echo $SETUP | cut -d "|" -f 5)
echo $SIZE
echo $START
echo $DUR
echo $LOOP

if [ "$LOOP" = "TRUE" ]; then
export NUM=1
else
export NUM=0
fi
echo $1
if [ -z "$1" ]; then
yad --title "No Input" --center --text "  No input video provided  \n  Press Close to exit  " --button="gtk-close:0"
exit
fi
export vid=$1

run_xterm () {
palette="/tmp/palette.png"

filters="fps=10,scale=$SIZE:-1:flags=lanczos"

ffmpeg -ss $START -t $DUR -v warning -i $vid -loop $NUM -vf "$filters,palettegen" -y $palette
ffmpeg -ss $START -t $DUR -v warning -i $vid -i $palette -loop $NUM -lavfi "$filters [x]; [x][1:v] paletteuse" -y ${vid%.*}.gif
sleep 3
}
export -f run_xterm

xterm -T "GifenC" -e /bin/bash -c run_xterm


Fredx181's most recent release of gifenc-yad (with more functionality) is nicely illustrated and described at this link:

http://murga-linux.com/puppy/viewtopic.php?p=981267#981267

wiak
Screenshot_gifenc-yad.jpg
 Description   Screenshot fred's gifenc-yad
 Filesize   27.19 KB
 Viewed   485 Time(s)

Screenshot_gifenc-yad.jpg

Screenshot_gifenc-iuplua.jpg
 Description   Screenshot gifenc-iup.lua
 Filesize   28.98 KB
 Viewed   479 Time(s)

Screenshot_gifenc-iuplua.jpg

Back to top
View user's profile Send private message 
fredx181


Joined: 11 Dec 2013
Posts: 3482
Location: holland

PostPosted: Fri 13 Apr 2018, 11:50    Post subject:  

Hi wiak, nice !!

I know your script is not finished yet, but just mentioning that I got error message first (see pic below), and when I click Continue I see the gifenc GUI.
What I did was install iuplua-core deb (32bit) that you provided and installed lua5.3 with apt-get on Xenialdog32.
And put on top of script: #!/usr/bin/lua5.3

Exactly the same I did on StretchDog, btw, and got the same result.

EDIT: Complete error message:
Code:
/mnt/sda7/01-repos/gifenc-iup.lua:20: attempt to index a nil value (local 'param')
stack traceback:
   /mnt/sda7/01-repos/gifenc-iup.lua:20: in function 'param_action'
   [C]: in function 'iuplua.GetParam'
   /mnt/sda7/01-repos/gifenc-iup.lua:32: in main chunk
   [C]: in ?


EDIT2:
wiak wrote:
Fredx181's most recent release of gifenc-yad (with more functionality) is nicely illustrated and described at this link:

http://murga-linux.com/puppy/viewtopic.php?p=981267#981267


Also here (weX thread), see EDIT5 (and attached scripts):
http://murga-linux.com/puppy/viewtopic.php?p=948724#948724

Fred
2018-04-13-174036_550x344_scrot.png
 Description   lua error
 Filesize   27.22 KB
 Viewed   456 Time(s)

2018-04-13-174036_550x344_scrot.png


_________________
Dog Linux website
Back to top
View user's profile Send private message 
wiak

Joined: 11 Dec 2007
Posts: 957
Location: not Bulgaria

PostPosted: Fri 13 Apr 2018, 19:29    Post subject:  

fredx181 wrote:
Hi wiak, nice !!

I know your script is not finished yet, but just mentioning that I got error message first (see pic below), and when I click Continue I see the gifenc GUI.


Yes, I get the same (I think same issue in tecgraf example getparam.lua?). Commenting out (with --) the following line gets rid of the error.

Code:
--    print("PARAM"..param_index.." = "..param.value)


Lua doesn't seem to like the ..param.value (.. is way to concatenate strings I think, so guess param.value doesn't make sense somehow). EDIT: But the line is needed currently to get print out of slider control values. I think the 'error' must just be that param is not initialised prior to first use - not sure how to do that... I suspect Lua just notices that param not initialised at that stage, prior to actually first creating the dialog with iup.GetParam(). So likely just a warning that can somehow be suppressed?

EDIT2: Putting the function param_action() after iup.GetParam() block seems to fix the Lua run error message (presumably cos iup.GetParam() correctly initialises param before function param_action() is first called. EDIT3: No, that doesn't work, cos then function param_action() isn't seen and the PARAM value messages don't then get printed to the terminal... But in finished program wouldn't want to print param.value messages in function param_action() anyway, so actually not important so current run-time error can be ignored I'd say.

Maybe this will help work out how the param_actions stuff works (?):

https://webserver2.tecgraf.puc-rio.br/iup/en/elem/iupparambox.html

GetParamParam() function seems to be described in above link.
-----

You can use an os.exit() in the param_action statements for when OK button is pressed to exit the program for that action. Or better still, put os.exit() just before the last if statement in the program, perhaps with a Message or some other code. For example, this worked for me (but I'm totally guessing how to do things just now...):

Code:
iup.Message("IupGetParam",
            "Boolean Value: "..pboolean.."\n"..
            "Integer: "..SIZE.."\n"..
            "Real 1: "..START.."\n"..
            "Real 2: "..DURATION.."\n"
)

os.exit(0)

if (iup.MainLoopLevel()==0) then
  iup.MainLoop()
end


As I've said, I don't know Lua yet nor IUP details, so have a bit of learning to do! Like I suggested, I expect io.popen() and os.execute(), which is like system() in C, to be useful for interfacing with underlying OS and shell. If these aren't adequate then additional Lua module called LuaPosix sounds useful as does luash module I mentioned earlier.

http://lua-users.org/wiki/OsLibraryTutorial

https://github.com/luaposix/luaposix

https://github.com/zserge/luash

I'll probably be a while trying all these possibilities out, but clearly it can be done.

EDIT: By the way, if you replace line:
Code:
"Size: %i[0,2000,10]\n"..

with
Code:
"Size: %a[0,2000,10]\n"..


i.e. use %a instead of %i, you get a spin-type volume control instead of slider.

wiak

Last edited by wiak on Sat 14 Apr 2018, 01:33; edited 6 times in total
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 2 [24 Posts]   Goto page: 1, 2 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1706s ][ Queries: 12 (0.0132s) ][ GZIP on ]