Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Tk oddity with Label, iconbitmap and listbox

by davies (Prior)
on May 28, 2005 at 15:11 UTC ( #461355=perlquestion: print w/replies, xml ) Need Help??

davies has asked for the wisdom of the Perl Monks concerning the following question:

The code given is cut down as far as I can to demonstrate the problem. I have a Tk window, where I want a listbox with a label at the top. I also want to set the icon myself. The following code is intended to do this:
use strict; use warnings; use diagnostics; use Tk; my $cboAgent; my $mw = MainWindow->new; $mw->geometry('200x400'); $mw->toplevel->resizable(0,0); $mw->Label(-text => 'Agent' ) ->place(-x => 0, -y => 0 ); ($cboAgent) = $mw->Scrolled('Listbox', -height => 20, -width => 10, -scrollbars => 'e') ->place(-x => 0, -y => 25 ); $mw->toplevel->iconbitmap('C:\Template\v3_5\TARDISdv\Tardis.ico'); MainLoop;
This produces everything bar the listbox. However, if I comment out either the label or the icon commands (or both), I get the listbox. I have tried changing the order of the commands, but it doesn't seem to make a difference. However, I haven't tried every possible combination. Please would someone point out my stupidity? My system configuration is in my scratchpad. Update: WAS in my scratchpad. I didn't think it was relevant, and so it proved. But it's in my private scratchpad if anyone REALLY needs it. /update

TIA & regards,

John Davies

Replies are listed 'Best First'.
Re: Tk oddity with Label, iconbitmap and listbox
by thundergnat (Deacon) on May 28, 2005 at 20:06 UTC

    Just update the main window before you set the icon.

    use strict; use warnings; use diagnostics; use Tk; my $cboAgent; my $mw = MainWindow->new; $mw->geometry('200x400'); $mw->toplevel->resizable(0,0); $mw->Label(-text => 'Agent' ) ->place(-x => 0, -y => 0 ); ($cboAgent) = $mw->Scrolled('Listbox', -height => 20, -width => 10, -scrollbars => 'e') ->place(-x => 0, -y => 25 ); $mw->update; $mw->toplevel->iconbitmap('C:\Template\v3_5\TARDISdv\Tardis.ico'); MainLoop;
      Works perfectly. Many thanks! I didn't know about update - now I know what to look for in the man pages.

      Regards,

      John Davies

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://461355]
Approved by prasadbabu
Front-paged by Courage
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2022-09-26 00:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer my indexes to start at:




    Results (116 votes). Check out past polls.

    Notices?