touch software group
just a beginning
This commit is contained in:
@@ -7,9 +7,13 @@ import ri_widget
|
||||
import ri_data
|
||||
|
||||
import re
|
||||
import copy
|
||||
|
||||
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()
|
||||
display.quit()
|
||||
ri_data.to_xml()
|
||||
|
||||
@@ -119,7 +123,7 @@ def mp_top_cancel():
|
||||
def network_init():
|
||||
''' network initialize '''
|
||||
display.var_dict['network_host_name']. set(value=ri_data.Network.hostname)
|
||||
ri_widget.Widget.dict['network_config_%s' %(ri_data.Network.configuration,)].tk_widget.select()
|
||||
ri_widget.Widget.dict['network_config_%s' %(ri_data.Network.configuration,)].tk_widget.invoke()
|
||||
display.var_dict['network_domain_name']. set(value=ri_data.Network.domain)
|
||||
display.var_dict['network_ip']. set(value=ri_data.Network.ip)
|
||||
display.var_dict['network_subnet_mask']. set(value=ri_data.Network.mask)
|
||||
@@ -138,5 +142,40 @@ def network_quit():
|
||||
ri_data.Network.primary_dns = display.var_dict['network_primary_dns'].get()
|
||||
ri_data.Network.secondary_dns = display.var_dict['network_secondary_dns'].get()
|
||||
|
||||
def ncm_dynamic():
|
||||
''' when radio button ncm dynamic is checked, several data entry will be set 'disable' '''
|
||||
|
||||
for n in ('network_domain_name','network_ip','network_subnet_mask','network_gateway','network_primary_dns','network_secondary_dns'):
|
||||
ri_widget.Widget.dict[n].tk_widget.configure(state='disable')
|
||||
|
||||
def ncm_static():
|
||||
''' when radio button ncm static is checked, several data entry will be set 'normal' '''
|
||||
for n in ('network_domain_name','network_ip','network_subnet_mask','network_gateway','network_primary_dns','network_secondary_dns'):
|
||||
ri_widget.Widget.dict[n].tk_widget.configure(state='normal')
|
||||
|
||||
def software_group_construct(w):
|
||||
''' draw group information on, based on actual data
|
||||
w - Widget instance '''
|
||||
mdt = [ m for m in ri_data.Group.dict.values() if m.install == 'mandatory' ]
|
||||
opt = [ o for o in ri_data.Group.dict.values() if o.install != 'mandatory' ]
|
||||
|
||||
wit = w.widgets.pop()
|
||||
for i in mdt:
|
||||
print i
|
||||
wi = copy.deepcopy(wit)
|
||||
wi.attr['text'] = i.name
|
||||
vn = "software_group_%s" %(i.name)
|
||||
wi.attr['variable'] = vn
|
||||
wi.variables = [(vn, 'StringVar', ''),]
|
||||
wi.grid_location.dict['column'] = mdt.index(i)
|
||||
wi.grid_location.dict['row'] = 0
|
||||
w.add_sub_widget(wi)
|
||||
|
||||
def software_group_init():
|
||||
pass
|
||||
|
||||
def software_group_quit():
|
||||
pass
|
||||
|
||||
def software_group_item():
|
||||
pass
|
||||
|
||||
@@ -79,11 +79,9 @@ def create_widget_sub(w, p_win):
|
||||
for sub_w in w.widgets:
|
||||
create_widget_sub(sub_w, w_win)
|
||||
|
||||
# grid management
|
||||
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])
|
||||
# process action init
|
||||
if 'action' in dir(w) and 'init' in w.action.dict:
|
||||
getattr(sys.modules['ri_cmd'], w.action.dict['init'])()
|
||||
|
||||
# handle scroll bar for sub_widgets
|
||||
if 'action' in dir(w):
|
||||
@@ -101,6 +99,12 @@ def create_widget_sub(w, p_win):
|
||||
ing_win.configure(command=ing_cmd)
|
||||
ed_win[ed_cmd_name]=ing_win.set
|
||||
|
||||
# grid management
|
||||
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])
|
||||
|
||||
# grid location
|
||||
if 'grid_location' in dir(w):
|
||||
w_win.grid(w.grid_location.dict)
|
||||
@@ -112,30 +116,10 @@ def create_widget_sub(w, p_win):
|
||||
# save tk widget instance into w (widget instance)
|
||||
setattr(w, 'tk_widget', w_win)
|
||||
|
||||
# process action init
|
||||
if 'action' in dir(w) and 'init' in w.action.dict:
|
||||
getattr(sys.modules['ri_cmd'], w.action.dict['init'])()
|
||||
|
||||
return w_win
|
||||
|
||||
# When creating widget, I have to create each sub widget.
|
||||
# while destroying a widget, only destroy one. Tk functions will
|
||||
# destroy all descendant.
|
||||
# so init is a little different from quit.
|
||||
def process_action_quit(w):
|
||||
''' process action quit '''
|
||||
if 'action' in dir(w) and 'quit' in w.action.dict:
|
||||
getattr(sys.modules['ri_cmd'], w.action.dict['quit'])()
|
||||
|
||||
if 'widgets' in dir(w):
|
||||
for sub_w in w.widgets:
|
||||
process_action_quit(sub_w)
|
||||
|
||||
def destroy_widget(w):
|
||||
''' w - Widget instance '''
|
||||
# process action quit
|
||||
process_action_quit(w)
|
||||
|
||||
w.tk_widget.destroy()
|
||||
|
||||
def create_message_box(w):
|
||||
@@ -181,3 +165,4 @@ w - TopWindow instance '''
|
||||
def destroy_top_window(w):
|
||||
''' w - Toplevel instance '''
|
||||
w.tk_widget.destroy()
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import ri_tk as display
|
||||
import sys
|
||||
import ri_cmd
|
||||
|
||||
class GridManagement:
|
||||
''' implement grid management '''
|
||||
@@ -46,6 +48,7 @@ class Widget:
|
||||
if 'name' in xml_node.attributes.keys():
|
||||
self.name = xml_node.attributes["name"].value
|
||||
Widget.dict[self.name] = self
|
||||
|
||||
self.tp = xml_node.attributes["type"].value
|
||||
self.attr = {}
|
||||
self.widgets=[]
|
||||
@@ -76,11 +79,32 @@ class Widget:
|
||||
self.bindings.append((seq, \
|
||||
node.attributes["function"].value))
|
||||
|
||||
if 'construct' in xml_node.attributes.keys():
|
||||
getattr(ri_cmd, xml_node.attributes["construct"].value)(self)
|
||||
|
||||
|
||||
def add_sub_widget(self, w):
|
||||
self.widgets.append(w)
|
||||
|
||||
def show(self):
|
||||
Widget.current_widget = self
|
||||
display.create_widget(self)
|
||||
|
||||
# When creating widget, I have to create each sub widget.
|
||||
# while destroying a widget, only destroy one. Tk functions will
|
||||
# destroy all descendant.
|
||||
# so init is a little different from quit.
|
||||
def process_action_quit(self):
|
||||
''' process action quit '''
|
||||
if 'action' in dir(self) and 'quit' in self.action.dict:
|
||||
getattr(sys.modules['ri_cmd'], self.action.dict['quit'])()
|
||||
|
||||
if 'widgets' in dir(self):
|
||||
for sub_w in self.widgets:
|
||||
sub_w.process_action_quit()
|
||||
|
||||
def hide(self):
|
||||
self.process_action_quit()
|
||||
display.destroy_widget(self)
|
||||
|
||||
class MessageBox:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<install>
|
||||
<serial-number>123456789012</serial-number>
|
||||
<serial-number>0123</serial-number>
|
||||
<partitions unit='sector'>
|
||||
<partition device='/dev/hda1' start='63' id='83' size='16450497'/>
|
||||
<partition device='/dev/hda2' start='16450560' id='5' size='4016250'/>
|
||||
@@ -18,12 +18,12 @@
|
||||
</raid>
|
||||
</raids>
|
||||
<mount-points>
|
||||
<mount-point device='/dev/hda1' directory='/' file-system='ext3' format='yes'/>
|
||||
<mount-point device='/dev/hda1' directory='/' file-system='jfs' format='yes'/>
|
||||
<mount-point device='/dev/hda5' directory='/usr' file-system='reiserfs' format='no'/>
|
||||
</mount-points>
|
||||
<network domain='in.linx' secondary_dns='' ip='192.168.1.25' hostname='localhost' mask='255.255.255.0' primary_dns='192.168.1.254' configuration='static' gateway='192.168.1.254'/>
|
||||
<network domain='google.com' secondary_dns='188.188.166.166' ip='192.168.1.111' hostname='lizhi' mask='255.255.192.0' primary_dns='192.168.1.212' configuration='static' gateway='192.168.1.192'/>
|
||||
<groups>
|
||||
<group name='base' install='yes'>
|
||||
<group name='base' install='mandatory'>
|
||||
<description>base software packages</description>
|
||||
<mandatory>
|
||||
<package name='acct'/>
|
||||
@@ -32,6 +32,7 @@
|
||||
<package name='at' install='yes'/>
|
||||
</optional>
|
||||
</group>
|
||||
<group name='dev' install='mandatory'/>
|
||||
</groups>
|
||||
<services>
|
||||
<service start='yes' package='openssh' script='sshd' name='ssh' number='100'/>
|
||||
|
||||
@@ -29,6 +29,9 @@
|
||||
<optional>
|
||||
<attribute name="name"/>
|
||||
</optional>
|
||||
<optional>
|
||||
<attribute name='construct'/>
|
||||
</optional>
|
||||
<optional>
|
||||
<ref name="widget_attribute"/>
|
||||
</optional>
|
||||
|
||||
@@ -266,6 +266,18 @@ row 4 | |
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<!--
|
||||
column 1 column 2 column 3
|
||||
________________________________________________________________________
|
||||
| ___________ __________ ________ |
|
||||
| | | host name |__________| domain name |________| |
|
||||
| | Text | _ IP |________| |
|
||||
| |___________| NCM |_| dynamic Subnet mask |________| |
|
||||
| _ Gateway |________| |
|
||||
| |_| static Primary DNS |________| |
|
||||
| Secondary DNS|________| |
|
||||
|________________________________________________________________________|
|
||||
-->
|
||||
<widget type='Frame' name='network'>
|
||||
<grid_management rows='1' columns='3'>
|
||||
<configure row='0' weight='1'/>
|
||||
@@ -274,7 +286,7 @@ row 4 | |
|
||||
<configure column='2' weight='1'/>
|
||||
</grid_management>
|
||||
<grid_location row='2' column='0' columnspan='3' sticky='NSWE'/>
|
||||
<action init='network_init'/>
|
||||
<action init='network_init' quit='network_quit'/>
|
||||
|
||||
<widget type='Text'>
|
||||
<widget_attribute width='40' height='15' state='disabled'/>
|
||||
@@ -306,12 +318,12 @@ row 4 | |
|
||||
</widget>
|
||||
|
||||
<widget type='Radiobutton' name='network_config_dynamic'>
|
||||
<widget_attribute text='dynamic' variable='network_config_method' value='dynamic'/>
|
||||
<widget_attribute text='dynamic' variable='network_config_method' value='dynamic' command='ncm_dynamic'/>
|
||||
<grid_location row='1' column='1' sticky='W'/>
|
||||
</widget>
|
||||
|
||||
<widget type='Radiobutton' name='network_config_static'>
|
||||
<widget_attribute text='static' variable='network_config_method' value='static' />
|
||||
<widget_attribute text='static' variable='network_config_method' value='static' command='ncm_static'/>
|
||||
<grid_location row='2' column='1' sticky='W'/>
|
||||
</widget>
|
||||
</widget>
|
||||
@@ -323,7 +335,7 @@ row 4 | |
|
||||
<widget_attribute text='Domain name'/>
|
||||
<grid_location row='0' column='0'/>
|
||||
</widget>
|
||||
<widget type='Entry'>
|
||||
<widget type='Entry' name='network_domain_name'>
|
||||
<widget_attribute width='16' textvariable='network_domain_name'/>
|
||||
<grid_location row='0' column='1' pady='2'/>
|
||||
<variable name='network_domain_name' type='StringVar'/>
|
||||
@@ -333,7 +345,7 @@ row 4 | |
|
||||
<widget_attribute text='IP'/>
|
||||
<grid_location row='1' column='0'/>
|
||||
</widget>
|
||||
<widget type='Entry'>
|
||||
<widget type='Entry' name='network_ip'>
|
||||
<widget_attribute width='16' textvariable='network_ip'/>
|
||||
<grid_location row='1' column='1' pady='2'/>
|
||||
<variable name='network_ip' type='StringVar'/>
|
||||
@@ -343,7 +355,7 @@ row 4 | |
|
||||
<widget_attribute text='Subnet mask'/>
|
||||
<grid_location row='2' column='0'/>
|
||||
</widget>
|
||||
<widget type='Entry'>
|
||||
<widget type='Entry' name='network_subnet_mask'>
|
||||
<widget_attribute width='16' textvariable='network_subnet_mask'/>
|
||||
<grid_location row='2' column='1' pady='2'/>
|
||||
<variable name='network_subnet_mask' type='StringVar'/>
|
||||
@@ -353,7 +365,7 @@ row 4 | |
|
||||
<widget_attribute text='Gateway'/>
|
||||
<grid_location row='3' column='0'/>
|
||||
</widget>
|
||||
<widget type='Entry'>
|
||||
<widget type='Entry' name='network_gateway'>
|
||||
<widget_attribute width='16' textvariable='network_gateway'/>
|
||||
<grid_location row='3' column='1' pady='2'/>
|
||||
<variable name='network_gateway' type='StringVar'/>
|
||||
@@ -363,7 +375,7 @@ row 4 | |
|
||||
<widget_attribute text='Primary DNS'/>
|
||||
<grid_location row='4' column='0'/>
|
||||
</widget>
|
||||
<widget type='Entry'>
|
||||
<widget type='Entry' name='network_primary_dns'>
|
||||
<widget_attribute width='16' textvariable='network_primary_dns'/>
|
||||
<grid_location row='4' column='1' pady='2'/>
|
||||
<variable name='network_primary_dns' type='StringVar'/>
|
||||
@@ -373,7 +385,7 @@ row 4 | |
|
||||
<widget_attribute text='Secondary DNS'/>
|
||||
<grid_location row='5' column='0'/>
|
||||
</widget>
|
||||
<widget type='Entry'>
|
||||
<widget type='Entry' name='network_secondary_dns'>
|
||||
<widget_attribute width='16' textvariable='network_secondary_dns'/>
|
||||
<grid_location row='5' column='1' pady='2'/>
|
||||
<variable name='network_secondary_dns' type='StringVar'/>
|
||||
@@ -381,6 +393,34 @@ row 4 | |
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<!--
|
||||
|
||||
-->
|
||||
|
||||
<widget type='Frame' name='software-group'>
|
||||
<grid_management rows='1' column='2'>
|
||||
<configure row='0' weight='1'/>
|
||||
<configure column='0' weight='1'/>
|
||||
<configure column='1' weight='1'/>
|
||||
</grid_management>
|
||||
<grid_location row='2' column='0' columnspan='3' sticky='NSWE'/>
|
||||
|
||||
<widget type='Text'>
|
||||
<widget_attribute width='40' height='15' state='disabled'/>
|
||||
<grid_location row='0' column='0'/>
|
||||
</widget>
|
||||
|
||||
<widget type='Frame' name='software_group_content' construct='software_group_construct'>
|
||||
<grid_location row='0' column='1' sticky='NSWE' />
|
||||
<action init='software_group_init' quit='software_group_quit'/>
|
||||
<!-- a template for software group item -->
|
||||
<widget type='Checkbutton' name='software-group-item'>
|
||||
<widget_attribute text='' command='software_group_item' variable='' onvalue='on' offvalue='off'/>
|
||||
<grid_location row='0' column='0'/>
|
||||
</widget>
|
||||
</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'/>
|
||||
|
||||
@@ -482,5 +522,6 @@ row 4 | |
|
||||
<widget name='serial_no'/>
|
||||
<widget name='mount'/>
|
||||
<widget name='network'/>
|
||||
<widget name='software-group'/>
|
||||
</sequence>
|
||||
</interface>
|
||||
|
||||
Reference in New Issue
Block a user