|
From: Kevin A. <al...@se...> - 2002-02-15 16:54:18
|
It isn't hard to do the code. What is hard is deciding on the way this will
be exposed. So far we haven't supported generic style overrides so that it
is possible to pass in the actual wxPython constants, instead we have always
wrapped the styles. Since are moving towards following wxPython more
closely, supporting the actual constants might make sense.
wxWindows/wxPython is filled with constants, but in order to manage the
complexity we have to be careful what is exposed and how we do it.
We could do something like this in choice.py (see code below KEA 2002-02-15
comments):
class ChoiceSpec(widget.WidgetSpec):
def __init__(self):
widget.WidgetSpec.__init__(self)
self.name = 'Choice'
self.parent = 'Widget'
self.parentName = self.parent
self.events.extend( [ event.SelectEvent ] )
self._attributes.update({
'items' : { 'presence' : 'optional', 'default' : [] },
'selected' : { 'presence' : 'optional', 'default' : None }
# KEA 2002-02-15
# added border attribute
'border' : { 'presence' : 'optional', 'default' : 'simple',
'values' : [ 'simple', 'double', 'sunken', 'raised', 'static' ] } })
self.attributes = self.parseAttributes(self._attributes)
self.requiredAttributes = self.parseRequiredAttributes()
self.optionalAttributes = self.parseOptionalAttributes()
class Choice(widget.Widget, wx.wxChoice):
"""
A popup menu.
"""
_spec = ChoiceSpec()
def __init__( self, aParent, aResource ) :
attributes = ['_items']
self._createAttributes(attributes)
widget.Widget.__init__( self, aParent, aResource )
# KEA 2002-02-15
# now we set the border
if aResource.border == 'simple':
border = wx.wxSIMPLE_BORDER
elif aResource.border == 'double':
# Windows only
border = wx.wxDOUBLE_BORDER
elif aResource.border == 'sunken':
border = wx.wxSUNKEN_BORDER
elif aResource.border == 'raised':
# GTK only
border = wx.wxRAISED_BORDER
elif aResource.border == 'static':
# Windows only
border = wx.wxSTATIC_BORDER
wx.wxChoice.__init__(
self,
aParent,
self.getId(),
wx.wxPoint( aResource.position[ 0 ], aResource.position[ 1 ] ),
wx.wxSize( aResource.size[ 0 ], aResource.size[ 1 ] ),
aResource.items,
style = wx.wxCLIP_SIBLINGS + border,
name = aResource.name
)
...
I didn't test it, but that probably works. Since wxControl inherits from
wxWindow and all of the components inherit from wxControl, this attribute
can probably be rolled higher up to Widget, but I'll have to look a little
closer at it since we already have a border style for some components. The
change above should allow you to manually change a .rsrc.py file to test the
border style for a Choice component, but it will be ignored by the Property
Editor window and resourceEditor.
We have tried to avoid the Windows and GTK specific settings in wxWindows
and discussed briefly on the list about a way to clearly identify which
options, styles, methods, etc. were platform-specific but never decided on
anything. I think the idea was to use some 'win', 'gtk', or 'mac' prefix so
it was obvious when something was platform-specific, which you can't tell
when you look at a wxWindows name, you have to check the docs.
Which style(s) in particular do you need?
ka
> From: rog...@gl...
> Sent: Friday, February 15, 2002 8:16 AM
> To: Kevin Altis
> Cc: pyt...@li...
> Subject: RE: [Pythoncard-users] border around choices
>
>
>
>
> At 15/02/2002 16:05:13, "Kevin Altis" <al...@se...> wrote:
> # > From: rog...@gl...
> # >
> # > I noticed from the resources editing tool kit that the choices
> # > component does
> # > not have a border property, and, looking at the wxWindows
> # > documentation it looks
> # > like it could be added in. How easy would this be to do?
> #
> # Do you mean these styles for wxWindow?
>
> Yes.
>
> # wxSIMPLE_BORDER Displays a thin border around the window.
> wxBORDER is the
> # old name for this style.
> # wxDOUBLE_BORDER Displays a double border. Windows only.
> # wxSUNKEN_BORDER Displays a sunken border.
> # wxRAISED_BORDER Displays a raised border. GTK only.
> # wxSTATIC_BORDER Displays a border suitable for a static
> control. Windows
> # only.
> # wxTRANSPARENT_WINDOW The window is transparent, that is, it will not
> # receive paint events. Windows only.
> #
> # If so, this is the kind of style option we'll have to add, there isn't
> # support right now. I don't see a special border attribute for wxChoice.
> #
> # As a side note, this reminds me that I always wanted to rename
> Choice to
> # PopupMenu, which seems like a better name.
>
> Agreed. Any idea when? I'm trying to replace the tools that we use with
> Pythoncard - and the apps that the old tools produce use the
> border style *a
> lot*.
>
> Roger
|