Phoenix: converted snippets for xml and xrc. Fixed minor issues in the docs.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@73093 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Andrea Gavana
2012-12-01 22:38:22 +00:00
parent cc30e20a0c
commit bd891fbdf4
9 changed files with 67 additions and 2 deletions

View File

@@ -0,0 +1,41 @@
doc = wx.xml.XmlDocument()
if not doc.Load("myfile.xml"):
return False
# start processing the XML file
if doc.GetRoot().GetName() != "myroot-node":
return False
# examine prologue
prolog = doc.GetDocumentNode().GetChildren()
while prolog:
if prolog.GetType() == wx.xml.XML_PI_NODE and prolog.GetName() == "target":
# process Process Instruction contents
pi = prolog.GetContent()
# Other code here...
child = doc.GetRoot().GetChildren()
while child:
if child.GetName() == "tag1":
# process text enclosed by tag1/tag1
content = child.GetNodeContent()
# Other code here...
# process attributes of tag1
attrvalue1 = child.GetAttribute("attr1", "default-value")
attrvalue2 = child.GetAttribute("attr2", "default-value")
elif child.GetName() == "tag2":
# process tag2 ...
attrvalue3 = child.GetAttribute("attr3", "default-value")
child = child.GetNext()

View File

@@ -0,0 +1,6 @@
doc = wx.xml.XmlDocument()
doc.Load("myfile.xml", "UTF-8", wx.xml.XMLDOC_KEEP_WHITESPACE_NODES)
# myfile2.xml will be identical to myfile.xml saving it self way:
doc.Save("myfile2.xml", wx.xml.XML_NO_INDENTATION)

View File

@@ -0,0 +1,4 @@
doc = wx.xml.XmlDocument()
doc.Load("myfile.xml")
doc.Save("myfile2.xml") # myfile2.xml != myfile.xml

View File

@@ -0,0 +1,4 @@
# .. code-block:: text
XML_ELEMENT_NODE name="tagname", content=""
|-- XML_TEXT_NODE name="", content="tagcontent"

View File

@@ -0,0 +1,4 @@
# .. code-block:: text
XML_ELEMENT_NODE name="tagname", content=""
|-- XML_CDATA_SECTION_NODE name="", content="tagcontent"

View File

@@ -0,0 +1,3 @@
if not wx.xml.XmlResource.Get().Load("rc/*.xrc"))
wx.LogError("Couldn't load resources!")

View File

@@ -0,0 +1,3 @@
dlg = wx.xml.XmlResource.Get().LoadDialog(mainFrame, "my_dialog")
dlg.ShowModal()

View File

@@ -2355,7 +2355,6 @@ class XMLDocString(object):
found = False found = False
for line in py_docs.splitlines(): for line in py_docs.splitlines():
if line.startswith(name): if line.startswith(name):
if not found: if not found:
newlines.append("**Possible constructors**::\n") newlines.append("**Possible constructors**::\n")
@@ -2365,6 +2364,7 @@ class XMLDocString(object):
newlines.append(ConvertToPython(line)) newlines.append(ConvertToPython(line))
if found: if found:
line = line.replace('wx.EmptyString', '""')
newlines = self.CodeIndent(line, newlines) newlines = self.CodeIndent(line, newlines)
newdocs = '' newdocs = ''

View File

@@ -25,7 +25,7 @@ IGNORE = ['wxPython', 'wxWidgets', 'wxOSX', 'wxMGL', 'wxDFB', 'wxMAC', 'wxGTK',
'OS', 'X', 'OSX', 'DFB', 'MAC', 'GTK', 'GTK2', 'MSW', 'wxMSW', 'X11', 'OS2', 'MS', 'XP', 'GTK+', 'OS', 'X', 'OSX', 'DFB', 'MAC', 'GTK', 'GTK2', 'MSW', 'wxMSW', 'X11', 'OS2', 'MS', 'XP', 'GTK+',
'UI', 'GUI', '--', 'OTOH', 'GDI+', 'API', 'NT', 'RTL', 'GDI', '3D', 'MDI', 'SDI', 'TDI', 'URL', 'UI', 'GUI', '--', 'OTOH', 'GDI+', 'API', 'NT', 'RTL', 'GDI', '3D', 'MDI', 'SDI', 'TDI', 'URL',
'XPM', 'HTML', 'MIME', 'C++', 'XDG', 'A4', 'A5', 'KDE', 'GNOME', 'XFCE', 'CSS', 'IE', 'FONT', 'XPM', 'HTML', 'MIME', 'C++', 'XDG', 'A4', 'A5', 'KDE', 'GNOME', 'XFCE', 'CSS', 'IE', 'FONT',
'SIZE', 'COLOR'] 'SIZE', 'COLOR', 'NOT', 'DOES']
# C++ stuff to Python/ReST stuff # C++ stuff to Python/ReST stuff
VALUE_MAP = {'true': '``True``', VALUE_MAP = {'true': '``True``',