StrawberryPerl / Perl-Dist-Strawberry

Tooling to build and package releases for Perl on Windows.
https://strawberryperl.com
Other
281 stars 48 forks source link

Add PAR::Packer and Perl/Tkx and Win32::GUI as default GUI module for StrawberryPerl #87

Open amlan-sw opened 1 year ago

amlan-sw commented 1 year ago

@shawnlaffan

maybe next release need add default package from CPAN: Tcl Tk Tkx PAR::Packer as default cross platform GUI/Form programming for Perl, Its not easy to install on StrawberryPerl, which is in windows, and it must easy access for GUI programming and "compilation" to .exe.

I manage to install Tkx and PAR::Packer on your dev_20230316 (and current 5.32.1.1) , compile, and run this example below on windows 11 without c:/strawberry

the "not easy" part is not about compiling CPAN module, but how to add and set path for TCL (Step 2 below) and addition (Step 5) add convert.exe from ImageMagick so user can easyly create icon for Tk specs.

THE STEPS:

  1. update portableshell.bat

    set SP=%~dp0
    set PATH=%SP%\site\bin;%SP%\perl\bin;%SP%\c\bin;%SP%\Tcl\bin;%SP%\ImageMagick;%SP%\bin;%PATH%
  2. install Tcl

    - download: 

    https://github.com/teclab-at/tcltk/releases/download/version-8.6.12.7/tcltk86-8.6.12.7.tcl86.Win10.x86_64.zip

    - extract to c:\strawberry\Tcl
    - update Tcl\lib\tclConfig.sh
        replace: /d/CM/product-tcltk86/release      
        to:      c:/strawberry/tcl  
  3. cpan install deps

    notest force install Tcl Tk Tkx PAR::Packer App::PP::Autolink
  4. to compile .pl to .exe (in future maybe part of something like: guimake.bat)

    pp -o tkx_gui_example.exe -a Tcl/bin/tcl86.dll;Tcl/bin/tcl86.dll -a Tcl/bin/tk86.dll;Tcl/bin/tk86.dll -a Tcl/bin/zlib1.dll;Tcl/bin/zlib1.dll -a Tcl/lib/tcl8.6;Tcl/lib/tcl8.6 -a Tcl/lib/tk8.6;Tcl/lib/tk8.6 tkx_gui_example.pl
    
    - use: pp -gui ...   -> for production and hide console 
    - add: -a myicon.ico -> if you have 32x32 .ico file as window icon
    - for test: without c:/strawberry is needed for distribution .exe file 
    - for test: remove cache par-* in %TEMP% before run .exe 
  5. Addition Step: Install ImageMagick to change icon, myicon must only 32x32

    - download: 

    https://imagemagick.org/archive/binaries/ImageMagick-7.1.0-62-portable-Q16-HDRI-x64.zip

    - extract to c:\strawberry\ImageMagick
    - example convert .png to .ico run:
    
    convert.exe myicon.png -resize 32x32 -gravity center -background transparent -extent 32x32 myicon.ico
    
    - set .exe icon:
    
    exe_update --icon myicon.ico tkx_gui_example.exe
  6. the test if 1-4 step above success

    - test file:

    tkx_gui_example.zip

    put to c:\strawberry\tkx_gui_example.pl
    
    - the goal

    tkx_gui_example

    - run app with console:
    
    perl tkx_gui_example.pl
    
    - run app WITHOUT console:
    
    wperl tkx_gui_example.pl
    
    - run .exe
    
    tkx_gui_example.exe
    
    - run .exe for distribution
    
     rename or remove c:/strawberry, delete %TEMP%/pp-*, then run .exe again        
shawnlaffan commented 1 year ago

Thanks for opening a separate issue.

To restate a comment from the original (purely to save later readers looking for it): If a module can be installed easily then we can look at it. If it is more involved then we are open to pull requests, so long as the maintenance burden is low. If a module is difficult to install then that is often best taken up with the maintainers of the module.

PAR::Packer falls into the first category so can be added. It would seem that Tcl falls into the last category, although I am open to being convinced it falls into the middle category.

I would also suggest you look at developing an alien module to wrap the download of Tcl and ImageMagick. That can also handle the addition of the relevant bin dirs to the path and the update of the config.sh file. Alien::Build has very good documentation and has plugins that can download precompiled software rather than building from scratch.

Force installing modules should be a last resort, and tests should be skipped only when one is confident the module will work (e.g. it has already been shown to work on the same setup on another machine) or that functionality is not needed (and even then one should think twice). We do skip some tests for Strawberry perl but these are typically cases where the build env has false negatives (i.e. a test fails on the docker system but passes locally).

shawnlaffan commented 1 year ago

Also, if you only need ImageMagick to manipulate image files then have a look at Imager, specifically Imager::File::ICO. It is already part of Strawberry perl.

amlan-sw commented 1 year ago

I would also suggest you look at developing an alien module to wrap the download of Tcl and ImageMagick. That can also handle the addition of the relevant bin dirs to the path and the update of the config.sh file. Alien::Build has very good documentation and has plugins that can download precompiled software rather than building from scratch.

too complicated to create or maintain such module, nowday people want something "just werk" , maybe we can just make something like strawberry-perl-5.32.1.1-64bit-PDL.zip but for GUI edition like strawberry-perl-5.32.1.1-64bit-GUI-1.0.zip , portable zip version with addition all GUI module available:

- Win32::GUI  -> no dependecies needed
- Tcl Tk and Tkx  -> TCL dependensies
- SDLx::GUI -> low level GUI API, hard to build, like PDL, need GPU related build

After 20 years, at last , I understand how to code GUI with perl using Tk and newer Tkx with help from ChatGPT.
And now we need something different to make everything "just werk", I thing some module that can parse JSON then create GUI. all above module still complicated too code (at least for nowday generation) and very little example and documentation about all module above, best is only Tkx in https://tkdocs.com/tutorial/

And more reason people nowday using Python in windows because its very easy to install Tkinter (Tkx in perl) to create GUI /Form application.

Also, if you only need ImageMagick to manipulate image files then have a look at Imager, specifically Imager::File::ICO. It is already part of Strawberry perl.

For Tkx icon, I only find easiest way and only work from .ico build with ImageMagick convert.exe (still dont know why)

genio commented 1 year ago

I think this particular issue will have to be on hold while we work out getting a Strawberry release going. Looking into this for Windows seems to be a bit complex. A possible solution would be to build an install of TCL/TK with some useful modules after we get Strawberry released and create releases for those that would be Strawberry major-version-specific while we're on gcc/MinGW.

shawnlaffan commented 1 month ago

FWIW, a patched version of Tk is available at https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/download/patched_cpan_modules/

It can be installed using your preferred cpan utility. e.g. for cpanm:

cpanm https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/download/patched_cpan_modules/Tk-804.036_001.tar.gz