[Tutor] Bitmap editor and File-saving

Alan Gauld alan.gauld at btinternet.com
Sun Nov 11 10:29:56 CET 2007


"Johnston Jiaa" <oclbdk at gmail.com> wrote

> I am using Tkinter to create a program in which the user can draw a
> simple bitmap image.  What library would be best to use in this
> circumstance?  I have no idea how I would go about doing this except
> maybe I would use Tkinter's canvas component?

The canvas widget is probably adequate for simple drawing.
More advanvced libraries like PIL might be useful for converting
the format or doing large scale transformations.

> In order for the program to be useful, it should save the picture
> too.  I'd like for it to save the image with some strings of text.
> How can I implement such a file-saving feature?

You could either save two files one with the text and the other
the bitmap. Or you could convert the text to binary data and
write it to the same file as the bitmap. To read it back you will
need to write code to strip the text off again however. Or you
could use uuencode, or similar, to convert the image to text
and add your strings to that. Again you will need to write the
reverse process for retrieving it.

HTH,

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 




More information about the Tutor mailing list