On a Google Search, I found this article:
http://docs.python.org/release/1.4/lib/node201.html
Which showed examples of using the rect class, to perform union/intersections/ch开发者_开发问答ecking if points are inside rect. Importing rect fails in Python 2.7. Is this class in another package?
I assume the question isn't really "what happened to it?", but "where can I find a class like this that I can use?".
Most GUI libraries have a class like this. For example: wx.Rect, QRect/QRectF, gtk.gdk.Rectangle, PyGame rect.
If you want a generic rectangle class without the overhead of a GUI library, I think your only option is Sympy, which has a Geometry module that may suit your needs.
Finally, you may just choose to roll your own. It's not very hard to make such a class.
It's part of the Standard Windowing interface. To quote from the documentation you yourself linked to:
Using STDWIN is not recommended for new applications. It has never been ported to Microsoft Windows or Windows NT, and for X11 or the Macintosh it lacks important functionality -- in particular, it has no tools for the construction of dialogs.
The stdwin
module containing rect
class was obsolete since version 1.6 (see these notes) and I believe it was removed in some later version.
I think the rest of the answers have covered you. However I was in your shoes, and made a generic module to benefit more people. You can find the project here. The module works with both negative and positive numbers on a screen coordinate system (y grows downwards of screen, x grows to the right).
Some methods supported:
- Distance from one rectangle to an other
- See if rectangles overlap on x, y or both axis (default)
- See if a point is inside a rectangle
- Align rectangles
精彩评论