modified: di_dialog.py

This commit is contained in:
fling
2011-08-29 09:35:16 +08:00
parent db93555b67
commit 40e37daeb6

View File

@@ -1,19 +1,79 @@
import dialog
from xml.dom import minidom
from xml.dom.ext import PrettyPrint
#import ../interface/ri_data
d=dialog.Dialog()
d.setBackgroundTitle("Rocky 4.2 install")
class SerialNumber:
#d=dialog.Dialog()
#d.setBackgroundTitle("Rocky 4.2 install")
install_xml='/var/install/install.xml'
class Dialog:
dialog
dict={}
def __init__(self,text='Rocky 4.2 install'):
Dialog.dialog=dialog.Dialog()
Dialog.dialog.setBackgroundTitle(text)
def check(self):
return
def to_xml(self):
return
class SerialNumber(Dialog):
tuple=()
def __init__(self,height=10, width=30,text='plase input a serial number'):
Dialog.__init__(self)
self.text=text
self.height=height
self.width=width
Dialog.dict['serialnumber'] = self
def get_number(self):
SerialNumber.tuple=Dialog.dialog.inputbox(self.text,self.height,self.width)
def check_nubmer(self):
if SerialNumber.tuple[0] == 0 :
if len(SerialNumber.tuple[1]) == 12 or SerialNumber.tuple[1] == '' :
return True
return False
def to_xml(self,doc,p_node,data):
sn = doc.createElement('serial-number')
data = doc.createTextNode(data)
sn.appendChild(data)
p_node.appendChild(sn)
def show(self):
d.inputbox(self.text,self.height,self.width)
print SerialNumber.tuple
def to_xml():
def bigen(self,xmldoc,root):
SerialNumber.get_number(self)
while not SerialNumber.check_nubmer(self):
Dialog.dialog.msgbox('serial number must be 12 length or none',10,30)
SerialNumber.get_number(self)
SerialNumber.to_xml(self,xmldoc,root,SerialNumber.tuple[1])
class Partition(Dialog):
list=[]
def __init__(self,heigth=15,width=54,text='Partitions'):
Dialog.__init__(self)
self.heigth=heigth
self.width=width
self.text=text
def get_number(self):
Dialog.dialog.menu(self.text,self.heigth,self.width,Partitions.list)
f = file(install_xml, 'w')
xmldoc = minidom.Document()
root = xmldoc.createElement('install')
xmldoc.appendChild(root)
S=SerialNumber(10,50)
S.bigen(xmldoc,root)
S.show()
PrettyPrint(xmldoc, f)
f.close()