canvas drawing on button

Martin Franklin martin.franklin at westerngeco.com
Tue Apr 17 08:16:43 EDT 2001


Brian:

Try:

import Tkinter

root=Tkinter.Tk()

img=Tkinter.PhotoImage(width=5, height=5)

w='white'
b='black'
image_data=[ [ w, w, w, w, w ],
             [ w, w, b, w, w ],
             [ w, b, b, b, w ],
             [ w, w, b, w, w ],
             [ w, w, w, w, w ],
             ]


for x in range(5):
    for y in range(5):
        img.put(image_data[x][y], (x, y))

images={1:img} # keep a referance....

b=Tkinter.Button(root, image=images[1])
b.pack()
root.mainloop()


Thanks,
Martin.


Brian Elmegaard wrote:

> Hi,
>
> Is it possible in any way to make python generate a bitmap/image of a
> tkinter canvas item and use that for a button bitmap/image?
>
> or,
>
> can I make a canvas on a button?
>
> or,
>
> do I really have to make the drawing outside of python?
> --
> Brian
> http://www.et.dtu.dk/energysystems
> http://www.rk-speed.dk http://fiduso.dkhttp://sunsite.auc.dk/dk-tug
> \TeX, tak

--
          Martin Franklin Workstation Support
      (Tel. Work 01234 224793, Home 01234 881722)
Western G., Manton Lane, Bedford, Bedfordshire, MK41 7PA
           martin.franklin at bedford.waii.com







More information about the Python-list mailing list