Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #108960

Re: Image loading problem

From Michael Torrie <torriem@gmail.com>
Newsgroups comp.lang.python
Subject Re: Image loading problem
Date 2016-05-22 13:37 -0600
Message-ID <mailman.7.1463945887.20402.python-list@python.org> (permalink)
References <743e5fbe-3a6c-49ea-ac5e-9bc055f652b5@googlegroups.com> <nhq3sl$hv8$1@ger.gmane.org> <1463860505.689253.614738601.76B18B37@webmail.messagingengine.com> <9341584a-bbdb-c9c8-2cf2-d631671631d3@gmail.com>

Show all headers | View raw


On 05/21/2016 01:55 PM, Random832 wrote:
> On Sat, May 21, 2016, at 12:54, Peter Otten wrote:
>> It's not your fault, there's an odd quirk in the library: you have to
>> keep a reference of the PhotoImage instance around to prevent the
>> image from being garbage-collected.
> 
> Just out of curiosity, why is this a "quirk" and not a bug? Why isn't
> the reference held by the Label?

The reference is indeed held by the label but the problem is the label
is a Tcl/Tk object, thinly wrapped in Python.  It's essentially an
impedance mismatch between two different languages and object models
that each do their own reference holding and counting. I've run into
this issue with PySide also as one is instantiating C++ objects that do
their own internal reference counting through the Python wrapper.

I'm sure Python wrappers could try to correct for this somewhat, but
it's not a trivial thing to solve by any means.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Image loading problem "sweating_ant@yahoo.com" <huey.y.jiang@gmail.com> - 2016-05-21 08:22 -0700
  Re: Image loading problem Peter Otten <__peter__@web.de> - 2016-05-21 18:54 +0200
  Re: Image loading problem Peter Pearson <pkpearson@nowhere.invalid> - 2016-05-21 17:10 +0000
  Re: Image loading problem Gary Herron <gherron@digipen.edu> - 2016-05-21 10:16 -0700
  Re: Image loading problem Terry Reedy <tjreedy@udel.edu> - 2016-05-21 15:23 -0400
  Re: Image loading problem Random832 <random832@fastmail.com> - 2016-05-21 15:55 -0400
  Re: Image loading problem huey.y.jiang@gmail.com - 2016-05-21 21:01 -0700
  Re: Image loading problem Peter Otten <__peter__@web.de> - 2016-05-22 11:03 +0200
  Re: Image loading problem Michael Torrie <torriem@gmail.com> - 2016-05-22 13:37 -0600
  Re: Image loading problem Random832 <random832@fastmail.com> - 2016-05-22 16:19 -0400
    Re: Image loading problem Christian Gollwitzer <auriocus@gmx.de> - 2016-05-22 22:57 +0200

csiph-web