“显示"在tkinter.font.Font.measure中 [英] "displayof" in tkinter.font.Font.measure

查看:109
本文介绍了“显示"在tkinter.font.Font.measure中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下measure方法在模块/usr/lib/python3.5/tkinter/fontimport tkinter.fontclass Font中定义:

The following measure method is defined in class Font of module /usr/lib/python3.5/tkinter/font or import tkinter.font:

def measure(self, text, displayof=None):
    "Return text width"
    args = (text,)
    if displayof:
        args = ('-displayof', displayof, text)
    return self._tk.getint(self._call("font", "measure", self.name, *args))

问题:

  1. 什么是displayof?
  2. 何时以及如何使用displayof?
  1. What isdisplayof?
  2. When and how do I use displayof?

推荐答案

它将小部件作为参数.虽然很少见,但有可能在具有不同像素密度的多台显示器上显示多个窗口.如果您有这样的设置,则可以决定使用哪个窗口小部件/显示器作为确定字符串大小的基础.

It takes a widget as an argument. While rare, it’s possible to have multiple windows displaying on multiple displays with different pixel densities. If you have such a setup, this lets you decide which widget/display to use as the basis for determining the size of the string.

此参数的默认值为根窗口.

The default for this parameter is the root window.

这篇关于“显示"在tkinter.font.Font.measure中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