#!/usr/bin/perl use warnings; use strict; use Gtk2 -init; #if you want to adjust colors, otherwise comment out Gtk2::Rc->parse_string(<<__); style "calendar" { bg[NORMAL] = "#aadddd" #background of header bar bg[SELECTED] = "#ff0000" #color of weekday bg when window is moved bg[PRELIGHT] = "#ccffff" #color of bg of selector-scroller triangles f +or month/year fg[NORMAL] = "#000000" #text for days(active) and header fg[PRELIGHT] = "#ff0000" #color of fg of selector-scroller triangles f +or month/year # For the selected item base[NORMAL] = "#ffffff" #background of dates display base[SELECTED] = "#99aaaa" #background of weekday names and days base[ACTIVE] = "#999999" #selected color when active base[PRELIGHT] = "#0000ff" #selected color when active }class "*Calendar*" style "calendar" __ ############################################################## #adjust font my $font = Gtk2::Pango::FontDescription->from_string("Sans Bold 24"); my $window = Gtk2::Window -> new("toplevel"); $window -> set_title ("Simple Calendar"); $window -> signal_connect (delete_event => sub { Gtk2 -> main_quit(); +}); my $calendar = Gtk2::Calendar -> new(); $calendar->signal_connect( 'day_selected_double_click' => sub { my ($year, $month, $day) = $calendar->get_date; printf("%02d/%d/%d\n", $month+1, $day, $year); }); #will show headings and day names by default, but must #declare them manually if adding week numbers $calendar->set_display_options(['show-week-numbers','show-heading','sh +ow-day-names'] ); $calendar->modify_font($font); $window -> add($calendar); $window -> show_all(); Gtk2 -> main();
In reply to Gtk2 Simple Calendar/ Date Selector by zentara
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |