PixInsight Forum (historical)
Software Development => PCL and PJSR Development => Topic started by: Silvercup on 2010 February 27 13:13:29
-
Hi I need help:
I need to update a Edit control inside a tab page. How I can access to the control?
I can do -> parent.tabs.currentPageIndex and return the active tab index.
Thanks. Silvercup
-
I don't know if I can help you at all.
However, about a year ago Juan sent me the following code snippet to help get me going with <TABS> in PJSR, but I never had time to pursue things. Perhap it may be of 'some' use to you, I don't know
#include <pjsr/Sizer.jsh>
#include <pjsr/FrameStyle.jsh>
#include <pjsr/TextAlign.jsh>
function RandomChars( howMany )
{
const c = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
const n = c.length;
var s = new String;
for ( var i = 0; i < howMany; ++i )
s += c[Math.round( Math.random()*(n-1) )];
return s;
}
function MyTabPageControl( parent )
{
this.__base__ = Control;
if ( parent )
this.__base__( parent );
else
this.__base__();
this.helpLabel = new Label( this );
this.helpLabel.frameStyle = FrameStyle_Box;
this.helpLabel.margin = 4;
this.helpLabel.wordWrapping = true;
this.helpLabel.useRichText = true;
this.helpLabel.text = "<p>This is a Control object inside a TabBox.<br/>" +
"This is a random string:<br/>" +
RandomChars( 40 ) + "</p>";
this.targetImage_Label = new Label( this );
this.targetImage_Label.text = "Target image:";
this.targetImage_Label.textAlignment = TextAlign_Right|TextAlign_VertCenter;
this.targetImage_ViewList = new ViewList( this );
this.targetImage_ViewList.getAll(); // include main views as well as previews
this.targetImage_ViewList.toolTip = "<p>This is just an example.</p>";
this.targetImage_Sizer = new HorizontalSizer;
this.targetImage_Sizer.spacing = 4;
this.targetImage_Sizer.add( this.targetImage_Label );
this.targetImage_Sizer.add( this.targetImage_ViewList, 100 );
this.sizer = new VerticalSizer;
this.sizer.margin = 6;
this.sizer.spacing = 6;
this.sizer.add( this.helpLabel );
this.sizer.addSpacing( 4 );
this.sizer.add( this.targetImage_Sizer );
}
MyTabPageControl.prototype = new Control;
function MyTabbedDialog()
{
this.__base__ = Dialog;
this.__base__();
this.pages = new Array;
this.pages.push( new MyTabPageControl( this ) );
this.pages.push( new MyTabPageControl( this ) );
this.pages.push( new MyTabPageControl( this ) );
this.pages.push( new MyTabPageControl( this ) );
this.tabs = new TabBox( this );
this.tabs.setMinSize( 400, 200 );
this.tabs.addPage( this.pages[0], "First" );
this.tabs.addPage( this.pages[1], "Second" );
this.tabs.addPage( this.pages[2], "Third" );
this.tabs.addPage( this.pages[3], "Fourth" );
this.okButton = new PushButton( this );
this.okButton.text = "OK";
this.okButton.onClick = function()
{
this.dialog.ok();
}
this.buttons = new HorizontalSizer;
this.buttons.addStretch();
this.buttons.add( this.okButton );
this.sizer = new VerticalSizer;
this.sizer.margin = 6;
this.sizer.spacing = 6;
this.sizer.add( this.tabs );
this.sizer.add( this.buttons );
this.windowTitle = "TabBox Example Script";
this.adjustToContents();
}
MyTabbedDialog.prototype = new Dialog;
var dlg = new MyTabbedDialog;
dlg.execute();
Cheers,
-
Thanks for your support Niall.
With some trials I have found it. You can acces this form:
parent.tabs.pageControlByIndex(0).Ltext_Edit.text=""
Where tabs is the TabBox object and Ltext_Edit is the Edit object control which is in the first tab (first page) i.e. pageControlByIndex(0).
You can acces to controls on secont tab simply using pageControlByIndex(1).
Best. Silvercup.
-
I'll be looking forward to your completed script - adding TABS was the one thing I would have liked to have done with my <Batch deBayer> script (which I wrote out of necessity at the time, but which I also used to help me 'understand' PJSR in the absence of a "How to write PJSR" manual - hence the reason that the code is so long, and so FULL of detailed comments).
In fact, I will be interested to see your final code myself - if only to take your work with TABS and to then comment all the code sections in the same way as I did in my deBayer script!! In fact, despite my code being so camera-specific (for a Meade DSI-IC or -IIC camera), I reckon that Juan wanted to include it with all future 'standard distributions' of PI simply because it WAS so fully commented.
Cheers,