Reuse system icons

quit = wx.MenuItem(file, 1, '&Quit\tCtrl+Q')
quit.SetBitmap(wx.Bitmap('icons/exit.png'))

I can set icons using this but I want to use system icon so that my application loox similar to other apps…
I am using GNU/Linux

···


┌─────────────────────────┐
│ Narendra Sisodiya

http://narendrasisodiya.com
└─────────────────────────┘

Hi,
you may try wx.ArtProvider,
http://www.wxpython.org/docs/api/wx.ArtProvider-class.html
e.g.:
quit.SetBitmap(wx.ArtProvider.GetBitmap(wx.ART_QUIT, size=(16,16)))

However, I am not sure, whethere these icons are native or rather
emulated in some way...

hth,
   vbr

···

2011/8/28 Narendra Sisodiya <narendra@narendrasisodiya.com>:

quit = wx.MenuItem(file, 1, '&Quit\tCtrl+Q')
quit.SetBitmap(wx.Bitmap('icons/exit.png'))

I can set icons using this but I want to use system icon so that my
application loox similar to other apps..
I am using GNU/Linux

--
┌─────────────────────────┐
│ Narendra Sisodiya
http://narendrasisodiya.com
└─────────────────────────┘

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Perhaps Robin has more info on this topic?

Thanks

···

On Sun, Aug 28, 2011 at 8:32 PM, Vlastimil Brom vlastimil.brom@gmail.com wrote:

you may try wx.ArtProvider,

http://www.wxpython.org/docs/api/wx.ArtProvider-class.html

I tried this code…
This is not working. unable to see any icon.
I am not getting any error in console, what can be the problem ?

PreferencesMenuItem = menuEdit.Append(-1, ‘Preferences’, ‘View Prefrences. Still not configured.’)
PreferencesMenuItem.SetBitmap(wx.Bitmap(‘icons/preferences-desktop.png’))

Maybe you'll need to set the "type" argument and give it a value of
wx.BITMAP_TYPE_PNG

Tried !! not working ,
I checked Wxpython Demo
it that this was used… demo works

item = wx.MenuItem(menu5, 500, “&Smile!\tCtrl+S”, “This one has an icon”)

item.SetBitmap(images.Smiles.GetBitmap())

But when I use in in my code then it says

import images
ImportError: No module named images

···

On Sun, Aug 28, 2011 at 10:32 PM, Boštjan Mejak bostjan.mejak@gmail.com wrote:

Maybe you’ll need to set the “type” argument and give it a value of

wx.BITMAP_TYPE_PNG

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en


┌─────────────────────────┐
│ Narendra Sisodiya

http://narendrasisodiya.com
└─────────────────────────┘

Hi,
images.py is custom file in the wxPython demo,
see the demo subfolder, e.g.

...\wxPython2.9 Docs and Demos\demo\images.py

it contains some predefined images as data.

vbr

···

2011/8/28 Narendra Sisodiya <narendra@narendrasisodiya.com>:

On Sun, Aug 28, 2011 at 10:32 PM, Boštjan Mejak <bostjan.mejak@gmail.com> > wrote:

Maybe you'll need to set the "type" argument and give it a value of
wx.BITMAP_TYPE_PNG

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Tried !! not working ,
I checked Wxpython Demo
it that this was used.. demo works

item = wx.MenuItem(menu5, 500, "&Smile!\tCtrl+S", "This one has an icon")
item.SetBitmap(images.Smiles.GetBitmap())

But when I use in in my code then it says

import images
ImportError: No module named images

--
┌─────────────────────────┐
│ Narendra Sisodiya
http://narendrasisodiya.com
└─────────────────────────┘

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

ArtProvider icons are system-independent. To use an operating system’s icons you must first extract them. How to do this is very specific the the particular operating system you are using. The easiest way to accomplish this is to use a separate utility written for your system to extract these operating system icons to PNG files.

