modify sequence processing
This commit is contained in:
@@ -13,17 +13,18 @@ import sys
|
||||
def quit():
|
||||
''' correspond to quit button '''
|
||||
# maybe a quit in current widget, so call widget.hide()
|
||||
if ri_widget.Widget.current_widget:
|
||||
ri_widget.Widget.current_widget.hide()
|
||||
# get current widget, call its quit()
|
||||
q, t = ri_seq.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()
|
||||
if wid_name is not None:
|
||||
if ri_widget.Widget.current_widget:
|
||||
ri_widget.Widget.current_widget.hide()
|
||||
ri_widget.Widget.dict[t].hide()
|
||||
|
||||
ri_widget.Widget.dict[wid_name].show()
|
||||
else:
|
||||
@@ -31,10 +32,10 @@ def previous():
|
||||
|
||||
def next():
|
||||
''' correspond to next button '''
|
||||
q, t = ri_seq.Sequence.current()
|
||||
wid_name = ri_seq.next()
|
||||
if wid_name is not None:
|
||||
if ri_widget.Widget.current_widget:
|
||||
ri_widget.Widget.current_widget.hide()
|
||||
ri_widget.Widget.dict[t].hide()
|
||||
|
||||
ri_widget.Widget.dict[wid_name].show()
|
||||
else:
|
||||
|
||||
@@ -1,48 +1,39 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
current_sequence=""
|
||||
previous_sequences=[]
|
||||
dict={}
|
||||
|
||||
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
|
||||
|
||||
def set_step(self, st):
|
||||
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])
|
||||
|
||||
|
||||
def construct(xml_root):
|
||||
''' construct Sequence's static members'''
|
||||
global current_sequence
|
||||
current_sequence = xml_root.attributes["sequence"].value
|
||||
for s in xml_root.childNodes:
|
||||
if s.nodeType == s.ELEMENT_NODE and s.nodeName == "sequence":
|
||||
dict[s.attributes["name"].value] = Sequence(s)
|
||||
Sequence.dict[s.attributes["name"].value] = Sequence(s)
|
||||
|
||||
def previous():
|
||||
global current_sequence
|
||||
cur_seq = dict[current_sequence]
|
||||
if cur_seq.current_step:
|
||||
cur_seq.current_step -= 1
|
||||
return cur_seq.steps[cur_seq.current_step]
|
||||
# current sequence already in first step
|
||||
elif previous_sequences:
|
||||
current_sequence = previous_sequences.pop()
|
||||
cur_seq = dict[current_sequence]
|
||||
return cur_seq.steps[cur_seq.current_step]
|
||||
if Sequence.current_sequence.current_step:
|
||||
Sequence.current_sequence.current_step -= 1
|
||||
return Sequence.current_sequence.steps[Sequence.current_sequence.current_step]
|
||||
|
||||
def next():
|
||||
global current_sequence
|
||||
cur_seq = dict[current_sequence]
|
||||
if cur_seq.current_step < len(cur_seq.steps)-1:
|
||||
cur_seq.current_step += 1
|
||||
return cur_seq.steps[cur_seq.current_step]
|
||||
# current sequence already in last step
|
||||
elif previous_sequences:
|
||||
current_sequence = previous_sequences.pop()
|
||||
cur_seq = dict[current_sequence]
|
||||
return cur_seq.steps[cur_seq.current_step]
|
||||
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]
|
||||
|
||||
@@ -45,7 +45,8 @@ base_widget_name = xmldoc.firstChild.attributes["base_widget"].value
|
||||
ri_widget.init_display(base_widget_name)
|
||||
|
||||
main_sequence_name = xmldoc.firstChild.attributes["sequence"].value
|
||||
main_sequence = ri_seq.dict[main_sequence_name]
|
||||
ri_seq.Sequence.set_current_sequence(main_sequence_name)
|
||||
main_sequence = ri_seq.Sequence.dict[main_sequence_name]
|
||||
|
||||
if begin_step is None:
|
||||
begin_step = main_sequence.steps[0]
|
||||
|
||||
Reference in New Issue
Block a user