⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 example-3.pl

📁 Developing with Gnome一书examples例子代码
💻 PL
字号:
#!/usr/bin/perl -w# This program displays a couple checkboxes and shows how to change# button labels, how to make widgets sensitive or unsensitive, how to# determine if a checkbox is active, how to provide access keys for# quick keyboard navigation, how to pass other widgets to callbacks *# besides the one that receives the event, and how to manually get# gtk+ to update widgets without returning to the main event loop.use Glib qw(TRUE FALSE);use Gtk2 '-init';use Gtk2::GladeXML;# Just to be pedantic...use strict;use vars qw($main_window);# Unlike the C bindings for libglade, perl does not use an equivalent# to G_CONNECT_SWAPPED when an Object is specified for a signal# handler.  This means that the parameters are not swapped.sub quit_handler{  my (undef, $tellme_widget) = @_;  # widget (quit_button) is unused  # If the user checked the OohTellMe button, we need to do some work...  if ($tellme_widget->get_active) {    # Change the checkbutton's label    $tellme_widget->set_label("M_ock me");    # Since we don't return to the main event loop, we have to manually tell    # gtk+ to process the gtk_button_set_label change (and any other changes    # that require processing).    while (Glib::MainContext->default->iteration(FALSE)) {    }    # Mock the user and give them some time to notice the change    print "Ha ha, you fell for it!  ";    print "I will not tell you what that checkbutton does!\n";    sleep (1);  }  Gtk2->main_quit;}# Unlike the C bindings for libglade, perl does not use an equivalent# to G_CONNECT_SWAPPED when an Object is specified for a signal# handler.  This means that the parameters are not swapped.sub delete_handler{  my ($quit_button, undef, $tellme_widget) = @_;  # event is not used  &quit_handler($quit_button, $tellme_widget);}# Unlike the C bindings for libglade, perl does not use an equivalent# to G_CONNECT_SWAPPED when an Object is specified for a signal# handler.  This means that the parameters are not swapped.sub sensitivity_toggled{  my ($sensitivity_widget, $tellme_widget) = @_;  $tellme_widget->set_sensitive($sensitivity_widget->get_active);}  # load the interface  $main_window = Gtk2::GladeXML->new('example-3.glade');  # connect the signals in the interface  $main_window->signal_autoconnect_from_package('main');  # start the event loop  Gtk2->main;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -