[wpdev-commits] xmlscripts/scripts xmlconfig.py,1.3,1.4
Brought to you by:
rip,
thiagocorrea
|
From: <co...@us...> - 2003-11-12 15:49:40
|
Update of /cvsroot/wpdev/xmlscripts/scripts
In directory sc8-pr-cvs1:/tmp/cvs-serv32473
Modified Files:
xmlconfig.py
Log Message:
Writing is working
Index: xmlconfig.py
===================================================================
RCS file: /cvsroot/wpdev/xmlscripts/scripts/xmlconfig.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** xmlconfig.py 11 Nov 2003 22:23:36 -0000 1.3
--- xmlconfig.py 12 Nov 2003 15:49:16 -0000 1.4
***************
*** 12,17 ****
--- 12,20 ----
self.choices = choices
+
class ConfigGroup:
def __init__(self, parent, y, text, options):
+ self.entries = []
+ self.text = text
self.gr = Pmw.Group( parent.interior(),
tag_text = text,
***************
*** 32,35 ****
--- 35,39 ----
entry.pack(fill='both',expand=1,pady=5,padx=5)
self.height += 40
+ self.entries.append( entry )
else:
entry = Pmw.EntryField(self.gr.interior(),
***************
*** 41,44 ****
--- 45,49 ----
entry.pack(fill='both',expand=1,pady=5,padx=5)
self.height += 40
+ self.entries.append( entry )
parent.create_window(1, y,width=300,height=self.height,anchor='nw',window = self.gr)
***************
*** 50,53 ****
--- 55,61 ----
class XMLConfig:
def __init__(self, parent):
+ self.resutl = ''
+ self.parent = parent
+ self.groups = []
self.xmlname = 'wolfpack.xml'
self.sc = Pmw.ScrolledCanvas(parent,
***************
*** 84,109 ****
opts.append( Option( op.getAttribute('key'), value, choices ) )
cfg = ConfigGroup( self.sc, y, gr.getAttribute('name'), opts )
y += cfg.height + 5
opts = []
-
self.sc.pack(padx = 5, pady = 5, fill = 'both', expand = 1)
self.sc.resizescrollregion()
!
! def writeXML(self):
! dom = Document()
! all = dom.createElement("preferences")
! all.setAttribute('version','1.0')
! all.setAttribute('application','Wolfpack')
! sub = dom.createElement("group")
! sub.setAttribute('name','AI')
! all.appendChild(sub)
! dom.appendChild(all)
! file = open(filename,'w')
! file.write("<!DOCTYPE preferences>\n")
! file.write(dom.toprettyxml())
! file.flush()
! file.close()
if __name__ == '__main__':
--- 92,148 ----
opts.append( Option( op.getAttribute('key'), value, choices ) )
cfg = ConfigGroup( self.sc, y, gr.getAttribute('name'), opts )
+ self.groups.append( cfg )
y += cfg.height + 5
opts = []
self.sc.pack(padx = 5, pady = 5, fill = 'both', expand = 1)
self.sc.resizescrollregion()
! def writexml(self):
! self.dialog = Pmw.MessageDialog(self.parent,
! buttons = ('OK','Cancel'),
! message_text = 'Save changes ?',
! defaultbutton = 'OK',
! title = 'My dialog',
! command = self.execute)
! self.dialog.withdraw()
! self.dialog.activate(geometry = 'centerscreenalways')
!
! if self.result == 'OK':
! self.dialog.deactivate(self.result)
! dom = Document()
! all = dom.createElement("preferences")
! all.setAttribute('version','1.0')
! all.setAttribute('application','Wolfpack')
! for gr in self.groups:
! entries = gr.entries
! groupname = gr.text
! xgr = dom.createElement('group')
! xgr.setAttribute('name',groupname)
! for en in entries:
! labeltext = en['label_text']
! try:
! value = en['value']
! except:
! value = str(en.get())
! xop = dom.createElement('option')
! xop.setAttribute('key',labeltext)
! xop.setAttribute('value',value)
! xgr.appendChild(xop)
!
! all.appendChild(xgr)
!
! all.appendChild(xgr)
! dom.appendChild(all)
! file = open(self.xmlname,'w')
! file.write("<!DOCTYPE preferences>\n")
! file.write(dom.toprettyxml())
! file.flush()
! file.close()
!
! def execute(self, result):
! self.result = result
! self.dialog.deactivate(result)
!
if __name__ == '__main__':
***************
*** 112,118 ****
root.title('Wolfpack configurator')
! exitButton = Tkinter.Button(root, text = 'Exit', command = root.destroy)
! exitButton.pack(side = 'bottom')
! widget = XMLConfig(root)
root.mainloop()
--- 151,161 ----
root.title('Wolfpack configurator')
! config = XMLConfig(root)
! saveButton = Tkinter.Button(root, text = 'Save changes', command = config.writexml)
! saveButton.pack(pady = 5, padx = 5)
! exitButton = Tkinter.Button(root, text = 'Exit configurator', command = root.destroy)
! exitButton.pack(pady = 5, padx = 5)
!
!
root.mainloop()
|