Jim Lee at 2018/6/19 PM 03:44 wrote:


On 06/18/2018 09:22 PM, Jach Fong wrote:
Ben Finney at 2018/6/19 PM 10:20 wrote:
Jach Fong <jf...@ms4.hinet.net> writes:

Although it passed the first examination, I have no idea if it can
work correctly in the real application:-)

Neither do I. What is the real-world problem you are trying to solve?
Why do you think this (and not some more idiomatic Python feature) is
needed for solving that problem?

No, I don't have any specific application in mind. This idea was just
triggered by a sentence in a Docstring in file font.py.

class Font:
    """Represents a named font.
    Constructor options are:
    ...
    exists -- does a named font by this name already exist?
       Creates a new named font if False, points to the existing font if True.
    ...
    """

But honestly I still don't know how it "points to the existing font":-(


If the font exists, the Font object calls this:
     tk.call("font", "configure", self.name, *font)
Otherwise, it calls this:
     tk.call("font", "create", self.name, *font)

If the Font was called through nametofont, then the font is None
and neither will be called:-)

--Jach

The font caching is all handled by Tk, not Python.  The Font object is just a wrapper around calls to Tk.

-Jim


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to