开发者

Putting images in a Tkinter

How can I place an image in a Tkinter GUI using the python standard library?开发者_开发知识库


I don't normally use Tkinter, but I'll take a shot at answering. According to Google, loading images in Tkinter has two main gotchas:

  1. It only accepts GIFs. (Example code for using PIL to convert to GIF while loading)
  2. You have to manually keep a reference to images due to an inability to refcount them. (solution) (explanation)

The example code for loading non-GIF images should also work perfectly well as an example of the basic procedure for displaying images in Tkinter GUIs.

If you'd prefer a more practical example, PySol is a suite of solitaire games written with Tkinter and PySolFC, its successor, demonstrates the same usage adapted to the new python-ttk Tkinter API which Python 2.7 added.


You can Built-In the images on the code encoding it on Base64

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