PauseForUser with control panel and access to graph window?
reepingk
I'm attempting to allow a procedure to let me interact with a window while it waits, but if I play around with the demo program, discussed in the "PauseforUser control panel example" in the manual. By default, the "continue button" simply closes the "control panel" window, which then ends the PauseforUser... pause. However, by default I cannot interact with any other window while the control panel is up.
If I change the pauseforuser to act on the graph window instead, here's what happens. Initially, it'll let me interact with the control panel window. I can click continue and close the graph window, but then I obviously can't do anything else (as I haven't added another button to "kill" the control panel.) However, if I click the graph after I start the program, it will not let me interact with the control panel again... Therefore I cannot click the continue button and end the program. I need to hit "command ." to force the program to stop.
How is this accomplished? What I'm trying to do is to have the program wait for me to adjust a spline fit to remove the background on the first of many sets of data imported into igor. Basically I'm using the spline fit background removal "package" discussed elsewhere on the site, which allows you to adjust the "points" where the spline fit runs through. So you run the initialization for the program, which creates the spline fit wave, then puts it on your graph. Then you adjust the points to get a good match with your background, then you can choose to subtract it if you'd like. Basically I just need my program to wait for me to adjust that spline fit, then continue on it's merry way. Sure, I could probably do it in multiple functions... but at this point that'd involve passing many... (many) variables between functions, and that'd take ages and make everything ugly.
Crap. I kinda just figured it out. Sure, you can't click back on the control panel if you currently have the graph selected, but if you click OUT of igor, then click directly on the control panel, it allows you to do that. It's not right, but it works. What's the correct way to do this?
Simply create a window named "Graph0" then run "Demo1()" to replicate what I'm seeing.
Function KillzeWindow(ctrlName) : ButtonControl
String ctrlName
DoWindow/K Graph0 // kill self
End
// Call with these variables already created and initialized: // root:tmp_PauseForUserDemo:numvar
// root:tmp_PauseForUserDemo:strvar
Function DoMyInputPanel()
NewPanel /W=(150,50,358,239)
DoWindow/C tmp_GetInputPanel
DrawText 33,23,"Enter some data"
SetVariable setvar0,pos={27,49},size={126,17},limits={-Inf,Inf,1}
SetVariable setvar0,value= root:tmp_PauseForUserDemo:numvar
SetVariable setvar1,pos={24,77},size={131,17},limits={-Inf,Inf,1}
SetVariable setvar1,value= root:tmp_PauseForUserDemo:strvar
Button button0,pos={52,120},size={92,20}
Button button0,proc=KillzeWindow,title="Continue"
PauseForUser Graph0
End
Function Demo1()
NewDataFolder/O root:tmp_PauseForUserDemo
Variable/G root:tmp_PauseForUserDemo:numvar= 12
String/G root:tmp_PauseForUserDemo:strvar= "hello"
DoMyInputPanel()
NVAR numvar= root:tmp_PauseForUserDemo:numvar
SVAR strvar= root:tmp_PauseForUserDemo:strvar
printf "You entered %g and %s\r",numvar,strvar
KillDataFolder root:tmp_PauseForUserDemo
End
Function Demo2()
Variable numvar= 12
String strvar= "hello"
Prompt numvar,"numvar:"
Prompt strvar,"strvar:"
DoPrompt "Enter some data",numvar,strvar
printf "You entered %g and %s\r",numvar,strvar
End
String ctrlName
DoWindow/K Graph0 // kill self
End
// Call with these variables already created and initialized: // root:tmp_PauseForUserDemo:numvar
// root:tmp_PauseForUserDemo:strvar
Function DoMyInputPanel()
NewPanel /W=(150,50,358,239)
DoWindow/C tmp_GetInputPanel
DrawText 33,23,"Enter some data"
SetVariable setvar0,pos={27,49},size={126,17},limits={-Inf,Inf,1}
SetVariable setvar0,value= root:tmp_PauseForUserDemo:numvar
SetVariable setvar1,pos={24,77},size={131,17},limits={-Inf,Inf,1}
SetVariable setvar1,value= root:tmp_PauseForUserDemo:strvar
Button button0,pos={52,120},size={92,20}
Button button0,proc=KillzeWindow,title="Continue"
PauseForUser Graph0
End
Function Demo1()
NewDataFolder/O root:tmp_PauseForUserDemo
Variable/G root:tmp_PauseForUserDemo:numvar= 12
String/G root:tmp_PauseForUserDemo:strvar= "hello"
DoMyInputPanel()
NVAR numvar= root:tmp_PauseForUserDemo:numvar
SVAR strvar= root:tmp_PauseForUserDemo:strvar
printf "You entered %g and %s\r",numvar,strvar
KillDataFolder root:tmp_PauseForUserDemo
End
Function Demo2()
Variable numvar= 12
String strvar= "hello"
Prompt numvar,"numvar:"
Prompt strvar,"strvar:"
DoPrompt "Enter some data",numvar,strvar
printf "You entered %g and %s\r",numvar,strvar
End
DisplayHelpTopic "Pause for User"
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
March 10, 2015 at 01:12 pm - Permalink
March 11, 2015 at 08:17 am - Permalink