BioPerl
view release on metacpan or search on metacpan
examples/tk/gsequence.pl view on Meta::CPAN
$window->set_title( "gSequence" );
$window->set_usize( 600, 400 );
# vertical box containing menu and text editor widget
my $main_vbox;
$main_vbox = new Gtk::VBox( $false, 1 );
$main_vbox->border_width( 1 );
$window->add( $main_vbox );
# handlebox for menubar
my $handlebox;
$handlebox = new Gtk::HandleBox();
$main_vbox->pack_start( $handlebox, $false, $true, 0 );
# menubar
my $menubar;
$menubar = get_menu( $window );
$handlebox->add( $menubar );
# text widget
$seq_edit[$current] = new Gtk::Text( undef, undef );
$seq_edit[$current]->set_editable( $true );
# vertical scrollbar for text widget
my $scrollbar;
$scrollbar = new Gtk::VScrollbar( $seq_edit[$current]->vadj );
# horizontal box containing text widget and scrollbar
my $seq_edit_hbox;
$seq_edit_hbox = new Gtk::HBox( $false, 1 );
$seq_edit_hbox->border_width( 1 );
$seq_edit_hbox->pack_start( $seq_edit[$current], $true, $true, 0);
$seq_edit_hbox->pack_end( $scrollbar, $false, $true, 0);
$main_notebook = new Gtk::Notebook();
$main_notebook->set_tab_pos( 'top' );
$main_vbox->pack_end( $main_notebook, $true, $true, 0);
# show everything
$window->show_all();
$main_notebook->signal_connect_after("switch-page",
sub{ #$seq[$current]->seq($seq_edit[$current]->get_chars(0,-1))
# if (defined($seq[$current]));
$current = $main_notebook->get_current_page();
&update_seq_data(); } );
}
sub get_menu
{
my ( $window ) = @_;
my $menubar;
my $item_factory;
my $accel_group;
$accel_group = new Gtk::AccelGroup();
# This function initializes the item factory.
# Param 1: The type of menu - can be 'Gtk::MenuBar', 'Gtk::Menu',
# or 'Gtk::OptionMenu'.
# Param 2: The path of the menu.
# Param 3: The accelerator group. The item factory sets up
# the accelerator table while generating menus.
$item_factory = new Gtk::ItemFactory( 'Gtk::MenuBar',
'<main>',
$accel_group );
# This function generates the menu items. Pass the item factory,
# the number of items in the array, the array itself, and any
# callback data for the the menu items.
$item_factory->create_items( @menu_items );
# Attach the new accelerator group to the window.
$window->add_accel_group( $accel_group );
# Finally, return the actual menu bar created by the item factory.
#*menubar = gtk_item_factory_get_widget (item_factory, "<main>");
return ( $item_factory->get_widget( '<main>' ) );
}
sub new_seq_page
{
my ($seq) = shift;
my $curr;
push @seq,$seq;
$curr = @seq - 1;
$main_label[$curr] = new Gtk::Label($seq[$curr]->id())
if (defined($seq[$curr]));
$main_label[$curr] = new Gtk::Label("<New>")
if (!defined($seq[$curr]));
# text widget
$seq_edit[$curr] = new Gtk::Text( undef, undef );
$seq_edit[$curr]->set_editable( $true );
# vertical scrollbar for text widget
my $scrollbar;
$scrollbar = new Gtk::VScrollbar( $seq_edit[$curr]->vadj );
# horizontal box containing text widget and scrollbar
my $seq_edit_hbox;
$seq_edit_hbox = new Gtk::HBox( $false, 1 );
$seq_edit_hbox->border_width( 1 );
$seq_edit_hbox->pack_start( $seq_edit[$curr], $true, $true, 0);
$seq_edit_hbox->pack_end( $scrollbar, $false, $true, 0);
$main_notebook->append_page( $seq_edit_hbox, $main_label[$curr] );
$main_notebook->show_all();
$main_notebook->set_page(-1);
}
sub seq_fetch
{
my ($server,$port,$dir,$db); # read from preferences
my ($dbobj);
return if (!defined($import_from) || !($import_from));
$dbobj = Bio::DB::GenPept->new() if ($import_from eq "genpept");
$dbobj = Bio::DB::Ace->new(-host=>$server,-port=>$port)
if ($import_from eq "ace");
$dbobj = Bio::Index::Abstract->new("$dir/$db")
if ($import_from eq "fasta") ||
( run in 0.856 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )