GUI Creation -- use of guimaker or uicontrol

CraigD craig at fasortronics.com
Fri Apr 20 19:01:34 CEST 2012


Samuel,

Thanks for responding to my questions on GUI control.  I tried using
'uicontrol' but found that I could only add text in a frame alongside my
graphics figure -- I could not get 'edit' working.  From what I have read in
the help documentation, it looks like 'edit' within a graphics figure is not
supported.

What I ended up doing is use the 'guimaker' function, which creates a new
window for every instance of a call.  It works, but a new window is created
every time even if I try to dock the window (like I have the graphics figure
docked) in the Scilab desktop.

QUESTION:  If there is a way to have 'guimaker' continue to use the same
window that would be great -- and allow me to keep it docked in the desktop.

I am using a copy of this function so that I can make changes to it.  I
tried assigning a fixed window 'tag' but it did not help.  I ended up
turning the 'OK' variable into a global variable so that I could know if the
user submitted new values.

Here is what I ended up doing with 'guimaker'.  Note that the first part of
the function prepares my graphics figure for adding a frame, but then I
abandoned that idea and used a modified 'guimaker' function -- turns out the
only modification is to make the variable 'OK' a global; though I tried many
things to get the window to stay docked.

function [AAParams]=GUI_Interact(AAParams, ZZout)	// Create GUI interface
for figure
	
// Alter figure to prepare for edit list window alongside
	raytrace_pump = scf(100);  // Choose correct graphics image
	
	// Remove certain graphics menus & toolbar
	delmenu(raytrace_pump.figure_id, gettext("&?"));
	toolbar(raytrace_pump.figure_id, "off");
	
	raytrace_pump.background      = -2;  // Changes background to white
	raytrace_pump.figure_position = [-1 -1];  // Orphan window control
	raytrace_pump.figure_name     = gettext("YAG Rod Pump Crossection");
	
	
	// Add new menu item
	h = uimenu( "parent", raytrace_pump,       ...
				"label" , gettext("TraceRays Figure"));
	uimenu( "parent"    , h,                   ...
			"label"     , gettext("Close"), ...
			"callback"  ,
"raytrace_pump=get_figure_handle(100);delete(raytrace_pump);", ...
			"tag"       , "close_menu");
	
// Make new window for data entry
exec ('mod_guimaker.sci');  // Load function until a proper library compile
is completed
global OK        // Added so that this variable is shared with mod_guimaker
Values=[];
page=list();
page($+1)=list(list([1 3],'text',''));  // Add padding above top of frame
page($+1)=list(list([1 11],'frame','Input Parameters'));
page($+1)=list(list('text','Lens focal length
[mm]'),list('edit',string(AAParams(7))));
page($+1)=list(list('text','Lens distance from slit
[mm]'),list('edit',string(AAParams(10))));
page($+1)=list(list('text','Pump beam incident angle
[degree]'),list('edit',string(AAParams(12))));
page($+1)=list(list('text','Pump beam divergence
[degree]'),list('edit',string(AAParams(14))));
page($+1)=list(list('text','Pump beam profile [1 or
0]'),list('edit',string(AAParams(15))));
page($+1)=list(list('text','Pump beam size [radius,
mm]'),list('edit',string(AAParams(16))));
page($+1)=list(list('text','Rod thickness
[mm]'),list('edit',string(AAParams(24))));
page($+1)=list(list('text','Width of slit
[mm]'),list('edit',string(AAParams(29))));
page($+1)=list(list('text','Total pump power
[W]'),list('edit',string(AAParams(35))));
page($+1)=list(list('text','Number of rays to trace
[#]'),list('edit',string(AAParams(13))));
page($+1)=list(list([1 2],'text',''));
page($+1)=list(list([1 9],'frame','Output Values'));
page($+1)=list(list('text','Power back out slit
[%]'),list('text',string(ZZout(1))));
page($+1)=list(list('text','Power clipped by slit
[%]'),list('text',string(ZZout(2))));
page($+1)=list(list('text','Power absorbed in ellipse
[%]'),list('text',string(ZZout(5))));
page($+1)=list(list('text','Power extracted by beam
[W]'),list('text',string(ZZout(6)/100*AAParams(35))));
page($+1)=list(list('text','Power absorbed by rod
[%]'),list('text',string(ZZout(9))));
page($+1)=list(list('text','Power absorbed first crossing
[%]'),list('text',string(ZZout(13))));
page($+1)=list(list('text','Power absorbed second crossing
[%]'),list('text',string(ZZout(14))));
page($+1)=list(list('text','Power absorbed third crossing
[%]'),list('text',string(ZZout(15))));
page($+1)=list(list([1 2],'text',''));
page($+1)=list(list(1),list([3 1],'pushbutton','Submit New
Values','callback','OK=%T'),...
				list(1),list('pushbutton','Exit','callback','CANCEL=%T'),list(1));
[Values]=mod_guimaker(page,list('TraceRays Model Parameters'));

// Write new Values into AAParams
if OK then
AAParams(7)=Values(1);
AAParams(10)=Values(2);
AAParams(12)=Values(3);
AAParams(14)=Values(4);
AAParams(15)=Values(5);
AAParams(16)=Values(6);
AAParams(24)=Values(7);
AAParams(29)=Values(8);
AAParams(30)=Values(8);  // Both are set to same value
AAParams(35)=Values(9);
AAParams(13)=Values(10);
end
endfunction


--
View this message in context: http://mailinglists.scilab.org/GUI-Creation-use-of-guimaker-or-uicontrol-tp3919097p3926629.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com.



More information about the users mailing list