font size ignored on linux with combobox

181 views
Skip to first unread message

C M

unread,
Dec 16, 2009, 12:59:53 AM12/16/09
to wxPytho...@googlegroups.com
(Ubuntu 8.10, wxPython 2.8.10, Python 2.5)

If someone has Linux, can you run the code below
and tell me if you also see that the font size, which
should be 8 point, is actually larger than that--looks
to be like 10 or 12 point--and if the text area is bleeding
out beyond the margin of the combobox?

Because that is what I am seeing with the very simple
code (at bottom). Attached also are two screenshots,
one running the code, the other using the Boa Constructor
"Designer" window, which is a visual workspace for how
the widget should look. As you can see, the Boa one
looks OK, whereas the actually running frame shows
the problem described.

The other point is: I can Set() the font on this combobox
to 18 point font and when actually running it doesn't
honor this at all--it just keeps it at 10 point or whatever
is in the first image shown below. In Boa's designer,
though, yes, then I see the 18 point font.

I don't see this problem when using a wxComboCtrl
(used with a popup), but do see it with the very common
wxComboBox. And I do not see this issue with WinXP.

Any ideas?

Thanks,
Che

-----------------------

#Boa:Frame:Frame1

import wx

def create(parent):
return Frame1(parent)

[wxID_FRAME1, wxID_FRAME1COMBOBOX1, wxID_FRAME1PANEL1,
] = [wx.NewId() for _init_ctrls in range(3)]

class Frame1(wx.Frame):
def _init_ctrls(self, prnt):
# generated method, don't edit
wx.Frame.__init__(self, id=wxID_FRAME1, name='', parent=prnt,
pos=wx.Point(319, 175), size=wx.Size(318, 210),
style=wx.DEFAULT_FRAME_STYLE, title='Frame1')
self.SetClientSize(wx.Size(318, 210))

self.panel1 = wx.Panel(id=wxID_FRAME1PANEL1, name='panel1', parent=self,
pos=wx.Point(0, 0), size=wx.Size(318, 210),
style=wx.TAB_TRAVERSAL)

self.comboBox1 = wx.ComboBox(choices=[], id=wxID_FRAME1COMBOBOX1,
name='comboBox1', parent=self.panel1, pos=wx.Point(24, 48),
size=wx.Size(240, 20), style=0, value='comboBox1')
self.comboBox1.SetFont(wx.Font(8, wx.SWISS, wx.NORMAL, wx.NORMAL, False,
u'Sans'))

def __init__(self, parent):
self._init_ctrls(parent)

if __name__ == '__main__':
app = wx.PySimpleApp()
frame = create(None)
frame.Show()

app.MainLoop()

-----------------
combo_font_fail.png
in_Boa.png

Andrea Gavana

unread,
Dec 16, 2009, 3:03:01 AM12/16/09
to wxpytho...@googlegroups.com
Hi Che,

2009/12/16 C M:
> (Ubuntu 8.10, wxPython 2.8.10, Python 2.5)
>
> If someone has Linux, can you run the code below
> and tell me if you also see that the font size, which
> should be 8 point, is actually larger than that--looks
> to be like 10 or 12 point--and if the text area is bleeding
> out beyond the margin of the combobox?

Does anything change if you do something like:

font = self.comboBox1.GetFont()
font.SetPointSize(8) # or 18 or whatever
self.comboBox1.SetFont(font)

?

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/
http://thedoomedcity.blogspot.com/

Robin Dunn

unread,
Dec 16, 2009, 3:51:51 PM12/16/09
to wxpytho...@googlegroups.com
On 12/15/09 9:59 PM, C M wrote:
> (Ubuntu 8.10, wxPython 2.8.10, Python 2.5)
>
> If someone has Linux, can you run the code below
> and tell me if you also see that the font size, which
> should be 8 point, is actually larger than that--looks
> to be like 10 or 12 point--and if the text area is bleeding
> out beyond the margin of the combobox?

The clipping problem is because you've set a fixed size for the widget
instead of letting it size itself. When you pass an explicit size to
the init method of most widgets then it will use that as the min size,
which will override the best size. If instead you pass -1 (at least for
the height) then the initial size will be based on the widget's best
size instead, which usually varies by the content and also by platform,
theme, etc.

The problem with the new font not actually being used by the combo is a
trickier issue. It could be that the active theme forces the use of a
specific font, or there could be a bug in wxGTK due to some change in
newer versions of the GTK+ lib. Experiment with different GTK themes,
and if possible also try it with themes disabled and see if that makes
any difference. Either way there should probably be a bug ticket opened
about this at wxTrac.

--
Robin Dunn
Software Craftsman
http://wxPython.org

C M

unread,
Dec 16, 2009, 10:52:22 PM12/16/09
to wxpytho...@googlegroups.com

I tried different Ubuntu themes, and the problem remained. I went to
submit a ticket but searched first and there is already one on this
issue, 9 months old:

http://trac.wxwidgets.org/ticket/10566

For now, I may look into using the wxOwnerDrawnComboBox or
ComboCtrl, which don't seem to have this problem.

Thanks,
Che

C M

unread,
Dec 16, 2009, 10:54:04 PM12/16/09
to wxpytho...@googlegroups.com
On Wed, Dec 16, 2009 at 3:03 AM, Andrea Gavana <andrea...@gmail.com> wrote:
> Hi Che,
>
> 2009/12/16 C M:
>> (Ubuntu 8.10, wxPython 2.8.10, Python 2.5)
>>
>> If someone has Linux, can you run the code below
>> and tell me if you also see that the font size, which
>> should be 8 point, is actually larger than that--looks
>> to be like 10 or 12 point--and if the text area is bleeding
>> out beyond the margin of the combobox?
>
> Does anything change if you do something like:
>
> font = self.comboBox1.GetFont()
> font.SetPointSize(8) # or 18 or whatever
> self.comboBox1.SetFont(font)
>
> ?
>
> Andrea.

Hi Andrea,
Unfortunately, that doesn't work either. It looks like it is a
known issue for the better part of this year (see my other
message from today). Oh well.

Thanks,
Che

Reply all
Reply to author
Forward
0 new messages