PyGObject修复按钮大小无论如何。相应地打破标签

时间:2019-01-02 21:36:03

标签: python python-3.x gtk gtk3 pygobject

我正在用PyGObject做一个均匀的按钮网格。目前,我正在执行此操作以进行按钮大小调整和添加。

time_a

如果按钮标签足够小以适合按钮内部,那一切都很好。但是,如果我的标签更长,则按钮会展开以适合标签。我想停止这种扩展,并相应地中断/缩放/截断标签。最好的方法是什么?

1 个答案:

答案 0 :(得分:0)

您可以ellipsize放在中间。示例:

label = Gtk.Label("This text is absolutely terribly too long to "
                        "fit in any decent size space on a normal window "
                        "anybody in his right mind would be using, so "
                        "please ellipsize it using a Gtk function that "
                        "calculates a decent size based on the rest of "
                        "the window by using some dots in the middle of "
                        "the text. Thank You!")
label.set_ellipsize (Pango.EllipsizeMode.MIDDLE)
folder_button = Gtk.Button(label=label)