in reply to Re: Perl/Tk and Transparent Canvases
in thread Perl/Tk and Transparent Canvases

Many thanks for the detailed response...

I am aware of how to put transparent objects on the canvas, but what I'm looking for is a way to make the canvas itself (which, now that I think about it, means the canvas and the Mainwindow) transparent. In other words, if you open a window with a transparent background and no window decoration, you'd see... nothing. I want the graphical equivalent of a piece of plate glass, so that I can "paint" control elements on it, and have it pop up such that the control elements appear to overlay whatever is on the screen.

Now, a Menu widget lets you pop up Menu buttons that can be made to appear near the cursor location, so maybe what I'm really looking for is a custom widget derived from the Menu widget. Hmmmm....

Replies are listed 'Best First'.
Re^3: Perl/Tk and Transparent Canvases
by graff (Chancellor) on Aug 02, 2005 at 21:20 UTC
    Um, if you're talking about your transparent canvas (or your popup menu) being its own separate app, distinct from other apps (or the user's "desktop") that make up the things that are always visible, then you might run into some issues with input focus.

    I'm a little rusty on the details for X (and I have only limited knowledge of MS-windows), but as a rule, any user input event (mouse click or keystroke) is normally available to only one app: the one that currently holds input focus, which is typically one whose window is on top. So if your "plate glass" interface is always on top, it might be tough to allow the user to interact directly with anything underneath it. (Or perhaps that is your intention?)

    If your "always-visible" background and your "usually invisible" control widgets are all part of the same Tk app, then I believe there is a way to handle the input events such that widgets at lower layers get a chance to see them (but I've never tried that, so I'm not sure).

      What I have in mind is a small canvas (with transparent background and now window decoration) that pops up under the cursor when a mouse button is pressed, and upon which canvas items like circles, polygons, etc. are drawn to act as control elements. I know I can do everything I need to do to make this work except put up a mainwindow whose background has a stipple of "transparent", and containing a canvas which also has a transparent background.

      That's the key element I can't seem to figure out how to do (and suspect can't be done without me doing something drastic like writing my own version of a canvas and/or mainwindow).

      If I can't do it, I'll have to settle for the less aesthetically pleasing (and content occluding) grey background.