I have been studying the wxPython demos (wxPython2.8-win32-docs-demos) which is very impressive and I have found them very useful for learning wxPython.
I have two questions:
1. The AboutBox demo --- how does one get the Python icon (upper left corner)? I have extracted the code for this demo and when I execute it the little green python (Python icon) does not display and further, I can find no direct reference to an image (bitmap) in the code.
2. The StatusBar demo --- how does one change the color and background of parts of the text displayed? For example, I would like the year (2012) to be displayed in RED on a GREEN background.
I have been studying the wxPython demos (wxPython2.8-win32-docs-demos)
which is very impressive and I have found them very useful for learning
wxPython.
I have two questions:
1. The AboutBox demo --- how does one get the Python icon (upper left
corner)? I have extracted the code for this demo and when I execute it
the little green python (Python icon) does not display and further, I
can find no direct reference to an image (bitmap) in the code.
By default it will use the icon of the application's "top" window, if it has one. You can use a different icon if desired by calling info.SetIcon.
2. The StatusBar demo --- how does one change the color and background
of parts of the text displayed? For example, I would like the year
(2012) to be displayed in RED on a GREEN background.
The status bar doesn't have built-in support for doing this, but you can do it yourself either by putting static text widgets on the statusbar (you'll have to manage their size and position so they appear to lie withing one of the statusbar's fields) or you can catch its paint event and draw the text yourself.
I have been studying the wxPython demos (wxPython2.8-win32-docs-demos)
which is very impressive and I have found them very useful for learning
wxPython.
I have two questions:
1. The AboutBox demo --- how does one get the Python icon (upper left
corner)? I have extracted the code for this demo and when I execute it
the little green python (Python icon) does not display and further, I
can find no direct reference to an image (bitmap) in the code.
By default it will use the icon of the application's "top" window, if it has one. You can use a different icon if desired by calling info.SetIcon.
Ok, thanks. I will now try to track down this "top" window icon.
2. The StatusBar demo --- how does one change the color and background
of parts of the text displayed? For example, I would like the year
(2012) to be displayed in RED on a GREEN background.
The status bar doesn't have built-in support for doing this, but you can do it yourself either by putting static text widgets on the statusbar (you'll have to manage their size and position so they appear to lie withing one of the statusbar's fields) or you can catch its paint event and draw the text yourself.
I would like to try your 2nd suggestion --- catch its paint event. Would you please elaborate a little on how to perform this "catch" for the status bar when the paint event fires?
I have been studying the wxPython demos (wxPython2.8-win32-docs-demos)
which is very impressive and I have found them very useful for learning
wxPython.
I have two questions:
1. The AboutBox demo --- how does one get the Python icon (upper left
corner)? I have extracted the code for this demo and when I execute it
the little green python (Python icon) does not display and further, I
can find no direct reference to an image (bitmap) in the code.
By default it will use the icon of the application's "top" window, if
it has one. You can use a different icon if desired by calling
info.SetIcon.
Ok, thanks. I will now try to track down this "top" window icon.
It is either the frame passed to theApp.SetTopWindow if you called it, otherwise it is the first top-level window (frame or dialog) created that still exists.
2. The StatusBar demo --- how does one change the color and background
of parts of the text displayed? For example, I would like the year
(2012) to be displayed in RED on a GREEN background.
The status bar doesn't have built-in support for doing this, but you
can do it yourself either by putting static text widgets on the
statusbar (you'll have to manage their size and position so they
appear to lie withing one of the statusbar's fields) or you can catch
its paint event and draw the text yourself.
I would like to try your 2nd suggestion --- catch its paint event. Would
you please elaborate a little on how to perform this "catch" for the
status bar when the paint event fires?
Bind a handler for the statusbar's EVT_PAINT event and in the handler create a wx.PaintDC and use it to DrawText where and how you want it. You can use the statusbar's GetFieldRect to get a rectangle defining the position and size of the field you want to draw yourself. There are several examples in the demo of implementing handlers for EVT_PAINT.
I have been studying the wxPython demos (wxPython2.8-win32-docs-demos)
which is very impressive and I have found them very useful for learning
wxPython.
I have two questions:
1. The AboutBox demo --- how does one get the Python icon (upper left
corner)? I have extracted the code for this demo and when I execute it
the little green python (Python icon) does not display and further, I
can find no direct reference to an image (bitmap) in the code.
By default it will use the icon of the application's "top" window, if
it has one. You can use a different icon if desired by calling
info.SetIcon.
Ok, thanks. I will now try to track down this "top" window icon.
It is either the frame passed to theApp.SetTopWindow if you called it, otherwise it is the first top-level window (frame or dialog) created that still exists.
Ummh.... I will see what I can find.
2. The StatusBar demo --- how does one change the color and background
of parts of the text displayed? For example, I would like the year
(2012) to be displayed in RED on a GREEN background.
The status bar doesn't have built-in support for doing this, but you
can do it yourself either by putting static text widgets on the
statusbar (you'll have to manage their size and position so they
appear to lie withing one of the statusbar's fields) or you can catch
its paint event and draw the text yourself.
I would like to try your 2nd suggestion --- catch its paint event. Would
you please elaborate a little on how to perform this "catch" for the
status bar when the paint event fires?
Bind a handler for the statusbar's EVT_PAINT event and in the handler create a wx.PaintDC and use it to DrawText where and how you want it. You can use the statusbar's GetFieldRect to get a rectangle defining the position and size of the field you want to draw yourself. There are several examples in the demo of implementing handlers for EVT_PAINT.
I tracked the icon down to be LB04.png and tried the following,
def OnButton(self, evt):
# First we create and fill the info object
info = wx.AboutDialogInfo()
info.SetIcon("LB04.png")
info.Name = "Hello World"
info.Version = "1.2.3"
...
which gave the following error
TypeError: in method 'AboutDialogInfo_SetIcon', expected argument 2 of type 'wxIcon const &'
Any suggestions as how to correct this?
···
On 2012-03-26 20:06, Robin Dunn wrote:
On 3/26/12 10:49 AM, Virgil Stokes wrote:
On 26-Mar-2012 19:23, Robin Dunn wrote:
On 3/26/12 10:00 AM, Virgil Stokes wrote:
I have been studying the wxPython demos (wxPython2.8-win32-docs-demos)
which is very impressive and I have found them very useful for learning
wxPython.
I have two questions:
1. The AboutBox demo --- how does one get the Python icon (upper left
corner)? I have extracted the code for this demo and when I execute it
the little green python (Python icon) does not display and further, I
can find no direct reference to an image (bitmap) in the code.
By default it will use the icon of the application's "top" window, if
it has one. You can use a different icon if desired by calling
info.SetIcon.
Ok, thanks. I will now try to track down this "top" window icon.
It is either the frame passed to theApp.SetTopWindow if you called it, otherwise it is the first top-level window (frame or dialog) created that still exists.
I have been studying the wxPython demos (wxPython2.8-win32-docs-demos)
which is very impressive and I have found them very useful for learning
wxPython.
I have two questions:
The AboutBox demo — how does one get the Python icon (upper left
corner)? I have extracted the code for this demo and when I execute it
the little green python (Python icon) does not display and further, I
can find no direct reference to an image (bitmap) in the code.
By default it will use the icon of the application’s “top” window, if
it has one. You can use a different icon if desired by calling
info.SetIcon.
Ok, thanks. I will now try to track down this “top” window icon.
It is either the frame passed to theApp.SetTopWindow if you called it, otherwise it is the first top-level window (frame or dialog) created that still exists.
I tracked the icon down to be LB04.png and tried the following,
It is not a matter of tracking the icon down…it is just using whatever icon was provided to the main frame (or other top-level window) in the Demo’s code.
Instead, what you need to do is:
Choose an icon you’d like to use.
Get the .ico file. / save it on your computer to a folder, like “myGraphicsFolder”
I recommend, though, using img2py to turn the image into Python code so you don’t have to worry about paths to a specific file. Google for more on that topic.
Che
···
On Mon, Mar 26, 2012 at 4:26 PM, Virgil Stokes vs@it.uu.se wrote:
On 2012-03-26 20:06, Robin Dunn wrote:
On 3/26/12 10:49 AM, Virgil Stokes wrote:
On 26-Mar-2012 19:23, Robin Dunn wrote:
On 3/26/12 10:00 AM, Virgil Stokes wrote:
def OnButton(self, evt):
# First we create and fill the info object
info = wx.AboutDialogInfo()
info.SetIcon("LB04.png")
info.Name = "Hello World"
info.Version = "1.2.3"
...
which gave the following error
TypeError: in method ‘AboutDialogInfo_SetIcon’, expected argument 2 of type ‘wxIcon const &’
I had an error in my previous email on this subject, it should have
been,
`def OnButton(self, evt):
# First we create and fill the info object
info = wx.AboutDialogInfo()
info.SetIcon("wxpdemo.ico")
info.Name = "Hello World"
info.Version = "1.2.3"`
....
But, this gives the same error,
` TypeError: in method 'AboutDialogInfo_SetIcon', expected
I had an error in my previous email on this subject, it should
have been,
`def OnButton(self, evt):
# First we create and fill the info object
info = wx.AboutDialogInfo()
info.SetIcon("wxpdemo.ico")
info.Name = "Hello World"
info.Version = "1.2.3"`
....
But, this gives the same error,
` TypeError: in method 'AboutDialogInfo_SetIcon',
expected argument 2 of type ‘wxIcon const &’ `
Of course it does. That's because you're still not reading what he
suggested. You can’t pass a string to SetIcon. As the error says,
you have to pass a wx.Icon. Fortunately, wx.Icon has a constructor
that accepts a file name:
The following works as per your suggestion,
`def OnButton(self, evt):
# First we create and fill the info object
info = wx.AboutDialogInfo()
info.SetIcon(wx.Icon('wxpdemo.ico', wx.BITMAP_TYPE_ICO))
info.Name = "Hello World"
info.Version = "1.2.3"`
...
I did look at the WWW wxPython documentation on AboutDialogInfo
before posting this problem; but, your solution was not obvious from
the documentation
().
Thanks again
But I did read the documentation and the error --- just could not
understand them. Hopefully, with time and more experience with
wxPython, I will be able to better understand wxPyton error messages
and the API documentation.