diff --git a/design.txt b/design.txt index e3ffe02..5e3a77c 100644 --- a/design.txt +++ b/design.txt @@ -73,6 +73,8 @@ row 4 | quit previous next | How to connect different windows? There are 2 alternatives. One is using Ids. Every window has a id, my program just sorts windows according to Ids. For example, there are 3 windows with id 1, 2, and 3. Number 1 window will be first displayed, when user clicks "next", number 2 window will be displayed. It seems reasonable, right? If it did not have the following 2 drawbacks, I would not think about the second alternative: first, id is an inborn attribute to each window, you have to decide the install sequence at the same time or before you define the window; second it is a little hard to solve the "detour" problem. The install sequence is not a straight line, but has some side road, which is called "detour" by I. For example, when in partition dividing, there may or may not be some windows for RAID setup. Now comes the second alternative: using names. I admit and believe that human beings like string while computers like number. Each window has a name. The install/setup sequence will be defined separately like ["welcome", "serial number", "partition dividing", "package selecting"]. For detour problem, another sequence will be defined, and some button in main sequence will open the detour sequence. + I will just use top window to handle detour! + 3.1.2 Curses I have investigated several choices: urwid, pycdk, and python+dialog. Some is a little complicated and error-prone: urwid. Some has few documents: pycdk. Finally, I chose python+dialog. It is simple, and workable. I like the demo.py in it very much. It demonstrates excellent programming skills. The curses interface will be simple and terse. It will only include the changing part in GUI interface(row 2). diff --git a/python/mine/ri_cmd.py b/python/mine/ri_cmd.py index 289bfd9..c96faa6 100644 --- a/python/mine/ri_cmd.py +++ b/python/mine/ri_cmd.py @@ -4,6 +4,7 @@ import ri_tk as display import ri_seq import ri_widget +import re def quit(): ''' correspond to quit button ''' @@ -37,3 +38,22 @@ def serial_no_init(): def serial_no_quit(): v = display.var_dict['serial_no.number'].get() +def mount_list_init(): + ''' initialize mount list ''' + f = file('/proc/partitions', 'r') + pattern = re.compile(r''' +\s*\d+ # major dev number +\s*\d+ # minor dev number +\s*\d+ # blocks +\s*(\w+\d) # name +\s*$''', re.VERBOSE) + s = [] + while True: + l = f.readline() + if not l: + break + res = pattern.search(l) + if res: + s.append(res.groups()[0]) + + display.var_dict['mount.list'].set(value='\n'.join(s)) diff --git a/python/mine/ri_tk.py b/python/mine/ri_tk.py index be5867c..5f06889 100644 --- a/python/mine/ri_tk.py +++ b/python/mine/ri_tk.py @@ -5,6 +5,7 @@ import Tkinter import tkMessageBox import sys import ri_cmd +import ri_widget var_dict={} @@ -18,6 +19,8 @@ def init(base_w): root_window.rowconfigure(0, weight=1) root_window.geometry("%sx%s+0+0" %(root_window.winfo_screenwidth(),root_window.winfo_screenheight())) + # bind WM_DELETE_WINDOW + root_window.protocol("WM_DELETE_WINDOW", root_window.quit) global base_widget base_widget = create_widget_sub(base_w, root_window) @@ -86,6 +89,22 @@ def create_widget_sub(w, p_win): cf_func = getattr(w_win, cf[0]) cf_func( cf[1], weight=cf[2]) + # handle scroll bar for sub_widgets + if 'action' in dir(w): + # ing for scrolling, ed for scrolled + for ing, ed in w.action.scrolls: + ing_win = w.dict[ing].tk_widget + ed_win = w.dict[ed].tk_widget + if ing_win['orient'] == 'vertical': + ed_cmd_name = 'yscrollcommand' + ing_cmd = getattr(ed_win, 'yview') + else: + ed_cmd_name = 'xscrollcommand' + ing_cmd = getattr(ed_win, 'xview') + + ing_win.configure(command=ing_cmd) + ed_win[ed_cmd_name]=ing_win.set + # grid location if 'grid_location' in dir(w): w_win.grid(w.grid_location.dict) diff --git a/python/mine/ri_widget.py b/python/mine/ri_widget.py index 55cc4e4..2b93acd 100644 --- a/python/mine/ri_widget.py +++ b/python/mine/ri_widget.py @@ -32,6 +32,10 @@ class Action: self.dict={} for a in xml_node.attributes.values(): self.dict[a.name] = a.value + self.scrolls = [] + for node in xml_node.childNodes: + if node.nodeName == 'scroll': + self.scrolls.append((node.attributes['scrolling'].value, node.attributes['scrolled'].value)) class Widget: ''' implement widget in interface xml ''' diff --git a/xml/install.xml b/xml/install.xml index c65bcb0..35f3887 100644 --- a/xml/install.xml +++ b/xml/install.xml @@ -1,17 +1,11 @@ 123456789012 - - - - - - - - - - - + + + + + /dev/hda1 diff --git a/xml/install_ng.xml b/xml/install_ng.xml index d02a7be..988de60 100644 --- a/xml/install_ng.xml +++ b/xml/install_ng.xml @@ -20,24 +20,17 @@ - - - - - - - - - primary - extended - logic - - - - - - - + + + + + + + + + + + diff --git a/xml/interface_ng.xml b/xml/interface_ng.xml index 3ec224a..0f850f2 100644 --- a/xml/interface_ng.xml +++ b/xml/interface_ng.xml @@ -80,6 +80,9 @@ on special cases --> + + + diff --git a/xml/interface_t.xml b/xml/interface_t.xml index 9176188..ba6a7bc 100644 --- a/xml/interface_t.xml +++ b/xml/interface_t.xml @@ -205,23 +205,64 @@ row 4 | | + + - + - + + + + + + - - + + + + + + + + + + + + + + + + @@ -291,7 +332,6 @@ row 4 | | -