diff --git a/python/mine/ri_cmd.py b/python/ri_cmd.py
similarity index 97%
rename from python/mine/ri_cmd.py
rename to python/ri_cmd.py
index 13844f7..affe636 100644
--- a/python/mine/ri_cmd.py
+++ b/python/ri_cmd.py
@@ -2,7 +2,6 @@
''' handle gui button related commands.'''
import ri_tk as display
-import ri_seq
import ri_widget
import ri_data
@@ -14,15 +13,15 @@ def quit():
''' correspond to quit button '''
# maybe a quit in current widget, so call widget.hide()
# get current widget, call its quit()
- q, t = ri_seq.Sequence.current()
+ q, t = ri_widget.Sequence.current()
ri_widget.Widget.dict[t].hide()
display.quit()
ri_data.to_xml()
def previous():
''' correspond to previous button '''
- q, t = ri_seq.Sequence.current()
- wid_name = ri_seq.previous()
+ q, t = ri_widget.Sequence.current()
+ wid_name = ri_widget.Sequence.previous()
if wid_name is not None:
ri_widget.Widget.dict[t].hide()
@@ -32,8 +31,8 @@ def previous():
def next():
''' correspond to next button '''
- q, t = ri_seq.Sequence.current()
- wid_name = ri_seq.next()
+ q, t = ri_widget.Sequence.current()
+ wid_name = ri_widget.Sequence.next()
if wid_name is not None:
ri_widget.Widget.dict[t].hide()
diff --git a/python/mine/ri_data.py b/python/ri_data.py
similarity index 100%
rename from python/mine/ri_data.py
rename to python/ri_data.py
diff --git a/python/mine/ri_seq.py b/python/ri_seq.py
similarity index 65%
rename from python/mine/ri_seq.py
rename to python/ri_seq.py
index 3b63739..9b2428d 100644
--- a/python/mine/ri_seq.py
+++ b/python/ri_seq.py
@@ -20,7 +20,18 @@ class Sequence:
@staticmethod
def current():
return (Sequence.current_sequence, Sequence.current_sequence.steps[Sequence.current_sequence.current_step])
-
+
+ @staticmethod
+ def previous():
+ if Sequence.current_sequence.current_step:
+ Sequence.current_sequence.current_step -= 1
+ return Sequence.current_sequence.steps[Sequence.current_sequence.current_step]
+
+ @staticmethod
+ def next():
+ if Sequence.current_sequence.current_step < len(Sequence.current_sequence.steps)-1:
+ Sequence.current_sequence.current_step += 1
+ return Sequence.current_sequence.steps[Sequence.current_sequence.current_step]
def construct(xml_root):
''' construct Sequence's static members'''
@@ -28,12 +39,4 @@ def construct(xml_root):
if s.nodeType == s.ELEMENT_NODE and s.nodeName == "sequence":
Sequence.dict[s.attributes["name"].value] = Sequence(s)
-def previous():
- if Sequence.current_sequence.current_step:
- Sequence.current_sequence.current_step -= 1
- return Sequence.current_sequence.steps[Sequence.current_sequence.current_step]
-def next():
- if Sequence.current_sequence.current_step < len(Sequence.current_sequence.steps)-1:
- Sequence.current_sequence.current_step += 1
- return Sequence.current_sequence.steps[Sequence.current_sequence.current_step]
diff --git a/python/mine/ri_tk.py b/python/ri_tk.py
similarity index 98%
rename from python/mine/ri_tk.py
rename to python/ri_tk.py
index 75c6ed4..a9cf30d 100644
--- a/python/mine/ri_tk.py
+++ b/python/ri_tk.py
@@ -38,6 +38,8 @@ def create_widget(w):
# set step name which will be shown on base widget column 1 row 0
var_dict['main.step_name'].set(w.name)
+import os.path
+
class MyImage:
''' MyImage - a dummy class to hold Image variable '''
count = 0
@@ -49,7 +51,8 @@ def modify_attributes(attr_dict):
# I think there is a bug in Tkinter on Image processing
# I have to bypass it in the following way:
image_var = 'a' + str(MyImage.count)
- setattr(MyImage, image_var, Tkinter.PhotoImage(file=attr_dict[a]))
+ drt = os.path.join(os.path.dirname(__file__), '../data')
+ setattr(MyImage, image_var, Tkinter.PhotoImage(file=os.path.join(drt, attr_dict[a])))
MyImage.count += 1
attr_dict[a] = getattr(MyImage, image_var)
elif a == 'command':
diff --git a/python/mine/ri_widget.py b/python/ri_widget.py
similarity index 79%
rename from python/mine/ri_widget.py
rename to python/ri_widget.py
index ce4ba81..0e8604d 100644
--- a/python/mine/ri_widget.py
+++ b/python/ri_widget.py
@@ -135,13 +135,48 @@ class TopWindow:
def hide(self):
display.destroy_top_window(self)
+class Sequence:
+ ''' implement sequence in interface xml'''
+ dict={}
+
+ def __init__(self, xml_node):
+ self.steps = [ s.attributes["name"].value for s in xml_node.childNodes
+ if s.nodeType == s.ELEMENT_NODE and s.nodeName == "widget" ]
+ self.current_step = 0
+ Sequence.dict[xml_node.attributes["name"].value] = self
+
+ def set_current_step(self, st):
+ ''' set current step based on input step name'''
+ self.current_step = self.steps.index(st)
+
+ @staticmethod
+ def set_current_sequence(name):
+ Sequence.current_sequence = Sequence.dict[name]
+
+ @staticmethod
+ def current():
+ return (Sequence.current_sequence, Sequence.current_sequence.steps[Sequence.current_sequence.current_step])
+
+ @staticmethod
+ def previous():
+ if Sequence.current_sequence.current_step:
+ Sequence.current_sequence.current_step -= 1
+ return Sequence.current_sequence.steps[Sequence.current_sequence.current_step]
+
+ @staticmethod
+ def next():
+ if Sequence.current_sequence.current_step < len(Sequence.current_sequence.steps)-1:
+ Sequence.current_sequence.current_step += 1
+ return Sequence.current_sequence.steps[Sequence.current_sequence.current_step]
+
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)
+ elif n.nodeName == "top_window": TopWindow(n)
+ elif n.nodeName == "sequence": Sequence(n)
def init_display(bw):
''' base widget name'''
diff --git a/python/mine/test.py b/python/test.py
similarity index 79%
rename from python/mine/test.py
rename to python/test.py
index 4baf9f2..f777d05 100644
--- a/python/mine/test.py
+++ b/python/test.py
@@ -2,7 +2,6 @@
import ri_widget
import ri_tk
-import ri_seq
import ri_data
import sys
@@ -24,11 +23,11 @@ for opt, arg in opts:
begin_step = arg
if len(args) == 0:
- itf_xml = "../../xml/interface_t.xml"
- ins_xml = "../../xml/install.xml"
+ itf_xml = "../xml/interface_t.xml"
+ ins_xml = "../xml/install.xml"
elif len(args) == 1:
itf_xml = args[0]
- ins_xml = "../../xml/install.xml"
+ ins_xml = "../xml/install.xml"
else:
itf_xml = args[0]
ins_xml = args[1]
@@ -39,14 +38,13 @@ ri_data.init_from_xml()
#ri_data.init()
ri_widget.construct(xmldoc.firstChild)
-ri_seq.construct(xmldoc.firstChild)
base_widget_name = xmldoc.firstChild.attributes["base_widget"].value
ri_widget.init_display(base_widget_name)
main_sequence_name = xmldoc.firstChild.attributes["sequence"].value
-ri_seq.Sequence.set_current_sequence(main_sequence_name)
-main_sequence = ri_seq.Sequence.dict[main_sequence_name]
+ri_widget.Sequence.set_current_sequence(main_sequence_name)
+main_sequence = ri_widget.Sequence.dict[main_sequence_name]
if begin_step is None:
begin_step = main_sequence.steps[0]
diff --git a/python/mine/test_data.py b/python/test_data.py
similarity index 100%
rename from python/mine/test_data.py
rename to python/test_data.py
diff --git a/xml/interface_t.xml b/xml/interface_t.xml
index 8b1ebd2..50d3e7d 100644
--- a/xml/interface_t.xml
+++ b/xml/interface_t.xml
@@ -22,7 +22,7 @@ row 4 | quit previous next |
-
+