john15276 has asked for the wisdom of the Perl Monks concerning the following question:
Hi Perlmonks,
I am learning canvas with Perl Tkx and having problem adding text to the item
created. In my program, a rectangular box is created and a text "testing" is inserted
for the rectangle item. I expect to see the text "testing" next to the rectangular
box but it does not. Please point out what wrong with my codes. Thanks so much.
----------------------------------- use Tkx; $mw = Tkx::widget->new("."); $canvas = $mw->new_tk__canvas; $canvas->g_grid(-column=>0, -row=>0, -sticky=>"nwes"); $mw->g_grid_columnconfigure(0, -weight=>1); $mw->g_grid_rowconfigure(0, -weight=>1); $id = $canvas->create_rectangle(30, 30, 200, 80, -fill => "red", -tags => "first_box"); $canvas->insert($id, 0, "testing"); #<== testing not displayed $canvas->g_bind("<1>", [sub {$canvas->itemconfigure("current",-fill => "green");}]); Tkx::MainLoop();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Canvas Text Item
by Loops (Curate) on Jul 24, 2013 at 22:57 UTC | |
by john15276 (Initiate) on Jul 24, 2013 at 23:22 UTC |