Platofrom-independent font selection

I've written a little application which generated graphics incorporating text, rendered in a font and colour selected using a wx.FontDialog. It's currently running on Windows, but I'm looking to migrate to Linux and other platforms before too long. I find the relationship between wx.Font, wx.FontDialog and wx.FontData a little confusing, but I think I've done what I need to (on Windows, anyway).

On Windows the wx.FontDialog allows choice of color, but only from a very limited set. Testing under Linux reveals that font selection with FontDialog doesn't allow any colour choice.

So my question is, what's the recommendation for cross-platform font and colour selection in a way that allows the full range of colours to be selected on either platform?

regards
  Steve

···

--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/

Not helping you, but just warning… When debugging Andrea’s control
for the Mac, I found out that this code crashes on Mac without mercy,
while it works on Windows & Linux:

dlg.SetFont

(wx.Font(8, wx.NORMAL, wx.NORMAL,wx.NORMAL, False, “Verdana”))

It’s hopefully a wxPython bug which will fade away in a next release of wxPython.

Stani

···

On 12/16/05, Steve Holden steve@holdenweb.com wrote:

So my question is, what’s the recommendation for cross-platform font and
colour selection in a way that allows the full range of colours to be
selected on either platform?


http://pythonide.stani.be
http://pythonide.stani.be/manual/html/manual.html

SPE Stani's Python Editor wrote:

    So my question is, what's the recommendation for cross-platform font and
    colour selection in a way that allows the full range of colours to be
    selected on either platform?

Not helping you, but just warning... When debugging Andrea's control for the Mac, I found out that this code crashes on Mac without mercy, while it works on Windows & Linux:
dlg.SetFont (wx.Font(8, wx.NORMAL, wx.NORMAL,wx.NORMAL, False, "Verdana"))

It's hopefully a wxPython bug which will fade away in a next release of wxPython.

Well, even a warning is a help, so thanks for your response. The Mac is along way off yet ...

I'm wondering what I don't understand about the documentation: wx.FontDialog is written up like its API requires you to set up a wx.FontData object, but when I look at its properties in WingIDE I see it has GetFont and SetFont methods that aren't mentioned in the docs. I'm not sure where these are inherited from or what they do. Maybe that's triggering the bug on the Mac?

I copied my own coding technique from the demo: I create a FontData object from the current font, SetInitialFont to that FontData, then after the dialog succeeds I do a GetChosenFont from the FontData gotten from the FontDialog. So I'm not sure what all these undocumented methods are doing in the FontDialog, and don't have any guidance at all about how to use them. :frowning:

Plus which, I'm still unsure how to set a wider range of colours than Windows offers, or how to do colour selection in a platform-independent way. Anyway, thanks again!

regards
  Steve

···

On 12/16/05, *Steve Holden* <steve@holdenweb.com > <mailto:steve@holdenweb.com>> wrote:

--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/

Steve,

FWIW, I ended up writing my own Font Dialog box because I found the one on
the Mac so inadequate.

David
http://www.transana.org

···

-----Original Message-----
From: Steve Holden [mailto:steve@holdenweb.com]
Sent: Friday, December 16, 2005 3:12 PM
To: wxPython-users@lists.wxwidgets.org
Subject: Re: [wxPython-users] Platfom-independent font selection

SPE Stani's Python Editor wrote:
> On 12/16/05, *Steve Holden* <steve@holdenweb.com > > <mailto:steve@holdenweb.com>> wrote:
>
> So my question is, what's the recommendation for
cross-platform font and
> colour selection in a way that allows the full range of
colours to be
> selected on either platform?
>
>
> Not helping you, but just warning... When debugging
Andrea's control
> for
> the Mac, I found out that this code crashes on Mac without
mercy, while
> it works on Windows & Linux:
> dlg.SetFont (wx.Font(8, wx.NORMAL, wx.NORMAL,wx.NORMAL,
False, "Verdana"))
>
> It's hopefully a wxPython bug which will fade away in a
next release
> of
> wxPython.
>
Well, even a warning is a help, so thanks for your response.
The Mac is
along way off yet ...

I'm wondering what I don't understand about the documentation:
wx.FontDialog is written up like its API requires you to set up a
wx.FontData object, but when I look at its properties in
WingIDE I see
it has GetFont and SetFont methods that aren't mentioned in the docs.
I'm not sure where these are inherited from or what they do. Maybe
that's triggering the bug on the Mac?

I copied my own coding technique from the demo: I create a FontData
object from the current font, SetInitialFont to that FontData, then
after the dialog succeeds I do a GetChosenFont from the
FontData gotten
from the FontDialog. So I'm not sure what all these
undocumented methods
are doing in the FontDialog, and don't have any guidance at all about
how to use them. :frowning:

Plus which, I'm still unsure how to set a wider range of colours than
Windows offers, or how to do colour selection in a
platform-independent
way. Anyway, thanks again!

regards
  Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail:
wxPython-users-help@lists.wxwidgets.org

Steve Holden wrote:

So my question is, what's the recommendation for cross-platform font and colour selection in a way that allows the full range of colours to be selected on either platform?

Disable color selection in the font dialog and then handle the color selection from a separate widget. For example you could use the wx.lib.colourselect.ColourSelect widget.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin Dunn wrote:

Steve Holden wrote:

So my question is, what's the recommendation for cross-platform font and colour selection in a way that allows the full range of colours to be selected on either platform?

Disable color selection in the font dialog and then handle the color selection from a separate widget. For example you could use the wx.lib.colourselect.ColourSelect widget.

Thanks. It was fontData.EnableEffects(False) I was looking for, and I found it eventually.

regards
  Steve

···

--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/