![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Expert Programmer
Join Date: May 2005
Location: East Lansing, MI
Posts: 663
Rep Power: 4
![]() |
Anyone knows how to set the application icon for a wxPython app? I have some leads about the wx.Frame.SetIcon() function, but how do I load the icon from a .ico or .bmp file into my program?
|
|
|
|
|
|
#2 |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,791
Rep Power: 5
![]() |
Re: Set application Icon wxPython
There's a wxBitmap function. Check the alphabetical class reference in the docs. I'll look for the exact code when I get home.
|
|
|
|
|
|
#3 |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,791
Rep Power: 5
![]() |
Re: Set application Icon wxPython
I believe there are multiple ways to do it, including the wxBitmap way. But the easiest way is with wxIcon.
Here, wx.BITMAP_TYPE_ICO specifies that the file is .ico. I've found that no other format will handle transparency very well (including PNG) for application icons. class myApp(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self, None,
pos=wx.DefaultPosition, size=wx.Size(548, 438),
style=wx.MINIMIZE_BOX | wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX | wx.CLIP_CHILDREN,
title="My Application")
favicon = wx.Icon('favicon.ico', wx.BITMAP_TYPE_ICO, 16, 16)
wx.Frame.SetIcon(self, favicon)Edit: And here's the Alphabetical Class Reference. Perhaps the most useful thing out there for wxWidgets and wxPython. |
|
|
|
|
|
#4 |
|
Expert Programmer
Join Date: May 2005
Location: East Lansing, MI
Posts: 663
Rep Power: 4
![]() |
Re: Set application Icon wxPython
Works great. I was going about it the wrong way trying to self.SetIcon() on on the frame class since I couldn't find decent references for this specific issue under wxPython documentations. I really miss the F1 in C# & MSDN when working with python. Thanks for the help.
|
|
|
|
|
|
#5 |
|
Professional Programmer
Join Date: May 2006
Location: Maryland, USA
Posts: 306
Rep Power: 3
![]() |
Re: Set application Icon wxPython
I am pretty sure those last two lines can be written like this as well (notice the self.SetIcon()):
python Syntax (Toggle Plain Text)
__________________
Robotics @ Maryland AUV Team - Software Lead |
|
|
|
|
|
#6 |
|
Expert Programmer
Join Date: May 2005
Location: East Lansing, MI
Posts: 663
Rep Power: 4
![]() |
Re: Set application Icon wxPython
I tried that and it seems to work... I was calling self.SetIcon(self, favicon) and it complained about the arguments but my real issue was reading the icon from a file.
I really don't understand the 'self' keyword. I try to think of it as 'this' in C++, but why does every function of a class has to have it as first argument in the definition, but then when you call it you have to omit the first argument? It's just a confusing way to do things! Back to the icon issue, this is unrelated but if anyone out there is looking for a way to set the icon of an exe file when using py2exe, here's how your setup.py should look like: PYTHON Syntax (Toggle Plain Text)
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| PC application with bluetooth | urip | Java | 5 | Feb 13th, 2008 12:15 PM |
| PFO URL icon | mrynit | Community Announcements and Feedback | 3 | Nov 21st, 2007 5:09 PM |
| creating an application that stands between the browser and the serve | ronias | Visual Basic | 5 | Oct 30th, 2005 4:22 PM |
| "Not Responding" Message in Windows Form Application | G_Zola | C# | 1 | Apr 29th, 2005 10:15 AM |