473,705 Members | 2,539 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Code without effect (wx demo TreeCtrl.py ImageList)

In the wx demoy TreeCtrl.py I find the following code, that should
have no effect but seems to be needed nevertheless.

class TestTreeCtrlPan el(wx.Panel):
def __init__(self, parent, log):
[...}
self.tree = MyTreeCtrl(self , tID, wx.DefaultPosit ion, ...
isz = (16,16)
il = wx.ImageList(is z[0], isz[1])
fldridx = il.Add(wx.ArtPr ovider_GetBitma p(wx.ART_FOLDER , wx.ART...
[...]

self.tree.SetIm ageList(il)
--> self.il = il

What is the effect of the last statement? self.il is not used
anywhere. I used similar code in my application and it crashes unless
I assign the image list to the parent panel. The name of the attribute
does not seem to matter. I can write self.foo=il just as well, but
without it it crashes.
Jul 18 '05 #1
2 2334
Martin Drautzburg wrote:
In the wx demoy TreeCtrl.py I find the following code, that should
have no effect but seems to be needed nevertheless.

class TestTreeCtrlPan el(wx.Panel):
def __init__(self, parent, log):
[...}
self.tree = MyTreeCtrl(self , tID, wx.DefaultPosit ion, ...
isz = (16,16)
il = wx.ImageList(is z[0], isz[1])
fldridx = il.Add(wx.ArtPr ovider_GetBitma p(wx.ART_FOLDER , wx.ART...
[...]

self.tree.SetIm ageList(il)
--> self.il = il

What is the effect of the last statement? self.il is not used
anywhere. I used similar code in my application and it crashes unless
I assign the image list to the parent panel. The name of the attribute
does not seem to matter. I can write self.foo=il just as well, but
without it it crashes.


You will probably find that without that reference to the image list it
will be garbage-collected while the images are still beign displayed,
leading to results that are at best unpredictable and at worst fatal to
your program.

regards
Steve
--
Steve Holden http://www.holdenweb.com/
Python Web Programming http://pydish.holdenweb.com/
Holden Web LLC +1 703 861 4237 +1 800 494 3119
Jul 18 '05 #2
"Martin Drautzburg" <ma************ ***@web.de> wrote in message
news:87******** ****@web.de...
In the wx demoy TreeCtrl.py I find the following code, that should
have no effect but seems to be needed nevertheless.

class TestTreeCtrlPan el(wx.Panel):
def __init__(self, parent, log):
[...}
self.tree = MyTreeCtrl(self , tID, wx.DefaultPosit ion, ...
isz = (16,16)
il = wx.ImageList(is z[0], isz[1])
fldridx = il.Add(wx.ArtPr ovider_GetBitma p(wx.ART_FOLDER , wx.ART...
[...]

self.tree.SetIm ageList(il)
--> self.il = il

What is the effect of the last statement? self.il is not used
anywhere. I used similar code in my application and it crashes unless
I assign the image list to the parent panel. The name of the attribute
does not seem to matter. I can write self.foo=il just as well, but
without it it crashes.


Two possibilities come to mind:
- used by a base class wx.Panel for which you do not have the source
(although if this were the case, I would think the attribute name would be
significant)
- needed to retain a reference handle to the image list, to prevent it from
being garbage collected (kind of far-fetched, but consistent with the "name
it anything you want" behavior)

-- Paul
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2445
by: Matt | last post by:
Is there a way to execute server code without doing a complete page refresh in .Net? I have an ASP page to convert that uses XMLHTTP and I'm wondering if I should continue to use it in ASPX or do something else. The XMLHTTP is used in ASP to populate drop down boxes based on user input without having to send the entire page contents back and forth to the server. Our remote users have slow connections so it really helps to keep the amount...
1
2004
by: Fred W | last post by:
I have 2 dependent dropdowns and would like to populate the contents of the child dropdown dynamically based on the selected item of the parent. Pretty standard requirement. However, can this be done without posting back to the server each time and without sending all possible data to the client first? I'm attempting to call a server function, passing a value from the
3
4877
by: Marcel Brekelmans | last post by:
Hi, I was wondering if it's possible to install/uninstall a service from code without using the InstalUtil.exe tool with the /i and /u flags. As far as I can Google everyone is doing it that way and MicroSoft also mentions this. There's something like the ServiceBase class from which you ought to derive your own class. This has a Uninstall() and a Install() method, but I'm not getting access to these methods. MicroSoft says that this...
9
1836
by: srinivask | last post by:
hai just tell that how can i protect the java script code without seeing view source it should not the code. i want function to perform
0
925
by: Zytan | last post by:
With exception to turning auto-format off, in VB .NET, is it possible to paste copied text (say from an online help source) into the code, that spans multiple lines, into the VB .NET code without the auto- formatter formatting everything? It thinks every second word is a functions, and postfixes () at the end. If it were on one line, I could just type ' and then paste. I wish VB .NET had multi line comments. I like the auto-formatter,...
15
5927
by: mistral | last post by:
I want find code for clickable thumbnails, when click on small picture, a big image will popup in new window, sized to fit picture. Same as standard javascript image previewer, but without using javascript. I want try do this with html only, that this work on browsers with javascript disabled. I tried the following, but it still require javascript enabled to show popup resized to fit image, otherwise it open a fullscreen window. <a...
4
1344
by: Dr J R Stockton | last post by:
<URL:http://www.merlyn.demon.co.uk/js-index.htm>, and js-dates.htm, and some Easter pages, now include <BODY onload="Cuffs()">. function Cuffs() { var ThisPage, ThisSite, J, DLJ, HREF ThisPage = location.href.replace(/#.*/, "") ThisSite = location.protocol + "//" + location.hostname + "/" for (J in document.links) { DLJ = document.links ; HREF = DLJ.href if (!HREF) continue // why an undefined ? HREF =...
2
1159
by: _DD | last post by:
Is there any practical way to protect .NET demo programs from being reverse-engineered? This will be for a one-shot thing, and I'm far from making any money on this, so I'd prefer an economical solution if that's available. I'm thinking a combination of code 'obfuscation' and maybe a timeout, but I don't know what is available for either. I'm open to other suggestions in addition to those.
1
1226
by: pbd22 | last post by:
Hi. I have been asked to do a rather odd thing by my employer. I have to add a new feature to an old project that "should not know about the change". This is a bit of an odd request but just assume that my reasons for doing what I need to do cannot change. Assume that I need to add a list box to the pre-existing project page that uses some server code to grab its value. The ony way I can think of doing this is to open notepad on the...
0
8771
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9275
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9140
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8981
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7895
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5934
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4705
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3140
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2084
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.