~~~
This commit is contained in:
@@ -1,28 +1,34 @@
|
||||
#!/usr/bin/python
|
||||
''' handle gui button related commands.'''
|
||||
|
||||
import ri_tk
|
||||
import ri_tk as display
|
||||
import ri_seq
|
||||
import ri_widget
|
||||
|
||||
def quit():
|
||||
''' correspond to quit button '''
|
||||
ri_tk.quit()
|
||||
display.quit()
|
||||
|
||||
def previous():
|
||||
''' correspond to previous button '''
|
||||
if 'current_window' in dir(ri_tk):
|
||||
ri_tk.kill_widget(ri_tk.current_window)
|
||||
|
||||
wid_name = ri_seq.previous()
|
||||
print wid_name
|
||||
if wid_name is not None:
|
||||
ri_tk.display_widget(ri_widget.Widget.dict[wid_name])
|
||||
if 'current_window' in dir(display):
|
||||
display.kill_widget(display.current_window)
|
||||
|
||||
ri_widget.Widget.dict[wid_name].display()
|
||||
else:
|
||||
ri_widget.MessageBox.dict["previous"].display()
|
||||
|
||||
def next():
|
||||
''' correspond to next button '''
|
||||
if 'current_window' in dir(ri_tk):
|
||||
ri_tk.kill_widget(ri_tk.current_window)
|
||||
|
||||
wid_name = ri_seq.next()
|
||||
print wid_name
|
||||
if wid_name is not None:
|
||||
ri_tk.display_widget(ri_widget.Widget.dict[wid_name])
|
||||
if 'current_window' in dir(display):
|
||||
display.kill_widget(display.current_window)
|
||||
|
||||
ri_widget.Widget.dict[wid_name].display()
|
||||
else:
|
||||
ri_widget.MessageBox.dict["next"].display()
|
||||
|
||||
@@ -11,6 +11,10 @@ class Sequence:
|
||||
if s.nodeType == s.ELEMENT_NODE and s.nodeName == "widget" ]
|
||||
self.current_step = 0
|
||||
|
||||
def set_step(self, st):
|
||||
''' set current step based on input step name'''
|
||||
self.current_step = self.steps.index(st)
|
||||
|
||||
def construct(xml_root):
|
||||
''' construct Sequence's static members'''
|
||||
global current_sequence
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
''' handle display related work upon Tkinter '''
|
||||
|
||||
import Tkinter
|
||||
|
||||
import tkMessageBox
|
||||
def initialize(base_w):
|
||||
''' base widget xml node '''
|
||||
''' base_w - base widget instance '''
|
||||
global root_window
|
||||
root_window = Tkinter.Tk()
|
||||
|
||||
@@ -53,8 +53,14 @@ def kill_widget(win):
|
||||
''' win - Tk window instance '''
|
||||
win.destroy()
|
||||
|
||||
def display_entry(w):
|
||||
#def display_entry(w):
|
||||
|
||||
def display_listbox(w):
|
||||
#def display_listbox(w):
|
||||
|
||||
def display_radiobutton(w):
|
||||
#def display_radiobutton(w):
|
||||
|
||||
def display_message_box(w):
|
||||
''' display MessageBox
|
||||
w - widget instance'''
|
||||
disp = getattr(tkMessageBox, "show%s" %(w.tp))
|
||||
disp(w.title, w.message)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
import Tkinter
|
||||
import sys
|
||||
import ri_tk as display
|
||||
|
||||
class GridManagement:
|
||||
''' implement grid management '''
|
||||
@@ -70,7 +71,7 @@ class Widget:
|
||||
return d
|
||||
|
||||
def display(self):
|
||||
display_widget(self)
|
||||
display.display_widget(self)
|
||||
|
||||
class Label(Widget):
|
||||
''' Label '''
|
||||
@@ -113,8 +114,33 @@ class Radiobutton(Widget):
|
||||
def display(self):
|
||||
display_radiobutton(self)
|
||||
|
||||
class MessageBox():
|
||||
''' implement dialog in interface.xml '''
|
||||
dict={}
|
||||
|
||||
def __init__(self, xml_node):
|
||||
self.name = xml_node.attributes["name"].value
|
||||
self.tp = xml_node.attributes["type"].value
|
||||
self.title = xml_node.attributes["title"].value
|
||||
self.message = xml_node.attributes["message"].value
|
||||
|
||||
def display(self):
|
||||
''' display dialog'''
|
||||
display.display_message_box(self)
|
||||
|
||||
def construct(xml_root):
|
||||
''' construct Widget's static members'''
|
||||
for w in xml_root.childNodes:
|
||||
if w.nodeType == w.ELEMENT_NODE and w.nodeName == "widget" and "name" in w.attributes.keys():
|
||||
Widget.dict[w.attributes["name"].value] = Widget(w)
|
||||
elif w.nodeType == w.ELEMENT_NODE and w.nodeName == "message_box" and "name" in w.attributes.keys():
|
||||
MessageBox.dict[w.attributes["name"].value] = MessageBox(w)
|
||||
|
||||
def init_display(bw):
|
||||
''' base widget name'''
|
||||
base_w = Widget.dict[bw]
|
||||
display.initialize(base_w)
|
||||
|
||||
def mainloop():
|
||||
'''run message main loop '''
|
||||
display.root_window.mainloop()
|
||||
|
||||
@@ -5,19 +5,42 @@ import ri_tk
|
||||
import ri_seq
|
||||
from xml.dom import minidom
|
||||
|
||||
xmldoc = minidom.parse("../../xml/interface_t.xml")
|
||||
import sys
|
||||
import getopt
|
||||
|
||||
def print_usages():
|
||||
print 'Usages: %s [-b|--begin] xml_file_name' %sys.argv[0]
|
||||
|
||||
try:
|
||||
opts, args = getopt.getopt(sys.argv[1:], "b:", ["begin=",])
|
||||
except getopt.GetoptError:
|
||||
print_usages()
|
||||
sys.exit(1)
|
||||
|
||||
begin_step=None
|
||||
for opt, arg in opts:
|
||||
if opt in ('-b', '--begin'):
|
||||
begin_step = arg
|
||||
|
||||
if len(args):
|
||||
xmldoc = minidom.parse(args[0])
|
||||
else:
|
||||
xmldoc = minidom.parse("../../xml/interface_t.xml")
|
||||
|
||||
ri_widget.construct(xmldoc.firstChild)
|
||||
ri_seq.construct(xmldoc.firstChild)
|
||||
|
||||
base_widget_name = xmldoc.firstChild.attributes["base_widget"].value
|
||||
base_widget = ri_widget.Widget.dict[base_widget_name]
|
||||
|
||||
ri_tk.initialize(base_widget)
|
||||
ri_widget.init_display(base_widget_name)
|
||||
|
||||
main_sequence_name = xmldoc.firstChild.attributes["sequence"].value
|
||||
main_sequence = ri_seq.dict[main_sequence_name]
|
||||
|
||||
ri_tk.display_widget(ri_widget.Widget.dict[main_sequence.steps[0]])
|
||||
if begin_step is None:
|
||||
begin_step = main_sequence.steps[0]
|
||||
else:
|
||||
main_sequence.set_step(begin_step)
|
||||
|
||||
ri_widget.Widget.dict[begin_step].display()
|
||||
|
||||
ri_tk.root_window.mainloop()
|
||||
ri_widget.mainloop()
|
||||
|
||||
Reference in New Issue
Block a user