[Scilab-users] How to print GUI window?

Samuel Gougeon sgougeon at free.fr
Fri Aug 2 15:01:43 CEST 2019


Hello Philipp, hello Ted,

Yesterday evening, I got aware of two important drawbacks of using 
Irfanview, despite its numerous and  huge assets and qualities:

  * It runs only on Windows
  * It is free only for non-commercial usages

...in addition to the fact that it must be installed (trivial, but OK).

These restrictions made me wondering about a more portable solution.
And gui2bitmap() is born :-) http://atoms.scilab.org/toolboxes/gui2bitmap

The printing is also worth considering.
I should have a look later to this matter, for instance to see if it is 
possible
and then how to print directly the snapshot with gui2bitmap, instead of
keeping an image file.
The discussion with Ted made me aware that presently Scilab seems not
able to send any image to a printer. This is a missing feature.

Best regards
Samuel

Le 02/08/2019 à 14:08, P M a écrit :
> Mh...
> From what I understnad is, that you want to get a print out from your 
> current GUI appearance.
>
> As Samuel suggested, one workaround is to make a screenshot, by 
> calling IrfanView from Scilab.
>
> The result is an image, that:
> - can be printed out in a normal way...e.g. by use of IrfanView
> - can be loaded into scilab (need maybe a toolbox) and printed 
> directly from scilab
>
>
> Note:
> In the example below, the screenshot is taken from the currently 
> foreground window (client area).
> So I guess you need to make sure, that all uicontrols are placed in 
> the same scilab figure.
> If not, you can probably capture the complete screen, after arranging 
> separate figures and use irfan view command line command (in scilab) 
> to crop the resulting image.
>
>
>
> // ################## Beginning of Code ################
>
> clear(); clc; mainDir = 'E:\Scilab_Uebungen\031_call_software\' // you 
> may want to change this cd (mainDir); pwd; h = figure('position', [50 
> 50 400 400], 'backgroundcolor', [0.7 0.9 1], .. "figure_name", 'WHAT 
> DAY WERE YOU BORN?'); // to have a plot within the GUI plot2d(); // 
> text T1 = uicontrol(h, 'style', 'text', 'string', 'Type 
> year:','position', [20 340 200 50], 'backgroundcolor', [0.7 0.9 1]); 
> // edit E1 = uicontrol(h, 'style', 'edit', 'string', '9999', 
> 'position', [150 350 70 30], 'fontsize', 15, 'backgroundcolor', [1 1 
> 1]); // text T2 = uicontrol(h, 'style', 'text', 'string', 'Select 
> month:','position', [20 260 200 50], 'backgroundcolor', [0.7 0.9 1]); 
> // listbox L1 = uicontrol(h, 'style', 'listbox', 'position', [150 130 
> 120 170], 'fontsize', 15, 'backgroundcolor', [1 1 1]); set(L1, 
> 'string', 'January |February |March |April |May |June |July |August 
> |September |October |November |December'); set(L1, 'value', [2]); // 
> text T3 = uicontrol(h, 'style', 'text', 'string', 'Type day:', 
> 'position', [20 60 200 50], 'backgroundcolor', [0.7 0.9 1]); // edit 
> E2 = uicontrol(h, 'style', 'edit', 'string', '12', 'position', [150 70 
> 70 30], 'fontsize', 15, 'backgroundcolor', [1 1 1]); // callback 
> function for push button // seems that this has to be defined before 
> the bush button is generated function birthday(guientries) y = 
> evstr(get(E1, 'string')) m = get(L1, 'value') d = evstr(get(E2, 
> 'string')) num = datenum(y, m, d); [n, s] = weekday(num); disp('You 
> were born on '+s) // access IrfanView and try to make a screen shot of 
> the GUI IV_PATH = 'C:\Program Files (x86)\IrfanView'; // check if this 
> is true for your system OUT_PATH = 
> 'E:\Scilab_Uebungen\031_call_software' // you may want to change this 
> // capture the GUI crop it, so that figure borders are not visible 
> anymore and save it as a png file cd (IV_PATH); dos('i_view32.exe 
> /capture=3 /crop=(0,47,0,420,0) /convert='+OUT_PATH+'\test.png '); cd 
> (mainDir); pwd; endfunction // push button P1 = uicontrol(h, 
> 'position', [300 70 80 30], 'style', 'pushbutton', 'string', 'Submit', 
> 'callback', 'birthday', 'backgroundcolor', [1 1 0]);
>
>
> // ################## End of Code ###########################
>
> Attached the result as it is created at my PC.
>
> Hope this helps,
> best regards,
> Philipp
>
> ps.
>
> From http://www.etcwiki.org/wiki/IrfanView_Command_Line_Options
> capture values:
> 0 = whole screen
> 1 = current monitor, where mouse is located
> 2 = foreground window
> 3 = foreground window - client area
> 4 = rectangle selection
> 5 = object selected with the mouse
> 6 = start in capture mode (can't be combined with other commandline 
> options)
>
> Am Fr., 2. Aug. 2019 um 01:02 Uhr schrieb VTX1801 
> <sl1800 at rochester.rr.com <mailto:sl1800 at rochester.rr.com>>:
>
>     Thanks for the effort to resolve this issue.
>     If this has been a known bug since 2016 what is the likelihood it
>     will be
>     addressed and resolved?
>     I appreciate the timely responses from Samuel.
>     Evidently Scilab is not mature enough to use for this application.
>     Best Regards,
>     Ted
>
>     --
>     Sent from:
>     http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
>     _______________________________________________
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20190802/fa54cadb/attachment.htm>


More information about the users mailing list