Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7887693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:38:48+00:00 2026-06-03T05:38:48+00:00

from Tkinter import * root = Tk() cv = Canvas(root) cv.create_rectangle(10,10,50,50) cv.pack() root.mainloop() I

  • 0
from Tkinter import *
root = Tk()
cv = Canvas(root)
cv.create_rectangle(10,10,50,50)
cv.pack()
root.mainloop()

I want to convert canvas content to a bitmap or other image, and then do other operations, such as rotating or scaling the image, or changing its coordinates.

Bitmaps can improve efficiency to show if I am no longer drawing.

What should I do?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T05:38:50+00:00Added an answer on June 3, 2026 at 5:38 am

    You can either generate a postscript document (to feed into some other tool: ImageMagick, Ghostscript, etc):

    from Tkinter import *
    root = Tk()
    cv = Canvas(root)
    cv.create_rectangle(10,10,50,50)
    cv.pack()
    root.mainloop()
    
    cv.update()
    cv.postscript(file="file_name.ps", colormode='color')
    
    root.mainloop()
    

    or draw the same image in parallel on PIL and on Tkinter’s canvas (see: Saving a Tkinter Canvas Drawing (Python)). For example (inspired by the same article):

    from Tkinter import *
    import Image, ImageDraw
    
    width = 400
    height = 300
    center = height//2
    white = (255, 255, 255)
    green = (0,128,0)
    
    root = Tk()
    
    # Tkinter create a canvas to draw on
    cv = Canvas(root, width=width, height=height, bg='white')
    cv.pack()
    
    # PIL create an empty image and draw object to draw on
    # memory only, not visible
    image1 = Image.new("RGB", (width, height), white)
    draw = ImageDraw.Draw(image1)
    
    # do the Tkinter canvas drawings (visible)
    cv.create_line([0, center, width, center], fill='green')
    
    # do the PIL image/draw (in memory) drawings
    draw.line([0, center, width, center], green)
    
    # PIL image can be saved as .png .jpg .gif or .bmp file (among others)
    filename = "my_drawing.jpg"
    image1.save(filename)
    
    root.mainloop()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

from Tkinter import * app = Tk() text_field = Entry(app) text_field.pack() app.mainloop() I want
from Tkinter import * import socket, sys from PIL import Image, ImageTk root =
Something like this: from Tkinter import * root = Tk() but = Button(root, text
I've created this simple GUI: from tkinter import * root = Tk() def grabText(event):
from Tkinter import * root = Tk() root.title(Whois Tool) text = Text() text1 =
from Tkinter import * import socket, sys, os import tkMessageBox root = Tk() root.title(File
from Tkinter import * import tkMessageBox, socket root = Tk() root.title(pynet v1.0) root.config(bg='black') root.resizable(0,0)
from Tkinter import * class StatusBar(Frame): def __init__(self, master): Frame.__init__(self, master) self.label = Label(self,
here is some code: from Tkinter import * class Main(object): def __init__(self): self.console =
from Tkinter import * class Output: def __init__(self,master): self.u=Text(master,width=40) self.u.grid(row=0,column=0) self.v=Button(master,text=Add text,command=Write) self.v.grid(row=1,column=0) def

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.