On Tue, Jun 12, 2012 at 2:26 AM, Paul K <[email protected]> wrote:
>
> I have the same problem as described here
> (https://groups.google.com/forum/?fromgroups#!topic/wxpython-users/T78KWU6vS_A):
> when tabs in AuiNotebook are moved using drag and drop, their order
> changes on the screen, but not internally and I'd like to enumerate
> them in the right order.
Use a unique wxWindow ID or wxWindow::Get/SetName() to give each
notebook page a unique name so you can find the window no matter what.
You can also use wxWindow::FindWindowById/Name(). Doing this should be
the cleanest solution since you will definitely know what window
you're getting.
> I can get the list of children for my notebook
> (notebook:GetChildren()) and can enumerate those using
> GetFirst()/GetNext() and then get their target using GetData(), but
> all their targets are of wxWindow type. How do I know which one is
> AuiTabCtrl and how do I cast it to AuiTabCtrl to call GetPage()?
Here's how to get information about what an object is and how to cast
wxObject derived classes up and down their class hierarchy.
The wxClassInfo is may not be right for all classes and this function
only works for wxObject derived classes, but it will work for all
major classes. You can also just call Lua's tostring() function to get
the object type as string name. NOTE! The integer number is NOT fixed
between versions, but will be constant within a single run.
Here's some code run in the wxLuaEdit console to show some of the
possibilities and what works and what doesn't.
f = wx.wxFrame(wx.NULL, -1, "Hello")
w = wx.wxWindow(f, -1)
f:Show(true)
c = wx.wxComboBox(w, -1)
ci = c:GetClassInfo() -- from wxObject
print(ci)
userdata: 0x161d918 [wxClassInfo(0x7f33d2cf8b40, 23)]
print(ci:GetClassName())
wxComboBox
print(tostring(c))
userdata: 0x161b368 [wxComboBox(0x1614c00, 134)]
cw = c:DynamicCast("wxWindow")
print(cw)
userdata: 0x16273f8 [wxWindow(0x1614c00, 368)]
ciw = ci:DynamicCast("wxWindow")
Error: Lua: Error while running chunk
[string "wxLuaShell"]:1: wxLua: Unable to call an unknown method
'DynamicCast' on a 'wxClassInfo' type.
stack traceback:
[C]: ?
[string "wxLuaShell"]:1: in main chunk
c_from_win = cw:DynamicCast("wxComboBox")
print(c_from_win)
userdata: 0x161b368 [wxComboBox(0x1614c00, 134)]
dialog_from_combobox = cw:DynamicCast("wxDialog")
Error: Lua: Error while running chunk
[string "wxLuaShell"]:1: wxLua: wxObject::DynamicCast() Unable to cast
a 'wxComboBox' to a 'wxDialog' with wxClassInfo 'wxDialog'.
Function called: 'DynamicCast(wxWindow, string)'
01. wxObject::DynamicCast(wxObject(self), string)
stack traceback:
[C]: in function 'DynamicCast'
[string "wxLuaShell"]:1: in main chunk
Hope this helps,
John
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
wxlua-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wxlua-users