Ticket #1084 (new defect)

Opened 10 months ago

Last modified 10 months ago

dPemMixin.draw() without fontFace set gives a wx errors

Reported by: paul Assigned to: somebody
Priority: major Milestone: 0.8.3
Component: ui Version:
Keywords: Cc:

Description

Originally reported by Simen Haugen on dabo-dev: http://leafe.com/archives/byMID/dabo-dev/53A419546187524EA5308C0A2062C5550BB44D@HEIMDAL.nordicstats.com

The errors comes when trying fnt.GetFaceName() when no fontFace is set.

Here's a hackish fix:

--- \temp\dabo\dabo\dabo\ui\uiwx\dPemMixin.py	2007-07-02
18:10:40.489001500 +0200
+++ dPemMixin.py	2007-07-11 16:29:42.735976200 +0200
@@ -2717,10 +2717,13 @@
 			fnt = dc.GetFont()
 			# If the following call fails, the font has not
been initialized, and can look 
 			# pretty ugly. In this case, initialize it to
the system-default font.	
-			try:
-				fnt.GetFaceName()
-			except:
+			if not self.FontFace:
 				fnt =
wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
+			else:
+				try:
+					fnt.GetFaceName()
+				except:
+					fnt =
wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
 			if self._fontFace is not None:
 				fnt.SetFaceName(self._fontFace)
 			if self._fontSize is not None:

Change History

07/12/07 07:57:40 changed by Simen Haugen <simen@norstat.no>

Here's an example, but I found out that the error only gets reported when I use wing ide (3.0a) to run the application.

import dabo
import dabo.ui
dabo.ui.loadUI("wx")
from dabo.ui import dControlMixin

class TestControl(dControlMixin, dabo.ui.wx.Control):
	def __init__(self, parent, properties=None, attProperties=None, *args, **kwargs):
		self._baseClass = TestControl
		preClass = dabo.ui.wx.Control
		dControlMixin.__init__(self, preClass, parent, properties, attProperties, *args, **kwargs)
		self.drawText("Text here", 22)


class TestForm(dabo.ui.dForm):
	def afterInit(self):
		self.Sizer.append1x(TestControl(self))


app = dabo.dApp()
app.MainFormClass = TestForm
app.setup()
app.start()