even though Gtk3 module is still in development . Most the code is working in Gtk3.
i have experienced some issues when the window is resized .. buttons are expanding with it .. and help me with accelerators .... please
use strict;
use warnings;
use Gtk3 '-init';
use Glib qw/TRUE FALSE/;
#Creating Window
my $window = Gtk3::Window->new('toplevel');
$window->set(
title=>rand(int(100)),
# default_height=>'300',
# default_width=>'300',
resizable=>'TRUE',
focus_on_map=>'TRUE'
);
#creating a Vbox
my $vbox = Gtk3::Box->new('vertical',3);
$vbox->set(
visible=>TRUE,
can_focus=>FALSE,
double_buffered=>FALSE,
homogeneous=>TRUE,
expand=>'false'
);
#creating button
my $button = &button;
my $menubar = &createmenubar;
my $text_view = Gtk3::TextView->new();
$text_view->set(editable=>FALSE,cursor_visible=>FALSE);
my $scroll = Gtk3::ScrolledWindow->new();
$scroll->add($text_view);
# Vbox
# |--->Menubar
# |--->Button
# |--->TextView
#adding itesm to Vbox
$vbox->pack_start($menubar,FALSE,TRUE,3);
$vbox->pack_start($scroll,TRUE,TRUE,0);
$vbox->pack_start($button,FALSE,FALSE,0);
# Window
# |--->Vbox
$window->add($vbox);
#adding accelerator group
my $accel_group = Gtk3::AccelGroup->new();
$window->add_accel_group($accel_group);
#signale to destroy the main Gtk
$window->signal_connect(destroy=>\&quit);
$window->show_all;
Gtk3->main;
sub changetitle{
print $window->get_title(),"\n";
$window->set(
title=>rand(int(100)),
);
}
sub createmenubar{
my $menu_item_file = Gtk3::MenuItem->new_with_label('File');
my $menu_bar = Gtk3::MenuBar->new();
$menu_bar->add($menu_item_file);
my $menu_file = Gtk3::Menu->new();
my $menu_item_refresh = Gtk3::ImageMenuItem->new_from_stock('gtk-r
+efresh');
$menu_file->add($menu_item_refresh);
$menu_item_refresh->signal_connect(activate=>\&changetitle);
my $menu_item_quit = Gtk3::ImageMenuItem->new_from_stock('gtk-quit
+');
$menu_item_quit->signal_connect(activate=>\&quit);
# $menu_item_quit->add_accelerator('activate',$accel_group,Gtk3::Ac
+celerator->parse('<Control>Q'),'visible');
$menu_file->add($menu_item_quit);
$menu_item_file->set_submenu($menu_file);
return $menu_bar;
}
sub button {
my $button_sub =Gtk3::Button->new_with_label('Click to Change the
+Title');
#connecting signale connnect clicked to subroutine
$button_sub->signal_connect(clicked=>\&changetitle);
$button_sub->set(
use_action_appearance=>FALSE,
visible=>TRUE,
can_focus=>TRUE,
receives_default=>TRUE,
use_action_appearance=>FALSE
);
return $button_sub;
}
sub quit {
Gtk3->main_quit;
}
Sorry Mistake ... i have got figured the thing
#creating a Vbox
my $vbox = Gtk3::Box->new('vertical',3);
$vbox->set(
visible=>TRUE,
can_focus=>FALSE,
double_buffered=>FALSE,
expand=>'false'
);
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.