When error "wx._core.PyAssertionError: C++ assertion "hFont" failed" occur?

Hi All,

In my app i am putting some wxWidget on a panel (child of frame).
There are two option buttons available like load and reload(reload
will enable after once load happen).
Once you press on load button this will load/create all the wxWidget
on the panel.
Once you reload the button it will delete/destroy all children of the
panel by panel.DestroyChildren() method and load ie create all the
wxWidget again.

But while reloading the wxWidgets i am getting the following error in
the the __init__method of of the wxWidgets.
like "wx._core.PyAssertionError: C++ assertion "hFont" failed at ..\..
\src\msw\window.
cpp(820) in wxWindow::SetFont(): should have valid font".

Any guess where it can go wrong.

Because in the whole destroying children process i am not deleting or
using font anywhere.
If some font error is there then why i doesn't appear while creating
wxWidget first time.

Thanks .

Hey mukul,

What kind of controls are the children?

Why are you destroying the children and then resetting them when you can
just clear the controls instead?

All I can gather from the little bit of information you provided is that
your overall goal is to clear the current data from the controls when
"Reload" is pushed. If this assumption is correct, then I would suggest you
create a function that will reset all of your controls values when Reload is
clicked. Most, if not all, controls have some sort of method to clear their
value(s). Here's a couple of examples:

  - TextCtrl: Clear(), ChangeValue(), SetValue(),
WriteText(), etc.
  - StaticText: SetLabel()
  - ListCtrl: ClearAll(), DeleteAllColumns(),
DeleteAllItems(), DeleteColumn(), DeleteItem(), etc.

  self.myTextCtrl = wx.TextCtrl(self, -1, "Current Value")
  self.myStaticText = wx.StaticText(self, -1, "Current Label")

  self.ClearCtrls()

      def ClearCtrls(self):
      #will blank/reset the control
      self.myTextCtrl.Clear()
      self.myStaticText.SetLabel("")

I would have been more specific but you have not given us enough info to
work with. Best to take a look at the individual docs for each control you
are using, Try:

http://www.wxpython.org/docs/api/wx-module.html or
http://www.wxpython.org/onlinedocs.php

Some sample code would be helpful...

Regards,

···

-----Original Message-----
From: wxpython-users@googlegroups.com
[mailto:wxpython-users@googlegroups.com] On Behalf Of mukul
Sent: September-18-10 7:24 AM
To: wxPython-users
Subject: [wxPython-users] When error "wx._core.PyAssertionError: C++
assertion "hFont" failed" occur?

Hi All,

In my app I am putting some wxWidget on a panel (child of frame).
There are two option buttons available like load and reload(reload
will enable after once load happen).
Once you press on load button this will load/create all the wxWidget
on the panel.
Once you reload the button it will delete/destroy all children of the
panel by panel.DestroyChildren() method and load ie create all the
wxWidget again.

But while reloading the wxWidgets i am getting the following error in
the the __init__method of of the wxWidgets.
like "wx._core.PyAssertionError: C++ assertion "hFont" failed at ..\..
\src\msw\window.
cpp(820) in wxWindow::SetFont(): should have valid font".

Any guess where it can go wrong.

Because in the whole destroying children process i am not deleting or
using font anywhere.
If some font error is there then why i doesn't appear while creating
wxWidget first time.

Thanks .

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Please make a small runnable sample that demonstrates the problem. MakingSampleApps - wxPyWiki

···

On 9/18/10 4:23 AM, mukul wrote:

Hi All,

In my app i am putting some wxWidget on a panel (child of frame).
There are two option buttons available like load and reload(reload
will enable after once load happen).
Once you press on load button this will load/create all the wxWidget
on the panel.
Once you reload the button it will delete/destroy all children of the
panel by panel.DestroyChildren() method and load ie create all the
wxWidget again.

But while reloading the wxWidgets i am getting the following error in
the the __init__method of of the wxWidgets.
like "wx._core.PyAssertionError: C++ assertion "hFont" failed at ..\..
\src\msw\window.
cpp(820) in wxWindow::SetFont(): should have valid font".

Any guess where it can go wrong.

Because in the whole destroying children process i am not deleting or
using font anywhere.
If some font error is there then why i doesn't appear while creating
wxWidget first time.

--
Robin Dunn
Software Craftsman