Prev: accessing GUI with TWAPI (was: Accessing GUI of CAD through Tcl/Tk)
Next: Where can I find "tcom" package for Linux?
From: ggw on 13 Dec 2009 14:59 Back in the late 1980, our programmers modified tkCanvas.c to have a static static XImage *dispixstruct; static char *dispixmapaddress; static int dispixmap_id; and modified its DisplayCanvas() to check dispixmapaddress (0 the 1st time) and if 0, map a specific file storing its address at dispixmapaddress. Then and, there after it, it would XPutImage(Tk_Display(tkwin),Tk_WindowId(tkwin),canvasPtr->pixmapGC, dispixstruct, screenX1,screenY1,screenX1,screenY1,screenX2- screenX1,screenY2-screenY1); (Another program controlled by Expect would modify that specific file.) That was then. A very easy recompile to get the Tk library, and all was cool. Now, I want to use Tk8.5, in my desire to keep up to date, so I have 2 questions: 1) Does Tk have a way these days to accomplish the above without my resorting to modifying "official" Tk8.5 source code? 2) If "No!" to #1, how can I, after again modifying tkCanvas.c, go about making a Tk library. Last XMas I tried doing straight compiles on Tk (using gcc), but had trouble. In this forum I was advised give up and use ActiveTcl provided stuff, which I did and was sufficient for my needs at the time. gwyche(a)io.com
From: Alexandre Ferrieux on 13 Dec 2009 15:58 On Dec 13, 8:59 pm, ggw <gwy...(a)io.com> wrote: > Back in the late 1980, our programmers modified tkCanvas.c to have a > static > static XImage *dispixstruct; > static char *dispixmapaddress; > static int dispixmap_id; > and modified its DisplayCanvas() to check dispixmapaddress (0 the 1st > time) and if 0, map a specific file storing its address at > dispixmapaddress. Then and, there after it, it would > XPutImage(Tk_Display(tkwin),Tk_WindowId(tkwin),canvasPtr->pixmapGC, > dispixstruct, > screenX1,screenY1,screenX1,screenY1,screenX2- > screenX1,screenY2-screenY1); > > (Another program controlled by Expect would modify that specific > file.) > > That was then. A very easy recompile to get the Tk library, and all > was cool. > > Now, I want to use Tk8.5, in my desire to keep up to date, so I have 2 > questions: > > 1) Does Tk have a way these days to accomplish the above without my > resorting to modifying "official" Tk8.5 source code? > 2) If "No!" to #1, how can I, after again modifying tkCanvas.c, go > about making a Tk library. Last XMas I tried doing straight compiles > on Tk (using gcc), but had trouble. In this forum I was advised give > up and use ActiveTcl provided stuff, which I did and was sufficient > for my needs at the time. > > gwy...(a)io.com If, instead of describing the somewhat short-sighted "solution" (the static), you described the problem (what you want to achieve in terms of external behavior), I'm sure you'd get back the optimal solution in no time, and quite possibly one that's compatible with unmodified wish. -Alex
From: ggw on 13 Dec 2009 21:33 On Dec 13, 2:58 pm, Alexandre Ferrieux <alexandre.ferri...(a)gmail.com> wrote: [ If, instead of describing the somewhat short-sighted "solution" ] OK. - - - - - - - - - - - - - I want Tk to handle the X11 events (redraw the screen) for an existing, Expect controlled, program that updates a file of a rectangle of pixel data. - - - - - - - - - - - - - This Solaris program modifies a file that that it thinks is a screen. Expect/Tk wrap the program (adding mouse support in particular) and handle transferring of the file data to the screen. Works like a charm with old Tk4.0's TkCanvas.c modified to do just that. However, modifying TkCanvas.c is best avoided, hence I seek confirmation (or not) that today's Tk "can do". > On Dec 13, 8:59 pm, ggw <gwy...(a)io.com> wrote: > > > > > Back in the late 1980, our programmers modified tkCanvas.c to have a > > static > > static XImage *dispixstruct; > > static char *dispixmapaddress; > > static int dispixmap_id; > > and modified its DisplayCanvas() to check dispixmapaddress (0 the 1st > > time) and if 0, map a specific file storing its address at > > dispixmapaddress. Then and, there after it, it would > > XPutImage(Tk_Display(tkwin),Tk_WindowId(tkwin),canvasPtr->pixmapGC, > > dispixstruct, > > screenX1,screenY1,screenX1,screenY1,screenX2- > > screenX1,screenY2-screenY1); > > > (Another program controlled by Expect would modify that specific > > file.) > > > That was then. A very easy recompile to get the Tk library, and all > > was cool. > > > Now, I want to use Tk8.5, in my desire to keep up to date, so I have 2 > > questions: > > > 1) Does Tk have a way these days to accomplish the above without my > > resorting to modifying "official" Tk8.5 source code? > > 2) If "No!" to #1, how can I, after again modifying tkCanvas.c, go > > about making a Tk library. Last XMas I tried doing straight compiles > > on Tk (using gcc), but had trouble. In this forum I was advised give > > up and use ActiveTcl provided stuff, which I did and was sufficient > > for my needs at the time. > > > gwy...(a)io.com > > If, instead of describing the somewhat short-sighted "solution" (the > static), you described the problem (what you want to achieve in terms > of external behavior), I'm sure you'd get back the optimal solution in > no time, and quite possibly one that's compatible with unmodified > wish. > > -Alex
From: Alexandre Ferrieux on 14 Dec 2009 04:12 On Dec 14, 3:33 am, ggw <gwy...(a)io.com> wrote: > On Dec 13, 2:58 pm, Alexandre Ferrieux <alexandre.ferri...(a)gmail.com> > wrote: > [ If, instead of describing the somewhat short-sighted "solution" ] > > OK. > - - - - - - - - - - - - - > I want Tk to handle the X11 events (redraw the screen) for an > existing, Expect controlled, program that updates a file of a > rectangle of pixel data. > > - - - - - - - - - - - - - > > This Solaris program modifies a file that that it thinks is a screen. > Expect/Tk wrap the program (adding mouse support in particular) and > handle transferring of the file data to the screen. Works like a > charm with old Tk4.0's TkCanvas.c modified to do just that. However, > modifying TkCanvas.c is best avoided, hence I seek confirmation (or > not) that today's Tk "can do". To transfer data to screen, the normal script-level way is to use a Tk (photo) image, assuming the format is among the supported ones: image create photo myimg myimg read $filename alternatively (eg if the data come over a pipe instead of a regular file), set data [read $channel $length] myimg data $data As a last resort, eg if the format is a bit more exotic, you can write an extension to populate the above photo image's buffer with data at the C level. What's important though is that none of these approaches needs a dedicated patch to the core. Please tell me what prevents you from going that route. -Alex
From: hae on 14 Dec 2009 04:58
On 14 Dez., 03:33, ggw <gwy...(a)io.com> wrote: > On Dec 13, 2:58 pm, Alexandre Ferrieux <alexandre.ferri...(a)gmail.com> > wrote: > [ If, instead of describing the somewhat short-sighted "solution" ] > > OK. > - - - - - - - - - - - - - > I want Tk to handle the X11 events (redraw the screen) for an > existing, Expect controlled, program that updates a file of a > rectangle of pixel data. > > - - - - - - - - - - - - - > > This Solaris program modifies a file that that it thinks is a screen. > Expect/Tk wrap the program (adding mouse support in particular) and > handle transferring of the file data to the screen. Works like a > charm with old Tk4.0's TkCanvas.c modified to do just that. However, > modifying TkCanvas.c is best avoided, hence I seek confirmation (or > not) that today's Tk "can do". > > > On Dec 13, 8:59 pm, ggw <gwy...(a)io.com> wrote: > > > > Back in the late 1980, our programmers modified tkCanvas.c to have a > > > static > > > static XImage *dispixstruct; > > > static char *dispixmapaddress; > > > static int dispixmap_id; > > > and modified its DisplayCanvas() to check dispixmapaddress (0 the 1st > > > time) and if 0, map a specific file storing its address at > > > dispixmapaddress. Then and, there after it, it would > > > XPutImage(Tk_Display(tkwin),Tk_WindowId(tkwin),canvasPtr->pixmapGC, > > > dispixstruct, > > > screenX1,screenY1,screenX1,screenY1,screenX2- > > > screenX1,screenY2-screenY1); > > > > (Another program controlled by Expect would modify that specific > > > file.) > > > > That was then. A very easy recompile to get the Tk library, and all > > > was cool. > > > > Now, I want to use Tk8.5, in my desire to keep up to date, so I have 2 > > > questions: > > > > 1) Does Tk have a way these days to accomplish the above without my > > > resorting to modifying "official" Tk8.5 source code? > > > 2) If "No!" to #1, how can I, after again modifying tkCanvas.c, go > > > about making a Tk library. Last XMas I tried doing straight compiles > > > on Tk (using gcc), but had trouble. In this forum I was advised give > > > up and use ActiveTcl provided stuff, which I did and was sufficient > > > for my needs at the time. > > > > gwy...(a)io.com > > > If, instead of describing the somewhat short-sighted "solution" (the > > static), you described the problem (what you want to achieve in terms > > of external behavior), I'm sure you'd get back the optimal solution in > > no time, and quite possibly one that's compatible with unmodified > > wish. > > > -Alex > > Why don't you check this file say every 100 ms and then update the canvas from script level as Alexandre suggests? As you are on solaris you don't have dnotify/inotify (linux) or twapi (windows) that could inform you with a callback when the file changes. But is is only polish, I think. Ruediger |