I'm having some problems with XRC on the Mac... I've got a bit of
XML which is being rendered completely fine on Windows: no border,
"selected" bitmap, in the correct position and the correct size.
However, when I try and render this on the Mac there are two main
problems.
- specifying wxNO_BORDER causes the image to be rendered a third of
the size
- the "selected" bitmap is not rendered when the button is pushed
(the "focus" bitmap is not honoured either)
Any help or advice would be greatly received,
Regards,
Ben Timms
(wxPython 2.6.2.1 / Python 2.4.1 / Mac OS 10.4.5)
The XML in question:
--------------
<?xml version="1.0" ?>
<resource>
<object class="wxFrame" name="main_frame">
<style>wxFRAME_SHAPED</style>
<style>wxFRAME_NO_TASKBAR</style>
<style>wxSIMPLE_BORDER</style>
<style>wxSTAY_ON_TOP</style>
<title>Testing the XRC resource system</title>
<object class="wxPanel" name="main_panel">
<style>wxNO_BORDER</style>
<object class="wxBitmapButton" name="Button1">
<style>wxNO_BORDER</style>
<pos>311,70</pos>
<size>36,36</size>
<bitmap>Button1.png</bitmap>
<selected>Button1s.png</selected>
</object>
</object>
</object>
</resource>
--------------
---
This electronic message may contain privileged and/or confidential information and is intended for the use of the addressee/s only. Any dissemination, access, copying, disclosure, use or redistribution of this message or any of its contents by anyone without prior permission of the sender is strictly prohibited. If you have received this message in error, please delete it and notify the sender by reply.
We disclaim all responsibility and cannot accept liability for the consequences of any person acting, or refraining from acting on the contents of the message and the information contained in this email can in no way be considered legally binding. Views presented in this message are solely the responsibility of the author and are not necessarily those of BON.net Limited.
The contents of any attachment to this message may contain software viruses which could damage your computer system. While BON.net Limited has taken every reasonable precaution to minimise this risk, we cannot accept liability for any damage which you sustain as a result of software viruses. You should carry out your own virus checks before opening the attachments.
Please provide a complete simple sample app that shows the problem.
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
Thanks for the response... I've zipped up the example app here.
http://www.trum.org.uk/download/BT-XRCShapedFrameMac.zip
Works on the PC, but not on the Mac. Granted, I might be doing some
strange things with shaped frames, but it's the only way to get the
effect I need - and shouldn't cause the problems I'm seeing (?)
Thanks!
Regards,
Ben
PS: apologies for the auto-signature
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-user...@lists.wxwidgets.org
> For additional commands, e-mail: wxPython-users-
> he...@lists.wxwidgets.org
No, it shouldn't. It's not related to loading it from XRC as I can get
the same problem from Python code. I commented out the bitmap button in
the XRC and then added code to testXRCShapedFrame.py like this:
def bindButtons(self):
p = xrc.XRCCTRL(self.frame, "main_panel")
b = wx.BitmapButton(p, -1, wx.Bitmap("Keypad1.png"),
style=wx.NO_BORDER)
b.SetPosition((311, 70))
b.SetSize((36, 36))
I seem to recall that there is something with the native mac icon type
that can cause it to force the image down to one of a set of fixed sizes
(16,16, 24x24, etc.) but I don't remember any details. Anyway this
looks like what is happening here. Maybe Kevin O. can chime in and fill
us in on that.
I found that if I resize the image before adding it to the bitmap
button, and then resize the button back then it will display right.
img = wx.Image("Keypad1.png")
img.Rescale(64,64)
b = wx.BitmapButton(p, -1, wx.BitmapFromImage(img),
style=wx.NO_BORDER)
b.SetPosition((311, 70))
b.SetSize((36, 36))
This is obviously a very weird, ugly and stupid workaround... I also
realized that the test I did the other day for setting the selected
bitmap was not valid and that wxMac doesn't support showing the selected
bitmap. (In my test I set it to a grayed out version of the original
bitmap, but that is what wxMac does by default anyway when the button is
selected.) So you may want to use a custom control here anyway. For
example, the wx.lib.buttons.GenBitmapButton works well:
b = wx.lib.buttons.GenBitmapButton(p, -1,
wx.Bitmap("Keypad1.png"),
style=wx.NO_BORDER)
b.SetBitmapSelected(wx.Bitmap("Keypad2.png"))
b.SetPosition((311, 70))
b.SetSize((36, 36))
It is probably not to hard to create a XmlResourceHandler that will
create a GenBitmapButton and I think if it specifies that it can handle
"wxBitmapButton" then it be used in place of the default handler.
Hi Robin,
Thanks for your speedy response... I'll probably go for the
XmlResourceHandler option to avoid workarounds. The important factor
for me was the XRC handling, so the workaround isn't an attractive
option.
Is there a process for highlighting features that are not supported
on the Mac, or is this a bug? Let me know if you'd like me to submit
anything.
Regards,
Ben Timms