[Scilab-users] How to print GUI window?

P M p.muehlmann at gmail.com
Fri Aug 2 14:08:35 CEST 2019


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 thiscd (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 GUIplot2d();
// textT1 = uicontrol(h, 'style', 'text', 'string', 'Type
year:','position', [20 340 200 50], 'backgroundcolor', [0.7 0.9 1]);//
editE1 = uicontrol(h, 'style', 'edit', 'string', '9999', 'position',
[150 350 70 30], 'fontsize', 15, 'backgroundcolor', [1 1 1]);// textT2
= 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]);// textT3 = uicontrol(h,
'style', 'text', 'string', 'Type day:', 'position', [20 60 200 50],
'backgroundcolor', [0.7 0.9 1]);// editE2 = 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 generatedfunction
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 buttonP1 = 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>:

> 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
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20190802/374e6ffc/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.png
Type: image/png
Size: 15347 bytes
Desc: not available
URL: <https://lists.scilab.org/pipermail/users/attachments/20190802/374e6ffc/attachment.png>


More information about the users mailing list