开发者

How to save tkinter table as an image

开发者 https://www.devze.com 2023-03-10 20:28 出处:网络
I am drawing a table using tKinter. I was wondering if there was a way to export the table as an image.

I am drawing a table using tKinter. I was wondering if there was a way to export the table as an image.

for r in range(numberOfRows):
 开发者_StackOverflow    for c in range(numberOfColumns):
         l = tk.Label(root, text=someText, relief="solid", height=5, width=10, bg="white")
         l.grid(row=r, column=c)

Thanks.


You can always go the draw-it-yourself way. There are several modules out there that allow you draw an image. Take the coordinates of your table, column width and so on and draw it into the image.


You can take a screen shot of it.

import PIL.ImageGrab as ImageGrab

screenshot = ImageGrab.grab().load()

rgb = screenshot[0, 0] 
print rgb

rgb would return the color value of any pixel on screen.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号