New to GTK+ and a question about Combo boxes.



I'm building a Perk-GTK application on Windows which includes a "date" element, which is three ComboBoxes clustered together in an Hbox: month, day, year.

Since there are several places in the application where a date is added, I built a function to return an Hbox containing those three combo boxes:

sub make_date
{
    my($element, $min_year, $max_year) = @_;

    my @MONTHS  = qw/Jan Feb Mar Apr May June July Aug Sep Oct Nov Dec/;
    my @DAYS    = (1 .. 31);
    my @YEARS   = ($min_year .. $max_year);

    my $hbox = Gtk2::HBox->new(FALSE, 0);

    # Month
    $E{"${element}_month"}{'obj'} = Gtk2::ComboBox->new_text;
    $E{"${element}_month"}{'obj'}->append_text(' ');
    foreach my $s (@MONTHS) {
        $E{"${element}_month"}{'obj'}->append_text($s);
    }
$E{"${element}_month"}{'obj'}->signal_connect('changed' => sub { $E{"${element}_month"}{'data'} = $E{"${element}_month"}{'obj'}->get_active_text(); } );

    $hbox->pack_start($E{"${element}_month"}{'obj'}, FALSE, FALSE, 0);


    # Day
    $E{"${element}_day"}{'obj'} = Gtk2::ComboBox->new_text;
    $E{"${element}_day"}{'obj'}->append_text(' ');
        foreach my $s (@DAYS) {
        $E{"${element}_day"}{'obj'}->append_text($s);
    }
$E{"${element}_day"}{'obj'}->signal_connect('changed' => sub { $E{"${element}_day"}{'data'} = $E{"${element}_day"}{'obj'}->get_active_text(); } );
    $hbox->pack_start($E{"${element}_day"}{'obj'}, FALSE, FALSE, 0);

    # Year
    $E{"${element}_year"}{'obj'} = Gtk2::ComboBox->new_text;
    $E{"${element}_year"}{'obj'}->append_text(' ');
    foreach my $s (@YEARS) {
        $E{"${element}_year"}{'obj'}->append_text($s);
    }
$E{"${element}_year"}{'obj'}->signal_connect('changed' => sub { $E{"${element}_year"}{'data'} = $E{"${element}_year"}{'obj'}->get_active_text(); } );
    $hbox->pack_start($E{"${element}_year"}{'obj'}, FALSE, FALSE, 0);

    return $hbox;
}

$E is a global hash I'm using for the time being to keep track of all the elements -- at least until I get more expert with GTK.

My questions:

1) How come whenever I resize the window the ComboBoxes themselves also expand? I've tried every combination in the pack_start function to no avail.

2) How come the pulldown lists appear (for lack of a better term) double spaced? Is there a fix for that?

3) How come I can't seem to get rid of the padding between the three ComboBoxes? I'd like there to be no space between them.

4) One more oddity: if I stick the output of this function in a table cell like this:

$table->attach_defaults(make_date('dob', 1950, 2010), 3, 4, $row, row+1);

and then give the table a small row spacing, like $table->set_row_spacings(2), the comboboxes expand to like 3x their normal height.

I'm guessing that all these symptoms are related to something I don't understand about GTK+ in general and Comboboxes in particular, at least versus the comboboxes in TKX.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]