diff --git a/python/mine/ri_cmd.py b/python/mine/ri_cmd.py
index 00c425a..71c519d 100644
--- a/python/mine/ri_cmd.py
+++ b/python/mine/ri_cmd.py
@@ -11,6 +11,7 @@ import re
def quit():
''' correspond to quit button '''
display.quit()
+ ri_data.to_xml()
def previous():
''' correspond to previous button '''
@@ -45,7 +46,21 @@ def mount_list_init():
''' initialize mount list '''
l = []
for m in ri_data.MountPoint.list:
-# s = m.device.center(10) + m.directory.center(20) + m.filesystem.center(10)
s = m.device.ljust(10) + m.directory.ljust(20) + m.filesystem.ljust(10)
l.append(s)
display.var_dict['mount.list'].set(value=tuple([str(i) for i in l]))
+
+def mount_list_quit():
+ ''' mount list quit function, write mount information into xml file '''
+ s = display.var_dict['mount.list'].get()
+ if not s: return
+ tpl = eval(s)
+ for i in range(len(tpl)):
+ dev, dir, fs = tpl[i].split()
+ ri_data.MountPoint.list[i].directory = dir
+ ri_data.MountPoint.list[i].filesystem = fs
+
+def mount_list_modify(*args):
+ ''' modify an item in mount list '''
+ tw = ri_widget.TopWindow.dict['mount_list_modify']
+ tw.show()
diff --git a/python/mine/ri_data.py b/python/mine/ri_data.py
index c9222da..f34a6e6 100644
--- a/python/mine/ri_data.py
+++ b/python/mine/ri_data.py
@@ -2,6 +2,12 @@
import re
import commands
+from xml.dom import minidom
+from xml.dom.ext import PrettyPrint
+
+# xml file names
+install_xml = '../../xml/install.xml'
+config_xml = './config.xml'
def to_xml_attr(doc, node, cls, name):
''' This method is called by to_xml. Its function is to create an attribute, and set its value based on Network data member
@@ -217,7 +223,7 @@ doc - xml document instance
p_node - xml node (parent node)'''
mps = doc.createElement('mount-points')
for m in MountPoint.list:
- mp = doc.createElement('mount-points')
+ mp = doc.createElement('mount-point')
dev_attr = doc.createAttribute('device')
dir_attr = doc.createAttribute('directory')
fs_attr = doc.createAttribute('file-system')
@@ -451,12 +457,6 @@ p_node - xml node (parent node)'''
srvs.appendChild(srv)
p_node.appendChild(srvs)
-# xml file names
-install_xml = '../../xml/install.xml'
-config_xml = './config.xml'
-
-from xml.dom import minidom
-
def init_from_xml():
''' init all classes in this module based input file (install xml) '''
xmldoc = minidom.parse(install_xml)
diff --git a/python/mine/ri_tk.py b/python/mine/ri_tk.py
index 5f06889..bb25eae 100644
--- a/python/mine/ri_tk.py
+++ b/python/mine/ri_tk.py
@@ -109,6 +109,10 @@ def create_widget_sub(w, p_win):
if 'grid_location' in dir(w):
w_win.grid(w.grid_location.dict)
+ # handle bindings
+ for bd in w.bindings:
+ w_win.bind(bd[0], getattr(ri_cmd, bd[1]))
+
# save tk widget instance into w (widget instance)
setattr(w, 'tk_widget', w_win)
return w_win
@@ -135,6 +139,40 @@ def destroy_widget(w):
def create_message_box(w):
''' display MessageBox
- w - widget instance'''
+ w - MessageBox instance'''
disp = getattr(tkMessageBox, "show%s" %(w.tp))
disp(w.title, w.message)
+
+def create_top_window(w):
+ ''' display TopWindow
+w - TopWindow instance '''
+ tk_attr = dict(w.attr)
+ modify_attributes(tk_attr)
+
+ w_win = Tkinter.Toplevel(root_window, tk_attr)
+
+ for sub_w in w.widgets:
+ create_widget_sub(sub_w, w_win)
+
+ if 'grid_management' in dir(w):
+ for cf in w.grid_management.cf_list:
+ cf_func = getattr(w_win, cf[0])
+ cf_func(cf[1], weight=cf[2])
+
+ # save tk widget instance into w (TopWindow instance)
+ setattr(w, 'tk_widget', w_win)
+
+ # 'bind' it to root window
+ w_win.transient(root_window)
+ # grab all events into it
+ while True:
+ try:
+ w_win.grab_set()
+ except Tkinter.TclError:
+ pass
+ else:
+ break
+
+ w_win.wait_window()
+
+ return w_win
diff --git a/python/mine/ri_widget.py b/python/mine/ri_widget.py
index 2b93acd..f1e5df7 100644
--- a/python/mine/ri_widget.py
+++ b/python/mine/ri_widget.py
@@ -50,6 +50,7 @@ class Widget:
self.attr = {}
self.widgets=[]
self.variables=[]
+ self.bindings = []
for node in xml_node.childNodes:
if node.nodeType == node.ELEMENT_NODE:
if node.nodeName == "grid_management":
@@ -67,6 +68,13 @@ class Widget:
"value" in node.attributes.keys() and node.attributes["value"].value or "" ))
elif node.nodeName == "action":
self.action = Action(node)
+ elif node.nodeName == 'binding':
+ if node.attributes['wrap'].value == 'single':
+ seq = '<'+node.attributes["sequence"].value+'>'
+ elif node.attributes['wrap'].value == 'double':
+ seq = '<<'+node.attributes["sequence"].value+'>>'
+ self.bindings.append((seq, \
+ node.attributes["function"].value))
def show(self):
Widget.current_widget = self
@@ -75,7 +83,7 @@ class Widget:
def hide(self):
display.destroy_widget(self)
-class MessageBox():
+class MessageBox:
''' implement dialog in interface.xml '''
dict={}
@@ -91,12 +99,37 @@ class MessageBox():
''' display dialog'''
display.create_message_box(self)
+class TopWindow:
+ ''' implement top_window in interface.xml - top_window corresponds to Toplevel in Tkinter '''
+ dict={}
+ def __init__(self, xml_node):
+ self.name = xml_node.attributes["name"].value
+ TopWindow.dict[self.name] = self
+ self.attr = {}
+ self.widgets = []
+ for node in xml_node.childNodes:
+ if node.nodeType == node.ELEMENT_NODE:
+ if node.nodeName == 'grid_management':
+ self.grid_management = GridManagement(node)
+ elif node.nodeName == "widget_attribute":
+ for a in node.attributes.values():
+ self.attr[a.name] = a.value
+ elif node.nodeName == "widget":
+ self.widgets.append(Widget(node))
+
+ def show(self):
+ display.create_top_window(self)
+
+ def hide(self):
+ display.destroy_top_window(self)
+
def construct(xml_root):
''' construct Widget's static members'''
for n in xml_root.childNodes:
if n.nodeType == n.ELEMENT_NODE:
if n.nodeName == "widget": Widget(n)
elif n.nodeName == "message_box": MessageBox(n)
+ elif n.nodeName == "top_window": TopWindow(n)
def init_display(bw):
''' base widget name'''
diff --git a/xml/install.xml b/xml/install.xml
index ff5658c..2b839e9 100644
--- a/xml/install.xml
+++ b/xml/install.xml
@@ -2,45 +2,38 @@
123456789012
-
-
-
+
+
+
-
-
+
/dev/hda1
/dev/hda2
-
-
+
/dev/hda3
/dev/hda5
/dev/hda6
-
-
-
+
+
-
-
-
+
-
+
base software packages
-
+
-
-
+
+
-
-
+
-
diff --git a/xml/interface_ng.xml b/xml/interface_ng.xml
index 0f850f2..f9e5d6c 100644
--- a/xml/interface_ng.xml
+++ b/xml/interface_ng.xml
@@ -11,6 +11,9 @@
+
+
+
@@ -37,12 +40,15 @@
-
+
-
+
+
+
+
@@ -168,6 +174,21 @@ on special cases -->
+
+
+
+
+
+
+
+ single
+ double
+
+
+
+
+
@@ -176,7 +197,23 @@ on special cases -->
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/xml/interface_t.xml b/xml/interface_t.xml
index ba6a7bc..8f03e63 100644
--- a/xml/interface_t.xml
+++ b/xml/interface_t.xml
@@ -235,8 +235,6 @@ row 4 | |
-
-
@@ -256,7 +254,9 @@ row 4 | |
-
+
+
+
@@ -309,6 +309,23 @@ row 4 | |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Rocky 4.2
磐石 4.2