mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-09 05:20:08 +01:00
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:
@@ -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()
|
||||
@@ -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)
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
doc = wx.xml.XmlDocument()
|
||||
doc.Load("myfile.xml")
|
||||
doc.Save("myfile2.xml") # myfile2.xml != myfile.xml
|
||||
@@ -0,0 +1,4 @@
|
||||
# .. code-block:: text
|
||||
|
||||
XML_ELEMENT_NODE name="tagname", content=""
|
||||
|-- XML_TEXT_NODE name="", content="tagcontent"
|
||||
@@ -0,0 +1,4 @@
|
||||
# .. code-block:: text
|
||||
|
||||
XML_ELEMENT_NODE name="tagname", content=""
|
||||
|-- XML_CDATA_SECTION_NODE name="", content="tagcontent"
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
if not wx.xml.XmlResource.Get().Load("rc/*.xrc"))
|
||||
wx.LogError("Couldn't load resources!")
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
dlg = wx.xml.XmlResource.Get().LoadDialog(mainFrame, "my_dialog")
|
||||
dlg.ShowModal()
|
||||
@@ -2355,7 +2355,6 @@ class XMLDocString(object):
|
||||
|
||||
found = False
|
||||
for line in py_docs.splitlines():
|
||||
|
||||
if line.startswith(name):
|
||||
if not found:
|
||||
newlines.append("**Possible constructors**::\n")
|
||||
@@ -2365,6 +2364,7 @@ class XMLDocString(object):
|
||||
newlines.append(ConvertToPython(line))
|
||||
|
||||
if found:
|
||||
line = line.replace('wx.EmptyString', '""')
|
||||
newlines = self.CodeIndent(line, newlines)
|
||||
|
||||
newdocs = ''
|
||||
|
||||
@@ -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+',
|
||||
'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',
|
||||
'SIZE', 'COLOR']
|
||||
'SIZE', 'COLOR', 'NOT', 'DOES']
|
||||
|
||||
# C++ stuff to Python/ReST stuff
|
||||
VALUE_MAP = {'true': '``True``',
|
||||
|
||||
Reference in New Issue
Block a user