Author Topic: Tabs in PJSR Dialogue windows  (Read 7799 times)

Offline Niall Saunders

  • PTeam Member
  • PixInsight Jedi Knight
  • *****
  • Posts: 1456
  • We have cookies? Where ?
Tabs in PJSR Dialogue windows
« on: 2009 May 22 03:27:17 »
Hi Juan,

Do you have a few spare minutes to write a code snippet to show me how to implement 'TABS' in a dialogue window?

Two tabs, with a single command button on each - no 'sizers' needed.

As usual, I am having difficulty getting my code to refer to the 'correct objects'

By the way - the code snippet does NOT have to be fully 'executable' !
Thanks in advance.
« Last Edit: 2009 May 22 03:29:44 by Niall Saunders »
Cheers,
Niall Saunders
Clinterty Observatories
Aberdeen, UK

Altair Astro GSO 10" f/8 Ritchey Chrétien CF OTA on EQ8 mount with homebrew 3D Balance and Pier
Moonfish ED80 APO & Celestron Omni XLT 120
QHY10 CCD & QHY5L-II Colour
9mm TS-OAG and Meade DSI-IIC

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: Tabs in PJSR Dialogue windows
« Reply #1 on: 2009 May 22 03:51:40 »
:) Sure. I'll write a snippet for you (executable and all) this afternoon (it's my turn to cook for lunch today)  8)
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: Tabs in PJSR Dialogue windows
« Reply #2 on: 2009 May 22 10:07:21 »
Hi Niall,

Take a look at this script:

Code: [Select]
#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();

As you see, using a TabBox is easy. You layout your controls inside a tab box page just as you do in a dialog.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline Niall Saunders

  • PTeam Member
  • PixInsight Jedi Knight
  • *****
  • Posts: 1456
  • We have cookies? Where ?
Re: Tabs in PJSR Dialogue windows
« Reply #3 on: 2009 May 22 12:23:50 »
Thanks for that 'head-start' Juan,

I will get to grips with the code, and add it my my deBayer script - which (like you), I would hope to publish some time this weekend (even though it is still very  much 'work in progress').

Certainly the code, commented as it is, seems to have been of some help to Georg - perhaps others can use it as a 'springboard' as well.

In any case, I want to get it to the next level, and then to use the framework to start building a 'Calibration' PJSR - I am just nit clear as to why no-one else has implemented this in PI yet. Unless I am missing something 'obvious'? (IN any case, I think the subject deserves a 'discussion thread' of it's own)

Cheers,
Cheers,
Niall Saunders
Clinterty Observatories
Aberdeen, UK

Altair Astro GSO 10" f/8 Ritchey Chrétien CF OTA on EQ8 mount with homebrew 3D Balance and Pier
Moonfish ED80 APO & Celestron Omni XLT 120
QHY10 CCD & QHY5L-II Colour
9mm TS-OAG and Meade DSI-IIC

Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2132
Re: Tabs in PJSR Dialogue windows
« Reply #4 on: 2009 May 22 12:26:57 »
Niall,

I haven't tested the functionality, but the rich comments were more than helpful. I would like to encourage you to publish it... it is always possible to post a second improved version later.

Cheers,
Georg
Georg (6 inch Newton, unmodified Canon EOS40D+80D, unguided EQ5 mount)

Offline Niall Saunders

  • PTeam Member
  • PixInsight Jedi Knight
  • *****
  • Posts: 1456
  • We have cookies? Where ?
Re: Tabs in PJSR Dialogue windows
« Reply #5 on: 2009 May 22 16:00:38 »
Hi Georg,

Yes, I would really like to publish it . . . but I changed something a few nights ago, for the better (I thought), but now something has 'broke' (again).

As soon as I get this 'glitch' sorted, I will try and post it here on the Forum (although, when I tried doing that, for you, a few days ago I was simply not able to get the script to upload - perhaps there is a limit on the amount of code you can include with a post?)

Back to the keyboard (after having waited, impatiently, for the last few hours, hoping that the skies were going to clear and that we would be able to roll off the roofs and actually get some imaging done !!!).

Cheers,
Cheers,
Niall Saunders
Clinterty Observatories
Aberdeen, UK

Altair Astro GSO 10" f/8 Ritchey Chrétien CF OTA on EQ8 mount with homebrew 3D Balance and Pier
Moonfish ED80 APO & Celestron Omni XLT 120
QHY10 CCD & QHY5L-II Colour
9mm TS-OAG and Meade DSI-IIC

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: Tabs in PJSR Dialogue windows
« Reply #6 on: 2009 May 23 01:22:38 »
Hi Niall,

Quote
perhaps there is a limit on the amount of code you can include with a post?

Indeed this may be the case. And it would be unpractical to include a huge amount of code inline, anyway.

The best way to upload your script is to compress it as a zip file and attach it to your post. You can attach files when you compose a post; just click the "Additional Options..." link.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline Niall Saunders

  • PTeam Member
  • PixInsight Jedi Knight
  • *****
  • Posts: 1456
  • We have cookies? Where ?
Re: Tabs in PJSR Dialogue windows
« Reply #7 on: 2009 May 23 01:28:27 »
Thanks for that Juan,

I am still trying to resolve my glitch - it is a real simple one, but my eyes and brain are just not cooperating !

OK - I have seen the 'Additional Options' link, and also see that this allows up to 128Kb to be attached, and that this size limit can encompass up to 4 files at the same time.

So, although my script is now over 3000 lines long (!!!), it is still only 147kB (but that may explain why I could not include it in a 'code' window) but, hopefully, it will 'zip' down to an acceptable size

I'll take a break, get some brain-food, and try again later.

Cheers,
Cheers,
Niall Saunders
Clinterty Observatories
Aberdeen, UK

Altair Astro GSO 10" f/8 Ritchey Chrétien CF OTA on EQ8 mount with homebrew 3D Balance and Pier
Moonfish ED80 APO & Celestron Omni XLT 120
QHY10 CCD & QHY5L-II Colour
9mm TS-OAG and Meade DSI-IIC

Offline David Serrano

  • PTeam Member
  • PixInsight Guru
  • ****
  • Posts: 503
Re: Tabs in PJSR Dialogue windows
« Reply #8 on: 2009 May 25 00:27:49 »
In any case, I want to get it to the next level, and then to use the framework to start building a 'Calibration' PJSR - I am just nit clear as to why no-one else has implemented this in PI yet.

I have a couple of ideas towards a quick'n'dirty calibration scriptlet, but I lately find myself somewhat away from computers...
--
 David Serrano

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: Tabs in PJSR Dialogue windows
« Reply #9 on: 2009 May 25 00:44:38 »
Quote
I lately find myself somewhat away from computers...

What? I can't believe what I read :o
Juan Conejero
PixInsight Development Team
http://pixinsight.com/