More code snippets converted for the docs

This commit is contained in:
Robin Dunn
2016-09-14 20:34:29 -07:00
parent bf707d9624
commit a3e3ddb60f
9 changed files with 51 additions and 0 deletions

View File

@@ -2446,6 +2446,8 @@
"PGEditor_Choice":"wx.propgrid.",
"PGEditor_ChoiceAndButton":"wx.propgrid.",
"PGEditor_ComboBox":"wx.propgrid.",
"PGEditor_DatePickerCtrl":"wx.propgrid.",
"PGEditor_SpinCtrl":"wx.propgrid.",
"PGEditor_TextCtrl":"wx.propgrid.",
"PGEditor_TextCtrlAndButton":"wx.propgrid.",
"PGFileDialogAdapter":"wx.propgrid.",

View File

@@ -0,0 +1,2 @@
# Thanks to the magic of Python nothing extra needs to be done here.

View File

@@ -0,0 +1,12 @@
def OnButtonClick(self, propGrid, value):
dlgSize = wx.Size(... size of your dialog ...)
dlgPos = propGrid.GetGoodEditorDialogPosition(self, dlgSize)
# Create dialog dlg at dlgPos. Use value as initial string
# value.
with MyCustomDialog(None, title, pos=dlgPos, size=dlgSize) as dlg:
if dlg.ShowModal() == wx.ID_OK:
value = dlg.GetStringValue()
return (True, value)
return (False, value)

View File

@@ -0,0 +1,2 @@
self.SetFlag(wx.propgrid.PG_PROP_NO_ESCAPE)

View File

@@ -0,0 +1,27 @@
class MyProperty(wx.propgrid.PGProperty):
# All arguments of this ctor should have a default value -
# use wx.propgrid.PG_LABEL for label and name
def __init__(self,
label = wx.propgrid.PG_LABEL,
name = wx.propgrid.PG_LABEL,
value = ""):
wx.propgrid.PGProperty.__init__(label, name)
self.value = value
def DoGetEditorClass(self):
# Determines editor used by property.
# You can replace 'TextCtrl' below with any of these
# builtin-in property editor identifiers: Choice, ComboBox,
# TextCtrlAndButton, ChoiceAndButton, CheckBox, SpinCtrl,
# DatePickerCtrl.
return wx.PGEditor_TextCtrl
def ValueToString(self, value, argFlags):
# TODO: Convert given property value to a string and return it
return ""
def StringToValue(self, text, argFlags):
# TODO: Adapt string to property value and return it
value = do_something(text)
return (True, value)

View File

@@ -0,0 +1,6 @@
class MyProperty(wx.propgrid.PGProperty):
def __init__(self, label, name, value):
wx.propgrid.PGProperty.__init__(self, label, name)
self.SetValue(value)