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:
|
||||
|
||||
Reference in New Issue
Block a user