Reputation: 22
I made a Tkinter GUI, added text-widget to it, and added a save button but when I click the save button it save as a text (.txt file) and I want it to save the text as a picture which would be read-only(.png) can anybody help? in simple words whats happening=user save the file - it is saved as a txt file what I want=user save the file - it is saved as a png Image It is a text widget not a canvas (Actually, first i wanted it to Do like because I was having an option that can change the color of the text according to the user's choice and save it as a pdf but that didn't work if you can do that would also work) :)
Upvotes: 0
Views: 772
Reputation: 11
Write your cods in txt file and go to file menu and click on (save as) and save file with .png format like (cod.png)
Upvotes: 1
Reputation: 179
I think this is help you
from PIL import Image, ImageDraw
img = Image.new('RGB', (100, 30))
d = ImageDraw.Draw(img)
d.text((10,10), "Hello", fill=(255,255,0))
img.save('text.png')
This project use Pillow.First we create a new image.Then we add text to this image and change fill for this text.And Finally we save this image.
Upvotes: 1