PNG files, as well as all other common image/graphics files can be read into a wx.Bitmap. Bitmaps can not be displayed directly, so use a control such as a wx.StaticBitmap, wx.BitmapButton or wx.Icon. You can also use a DC tool to Blit the bitmap directly to a Panel. Once the Bitmap has been put into a control, that control will be visible and can be positioned like all other controls.

I can only tell you how to extract icons from MS Windows DLL’s and executable files using free tools, but I imagine that GNU systems have many equivalent utilities to do this.

Ray

BITMAPPED-BUTTONS.py (3.6 KB)

HI,

quit = wx.MenuItem(file, 1, '&Quit\tCtrl+Q')
quit.SetBitmap(wx.Bitmap('icons/exit.png'))

I can set icons using this but I want to use system icon so that my application loox similar to other apps…
I am using GNU/Linux

On GTK you can use “stock items” for menu and buttons (i.e., the menu label, accelerators, help strings and bitmaps are provided by the platform). See here:

http://docs.wxwidgets.org/trunk/classwx_menu_item.html#6e9b0e1b786fa84250a42c88d84aed2b

As far as I know, this doesn’t work on Windows, so if you have to support other platforms beware of this limitation.

Andrea.

“Imagination Is The Only Weapon In The War Against Reality.”

http://xoomer.alice.it/infinity77/

import PyQt4.QtGui

Traceback (most recent call last):

File “”, line 1, in

ImportError: No module named PyQt4.QtGui

import pygtk

Traceback (most recent call last):

File “”, line 1, in

ImportError: No module named pygtk

···

On 28 August 2011 17:34, Narendra Sisodiya wrote:

import wx

On wxGTK the art provider uses icons from the active theme by default. On the other platforms they are generic icons provided by wx.

···

On 8/28/11 8:02 AM, Vlastimil Brom wrote:

2011/8/28 Narendra Sisodiya<narendra@narendrasisodiya.com>:

quit = wx.MenuItem(file, 1, '&Quit\tCtrl+Q')
quit.SetBitmap(wx.Bitmap('icons/exit.png'))

I can set icons using this but I want to use system icon so that my
application loox similar to other apps..
I am using GNU/Linux

--
┌─────────────────────────┐
│ Narendra Sisodiya
http://narendrasisodiya.com
└─────────────────────────┘

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Hi,
you may try wx.ArtProvider,
wxPython API Documentation — wxPython Phoenix 4.2.2 documentation
e.g.:
quit.SetBitmap(wx.ArtProvider.GetBitmap(wx.ART_QUIT, size=(16,16)))

However, I am not sure, whethere these icons are native or rather
emulated in some way...

--
Robin Dunn
Software Craftsman

Does the specified file exist? Since you don't give a full pathname then it will look for it relative to the process' current working directory. (check it with print os.getcwd())

···

On 8/28/11 9:06 AM, Narendra Sisodiya wrote:

I tried this code..
This is not working. unable to see any icon.
I am not getting any error in console, what can be the problem ?

PreferencesMenuItem = menuEdit.Append(-1, 'Preferences', 'View
Prefrences. Still not configured.')
PreferencesMenuItem.SetBitmap(wx.Bitmap('icons/preferences-desktop.png'))

--
Robin Dunn
Software Craftsman

Its Working now

Correct Syntax is

fileOpenMenuItem1 = wx.MenuItem(menuFile, -1, ‘&Open PDF file’, ‘Select a PDF’)
fileOpenMenuItem1.SetBitmap(wx.Bitmap(“icons/document-open.png”))

menuFile.AppendItem(fileOpenMenuItem1)

···

On Tue, Aug 30, 2011 at 12:15 AM, Robin Dunn robin@alldunn.com wrote:

On 8/28/11 9:06 AM, Narendra Sisodiya wrote:

I tried this code…

This is not working. unable to see any icon.

I am not getting any error in console, what can be the problem ?

PreferencesMenuItem = menuEdit.Append(-1, ‘Preferences’, 'View

Prefrences. Still not configured.')

PreferencesMenuItem.SetBitmap(wx.Bitmap(‘icons/preferences-desktop.png’))