Astro-Catalog

 view release on metacpan or  search on metacpan

lib/Tk/AstroCatalog.pm  view on Meta::CPAN


=item error

Displays an error message in Tk

    $cat->error('Error message');

=cut

sub error {
    my $MW = shift;
    my $errWin = $MW->Toplevel(-borderwidth => 10);
    $errWin->title('Observation Log Error!');
    $errWin->resizable(0,0);
    $errWin->Button(
        -text         => 'Ok',
        -command      => sub {
            destroy $errWin;
    })->pack(-side=>'bottom');
    my $message = shift;
    $errWin->Label (
        -text => "\nError!\n\n   " . $message . "   \n",
        -relief => 'sunken'
    )->pack(-side => 'bottom', -pady => 10);
    $errWin->title(shift) if @_;
    $MW->update;
    $errWin->grab;
}

=item inswt

inswt inserts text into a given text widget and applies
one or more tags to that text.

Parameters:
    $text  -  Text to insert (it's inserted at the "insert" mark)
    $args  -  One or more tags to apply to text.  If this is empty
              then all tags are removed from the text.

    $cat->inswt($text, $args);

=cut

sub inswt {
    my $self = shift;
    my $w = $self->Text;
    my ($text, @args) = @_;
    my $start = $w->index('insert');

    $w->insert('insert', $text);
    foreach my $tag ($w->tag('names', $start)) {
        $w->tag('remove', $tag, $start, 'insert');
    }
    foreach my $i (@args) {
        $w->tag('add', $i, $start, 'insert');
    }
}

=item getSource

getSource prompts the user to enter source coords and name
and filters the catalog based on the input provided.

Takes the new top level widget to use, and the search button
to be re-activated when this window closes.

    $obj = $cat->getSource($toplevel, $search_button);

=cut

sub getSource {
    my $self = shift;
    my $Top = shift;
    my $searchButton = shift;
    my @Epocs = ('RJ', 'RB');
    my %distances = (
        '15 degrees' => 15.0,
        '5 degrees'  => 5.0,
        '1 degree'   => 1.0,
        '30\''       => 0.5,
        '15\''       => 0.25,
        '5\''        => 1.0 / 12,
        '1\''        => 1.0 / 60,
        '30\'\''     => 0.5 / 60,
        '15\'\''     => 0.25 / 60,
        '5\'\''      => 1.0 / 12 / 60,
        '1\'\''      => 1.0 / 3600,
    );
    my $name;

    $Top->title('Source Plot');
    $Top->resizable(0,0);
    my $topFrame = $Top->Frame(
        -relief => 'groove', -borderwidth => 2, -width => 50
    )->pack(-padx => 10, -fill => 'x', -ipady => 10, -pady => 10);

    $topFrame->Label (
        -text => "Name:"
    )->grid(-column=>0, -row=>0);
    my $nameEnt = $topFrame->Entry(
        -relief=>'sunken', -width=>15
    )->grid(-column => 1, -row => 0, -padx => 10, -pady => 3);

    $topFrame->Label (
        -text => "Ra:"
    )->grid(-column => 0, -row => 1);
    my $raEnt = $topFrame->Entry(
        -relief => 'sunken', -width => 15
    )->grid(-column => 1, -row => 1, -padx => 10, -pady => 3);

    $topFrame->Label (
        -text => "Dec:"
    )->grid(-column => 0, -row => 2);
    my $decEnt = $topFrame->Entry(
        -relief => 'sunken', -width => 15
    )->grid(-column => 1, -row => 2, -padx => 10, -pady => 3);

    $topFrame->Label(
        -text => 'Distance:'
    )->grid(-column => 0, -row => 3);
    my $distEnt = '1\'';



( run in 0.652 second using v1.01-cache-2.11-cpan-0b5f733616e )