Good inhabitants of this list,
While attempting to test my naughty control
I wrote some doctests covering the whole
But when it came to a sent text event
Wx did its best to prevent
Success.
Many paths in my quest I wandered
Many hours in futility squandered
Many googled wx docs read I
Many prayers did I send to the sky...
Nothing.
All I wanted was a handler to test.
Send an event wrapped char to rest,
After traversing bound method to Skip()
To yon text field's furthest lip
Blank.
I conversed with friends of diverse name
EmulateKeyPress, wx.KeyEvent, the selfsame.
Events I created and ruefully spent
sending to GetEventHandler().ProcessEvent()
None.
The ProcessEvent finally filled me with hope
The event traversed the bound method's scope
Then reaching the end leaped through event.Skip
Never to be seen, nay, nary a blip.
0x00000000
My question to all, as I was wonderin':
Where is my char after all that conjurin'?
I am perplexed, and my tests are dissolute
Having no purpose, their depression's acute.
Below is a sample of what I was trying.
In development, by pants I am currently flying
I cannot regress or refactor with aplomb
With only debugger and luck I will bomb
Eventually.
Ta for reactions in advance of posting
I return with debugger to merry code-roasting.
I hope you will forgive my horrible rhyming,
And I'm not really pleased at all with the timing.
Thanks.
8<--------------------------------------------------------
>>> app = wx.App()
>>> app.frame = wx.Frame(None, -1)
>>> app.pan = wx.Panel(app.frame, -1)
>>> c = wx.TextCtrl(app.pan, -1)
>>> c.AppendText('a')
>>> c.GetInsertionPoint()
1
>>> len(c.GetValue())
1
Now we want to pass the event of adding a b
>>> event = wx.KeyEvent(wx.wxEVT_CHAR)
>>> event.m_keyCode = ord('a')
>>> event.GetKeyCode()
97
>>> c.SetFocus()
>>> c.GetEventHandler().ProcessEvent(event)
False
>>> event.Skip()
>>> c.GetValue()
u''
>>> c.GetEventHandler().ProcessEvent(event)
False
>>> c.GetValue()
u'a'
This fails when run, as c.GetValue() still has u''