Using the Stock ID's with ArtProvider

Dear All,

After many attempts I haven’t been able to figure out how to use Stock ID with ArtProvider.

The documentation says:

Stock items

The following is the list of the window IDs for which stock buttons and menu items are created.

*See the wxButton constructor and the **wxMenuItem *constructor for classes which automatically add stock bitmaps when using stock IDs. Also note that you can retrieve stock bitmaps using wxArtProvider.

(underline is mine) and then follows a long table with very nice icons, each one referred to by a name (actually a number) like wx.ID_ABOUT, wx.ID_ADD, … till wx.ID_ZOOM_OUT

The usual way to obtain a bitmap is to write:

bmp = wx.ArtProvider(wx.ART_HELP, wx.ART_MENU, (16,16))

where wx.ART_HELP is the name of the icon, ART_MENU is the name of the category and (16,16) is the (x,y) dimension of the required bitmap.

If I candidly write:

bmp = wx.ArtProvider(wx.ID_ABOUT, wx.ART_OTHER (16,16))

I obviously receive the error message:

File “C:_Python25\Lib\site-packages\wx-2.8-msw-unicode\wx_misc.py”, line 2717, in GetBitmap
return misc.ArtProvider_GetBitmap(*args, **kwargs)
TypeError: String or Unicode type required

as indeed:

*>>> type(wx.ID_ABOUT)
<type ‘int’>

type(wx.ART_HELP)
<type ‘unicode’>*

I tried to figure out the right code to write. Well … so far no success. How to retrieve a Stock Bitmap when one knows the Stock ID ? Can somebody please help me ?

Thanks in advance.

Regards, Rene

Hi Rene,

