Trees | Indices | Help |
---|
|
PyQt4.QtGui.QWidget --+ | GPanel
Class to create a graphics window of default size 501x501 pixels (client drawing area) using a coordinate system with x-axis from left to right, y-axis from bottom to top (called user coordinates, default range 0..1, 0..1). The drawing methods perform drawing operation in an offscreen buffer (QPixmap) and automatically renders it on the screen, so the graphics is shown step-by-step. The drawing methods perform drawing operation in an offscreen buffer (pixmap) and automatically renders it on the screen, so the graphics is shown step-by-step. User coordinates: (ux, uy) Pixel coordinates: (px, py) (screen pixels) Transformation: px = px(ux), py = py(uy) Pixel coordinate range: 0..winWidth - 1 (inclusive), 0..winHeight - 1 (inclusive); (0,0) upper left corner, x to the right, y downwards User coordinate range: xmin..xmax (inclusive), ymin..ymax (inclusive); (0,0) lower left corner, x to the right, y upwards. Transformation: user(ux, uy) to pixel(px, py): (width = winWidth - 1, height = winHeight - 1) px = a * ux + b py = c * uy + d with a = width / (xmax - xmin) b = width * xmin / (xmin - xmax) c = height / (ymin - ymax) d = height * ymax / (ymax - ymin) Inverse: ux = (px - b) / a uy = (py - d) / c Because of the transformation from float to pixel coordinates, some rounding errors may happen. If you need pixel accuracy, define a GPanel window with some user defined width x height, e.g. GPanal(Size(501, 401)). Define then user coordinates in the range 0..width-1, 0..height-1, e.g. setUserCoords(0, 500, 0, 400). Now pixels in the range 0..500 x 0..400 (inclusive) may be addressed with no rounding errors. (This is a total of 501 x 401 pixels.) If you prefer a coordinate system with the origin at the upper left corner, define the y-range in reverse order, e.g. setUserCoords(0, 500, 400, 0). WARNING: Because PyQt is not thread-safe, in principle all graphics drawings should be executed in the GUI thread (for GPanel the main thread or a GUI callback). Typical program: from pygpanel import * p = GPanel(0, 10, 0, 10) for ypt in range(0, 11, 1): p.line(0, ypt, 10 - ypt, 0) time.sleep(0.1) # to see what happens p.keep() keep() is blocking and keeps the graphics panel open until the close button is hit or the Python process terminates.
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|
Constructs a GPanel and displays a non-resizable graphics window. Defaults with no parameter: Window size: 501x501 pixels Window title: "GPanel" User coordinates: 0, 1, 0, 1 Background color: white Pen color: black Pen size: 1 1 Parameter: Size(window_width, window_height) 4 Parameters: xmin, xmax, ymin, ymax
|
Clears the graphics window and the offscreen buffer used by the window (fully paint with background color). Sets the current graph cursor position to (0, 0). If enableRepaint(false) only clears the offscreen buffer. |
Blocks until the title bar's close button is hit. Then cleans up the graphics system. |
Sets the title in the window title bar.
|
Sets the current pen color. 1 parameter: - string value considered as X11 color string
3 parameters: values considered as RGB (alpha = 255) 4 parameters: values considered as RGBA |
Sets the current pen size (width) (>=1). Returns the previous pen size.
|
Sets user coordinate system left_x, right_x, bottom_y, top_y (inclusive).
|
Enables/Disables automatic repaint in graphics drawing methods.
|
Draws a line with given user start and end coordinates and sets the graph cursor position to the end point. Also with 2 parameters of type complex, list or tuple. 4 parameters: x1, y1, x2, y2 2 parameters: pt1, pt2 as complex/list/tuple |
Sets the current graph cursor position to given user coordinates. (without drawing anything, same as move()).
|
Sets the current graph cursor position to given user coordinates. (without drawing anything, same as pos()).
|
Draws a line form current graph cursor position to (x, y). Sets the graph cursor position to (x, y).
|
Draws a line plot with given x,y data. 1 parameter: a list/tuple of subsequent data points [x, y] 2 parameters: two lists/tuples x, y of corresponding x-y pairs The graph cursor position remains unchanged. |
Draws a text at given position (user coordinates). 1 parameter: at current graph cursor position 2 parameters: target point (comolex/list/tuple), text 3 parameters: x, y, text |
Registers the given function that is called when the title bar close button is hit. If a listener (!= None) is registered, the automatic closing is disabled. To close the window, call sys.exit(). KEEP IN MIND: To use GUI callbacks, the main program must block in the keep() function.
|
Sets the background color. All drawings are erased and the current graph cursor is set to (0, 0). 1 parameter: - string value considered as X11 color string
3 parameters: values considered as RGB (alpha = 255) 4 parameters: values considered as RGBA |
Draws a circle with center at the current graph cursor position with given radius in horizontal window coordinates.
|
Draws a filled circle with center at the current graph cursor position with given radius in horizontal window coordinates (fill color = pen color).
|
Draws an ellipse with center at the current graph cursor position with given axes.
|
Draws a filled ellipse with center at the current graph cursor position with given axes (fill color = pen color).
|
Draws a rectangle. 2 parameters: Center at the current graph cursor position and given width and height. 4 parameters: Given diagonal |
Draws a filled rectangle (fill color = pen color). 2 parameters: Center at the current graph cursor position and given width and height. 4 parameters: Given diagonal |
Draws a polygon with given list of vertexes (list of [x, y] or (x, y)) (fill color = pen color). 1 parameter: a list/tuple of the corners [x, y] or (x, y) 2 parameters: two lists/tuples x, y of corresponding x-y pairs |
Draws a filled polygon with given list of vertexes (list of [x, y] or (x, y)) (fill color = pen color). 1 parameter: a list/tuple of the corners [x, y] or (x, y) 2 parameters: two lists/tuples x, y of corresponding x-y pairs |
Draws a triangle with given corners. 6 parameters: x1, y1, x2, y2, x3, y3 coordinates of corners 3 parameters: [x1, y1], [x2, y2], [x3, y3] lists of corners |
Draws a filled triangle with given corners. 6 parameters: x1, y1, x2, y2, x3, y3 coordinates of corners 3 parameters: [x1, y1], [x2, y2], [x3, y3] lists of corners |
Draws a circle sector with center at the current graph cursor position, given radius and given start and span angles.
|
Draws a filled circle sector with center at the current graph cursor position, given radius and given start and span angles.
|
Draws a circle chord with center at the current graph cursor position, given radius and given start and span angles (in degrees, positive counter-clockwise, zero to east).
|
Draws a filled circle chord with center at the current graph cursor position, given radius and given start and span angles (in degrees, positive counter-clockwise, zero to east).
|
Starts recording the path vertexes. The positions of subsequent draw() operations are saved. The path is used to show a filled polygon when fillPath() is called. |
Draws the picture with given file path or given image at given upper-left coordinates. 1st parameter: image path (string) or QImage reference 2nd, 3rd parameters: llx, lly (lower left corner in user coordinates) |
Draws a single point with current pen size and pen color at given user coordinates. No params: draws a current graph cursor position
|
Returns the RGBA color tuple of a pixel with given user coordinates. No params: Returns color at current graph cursor position. |
Returns the X11 color string of a pixel with given user coordinates. No params: Returns color at current graph cursor position. |
Fills the closed unicolored region with the inner point (x, y) with the replacement color (RGB, RGBA or X11 color string). The old color is not given, the color of the current (x, y) pixel is taken.
|
Draws a coordinate system with annotated axes. (You must increase the user coordinate system at least 10% in both directions.) drawGrid(x, y): Grid with 10 ticks in range 0..x, 0..y. Label text depends if x, y or int or float drawGrid(x, y, color): same with given grid color drawGrid(x1, x2, y1, y2): same with given span x1..x2, y1..y2 drawGrid(x1, x2, y1, y2, color): same with given grid color drawGrid(x1, x2, y1, y2, x3, y3): same with given number of ticks x3, y3 in x- and y-direction |
Registers a callback that is invoked when a mouse button is pressed. Use isLeftMouseButton() or isRightMouseButton() to check which button used. KEEP IN MIND: To use GUI callbacks, the main program must block in the keep() function.
|
Registers a callback that is invoked when a mouse button is releases. Use isLeftMouseButton() or isRightMouseButton() to check which button used. KEEP IN MIND: To use GUI callbacks, the main program must block in the keep() function.
|
Registers a callback that is invoked when the mouse is moved while a mouse button is pressed (drag). KEEP IN MIND: To use GUI callbacks, the main program must block in the keep() function.
|
Registers a callback that is invoked when a key is pressed (and the graphics window has the focus). KEEP IN MIND: To use GUI callbacks, the main program must block in the keep() function.
|
Registers a callback that is invoked when a key is released (and the graphics window has the focus). KEEP IN MIND: To use GUI callbacks, the main program must block in the keep() function.
|
Sets the screen position of the graphics window.
|
Saves the current graphics into a image buffer. Use restoreGraphics() to restore it. |
Restores the saved graphics from the image buffer. Use saveGraphics() to save it. |
Performs pixel color XOR operation with the existing background pixel. Be aware that if the background is white, drawing with a white pen shows a black pixel. (Parameter not used, for TigerJython compatibility) |
Draws an arrow from point pt1 = [x1, y1] to pt2 = [x2, y2] @param pt1 the starting point
|
Draws a double arrow from point pt1 = [x1, y1] to pt2 = [x2, y2] (arrowheads on both ends). @param pt1 one end of the arrow
|
Returns a QImage of the picture loaded from the given file. For pic_format = None, the picture format is guessed from the file data.
|
Returns a tuple with the RGBA values at given pixel position (pixel coordinates).
|
Returns a new QImage of the scaled picture of the given QImage.
|
Returns a QImage of the sub-area of the given QImage.
|
Returns the tuple of user coordinates of the point on the line through the point pt1 = (x1, y1) and the point pt2 = (x2, y2) that is in distance ratio times the length from pt1 to pt2 from pt1. For ratio < 0 the point is in the opposite direction. 3 parameteters: pt1, pt2 (complex/list/tuple), ratio 5 parameteters: x1, y1, x2, y2, ratio |
Fills a bounded single-colored region with the given color. The given point is part of the region and used to specify it. @param pm the pixmap containing the connected region @param pt a point inside the region @param oldColor the old color of the region (RGB list/tuple) @param newColor the new color of the region (RGB list/tuple) @return a new qImage with the transformed region |
Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Sun Apr 16 12:46:33 2017 | http://epydoc.sourceforge.net |