Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Images in Canvas

by Crian (Chaplain)
on Nov 26, 2008 at 09:41 UTC ( #726048=note: print w/replies, xml ) Need Help??


in reply to Images in Canvas

You use my $xpm two times, I think one of that lines should be commented out.

In different to the createBitmap method you do not need to put a @ in front of the image name when using createImage, if I understand "Mastering Perl/TK" the right way.

Perhaps try one of the built in bitmaps first, to be shure to have no problems with the bitmap file, e.g. my $xpm = $drawing->createBitmap(0, 0, -bitmap  => 'info');.

In case of the createImage method, you have to use an object created with the Photo or Bitmap methods.


I tested a little bit and ending with this, perhaps it is a source for an idea for you:

#!/usr/bin/perl use strict; use warnings; use Tk; my $mw = new MainWindow; $mw->geometry('600x600+110+110'); my $drawing = $mw->Canvas( -width => 500, -height => 500, -background => 'white', )->pack(); my $xpm = <<'END'; /* XPM */ static char *test[]={ "32 32 11 1", ". c None", "# c #000000", "h c #004000", "g c #004040", "f c #404000", "e c #808080", "i c #a0a0a4", "c c #c0c000", "d c #ffff00", "b c #ffffc0", "a c #ffffff", "................................", "................................", "................................", "................................", ".............#....###...........", "............#a##.#aba##.........", "...........#aaaa#aaaaaa##.......", "..........#aaaa#aaaaaaaba##.....", ".........#aaaa#aaaaaaaaaaab##...", "........#aaba#aaaaaaabaabaaaa##.", ".......#aaba#baaaaa#baaaaaabaaa#", "......#aaaa#aaaaab#a##baaaaaaa#.", ".....#aaba#aacbba#aaaa##baaab#..", "....#bbaa#abaacc#aaaaaaa##aa#...", "...#bbbb#aaabaa#aaabaaaaaa##....", "..#bbbb#bacaaa#aaaaaaaabaaaa##..", ".#bbbb#bbaacc#aacaaaaaaaaaaaba#.", "#ddbb#bbbbba#aaaaccaaaaaaaaaaaa#", "#edddfgcbbbfaacaaaaccaaaaaaaaa#e", ".#hedddfhcfabaaccaaabccaaaaaa#e.", "...##edddhaacbbaaccbaaaccaab#i..", ".....##e#baaaccabaaccbaabaa#i...", "......##bacbaabccbaaaccabb#e....", "......#bbbbccaabbccaaaaab#i.....", ".....#bbbbbbbccabbaccaab#i......", ".....#ebbbbbbbbccbaabba#i.......", "......##ebbbbbbbbccaabhe........", "........##ebbbbbbbbbb#e.........", "..........##ibbbbbbbhe..........", "............##ebbbb#e...........", "..............#hee#i............", "................##i............."}; END my $bitmap = $mw->Pixmap(-data => $xpm); $drawing->createImage(100, 100, -image => $bitmap); MainLoop();

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://726048]
help
Chatterbox?
[Corion]: Hehe - $work is a place where we have lots of (money) accounts, and lots of journals where every transaction is recorded. But our HR system where the accounts of hours worked and vacation days taken are stored, there is no real account of who changed ...
[Corion]: ... that balance, and when. And it seems to me that they somehow really messed up the database since the start of the year and have been frantically adding and subtracting numbers from the totals, but without trace ;)

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2018-01-23 16:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How did you see in the new year?










    Results (249 votes). Check out past polls.

    Notices?