winop changes window
winop gradients leftcolor rightcolor gradients
winop image subcommand ...
winop image alpha srcImage destImage color
winop image colors ?-alpha? srcImage
winop image convolve srcImage destImage filter
winop image gradient image leftcolor rightcolor ...
winop image merge srcImage1 srcImage2 destImage ?alpha? ?...?
winop image mirror srcImage1 destImage ?x|y|xy|tile|outer|inner?
winop image quantize srcImage destImage ?nColors?
winop image readjpeg filename photoname
winop image resample srcImage destImage ?horizFilter? ?vertFilter?
winop image rotate srcImage destImage angle
winop image subsample srcImage destImage x y width height ?horizFilter? ?vertFilter?
winop lower ?window?...
winop map ?window?...
winop move window x y
winop raise ?window?...
winop snap window photoName ?width height ?
winop unmap ?window?...
winop warpto ?window?
DESCRIPTIONThe winop command performs various window and image operations on Tk windows using low-level Xlib function calls to work around window manager pecularities.
INTRODUCTIONTk has several commands for manipulating its windows: raise, lower, wm, etc. These commands ask the window manager to perform operations on Tk windows. In some cases, a particular window manager won't perform the operation as expected.
For example, if you positioned a toplevel window using wm geometry, the window may not actually be at those particular coordinates. The position of the window may be offset by dimensions of the title bar added by the window manager.
In situations like these, the winop command can be used to workaround these difficulties. Instead, it makes low-level Xlib (such XRaiseWindow and XMapWindow) calls to perform these operations.
toplevel .top wm withdraw .top # Set the geometry to make the window manager # place the window. wm geometry .top +100+100 # Move the window to the desired location # and "update" to force the window manager # to recognize it. winop move .top 100 100 update wm deiconify .top winop move .top 100 100
OPERATIONSThe following operations are available for the winop command:
- winop changes window
- Realize window.
- winop image subcommand ...
- winop image alpha ?-shift? srcImage destImage color ?alpha? ?withalpha?
- Set image pixels of the given color to transparent. If an alpha value is not given, it defaults to 0 (meaning transparent). An alpha of 255 is used for solid. The srcImage and destImage may be the same. If the color is * any color is matched. If color is prefixed with ! match is inverted.
- winop gradients leftcolor rightcolor width
- Return a list of width colors that graduate from leftcolor to the color just before rightcolor. Note that the last color in the returned list is not rightcolor. A typical use for this is calculating shadow colors.
- winop image blur srcImage dstImage ?radius?
- Blur an image using gaussian blur.
- winop image colors ?-alpha? ?-count? srcImage
- Return list of distinct colors. If -alpha is given, the alpha is appended to each color after a colon, eg #FF0000:00. If -count is given, returns color/count pairs.
- winop image convolve srcImage destImage filter
- Convolve an image: filter is a list of numbers. The srcImage and destImage may be the same.
- winop image gradient image leftcolor rightcolor ...
Generate a gradient from left to right into image.
The following options are available:
- -type halfsine|sine|linear|rectangular|radial|split|blank
- Set the type of gradient. The default is sine.
- -skew N
- The skew determines the initial fraction of the image that the gradient occupies, after which only rightcolor is used. The skew must be > 0 and <= 1.0. The default value is 1.0, meaning not skewed.
- -slant N
- Make the gradient slant where a value of 1.0 slants at 45 degrees. The value must be between -100.0 and 100.0.
- -mathval N
- Curve the gradient by passing the Y position to the function -mathfunc. The value must be between -100.0 and 100.0 (typically 1.0). The default is 0.0, which means disabled.
- -mathfunc X
- Function to use with -mathval. The default value is sin. The value must be one of: sin cos tan sinh cosh tanh asin acos atan log log10 exp sqrt rand circle.
- -rand N
- Add small random purturbations to gradient to avoid striation lines. The value must be between 0.0 and 0.1.
- -height N
- Change the image height.
- -width N
- Change the image width.
- winop image merge srcImage1 srcImage2 destImage ?opacity? ?opacity2?
- Merge two images with alpha blending. The default ?opacity? is 0.5, and the default for ?opacity2? is 1.0 - ?opacity?.
- winop image mirror srcImage1 destImage ?x|y|xy|tile|outer|inner? ?halo?
- Flips an image on axis x, y or xy. The tile option results in a double size image with mirror copies appended to generate a tile-able image. The outer option is used to resize an image while preserving the outside border by halo pixels (default is 16). The inner option copies from the center of source keeping it centered. These last 2 are used implicitly by blt::tile::button -bdtile, etc. The srcImage1 and destImage must not be the same if using tile, inner or outer. The default is xy.
- winop image quantize srcImage destImage ?nColors?
- Limit number of colors in image. Default 1. The srcImage and destImage may be the same.
- winop image readjpeg filename photoname
- Read a jpeg image using libjpeg. IMG makes this obsolete (and thus probably not builtin).
- winop image recolor srcImage destImage oldColor newColor ?alpha?
- Change pixels from oldColor to newColor. If ?alpha? is not given it defaults to 255 (opaque). The srcImage and destImage may be the same.
- winop image resample srcImage destImage ?horizFilter? ?vertFilter?
- Resample an image. If srcImage and destImage are the same size, just makes a copy. Otherwise the image is resized to the size of destImage, possibly wih filtering. Filters are one of: bell bessel box bspline catrom default dummy gauss8 gaussian gi lanczos3 mitchell none sinc triangle. The destImage must be greater than 1x1.
- winop image rotate srcImage destImage angle
- Rotate an image. The srcImage and destImage may be the same.
- winop image subsample srcImage destImage x y width height ?horizFilter? ?vertFilter?
- Resample area of an image. See resample.
- winop image trans image x y ?alpha?
- Get or set the integer alpha value within an image.
- winop lower ?window?...
- Lowers window to the bottom of the X window stack. Window is the path name of a Tk window.
- winop map ?window?...
- Maps window on the screen. Window is the path name of a Tk window. If window is already mapped, this command has no effect.
- winop move window x y
- Move window to the screen location specified by x and y. Window is the path name of a Tk window, while x and y are screen coordinates. This command returns the empty string.
- winop query
- Query pointer position. Returns @X,Y.
- winop raise ?window?...
- Raises window to the top of the X window stack. Window must be a valid path name of a Tk window. This command returns the empty string.
- winop snap window photoName ?width height?
- Takes a snapshot of the window and stores the contents in the photo image photoName. Window is the valid path name of a Tk window which must be totally visible (unobscured). PhotoName is the name of a Tk photo image which must already exist. This command can fail if the window is obscured in any fashion, such as covered by another window or partially offscreen. In that case, an error message is returned. If width or height is given, the image is resampled to the given size.
- winop unmap ?window?...
- Unmaps window from the screen. Window is the path name of a Tk window.
- winop warpto ?window?
Warps the pointer to window. Window is the path name of a Tk window
which must be mapped. If window is in the form @x,y, where
x and y are root screen coordinates, the pointer is warped to
that location on the screen.
[I've never heard a good case for warping the pointer in an application. It can be useful for testing, but in applications, it's always a bad idea. Simply stated, the user owns the pointer, not the application. If you have an application that needs it, I'd like to hear about it.]
If no window argument is present the current location of the pointer is returned. The location is returned as a list in the form "x y", where x and y are the current coordinates of the pointer.
KEYWORDSwindow, map, raise, lower, pointer, warp