'''Running two copies of the program simultaneously or setting up two windows with one copy of the program running''' [Didier](Saturday February 5th 2011) I'd like to program my editor so that two copies of the program run at the same time: the first version of the Editor will occupy one half of the screen and the second one will occupy the other half. I am doing this so that I can copy and paste parts of documents more easily than if I open two copies of the program on two different windows. How should I proceed? Please note once again that I'd like the two programs to open at the same time on split screen. Tx! [RLE] (2011-05-05) Your question appears to mix some metaphors. Do you really want two independent copies of the program, or are you just asking for a split-screen, side-by-side view of two documents? I.e., you want one big window, which contains two document views side by side? If so you should take a look at the [ttk::panedwindow] widget if you are running 8.5.x. You can put two [text] widgets inside of it side by side. Or, you could just open two top level windows, put one [text] widget in each, and then using the [wm] command, adjust the sizes and positions of the two windows so that the each take up a half screen, and sit side by side. [Didier] (2011-02-05) Tx [RLE]. I imperatively must open two copies of the same program for technical reasons and not simply two windows. [RLE] (2011-02-05) fails to understand why such technical reasons exist, but suggests you take a look at [How to embed a non-Tk GUI into a Tk frame] which part way down mentions [BLT] containers among other ideas. You could also take a look at [Embedding Windows applications in Tk frames]. However I fear both will be suboptimal. You may simply find it easiest to either manually position and size both independent windows, or to include some form of command line argument or push button that sizes the windows appropriately. I.e., a -left/-right command line argument that causes the relevant window to be 1/2 screen on the left or right side, or a pair of buttons "Left" "Right" that reposition/size their parent toplevel to be 1/2 screen, left or right side. [Didier](2011-02-06) Tx again, RLE. Is there a simpler solution? What I want to do in fact is to load a precise page from Directory X on the left window and load another precise page from Directory Y on the right window. My editor works '''on a subdirectory level with automatic saving''' and if I open two files that belong to two different directories each on its own window, I get a '''gigantic screw-up''' and this is why I need to open two versions of the program. Version A will handle file in directory X and Version B will handle file in directory Y. I agree however that in most cases your solution works. But your solution would work with my editor only if both files belonged to the same directory. I have programmed what you suggest already. What I really want to do is to start two copies of the program simultaneously each working in its own window. As I said, each will open a different file in a different directory. I was thinking it would simply be a case of: - a) Open ''Editor Version 1.exe'' and run it on left window - b) Open ''Editor Version 2.exe'' and run it on right window What's really needed is the capacity to work with two files located on two different directories thus avoiding the gigantic screw-up that will result if I don't plan things differently. [GJS] You may simply try minimizing all windows but the two you want shown side by side, then right clicking the task bar. On vista there is an option labeled "Show Windows Side by Side". I don't know what OS you're using but it may have a similar option. While not being a TK solution it may be adequate. [RLE] (2011-02-06): Are you writing this from scratch or are you attempting to morph someone else's code to fit your needs? I ask because there is no technical reason why, programmed correctly, something like what I outline below would not work (this is not all Tcl code, just an outline mostly): ====== create text widget .ew1 position .ew1 on left half of screen create text widget .ew2 position .ew2 on right half of screen load file X into .ew1; remember file X's name somewhere, say ::state(.ew1-filename) note: as an absolute path, [file normalize] and/or [tk_getOpenFile] are your friends; load file Y (from a different directory, again as an absolute path) into .ew2; remember file Y's name, say as ::state(.ew2-filename) (again, as an absolute path); set up a pair of "after" timers after $delay [ list savefile .ew1 $delay ] after $delay [ list savefile .ew2 $delay ] proc savefile { widget save_delay } { global state set fp [ open $state(${widget}-filename) {WRONLY TRUNC} ] puts -nonewline $fp [ $widget get 0.0 end ] close $fp after $save_delay [ list savefile $widget $save_delay ] } ====== The result being that after every $delay milliseconds both text widgets overwrite the contents of the original file they contain, in the original directory that the file was loaded from. If what you want are versioned backups, that is a small change to the savefile proc that I will leave as an exercise. Note, the "$widget get 0.0 end" command might make the file contents grow, in which case, replace "end" with "end-1c" to not save the final newline that the text widget contains. And, voila, works with two different files, in two different directories, with no screw-ups. I suspect you might be working with relative file names (i.e. "my_file.txt") instead of absolute file names (/home/dider/edit/files1/my_file.txt or c:\users\dider\Documents\files1\my_file.txt). If I understand what you are attempting to do and what has gone wrong correctly (telling us what the gigantic screw-up actually is would be helpful), you've been bitten by the fact that a relative filename is, well, "relative" and exactly what it points to on disk varies dependent upon the current working directory value. This is where [file normalize] can help, it will take a relative name and return the current absolute name that the relative name will reference. ----- '''Setting up the height of a window + What does pw stand for?''' [Didier] Saturday (February 5th 2011) This is a pretty dumb question. I have in my code the following width: .pw.add.pw.left -width 310 What do I have to do to set the height? This? .pw.add.pw.left -height 110. I tried and it does not work. Any idea what should be typed in? I have another question: I see pw.forget in the code. What does this forget do? What does it forget? :-) Thanks! [RLE] (2011-02-05): Without knowing what kind of widget that path (.pw.add.pw.left) refers to, it is impossible to answer your question. As to pw.forget, as we are not physic, we can't tell. "pw.forget" is not a built-in Tcl or Tk command, so it must refer to a proc that the code you are looking at has defined. So you will have to find the definition of pw.forget to find out what it does. Unless you meant ".pw.forget" (widget path), in which case, the answer is almost the same, look in the code for where "pw.forget" or ".pw.forget" is defined, and read what it does there. [Didier] (2011-02-06) Thanks for the info! I won't forget to look up the code for ''forget'' :-) ----- <> Discussion | Development