~~~
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()
|
||||
|
||||
@@ -6,11 +6,14 @@
|
||||
<attribute name="base_widget"/>
|
||||
<attribute name="sequence"/>
|
||||
<oneOrMore>
|
||||
<ref name="widget"/>
|
||||
<zeroOrMore>
|
||||
<ref name="message"/>
|
||||
</zeroOrMore>
|
||||
<ref name="widget"/>
|
||||
</oneOrMore>
|
||||
<oneOrMore>
|
||||
<ref name="message_box"/>
|
||||
</oneOrMore>
|
||||
<zeroOrMore>
|
||||
<ref name="message"/>
|
||||
</zeroOrMore>
|
||||
<oneOrMore>
|
||||
<ref name="sequence"/>
|
||||
</oneOrMore>
|
||||
@@ -35,6 +38,9 @@
|
||||
<!-- geometry location is the location inside its parent -->
|
||||
<ref name="geometry_location"/>
|
||||
</optional>
|
||||
<optional>
|
||||
<ref name="variable"/>
|
||||
</optional>
|
||||
</interleave>
|
||||
<zeroOrMore>
|
||||
<ref name="widget"/>
|
||||
@@ -70,6 +76,9 @@ on special cases -->
|
||||
<optional>
|
||||
<attribute name="state"/>
|
||||
</optional>
|
||||
<optional>
|
||||
<attribute name="textvariable"/>
|
||||
</optional>
|
||||
</interleave>
|
||||
</element>
|
||||
</define>
|
||||
@@ -120,6 +129,25 @@ on special cases -->
|
||||
</choice>
|
||||
</define>
|
||||
|
||||
<define name="variable">
|
||||
<element name="variable">
|
||||
<attribute name="name"/>
|
||||
<attribute name="type"/>
|
||||
<optional>
|
||||
<attribute name="value"/>
|
||||
</optional>
|
||||
</element>
|
||||
</define>
|
||||
|
||||
<define name="message_box">
|
||||
<element name="message_box">
|
||||
<attribute name="name"/>
|
||||
<attribute name="type"/>
|
||||
<attribute name="title"/>
|
||||
<attribute name="message"/>
|
||||
</element>
|
||||
</define>
|
||||
|
||||
<define name="message">
|
||||
<element name="message">
|
||||
<optional>
|
||||
|
||||
@@ -53,16 +53,6 @@ row 4 | quit previous next |
|
||||
|
||||
</widget>
|
||||
|
||||
<message key='#os-name'>
|
||||
<English>Rocky 4.2</English>
|
||||
<Chinese>磐石 4.2</Chinese>
|
||||
</message>
|
||||
|
||||
<message>
|
||||
<English>Copyright</English>
|
||||
<Chinese>版权</Chinese>
|
||||
</message>
|
||||
|
||||
<!--
|
||||
column 0 column 1 column 2
|
||||
____________________________________________________________
|
||||
@@ -102,7 +92,7 @@ row 4 | |
|
||||
<configure column='2' weight='1'/>
|
||||
</grid_management>
|
||||
<grid_location row='2' column='0' columnspan='3' sticky='NSWE'/>
|
||||
|
||||
<variable name='number' type='StringVar'/>
|
||||
<widget type='Text'>
|
||||
<widget_attribute width='40' height='15' state='disabled'/>
|
||||
<grid_location row='0' column='0'/>
|
||||
@@ -115,7 +105,7 @@ row 4 | |
|
||||
<grid_location row='0' column='0' sticky='W'/>
|
||||
</widget>
|
||||
<widget type='Entry'>
|
||||
<widget_attribute width='12'/>
|
||||
<widget_attribute width='12' textvariable='serial_no.number'/>
|
||||
<grid_location row='1' column='0'/>
|
||||
</widget>
|
||||
</widget>
|
||||
@@ -126,7 +116,7 @@ row 4 | |
|
||||
____________________________________________________________
|
||||
row 0 | |
|
||||
row 1 | |
|
||||
row 2 | partition |
|
||||
row 2 | |
|
||||
| _________ _________ |
|
||||
| | | device: |_________| |
|
||||
| | | __________________________ |
|
||||
@@ -143,9 +133,9 @@ row 4 | |
|
||||
|____________________________________________________________|
|
||||
-->
|
||||
<widget type='Frame' name='partition'>
|
||||
<grid_management rows='4' columns='2'>
|
||||
<grid_management rows='3' columns='2'>
|
||||
<configure row='0' weight='1'/>
|
||||
<configure row='1' weight='1'/>
|
||||
<configure row='2' weight='1'/>
|
||||
<configure column='0' weight='1'/>
|
||||
<configure column='1' weight='1'/>
|
||||
</grid_management>
|
||||
@@ -156,13 +146,8 @@ row 4 | |
|
||||
<grid_location row='0' column='0' rowspan='4'/>
|
||||
</widget>
|
||||
|
||||
<widget type='Label'>
|
||||
<widget_attribute text='partition'/>
|
||||
<grid_location row='0' column='0' columnspan='2'/>
|
||||
</widget>
|
||||
|
||||
<widget type='Frame'>
|
||||
<grid_location row='1' column='1' sticky='WS' pady='10'/>
|
||||
<grid_location row='0' column='1' sticky='WS' pady='10'/>
|
||||
<widget type='Label'>
|
||||
<widget_attribute text='device:'/>
|
||||
<grid_location row='0' column='0' />
|
||||
@@ -177,7 +162,7 @@ row 4 | |
|
||||
<grid_management rows='2' columns='4'>
|
||||
<configure column='3' weight='1'/>
|
||||
</grid_management>
|
||||
<grid_location row='2' column='1' sticky='NW'/>
|
||||
<grid_location row='1' column='1' sticky='NW'/>
|
||||
|
||||
<widget type='Listbox'>
|
||||
<widget_attribute width='60' height='15'/>
|
||||
@@ -266,6 +251,19 @@ row 4 | |
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<message_box name='previous' type='info' title='#install-sequence' message='#first-step'/>
|
||||
<message_box name='next' type='info' title='#install-sequence' message='#last-step'/>
|
||||
|
||||
<message key='#os-name'>
|
||||
<English>Rocky 4.2</English>
|
||||
<Chinese>磐石 4.2</Chinese>
|
||||
</message>
|
||||
|
||||
<message>
|
||||
<English>Copyright</English>
|
||||
<Chinese>版权</Chinese>
|
||||
</message>
|
||||
|
||||
<message key='host name'>
|
||||
<English>host name</English>
|
||||
<Chinese>主机名</Chinese>
|
||||
|
||||
Reference in New Issue
Block a user