Python/Tkinter:在“标签"小部件中自定义图像和文本之间的水平填充? [英] Python/Tkinter: Customize horizontal padding between image and text in Label widget?
问题描述
当compound = left或right时,是否可以自定义Label小部件中图像和文本之间的水平填充?
Is there a way to customize the horizontal padding between an image and text in a Label widget when compound=left or right?
我能想到的2种方法是:
The 2 ways I can think of are:
-
使用PIL向图像中动态添加像素列
Use PIL to dynamically add columns of pixels to an image
在标签的text =选项中插入或附加空格以强制图像和文本分开
Insert or append spaces to the text= option of the label to force the separation of image and text
我正在寻找一种以像素为单位指定水平填充(图像和文本之间)的方法.
What I'm looking for is a way to specify the horizontal padding (between image and text) in pixels.
推荐答案
没有内置的方法可以执行所需的操作.您自己的建议是好的.另一种选择是创建框架,并在框架中放置单独的图像和标签小部件.然后,您可以完全控制小部件的放置
There is no built-in way to do what you want. Your own suggestions are good. Another option is to create a frame, and place separate image and label widgets in the frame. You then have complete control of the placement of the widgets
这篇关于Python/Tkinter:在“标签"小部件中自定义图像和文本之间的水平填充?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!