diff --git a/python/mine/ri_cmd.py b/python/mine/ri_cmd.py index 3a0ef96..4871481 100644 --- a/python/mine/ri_cmd.py +++ b/python/mine/ri_cmd.py @@ -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 diff --git a/python/mine/ri_tk.py b/python/mine/ri_tk.py index 96fac75..ea0bcd8 100644 --- a/python/mine/ri_tk.py +++ b/python/mine/ri_tk.py @@ -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() + diff --git a/python/mine/ri_widget.py b/python/mine/ri_widget.py index f1e5df7..86fd76b 100644 --- a/python/mine/ri_widget.py +++ b/python/mine/ri_widget.py @@ -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: diff --git a/xml/install.xml b/xml/install.xml index ac6eed7..abe5a6a 100644 --- a/xml/install.xml +++ b/xml/install.xml @@ -1,6 +1,6 @@ - 123456789012 + 0123 @@ -18,12 +18,12 @@ - + - + - + base software packages @@ -32,6 +32,7 @@ + diff --git a/xml/interface_ng.xml b/xml/interface_ng.xml index 4297724..b6daa23 100644 --- a/xml/interface_ng.xml +++ b/xml/interface_ng.xml @@ -29,6 +29,9 @@ + + + diff --git a/xml/interface_t.xml b/xml/interface_t.xml index 0f28ded..bfa9920 100644 --- a/xml/interface_t.xml +++ b/xml/interface_t.xml @@ -266,6 +266,18 @@ row 4 | | + @@ -274,7 +286,7 @@ row 4 | | - + @@ -306,12 +318,12 @@ row 4 | | - + - + @@ -323,7 +335,7 @@ row 4 | | - + @@ -333,7 +345,7 @@ row 4 | | - + @@ -343,7 +355,7 @@ row 4 | | - + @@ -353,7 +365,7 @@ row 4 | | - + @@ -363,7 +375,7 @@ row 4 | | - + @@ -373,7 +385,7 @@ row 4 | | - + @@ -381,6 +393,34 @@ row 4 | | + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -482,5 +522,6 @@ row 4 | | +