summaryrefslogtreecommitdiffstats
path: root/lib/jython/Lib/pawt
diff options
context:
space:
mode:
authorjhugunin <jhugunin>2003-01-03 23:19:47 +0000
committerjhugunin <jhugunin>2003-01-03 23:19:47 +0000
commit8ec8f0c0c6c68d9b13c3bc3416c3234eddd48379 (patch)
tree8a2e07ba2a0048aae570053e019e02bd093f175f /lib/jython/Lib/pawt
parentf685f979a4d3eb3844f74850deece1da265bc975 (diff)
downloadaspectj-8ec8f0c0c6c68d9b13c3bc3416c3234eddd48379.tar.gz
aspectj-8ec8f0c0c6c68d9b13c3bc3416c3234eddd48379.zip
making jython-2.1 available for scripting
Diffstat (limited to 'lib/jython/Lib/pawt')
-rw-r--r--lib/jython/Lib/pawt/__init__.py35
-rw-r--r--lib/jython/Lib/pawt/colors.py144
-rw-r--r--lib/jython/Lib/pawt/swing.py42
3 files changed, 221 insertions, 0 deletions
diff --git a/lib/jython/Lib/pawt/__init__.py b/lib/jython/Lib/pawt/__init__.py
new file mode 100644
index 000000000..5f37e6c76
--- /dev/null
+++ b/lib/jython/Lib/pawt/__init__.py
@@ -0,0 +1,35 @@
+import sys
+from java import awt
+
+def test(panel, size=None, name='AWT Tester'):
+ f = awt.Frame(name, windowClosing=lambda event: sys.exit(0))
+ if hasattr(panel, 'init'):
+ panel.init()
+
+ f.add('Center', panel)
+ f.pack()
+ if size is not None:
+ f.setSize(apply(awt.Dimension, size))
+ f.setVisible(1)
+ return f
+
+class GridBag:
+ def __init__(self, frame, **defaults):
+ self.frame = frame
+ self.gridbag = awt.GridBagLayout()
+ self.defaults = defaults
+ frame.setLayout(self.gridbag)
+
+ def addRow(self, widget, **kw):
+ kw['gridwidth'] = 'REMAINDER'
+ apply(self.add, (widget, ), kw)
+
+ def add(self, widget, **kw):
+ constraints = awt.GridBagConstraints()
+
+ for key, value in self.defaults.items()+kw.items():
+ if isinstance(value, type('')):
+ value = getattr(awt.GridBagConstraints, value)
+ setattr(constraints, key, value)
+ self.gridbag.setConstraints(widget, constraints)
+ self.frame.add(widget)
diff --git a/lib/jython/Lib/pawt/colors.py b/lib/jython/Lib/pawt/colors.py
new file mode 100644
index 000000000..36ae53d9f
--- /dev/null
+++ b/lib/jython/Lib/pawt/colors.py
@@ -0,0 +1,144 @@
+from java.awt import Color
+
+aliceblue = Color(240, 248, 255)
+antiquewhite = Color(250, 235, 215)
+aqua = Color(0, 255, 255)
+aquamarine = Color(127, 255, 212)
+azure = Color(240, 255, 255)
+beige = Color(245, 245, 220)
+bisque = Color(255, 228, 196)
+black = Color(0, 0, 0)
+blanchedalmond = Color(255, 235, 205)
+blue = Color(0, 0, 255)
+blueviolet = Color(138, 43, 226)
+brown = Color(165, 42, 42)
+burlywood = Color(222, 184, 135)
+cadetblue = Color(95, 158, 160)
+chartreuse = Color(127, 255, 0)
+chocolate = Color(210, 105, 30)
+coral = Color(255, 127, 80)
+cornflowerblue = Color(100, 149, 237)
+cornsilk = Color(255, 248, 220)
+crimson = Color(220, 20, 60)
+cyan = Color(0, 255, 255)
+darkblue = Color(0, 0, 139)
+darkcyan = Color(0, 139, 139)
+darkgoldenrod = Color(184, 134, 11)
+darkgray = Color(169, 169, 169)
+darkgreen = Color(0, 100, 0)
+darkkhaki = Color(189, 183, 107)
+darkmagenta = Color(139, 0, 139)
+darkolivegreen = Color(85, 107, 47)
+darkorange = Color(255, 140, 0)
+darkorchid = Color(153, 50, 204)
+darkred = Color(139, 0, 0)
+darksalmon = Color(233, 150, 122)
+darkseagreen = Color(143, 188, 143)
+darkslateblue = Color(72, 61, 139)
+darkslategray = Color(47, 79, 79)
+darkturquoise = Color(0, 206, 209)
+darkviolet = Color(148, 0, 211)
+deeppink = Color(255, 20, 147)
+deepskyblue = Color(0, 191, 255)
+dimgray = Color(105, 105, 105)
+dodgerblue = Color(30, 144, 255)
+firebrick = Color(178, 34, 34)
+floralwhite = Color(255, 250, 240)
+forestgreen = Color(34, 139, 34)
+fuchsia = Color(255, 0, 255)
+gainsboro = Color(220, 220, 220)
+ghostwhite = Color(248, 248, 255)
+gold = Color(255, 215, 0)
+goldenrod = Color(218, 165, 32)
+gray = Color(128, 128, 128)
+green = Color(0, 128, 0)
+greenyellow = Color(173, 255, 47)
+honeydew = Color(240, 255, 240)
+hotpink = Color(255, 105, 180)
+indianred = Color(205, 92, 92)
+indigo = Color(75, 0, 130)
+ivory = Color(255, 255, 240)
+khaki = Color(240, 230, 140)
+lavender = Color(230, 230, 250)
+lavenderblush = Color(255, 240, 245)
+lawngreen = Color(124, 252, 0)
+lemonchiffon = Color(255, 250, 205)
+lightblue = Color(173, 216, 230)
+lightcoral = Color(240, 128, 128)
+lightcyan = Color(224, 255, 255)
+lightgoldenrodyellow = Color(250, 250, 210)
+lightgreen = Color(144, 238, 144)
+lightgrey = Color(211, 211, 211)
+lightpink = Color(255, 182, 193)
+lightsalmon = Color(255, 160, 122)
+lightseagreen = Color(32, 178, 170)
+lightskyblue = Color(135, 206, 250)
+lightslategray = Color(119, 136, 153)
+lightsteelblue = Color(176, 196, 222)
+lightyellow = Color(255, 255, 224)
+lime = Color(0, 255, 0)
+limegreen = Color(50, 205, 50)
+linen = Color(250, 240, 230)
+magenta = Color(255, 0, 255)
+maroon = Color(128, 0, 0)
+mediumaquamarine = Color(102, 205, 170)
+mediumblue = Color(0, 0, 205)
+mediumorchid = Color(186, 85, 211)
+mediumpurple = Color(147, 112, 219)
+mediumseagreen = Color(60, 179, 113)
+mediumslateblue = Color(123, 104, 238)
+mediumspringgreen = Color(0, 250, 154)
+mediumturquoise = Color(72, 209, 204)
+mediumvioletred = Color(199, 21, 133)
+midnightblue = Color(25, 25, 112)
+mintcream = Color(245, 255, 250)
+mistyrose = Color(255, 228, 225)
+moccasin = Color(255, 228, 181)
+navajowhite = Color(255, 222, 173)
+navy = Color(0, 0, 128)
+oldlace = Color(253, 245, 230)
+olive = Color(128, 128, 0)
+olivedrab = Color(107, 142, 35)
+orange = Color(255, 165, 0)
+orangered = Color(255, 69, 0)
+orchid = Color(218, 112, 214)
+palegoldenrod = Color(238, 232, 170)
+palegreen = Color(152, 251, 152)
+paleturquoise = Color(175, 238, 238)
+palevioletred = Color(219, 112, 147)
+papayawhip = Color(255, 239, 213)
+peachpuff = Color(255, 218, 185)
+peru = Color(205, 133, 63)
+pink = Color(255, 192, 203)
+plum = Color(221, 160, 221)
+powderblue = Color(176, 224, 230)
+purple = Color(128, 0, 128)
+red = Color(255, 0, 0)
+rosybrown = Color(188, 143, 143)
+royalblue = Color(65, 105, 225)
+saddlebrown = Color(139, 69, 19)
+salmon = Color(250, 128, 114)
+sandybrown = Color(244, 164, 96)
+seagreen = Color(46, 139, 87)
+seashell = Color(255, 245, 238)
+sienna = Color(160, 82, 45)
+silver = Color(192, 192, 192)
+skyblue = Color(135, 206, 235)
+slateblue = Color(106, 90, 205)
+slategray = Color(112, 128, 144)
+snow = Color(255, 250, 250)
+springgreen = Color(0, 255, 127)
+steelblue = Color(70, 130, 180)
+tan = Color(210, 180, 140)
+teal = Color(0, 128, 128)
+thistle = Color(216, 191, 216)
+tomato = Color(255, 99, 71)
+turquoise = Color(64, 224, 208)
+violet = Color(238, 130, 238)
+wheat = Color(245, 222, 179)
+white = Color(255, 255, 255)
+whitesmoke = Color(245, 245, 245)
+yellow = Color(255, 255, 0)
+yellowgreen = Color(154, 205, 50)
+
+del Color
diff --git a/lib/jython/Lib/pawt/swing.py b/lib/jython/Lib/pawt/swing.py
new file mode 100644
index 000000000..debe9b975
--- /dev/null
+++ b/lib/jython/Lib/pawt/swing.py
@@ -0,0 +1,42 @@
+"""
+A hack to make pawt.swing point to the java swing library.
+This allows code which imports pawt.swing to work on both JDK1.1 and 1.2
+"""
+swing = None
+
+try:
+ import javax.swing.Icon
+ from javax import swing
+except (ImportError, AttributeError):
+ try:
+ import java.awt.swing.Icon
+ from java.awt import swing
+ except (ImportError, AttributeError):
+ try:
+ import com.sun.java.swing.Icon
+ from com.sun.java import swing
+ except (ImportError, AttributeError):
+ raise ImportError, 'swing not defined in javax.swing or java.awt.swing or com.sun.java.swing'
+import sys
+def test(panel, size=None, name='Swing Tester'):
+ f = swing.JFrame(name, windowClosing=lambda event: sys.exit(0))
+ if hasattr(panel, 'init'):
+ panel.init()
+
+ f.contentPane.add(panel)
+ f.pack()
+ if size is not None:
+ from java import awt
+ f.setSize(apply(awt.Dimension, size))
+ f.setVisible(1)
+ return f
+
+if swing is not None:
+ import pawt, sys
+ pawt.swing = swing
+ sys.modules['pawt.swing'] = swing
+ swing.__dict__['test'] = test
+
+ #These two lines help out jpythonc to figure out this very strange module
+ swing.__dict__['__file__'] = __file__
+ swing.__dict__['__jpythonc_name__'] = 'pawt.swing'