How to run the graphical tree experimenter. How to use it comes after this. 1. Install python. It is suprisingly easy, google download python and let it happen 2. Search for an app called idle and run it 3. To the idle prompt, type these two commands: import os os.getcwd() 4. The directory/folder name printed is where Python expects files to be 5. Download the two linked files, movable.py and example23.txt to that place You can change the names without consequence, but it must end in ".py". 6. Back to idle, and type import movable as m 7. The thing should run. With focus on the window with the grid just type onle letter commands: h for help (then you'll see all the other commands) or o to read in the example23 file, just select it in the file choice dialogue on creating your own diagrams use the s command to save them 8. You should look at the h (help) command and the H (help for macros) command, I have added a lot since the little demonstration, with a little practice, macros make tree transformations quick and easy 9. If you ever exit from the program and want to start it again, you can just re-run idle. If you want to stay in the same idle session, you need to enter two more commands: from importlib import reload reload(m) Once you have successfully imported a program, further imports of the same thing are ignored even if the file has changed. Reload is needed instead. the "from importlib import reload" only has to be typed once per session. While running this program, type h for the help screen. This is mostly the same but with examples added. Press ESC to exit from the help screens. Typing a letter that is attached to a command will also exit from the help screens, but it will obey the command too. The word "cell" refers to one of the rectangles in the displayed grid whether or not it has any content. "node" refers to a cell that has something in it, its text (even if an empty string) is displayed inside a thick rectangle. Most actions are based on the active grid cell or node which is always shown with a bright yellow background. To make a grid cell active click on it, to have no active cell click outside the grid but still inside the window. When there is no active cell, only a very limited number of commands are available. Commands are given by typing single keys. Left, right, up, down keys change the active cell. ctrl+arrow moves the active node (assuming that the active cell isn't empty) keeping children and parents attached. shift+arrow moves the entire subtree rooted at the active node and you are warned if that would overwrite any non-empty cells. If a command needs operands a dialogue will appear inviting you to type them. If a command needs a second click to indicate another cell, press the ESC key to cancel the command before clicking on another cell. All commands can be undone. s: save the diagram, the save_as dialogue appears and you can give the file any name you like. o: open (read and display) a saved diagram, the open file dialogue appears. The entire current display is erased and replaced by the newly read one. t: set/change text of the active cell. example: t the text can be long just typing t alone turns a cell into a node, the black box is very narrow. t and r create a node if the cell was empty. r: set the colour of the active cell. if you press ENTER alone, a red cell will turn black and any other will turn red. Python's colour chooser is a little odd: the the free-form colours that you pick will have the same darkness as the cell's current colour, so if that is black everything you click on comes out as black. To get around that, either move the brightness slider or first click on one of the small single colour boxes. Colouring an empty cell turns it into a proper node with the empty string as its text. examples: r pink r #8000FF colours are passed unchanged to Python's "tkinter" module, so google to find a complete list of colour names, there are a lot. The # form must have six hexadecimal digits. In pairs they give the red, green, and blue brightnesses in the range 0 to 255, so #000000 is black, #FFFF00 is yellow, etc. j: join the active cell to another (as with a pointer in a tree) with a line. select the other node by clicking on it. If the other node is lower than the active one it becomes a child, if higher it becomes a parent. You do not need to add children in any particular order, the lines will always be drawn in left to right order. (*) u: unjoin: click on a parent or child node and the connection will be removed. (*) m: the entire subtree rooted at the active node is moved, keeping its parents attached. Click on the new location for the root node. The subtree to be movd remains visible until the new location is clicked on. (*) n: the active node is moved, it remains connected to its parents and chuildren but they do not move. New location selected wit a click. (*) c: (copy) the entire subtree rooted at the active node is recorded in the "paste buffer" and can be pasted somewhere else with the p command. k: (kut) the entire subtree rooted at the active node is removed, it can be pasted back at any position with the p command. p: paste: the tree recorded in the paste buffer, i.e. the object of the last k or c command, is pasted in with its root at the active cell. d: delete a single node (the active one), children become independent trees. The d command does not update the paste buffer, so the lost node can't be pasted back. However, the d command (like all others) can be undone. l: split the active node into two nodes, divide children equally between the two, both get the same text and keep the same parents. The new duplicate node is placed two cells to the right, if either of those two cells are occupied, the entire diagram tothe right is moved up to make space. Special case: if the text contains any vertical bars "|" they become division points for the string. If there is exactly one | the left node gets the text before the | and the right node gets the text after it. If there are two or more | bars, the first node gets everything to the lext of the first | and the new node gets everything to the right of the second. A new node with no parents or children appears between the two, and has the text that was between the two | bars. This is for exploding an improper 4 node in a 2-3 tree. any spaces around the bars are removed. i: add new (empty) rows and/or columns to the grid beside the active cell. operands to this command begin with "a" for above, "b" for below, "l" for left and "r" for right. If more than one new row or column is needed, attach the number to the direction letter. example: i 2l a adds two empty columns left of the active node and one empty row above it. e: erase entire rows and columns from the grid, you are warned if any are not empty. In the dialogue box that appears, type a comma separated list of row and column specifications. Each begins with the letter "r" or "c" for row or column and is followed by a number or a range which is one number then a dash - then another larger number. example: e c15-19, r3, r5-9 removes columns 5, 6, 7, 8, 9, 15, 16, 17, 18, 19 and row 3. x: exchange (swap) nodes' texts and colours in a cyclic shift. After typing "x", click on any number of other nodes and type "x" again at the end. Let's imagine the active node is at (5, 9) and you clicked on the cells at (8, 7), (12, 3), and (9, 5) in that order. (9, 5) will get the text and colour of (12, 3), (12, 3) will get the text and colour of (8, 7), (8, 7) will get the text and colour of (5, 9), and (5, 9) will get the text and colour of (9, 5). z: undo. The last command is un-done. subsequent z's undo earlier commands. un-done commands may be re-done. Only one "o" command (read a new file) can be un-done. This is because an "o" command saves the existing diagram in a file, and you don't want to be over-run by a million unwanted files. These undo read files are deleted when the program exits. The undo and redo lists are not saved with the "s" command. If a macro is executed undo and redo apply to the whole macro, not its individual commands. y: redo. re-obeys the last un-done command. In every other way it behaves like the "z" command. q: query. Not very useful unless you are debugging this program. It prints in the text window everything there is to know about the active cell. a: obey a macro. The macro language is a lot like the normal command language, and is described below. A dialogue appears in which you type the macro's name followed by its space-separated parameters if there are any. If a parameter needs to contain a space, surround the whole thing in double quotes ". ctrl+a: re-obey the last executed macro with the same parameters. shift-A: exactly the same as "a" except that the macro's definition is re-read first. Macros are stored in files whose name consists of the macro's name followed by ".macro". The first time an "a" command is obeyed, the macro's definition is read from its file and kept in memory. If you edit the file, a capital A is needed to force a re-read. f: obey a temporary macro. You type the macro in a dialogue box that appears. It doesn't have a name, but ctrl-a will still re-execute it. E: (capital) edit a macro, the name is requested in a dialogue. The editor is quite basic, so if you're doing a complex edit it may be best to edit the .macro file directly with your favourite text editor. In particular there is no undo within the editor, and edit commands can not be undone either. F: (capital) edit the last executed macro. Exactly the same as "E" except for two things: you don't have to say which macro, and it allows you to edit (and therefore save) a macro that was given by the "f" command. N: create a new macro. It is the same as E, but no name is given, you must use save-as inside the editor. h: show the shorter version of this, the help screen, ESC to return. H: (capital) show the shorter help for macros, ESC to return. The following describes macro definitions. Macros are generally stored in files whose names consist of the macro name followed by ".macro". Commands in mcaros are a lot like normal commands. They are typed on single lines with the command first, followed by any operands, space separated (the "t" command is a slight exception). A new "ac" command is for changing the active cell which is normally done by clicking the mouse. Inside macros any part of a command may be replaced by $1, $2, $3, etc, and they are replaced by the first, second, third, etc, parameter supplied whtn the macro was called. Commands that normally rely on the mouse to select other cells have a way to navigate by typed steps. They express movement relative to (usually) the active cell: 3u 7d 2l 4r 12d u4 r7 means 3 cells up then 7 down then 2 left then 4 right, ... u d l r means one cell up, one down, one left, ... if the current cell has children or parents these are also available: 2c p c p2 means move to second child, (first) parent, first child, second parent these options can be combined in any order, but if c or p are used when the current cell has no child or parent, or for example if c3 is used when there are fewer than 3 children it is an error. if the first two items in the movement list are both ints, they represent an absolute starting position, row then column, so 10 24 c3 navigates to the third child node of the node in the cell at row 10 column 24. Any command may specify a temporary change to the active cell by putting movement indicators between the command name and its operands. For this to work,each movment indicator must have a ^ attached to its front. Example: t name would normally set the text of the active cell to "name" but t ^d2 ^r3 name would move the active cell down 2 by cells and right by three cells, set the text there, then change the active cell back to what it was originally. Errors stop macro execution, and the effects of a macro that stopped for an error are automatically undone. Commands in macros: ac Followed by movement commands or co-ordinates, e.g. ac 5 9 makes the cell in row 5 column 9 the active one. ac 3d r otherwise use the movement steps t Followed by text, to change or set the contents of the active cell, the whole line is taken, " quotes are not needed to include spaces. e.g. t 75 t bat | dog r Followed by a colour, change the colour of the active cell. e.g. r purple r #80FF80 j Followed by movement commands: join the active node to the one that the movements lead to. Both must be nodes i.e. have content or colour. e.g. j 2d 1r u Followed by movement commands: disconnect the two nodes. e.g. u c2 disconnects the active node's second child m Followed by "by" or "to", followed by movement commands, moves the entire subtree rooted at the active node as indicated. "to" means that the new position is relative to the active node, "by" means that it is relative to the subtree's root's original position. "by" is usually the one that makes the most sense. The subtree remains attached to any parents. n Is exactly the same as "m", except that only the active node is moved, parents and children remain attached but do not move. c Makes a copy of the subtree rooted at the active node. There is no visible change, but copies of the subtree may be pasted elsewhere in the diagram. k (Kut) Makes a subtree copy exatly the same as "c", but the subtree is then removed from the diagram. p Followed by movement commands pastes the most recently cut or copied subtree back into the diagram with its root at the position given by its movement commands relative to the active node. d The active node is deleted and reverts to an empty cell. Any children become independent trees, paresnts are disconnected. "p" (paste) does not paste nodes removed with "d", only subtrees with "c" or "k", but "z" (undo) will reverse a "d". l Split the active node, exactly as described for the normal (non-macro) "l" command. i Followed by row and/or column specifications adds new empty rows and/or columns to the diagram. All nodes below or right of insertions are moved up accordingly. The new rows/cells are inserted immediately beside the active cell. Specifications are "a" for above, "b" for below, "l" for to the left, and "r" for to the right. A number may be attached to the letter to specify the number of rows/columns to be inserted, default 1. e.g. i 2a 3r creates two empty rows immediately above the active cell and three empty columns immediately to the right of it. e Followed by a sequence of row/column specifications (different format from "i") erases the rows and columns from the diagram. the specifications are space separated and each begins with "r" or "c" which must be immediately followed by either a single number or a number-number range. e.g. e r4 c5-9 r18-20 removes rows 4, 18, 19, 20 and columns 5, 6, 7, 8, 9. you are warned and get a chance to cancel if anything non-empty is about to be removed. x Followed by comma separated movement sequences - the texts and colours the nodes, starting with the active node and including the nodes indicated by each of the movement sequences are exchanged in a circular swap, they move forwards in the chain, so for example, x c2; d3 r3; d2 l3 the active nodes secongd child gets the active node's content, the node down 3 and right 3 from the active node gets the second child's original content, and so on, until the active node gets d2 l3's original content. q Prints in the text/idle window all that is known about the active cell a Runs a macro. the "a" is followed by the macro's name and any parameters, all space separated. If a parameter needs to contain a space enclose it in " quotes. A The same as a, but forces the macro's definition to be re-read first.