Dear All,
After many attempts I haven't been able to figure out how to use Stock ID with ArtProvider.
The documentation says:
*/Stock items/*
//
/The following is the list of the window IDs for which stock buttons and menu items are created./
//
/See the *wxButton* constructor and the *wxMenuItem *constructor for classes which automatically add stock bitmaps when using stock IDs. _Also note that you can retrieve stock bitmaps using *wxArtProvider*._/
(underline is mine) and then follows a long table with very nice icons, each one referred to by a name (actually a number) like *wx.ID_ABOUT*, *wx.ID_ADD*, ... till *wx.ID_ZOOM_OUT*
** The usual way to obtain a bitmap is to write:
              /bmp = wx.ArtProvider(wx.ART_HELP, wx.ART_MENU, (16,16))/
where wx.ART_HELP is the name of the icon, ART_MENU is the name of the category and (16,16) is the (x,y) dimension of the required bitmap.
If I candidly write:
             / bmp = wx.ArtProvider(wx.ID_ABOUT, wx.ART_OTHER (16,16))/
I obviously receive the error message:
/File "C:\_Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\_misc.py", line 2717, in GetBitmap
    return _misc_.ArtProvider_GetBitmap(*args, **kwargs)
TypeError: String or Unicode type required/
as indeed:
/>>> type(wx.ID_ABOUT)
<type 'int'>
>>> type(wx.ART_HELP)
<type 'unicode'>/
// I tried to figure out the right code to write. Well ... so far no success. How to retrieve a *Stock Bitmap* when one knows the *Stock ID* ? Can somebody please help me ?
Thanks in advance.
Regards, Rene

I usually do it like this:

save_ico = wx.ArtProvider.GetBitmap(wx.ART_FILE_SAVE, wx.ART_TOOLBAR, (16,16))

I wrote a little bit about the process here: wxPython: Working with Menus, Toolbars and Accelerators - Mouse Vs Python In this case, it's written for toolbars, hence the wx.ART_TOOLBAR.

See also:

wxPython API Documentation — wxPython Phoenix 4.2.2 documentation http://xoomer.alice.it/infinity77/wxPython/Widgets/wx.ArtProvider.html?highlight=artprovider
BoxSizerTutorial - wxPyWiki

I hope that helps you some.

···

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org
Python Extension Building Network: http://www.pythonlibrary.org

Hi Rene,

···

2008/12/23 Rene Heymans <rene.heymans@gmail.com>:

The documentation says:
Stock items
The following is the list of the window IDs for which stock buttons and menu
items are created.
See the wxButton constructor and the wxMenuItem constructor for classes
which automatically add stock bitmaps when using stock IDs. Also note that
you can retrieve stock bitmaps using wxArtProvider.

(underline is mine) and then follows a long table with very nice icons, each
one referred to by a name (actually a number) like wx.ID_ABOUT, wx.ID_ADD,
... till wx.ID_ZOOM_OUT

The wx.ArtProvider documentation
(http://www.wxpython.org/onlinedocs.php) lists constants that start
with wx.ART_, like wx.ART_ADD_BOOKMARK, wx.ART_DEL_BOOKMARK, etc.
I think the wx.ID_* constants are for use with buttons and menu items only.

Cheers, Frank

Dear Mike and Frank,

Thank you both for your answer. Mike, I investigated yours but ultimately, I think Frank is right saying the icons referred to by the wx.ID_XYZ are to be used only for Buttons and for MenuItems while the ones referred to by wx.ART_WHATEVER are to be used only with the wx.ArtProvider class.

For instance, one can create a button by writing:

btn = wx.Button(panel, wx.ID_OK)

In the other cases when one needs a “bitmap” object, then indeed there are several ways, like:

wx.Image(‘ico_16.png’, …) followed by ConvertToBitmap()

or, following Robin’s demo, where:

data (almost a pure raw string) are fed into cStringIO.StringIO() to get a stream, fed in turn to wx.ImageFromStream() to obtain an image, finally passed to wx.BitmapFromImage() to obtain a bitmap.

This bitmap can then either be passed to a SetBitmap() method - if it exists for the class of objects one is looking at, e.g. wx.MenuItem - or pushed on the ArtProvider stack.

I will probably use Robin’s demo technique for my prototype: I downloaded from the web a few icons that I fine attractive and will convert them into one data file (using img2py I guess).

If you don’t mind, I add a few extra comments / questions that might lead into improving the documentation:

  1. I was confused because I read the wxWidgets documentation instead of the wxPython documentation.

The first ( http://docs.wxwidgets.org/trunk/page_stockitems.html) says:

The following is the list of the window IDs for which stock buttons and menu items are created. See the wxButton constructor and the wxMenuItem constructor for classes which automatically add stock bitmaps when using stock IDs. Also note that you can retrieve stock bitmaps using wxArtProvider.

The second (http://wxpython.org/onlinedocs.php > constants > Stock items) says:

Window IDs for which stock buttons and menu items are created (see wxButton constructor and wxMenuItem constructor):

The first one say one phrase more. Now that I read wxWidgets doc for the nth time, it says “you can retrieve stock bitmaps” and it doesn’t say “you can retrieve these stock bitmaps” … Most probably it was me assuming it talked about the same !? :frowning: I’m red with confusion. Sorry all if I made you lose your time.

  1. When I use the code:

** btn = wx.Button(panel, wx.ID_OK)**

the button is indeed created with the right text but without the icon. I guess this is because I run on Windows XP and Windows does probably not know what is GTk (am I correct to say this ?) or the gtk-xyz.png files have been misplaced on my PC ?

3) When dealing with a bitmap object, for instance:

** bmp = wx.Image(‘my_icon.png’, …).ConvertToBitmap()**

are the the 2 methods bmp.IsOK() and bmp.Ok() the same ?

4) The documentation says that 2 objects are predefined: wx.NullBitmap and wx.NullIcon. Are wx.EmptyBitmap and wx.EmptyIcon synonyms ?

Thank you very much.

Wish you the Peace and Blessings of a Merry Christmas

Rene

···

On Tue, Dec 23, 2008 at 5:00 AM, Mike Driscoll mike@pythonlibrary.org wrote:

Hi Rene,

Dear All,
After many attempts I haven’t been able to figure out how to use Stock ID with ArtProvider.

The documentation says:
/Stock items/
//
/The following is the list of the window IDs for which stock buttons and menu items are created./
//
/See the wxButton constructor and the *wxMenuItem *constructor for classes which automatically add stock bitmaps when using stock IDs. Also note that you can retrieve stock bitmaps using wxArtProvider./

(underline is mine) and then follows a long table with very nice icons, each one referred to by a name (actually a number) like wx.ID_ABOUT, wx.ID_ADD, … till wx.ID_ZOOM_OUT
** The usual way to obtain a bitmap is to write:

          /bmp = wx.ArtProvider(wx.ART_HELP, wx.ART_MENU, (16,16))/

where wx.ART_HELP is the name of the icon, ART_MENU is the name of the category and (16,16) is the (x,y) dimension of the required bitmap.
If I candidly write:

         / bmp = wx.ArtProvider(wx.ID_ABOUT, wx.ART_OTHER (16,16))/

I obviously receive the error message:
/File “C:_Python25\Lib\site-packages\wx-2.8-msw-unicode\wx_misc.py”, line 2717, in GetBitmap

return misc.ArtProvider_GetBitmap(*args, **kwargs)
TypeError: String or Unicode type required/
as indeed:
/>>> type(wx.ID_ABOUT)
<type ‘int’>

type(wx.ART_HELP)

<type ‘unicode’>/
// I tried to figure out the right code to write. Well … so far no success. How to retrieve a Stock Bitmap when one knows the Stock ID ? Can somebody please help me ?
Thanks in advance.

Regards, Rene

I usually do it like this:

save_ico = wx.ArtProvider.GetBitmap(wx.ART_FILE_SAVE, wx.ART_TOOLBAR, (16,16))

I wrote a little bit about the process here: http://www.blog.pythonlibrary.org/?p=44 In this case, it’s written for toolbars, hence the wx.ART_TOOLBAR.

See also:
http://www.wxpython.org/docs/api/wx.ArtProvider-class.html http://xoomer.alice.it/infinity77/wxPython/Widgets/wx.ArtProvider.html?highlight=artprovider

http://wiki.wxpython.org/BoxSizerTutorial

I hope that helps you some.


Mike Driscoll
Blog: http://blog.pythonlibrary.org

Python Extension Building Network: http://www.pythonlibrary.org


wxpython-users mailing list

wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

Hello,

  1. When I use the code:

** btn = wx.Button(panel, wx.ID_OK)**

the button is indeed created with the right text but without the icon. I guess this is because I run on Windows XP and Windows does probably not know what is GTk (am I correct to say this ?) or the gtk-xyz.png files have been misplaced on my PC ?

Only the gtk implementation use images in buttons when the button is created with a stock id (wx.ID_***). Other platforms only support stock labels associated with the stock ids.

3) When dealing with a bitmap object, for instance:

** bmp = wx.Image(‘my_icon.png’, …).ConvertToBitmap()**

are the the 2 methods bmp.IsOK() and bmp.Ok() the same ?

Yes, bmp.Ok() is just an alias for bmp.IsOk()

wx.Bitmap.IsOk == wx.Bitmap.Ok

True

4) The documentation says that 2 objects are predefined: wx.NullBitmap and wx.NullIcon. Are wx.EmptyBitmap and wx.EmptyIcon synonyms ?

No, the wx.EmptyBitmap/Icon are functions for creating an empty image that does not have any byte values in them, usually used for creating an empty canvas to draw in with a MemoryDC. The wx.NullBitmap/Icon are predefined instances of an (Null)Bitmap/Image.

Cody

···

On Tue, Dec 23, 2008 at 1:05 PM, Rene Heymans rene.heymans@gmail.com wrote:

Hi Rene,

Dear Mike and Frank,
Thank you both for your answer. Mike, I investigated yours but ultimately, I think Frank is right saying the icons referred to by the *wx.ID_XYZ* are to be used only for Buttons and for MenuItems while the ones referred to by *wx.ART_WHATEVER* are to be used only with the *wx.ArtProvider* class.

Frank's a smart man and I was likely confused about what exactly you needed. However, you can do what you want with some of the generic buttons...like this:

<code>

import wx
import wx.lib.buttons as buttons
class MyForm(wx.Frame):
     def __init__(self):
        wx.Frame.__init__(self, None, wx.ID_ANY, "Tutorial")
         # Add a panel so it looks the correct on all platforms
        panel = wx.Panel(self, wx.ID_ANY)
        bmp = wx.ArtProvider.GetBitmap(wx.ART_FILE_SAVE,
                                            wx.ART_TOOLBAR, (16,16))
        self.btn = buttons.GenBitmapTextButton(panel, -1, bmp, "My Text", size=(175, 75))
# Run the program
if __name__ == "__main__":
    app = wx.PySimpleApp()
    frame = MyForm().Show()
    app.MainLoop()

</code>

<snip>

If you don't mind, I add a few extra comments / questions that might lead into improving the documentation:
1) I was confused because I read the wxWidgets documentation instead of the wxPython documentation.
The first ( wxWidgets: Stock Items) says:
/The following is the list of the window IDs for which stock buttons and menu items are created. See the //wxButton/ <http://mail.google.com/mail/classwx_button.html&gt;/ constructor and the //wxMenuItem/ <http://mail.google.com/mail/classwx_menu_item.html&gt;/ constructor for classes which automatically add stock bitmaps when using stock IDs. Also note that you can retrieve stock bitmaps using //wxArtProvider/ <http://mail.google.com/mail/classwx_art_provider.html&gt;/\./
The second (http://wxpython.org/onlinedocs.php > constants > Stock items) says:
/Window IDs for which stock buttons and menu items are created (see //wxButton constructor/ <http://mail.google.com/mail/wx_wxbutton.html#wxbuttonctor&gt;/ and //wxMenuItem constructor/ <http://mail.google.com/mail/wx_wxmenuitem.html#wxmenuitemctor&gt;/\):confused:
The first one say one phrase more. Now that I read wxWidgets doc for the nth time, it says "you can retrieve stock bitmaps" and it doesn't say "you can retrieve these stock bitmaps" ... Most probably it was me assuming it talked about the same !? :frowning: I'm red with confusion. Sorry all if I made you lose your time.

You gotta watch out for that. Whenever I look up something for wxPython with Google, I do something like this in the search box: wxPython wx.Button

If you always preface it with wxPython, it seems to return the correct results in most cases.

2) When I use the code:
* btn = wx.Button(panel, wx.ID_OK)*
** *the button is indeed created with the right text but without the icon. I guess this is because I run on Windows XP and Windows does probably not know what is GTk (am I correct to say this ?) or the gtk-xyz.png files have been misplaced on my PC ?*

Windows just doesn't have pictures associated with the default id. I think you CAN do it if you're using standard dialogs though. It might work if you subclass wx.Dialog as well, but I'm not sure.

** *3) When dealing with a bitmap object, for instance:*
** * *bmp = wx.Image('my_icon.png', ...).ConvertToBitmap()**
** *are the the 2 methods *bmp.IsOK()* and *bmp.Ok()* the same ?*

I don't know. Robin (or another more knowledgeable wx guru) will hopefully be able to answer this and the next question...

** *4) The documentation says that 2 objects are predefined: *wx.NullBitmap* and *wx.NullIcon*. Are *wx.EmptyBitmap* and *wx.EmptyIcon* synonyms ?*

Thank you very much.
Wish you the Peace and Blessings of a Merry Christmas
Rene

Merry Christmas to you as well.

Mike

Dear Mike and Cody,

Thank you so much for your care and diligence in answering me.

I’m still amazed at the power of Python. If A == B answers True, we are facing the same object ! This is the real beauty of something great. Even after many years you never get bored and you find the gems are still shining and sparkling !

Thanks for your Christmas wishes. Enjoy the festivity and/or holidays.

Regards, Rene

···

On Tue, Dec 23, 2008 at 8:35 PM, Mike Driscoll mike@pythonlibrary.org wrote:

Hi Rene,

Dear Mike and Frank,
Thank you both for your answer. Mike, I investigated yours but ultimately, I think Frank is right saying the icons referred to by the wx.ID_XYZ are to be used only for Buttons and for MenuItems while the ones referred to by wx.ART_WHATEVER are to be used only with the wx.ArtProvider class.

Frank’s a smart man and I was likely confused about what exactly you needed. However, you can do what you want with some of the generic buttons…like this:

import wx

import wx.lib.buttons as buttons

class MyForm(wx.Frame):

def init(self):
wx.Frame.init(self, None, wx.ID_ANY, “Tutorial”)

  # Add a panel so it looks the correct on all platforms

  panel = wx.Panel(self, wx.ID_ANY)
  bmp = wx.ArtProvider.GetBitmap(wx.ART_FILE_SAVE,

                                      wx.ART_TOOLBAR, (16,16))

self.btn = buttons.GenBitmapTextButton(panel, -1, bmp, “My Text”, size=(175, 75))

Run the program

if name == “main”:
app = wx.PySimpleApp()
frame = MyForm().Show()
app.MainLoop()

If you don’t mind, I add a few extra comments / questions that might lead into improving the documentation:

  1. I was confused because I read the wxWidgets documentation instead of the wxPython documentation.

The first ( http://docs.wxwidgets.org/trunk/page_stockitems.html) says:

/The following is the list of the window IDs for which stock buttons and menu items are created. See the //wxButton/ <http://mail.google.com/mail/classwx_button.html>/ constructor and the //wxMenuItem/ <http://mail.google.com/mail/classwx_menu_item.html>/ constructor for classes which automatically add stock bitmaps when using stock IDs. Also note that you can retrieve stock bitmaps using //wxArtProvider/ <http://mail.google.com/mail/classwx_art_provider.html>/./

The second (http://wxpython.org/onlinedocs.php > constants > Stock items) says:

/Window IDs for which stock buttons and menu items are created (see //wxButton constructor/ <http://mail.google.com/mail/wx_wxbutton.html#wxbuttonctor>/ and //wxMenuItem constructor/ <http://mail.google.com/mail/wx_wxmenuitem.html#wxmenuitemctor>/):confused:

The first one say one phrase more. Now that I read wxWidgets doc for the nth time, it says “you can retrieve stock bitmaps” and it doesn’t say “you can retrieve these stock bitmaps” … Most probably it was me assuming it talked about the same !? :frowning: I’m red with confusion. Sorry all if I made you lose your time.

You gotta watch out for that. Whenever I look up something for wxPython with Google, I do something like this in the search box: wxPython wx.Button

If you always preface it with wxPython, it seems to return the correct results in most cases.

  1. When I use the code:
  •    btn = wx.Button(panel, wx.ID_OK)*
    

** the button is indeed created with the right text but without the icon. I guess this is because I run on Windows XP and Windows does probably not know what is GTk (am I correct to say this ?) or the gtk-xyz.png files have been misplaced on my PC ?

Windows just doesn’t have pictures associated with the default id. I think you CAN do it if you’re using standard dialogs though. It might work if you subclass wx.Dialog as well, but I’m not sure.

** 3) When dealing with a bitmap object, for instance:

** * bmp = wx.Image(‘my_icon.png’, …).ConvertToBitmap()*

** are the the 2 methods bmp.IsOK() and bmp.Ok() the same ?

I don’t know. Robin (or another more knowledgeable wx guru) will hopefully be able to answer this and the next question…

** 4) The documentation says that 2 objects are predefined: wx.NullBitmap and wx.NullIcon. Are wx.EmptyBitmap and wx.EmptyIcon synonyms ?

Thank you very much.
Wish you the Peace and Blessings of a Merry Christmas
Rene

Merry Christmas to you as well.

Mike


wxpython-users mailing list
wxpython-users@lists.wxwidgets.org

http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

Rene Heymans wrote:

I'm still amazed at the power of Python. If A == B answers True, we are facing the same object !

not necessarily -- A == B if A and B have the same value. Actually, you can override the definition of == if you like for custom objects. But anyway, if you really want to know if A and B are the same object, use is:

>>> A = "a string"
>>> B = A
>>> A == B
True
>>> A is B
True

>>> A = 5.6
>>> B = 5.6

>>> A == B
True
>>> A is B
False

···

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Christopher Barker wrote:

Rene Heymans wrote:

I'm still amazed at the power of Python. If A == B answers True, we are facing the same object !

not necessarily -- A == B if A and B have the same value. Actually, you can override the definition of == if you like for custom objects. But anyway, if you really want to know if A and B are the same object, use is:

>>> A = "a string"
>>> B = A
>>> A == B
True
>>> A is B
True

>>> A = 5.6
>>> B = 5.6

>>> A == B
True
>>> A is B
False

Comparing the id of the objects makes it a little bit clearer:

>>> A = 5.6
>>> B = 5.6
>>> id(A)
12788672
>>> id(B)
12788784

Notice that each object has a different id. Now if we do the other example that Chris gave us you'll see that they end up pointing at the same object (i.e. they have the same id)

A = "a string"
>>> B = A
>>> id(A)
31770464
>>> id(B)
31770464

Isn't introspection fun?

···

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org
Python Extension Building Network: http://www.pythonlibrary.org

Dear Christopher and Mike,

Thank you for going into these refreshing details. As a matter of fact it reminded me of something I read in the book of Wesly Chun (Core Python Programming) but I had to go back to the book (I’d forgotten). It is in section 4.5. I report the saillant points:

  1. foo1 = foo2 = 4.3

This is the same object (4.3) with two references (foo1 and foo2).

  1. a is b is an equivalent expression to id(a) == id(b)

  2. Unlike the A = 5.6 and B = 5.6 examples above, when writing

a = 1

id(a)

8402824

b = 1

id(b)

8402824

This means that a and b reference the same object (the integer 1) while A and B refer to two different objects with similar value (floating number 5.6) . The reason is that Python caches or interns simple integers for efficiency purpose because it believes it may use them frequently. As of Wesley’s writing any integer in the range of -5 to 257 is interned.

Yes, introspection is fun ! And also it is sometime very good to go back to basics or, as we say in French, the “B, A, BA”

Thanks again.

Cheers, Rene

···

On Tue, Dec 23, 2008 at 10:13 PM, Mike Driscoll mike@pythonlibrary.org wrote:

Christopher Barker wrote:

Rene Heymans wrote:

I’m still amazed at the power of Python. If A == B answers True, we are facing the same object !

not necessarily – A == B if A and B have the same value. Actually, you can override the definition of == if you like for custom objects. But anyway, if you really want to know if A and B are the same object, use is:

A = “a string”
B = A
A == B
True
A is B
True

A = 5.6
B = 5.6

A == B
True
A is B

False

Comparing the id of the objects makes it a little bit clearer:

A = 5.6
B = 5.6

id(A)
12788672
id(B)
12788784

Notice that each object has a different id. Now if we do the other example that Chris gave us you’ll see that they end up pointing at the same object (i.e. they have the same id)

A = “a string”

B = A

id(A)
31770464
id(B)
31770464

Isn’t introspection fun?


Mike Driscoll

Blog: http://blog.pythonlibrary.org
Python Extension Building Network: http://www.pythonlibrary.org


wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

Rene Heymans wrote:

Dear Christopher and Mike,
Thank you for going into these refreshing details. As a matter of fact it reminded me of something I read in the book of Wesly Chun (Core Python Programming) but I had to go back to the book (I'd forgotten). It is in section 4.5. I report the saillant points:
1) >>> foo1 = foo2 = 4.3
This is the same object (4.3) with two references (foo1 and foo2).
2) a is b is an equivalent expression to id(a) == id(b)
3) Unlike the A = 5.6 and B = 5.6 examples above, when writing
>>> a = 1
>>> id(a)
8402824
>>> b = 1
>>> id(b)
8402824
This means that a and b reference the same object (the integer 1) while A and B refer to two different objects with similar value (floating number 5.6) . The reason is that Python caches or _interns_ simple integers for efficiency purpose because it believes it may use them frequently. As of Wesley's writing any integer in the range of -5 to 257 is _interned_.

Hmmm...I'd forgotten that tidbit of Chun's. Then again, his book was almost as big as Lutz's "Programming Python". Interesting.

- Mike

···

Yes, introspection is fun ! And also it is sometime very good to go back to basics or, as we say in French, the "B, A, BA"
Thanks again.
Cheers, Rene
On Tue, Dec 23, 2008 at 10:13 PM, Mike Driscoll > <mike@pythonlibrary.org <mailto:mike@pythonlibrary.org>> wrote:

    Christopher Barker wrote:

        Rene Heymans wrote:

            I'm still amazed at the power of Python. If A == B answers
            True, we are facing the same object !

        not necessarily -- A == B if A and B have the same value.
        Actually, you can override the definition of == if you like
        for custom objects. But anyway, if you really want to know if
        A and B are the same object, use is:

        >>> A = "a string"
        >>> B = A
        >>> A == B
        True
        >>> A is B
        True

        >>> A = 5.6
        >>> B = 5.6

        >>> A == B
        True
        >>> A is B
        False

    Comparing the id of the objects makes it a little bit clearer:

    >>> A = 5.6
    >>> B = 5.6
    >>> id(A)
    12788672
    >>> id(B)
    12788784

    Notice that each object has a different id. Now if we do the other
    example that Chris gave us you'll see that they end up pointing at
    the same object (i.e. they have the same id)

    A = "a string"
    >>> B = A
    >>> id(A)
    31770464
    >>> id(B)
    31770464

    Isn't introspection fun?

    -------------------
    Mike Driscoll

    Blog: http://blog.pythonlibrary.org/&gt;
    Python Extension Building Network: http://www.pythonlibrary.org/&gt;

    _______________________________________________
    wxpython-users mailing list
    wxpython-users@lists.wxwidgets.org
    <mailto:wxpython-users@lists.wxwidgets.org>
    http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

------------------------------------------------------------------------

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users