Re: [datetime] wx, python, sqlalchemy
Robin Dunn <[email protected]>
| Newsgroups | gmane.comp.python.wxpython.devel |
|---|---|
| Message-ID | <[email protected]> |
[email protected] wrote: > On 2015-02-17 09:20 Robin Dunn<[email protected]> wrote: >> In Phoenix there is a typemap for the wxDateTime wrapper that will >> automatically convert from a Python date or datetime anywhere that a >> wxDateTime is needed. > > Just for me to learn: What is a "typemap"? I am quite new to Python3 at > all. It is a term used when wrapping C/C++ code for Python when there is code generated to automatically convert between a C/C++ type and Python type. The basic types like numbers will all be handled automatically by the wrapping tool, but more advanced types will usually need to have some specialized typemap code written for them. For example in wxWidgets there is a class called wxString that is used to contain and manipulate all string or unicode data, so I've written code that converts between wxString and Python str and unicode objects as needed. This means that whenever the C++ API is expecting a wxString object you can pass a Python str or unicode object instead, and you don't have to create an instance of a wx.String object yourself. Other, perhaps less obvious examples are things like wx.Point or wx.Size, where the wrappers will gladly accept any 2 item sequence wherever objects of one of those classes are expected. This means that you can write code like: foo = wx.Window(parent, size=(20,30)) instead of: foo = wx.Window(parent, size=wx.Size(20,30)) although the latter works just fine too if that is your preference. For wx.Colour the typemap is especially handy (IMO) allowing you to specify a color in any of these ways: * "blue" * "#0000FF" * (0, 0, 255) * wx.Colour(0, 0, 255) -- Robin Dunn Software Craftsman http://wxPython.org -- You received this message because you are subscribed to the Google Groups "wxPython-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.