1

In Perl Tkx I created my own popups which work great.

But I would like to embed those built-in icons, like info, question.

Does anyone know how I can do that on my own widgets and how?

sub PopDialog {
    my ($TITLE, $NOTE, @buttons) = @_;

    my (@butt, $ret);
    my $wait  = 1;
    my $xwm   = Tkx::widget->new(".");
    my $popwm = $xwm->new_toplevel();

    $popwm->g_wm_title("$TITLE");
    $popwm->g_wm_minsize(200, 10);
    $popwm->g_wm_resizable(0, 0);

    my $back = $popwm->new_ttk__frame(-padding => "5 5 5 5");
    $back->g_grid(-column => 0, -row => 0, -sticky => "n");

    $popwm->g_grid_columnconfigure(0, -weight => 1);
    $popwm->g_grid_rowconfigure(0, -weight => 1);

    if ($NOTE !~ /^$/) {
        my $frm0 = $back->new_ttk__frame(-padding => 5);
        my $label = $frm0->new_ttk__label(-text => "$NOTE", -font => 'logo_font')->
                g_grid(-column => 0, -row => 0);
        $frm0->g_pack();
    }

    my $frm1 = $back->new_ttk__frame(-padding => 5);

    for my $x (0 .. $#buttons) {
        $butt[$x] = $frm1->new_ttk__button(
            -text      => "$buttons[$x]",
            -underline => 0,
            -command   => sub { $ret = "$buttons[$x]"; $wait = 0; }
        )->g_grid(-column => $x, -row => 0);
    }

    $frm1->g_pack();
    $popwm->g_wm_protocol(WM_DELETE_WINDOW => sub { $ret = "Exit"; $wait = 0; });    # Close Button returns "Exit"
    $popwm->g_bind('<Unmap>', sub { $popwm->g_wm_deiconify; $xwm->g_focus; });    # No minimizing to Icon Allowed

    while ($wait) {
        Tkx::update();
        $popwm->g_focus;
    }

    $popwm->g_destroy;

    return $ret;
}
Borodin
  • 126,100
  • 9
  • 70
  • 144
  • Try to keep your code tidy, especially when asking others for help. I have tried to improve it for you by adding whitespace and indentation, but all the code is still your own. Also you shouldn't put scalar variables on their own in double-quotes, like `"$TITLE"`, `"$NOTE"`, and `"$buttons[$x]"`. – Borodin Apr 14 '13 at 01:06

0 Answers0