80 lines
2.2 KiB
Python
80 lines
2.2 KiB
Python
#!/usr/bin/python
|
|
''' handle gui button related commands.'''
|
|
|
|
import ri_tk as display
|
|
import ri_seq
|
|
import ri_widget
|
|
import ri_data
|
|
|
|
import re
|
|
|
|
def quit():
|
|
''' correspond to quit button '''
|
|
display.quit()
|
|
ri_data.to_xml()
|
|
|
|
def previous():
|
|
''' correspond to previous button '''
|
|
wid_name = ri_seq.previous()
|
|
if wid_name is not None:
|
|
if ri_widget.Widget.current_widget:
|
|
ri_widget.Widget.current_widget.hide()
|
|
|
|
ri_widget.Widget.dict[wid_name].show()
|
|
else:
|
|
ri_widget.MessageBox.dict["previous"].show()
|
|
|
|
def next():
|
|
''' correspond to next button '''
|
|
wid_name = ri_seq.next()
|
|
if wid_name is not None:
|
|
if ri_widget.Widget.current_widget:
|
|
ri_widget.Widget.current_widget.hide()
|
|
|
|
ri_widget.Widget.dict[wid_name].show()
|
|
else:
|
|
ri_widget.MessageBox.dict["next"].show()
|
|
|
|
def serial_no_init():
|
|
display.var_dict['serial_no.number'].set(value=ri_data.SerialNumber.value)
|
|
|
|
def serial_no_quit():
|
|
ri_data.SerialNumber.value = display.var_dict['serial_no.number'].get()
|
|
|
|
|
|
def mount_list_init():
|
|
''' initialize mount list '''
|
|
l = []
|
|
for m in ri_data.MountPoint.list:
|
|
s = m.device.ljust(10) + m.directory.ljust(20) + m.filesystem.ljust(10)
|
|
l.append(s)
|
|
display.var_dict['mount.list'].set(value=tuple([str(i) for i in l]))
|
|
|
|
def mount_list_quit():
|
|
''' mount list quit function, write mount information into xml file '''
|
|
s = display.var_dict['mount.list'].get()
|
|
if not s: return
|
|
tpl = eval(s)
|
|
for i in range(len(tpl)):
|
|
dev, dir, fs = tpl[i].split()
|
|
ri_data.MountPoint.list[i].directory = dir
|
|
ri_data.MountPoint.list[i].filesystem = fs
|
|
|
|
def mount_list_modify(*args):
|
|
''' modify an item in mount list '''
|
|
tw = ri_widget.TopWindow.dict['mount_list_modify']
|
|
tw.show()
|
|
|
|
def mp_top_fs_init():
|
|
''' mount dir top window initialize '''
|
|
ml_win = ri_widget.Widget.dict['mount.list'].tk_widget
|
|
idxs = ml_win.curselection()
|
|
if len(idxs) == 1:
|
|
idx = int(idxs[0])
|
|
s = display.var_dict['mount.list'].get()
|
|
if not s: return
|
|
tpl = eval(s)
|
|
dev, dir, fs = tpl[idx].split()
|
|
print dev, dir, fs
|
|
|