From d3b3855c7a14d6ba00f072416d51bd6a4d49ae09 Mon Sep 17 00:00:00 2001 From: lizhi-rocky Date: Fri, 9 Jul 2010 17:48:00 +0800 Subject: [PATCH] fill more design.txt --- design.txt | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/design.txt b/design.txt index f925ed6..924d06b 100644 --- a/design.txt +++ b/design.txt @@ -58,7 +58,7 @@ 3.1.1 GUI Python Tkinter is chosen as the tool. Grid is chose as the geometry manager. - Basically, each window will be divided into 5x3 grids, 5 rows plus 3 columns. Among them, row 0, 1, and 3 are same, while row 4 is partially same. The only changable one is row 3. + Basically, each window will be divided into 5x3 grids, 5 rows plus 3 columns. Among them, row 0, 1, 3, and 4 are same. The only changable one is row 2. The graph is as below: column 0 column 1 column 2 @@ -71,18 +71,18 @@ row 4 | quit previous next | ------------------------------------------------------------ figure 3.1.1-1 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, the sequence will be like ["welcome", "serial number", "partition dividing", ["raid 1" "raid 2" "raid 3"], "package selecting"]. + 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. 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 is very terse. - The curses interface will be simple and terse. It will only include the changing part in GUI interface, that is, the row 2. + 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). 3.1.3 XML and XML parser As previously mentioned, I will use XML to record widgets (Frame, Button, Label...). Here the detail will be discussed. For GUI, there shall be 3 kinds of information: Widgets attributes: background, height, width, text, command, etc, grid location - which row and column it will be located, and grid management. For details, please refer to: * http://www.pythonware.com/library/tkinter/ * http://www.tkdocs.com/tutorial/ - Besides these, 2 things I also think about: multi-language support(at least English & Chinese) and inheritance among windows/frames. Can Chinese font be displayed in Curses mode? I'm not sure for now. And, at least supporting English is not a bad choice, I think. As I mentioned in section 3.1.1, most windows are similar, they are 5 rows X 3 columns, and only one or two rows are different. So if I brought in a somehow inheritance way into xml format, it would save a lot of code lines and errors. - To the first problem, I will design a data type "Message" in XML in which there're key, English text, and Chinese text. All messages used, such as a text on a button, will be references to "Message" variables, via key(for long message) or just English text(for short text). To the second problem, I will introduce XML elements/attributes "derived_from" and "exception", which are similar to what I have done in building system implementation. + Besides these, 2 things I also think about: multi-language support(at least English & Chinese) and inheritance among windows/frames. Can Chinese font be displayed in Curses mode? I'm not sure for now. And, at least supporting English is not a bad choice, I think. As I mentioned in section 3.1.1, most windows are similar, they are 5 rows X 3 columns, and only one row are different. So if I brought in a somehow inheritance way into xml format, it would save a lot of code lines and errors. + To the first problem, I will design a data type "Message" in XML who has "key", "English text", and "Chinese text". All messages, such as a text on a button, will be references to "Message" variables, via key(for long message) or just English text(for short text). To the second problem, I first think about to introduce XML elements/attributes "derived_from" and "exception", which are similar to what I have done in building system implementation. But finally, I give up, for it is a little complex. Now it is enough to define a base widget for GUI row 0, 1, 3, and 4. While other widgets just define the content in row 2. 3.2 Data layer I have inspected those data files generated by current install program. After trying to merge them into one unified data, in xml format, I found it is unbelievable simple! @@ -100,3 +100,20 @@ row 4 | quit previous next | * initrd generating * boot (grub/elilo/yaboot) installing +4. Hello Modules + + Nothing is particularly hard if you divide it into small jobs. + - Henry Ford + + modules: + * widget - handle an internal data structure - widget and its descendants + * sequence - handle an internal data sequence + * tk - tk related operation + * dialog - dialog related operation + * xml - xml parser + * operation - install operation + + To support both Tk and dialog, I seperate display related functions from widget module into tk/dialog module. To connect different modules, I will: + 1) use call-back functions + 2) add init and quit functions to widget + 3)