Пример #1
0
    def init(self):
        bag = GridBag(self)

        self.framedArea = FramedArea(self)
        bag.addRow(self.framedArea, weighty=1.0, fill='BOTH')

        self.label = awt.Label('Click within the framed area')
        bag.addRow(self.label, weightx=1.0, weighty=0.0, fill='HORIZONTAL')
Пример #2
0
    def init(self):
        self.choices = awt.Choice(itemStateChanged=self.change)
        for item in ['ichi', 'ni', 'san', 'yon']:
            self.choices.addItem(item)

        self.label = awt.Label()
        self.change()

        self.add(self.choices)
        self.add(self.label)
Пример #3
0
    def __init__(self, title, units, controller):
        self.units = units
        self.controller = controller

        bag = GridBag(self, fill='HORIZONTAL')

        label = awt.Label(title, awt.Label.CENTER)
        bag.addRow(label)

        self.text = awt.TextField('0', 10, actionListener=self)
        bag.add(self.text, weightx=1.0)

        self.chooser = awt.Choice(itemListener=self)
        for name, multiplier in units:
            self.chooser.add(name)
        bag.addRow(self.chooser)

        self.slider = awt.Scrollbar(awt.Scrollbar.HORIZONTAL,
                                    maximum=self.max + 10,
                                    blockIncrement=self.block,
                                    adjustmentListener=self)
        bag.add(self.slider)
Пример #4
0
    n1 = getField(f1)
    n2 = getField(f2)
    sum.setText(repr(n1 + n2))
    diff.setText(repr(n1 - n2))
    prod.setText(repr(n1 * n2))
    quo.setText(repr(n1 / n2))


f = awt.Frame('BSH Calculator (jpython)', windowClosing=exit)

f1 = awt.TextField(20, actionPerformed=doMath)
f2 = awt.TextField(20, textValueChanged=doMath)

p = awt.Panel()
p.setLayout(awt.GridLayout(2, 2))
p.add(awt.Label('Enter Operand'))
p.add(f1)
p.add(awt.Label('Enter Operand'))
p.add(f2)

f.add('North', p)

f.add("Center", awt.Label('Results:'))

p = awt.Panel()
p.setLayout(awt.GridLayout(4, 2))
p.add(awt.Label('Sum'))
sum = awt.TextField(20)
p.add(sum)
p.add(awt.Label('Difference'))
diff = awt.TextField(20)
Пример #5
0
"""\
Create a panel showing all of the colors defined in the pawt.colors module
Display the names of bright colors in black and of dark colors in white
"""

from java import awt
from pawt import colors, test
from math import sqrt

p = awt.Panel()
for name in dir(colors):
    color = getattr(colors, name)
    if isinstance(color, awt.Color):
        l = awt.Label(name, awt.Label.CENTER, background=color)
        intensity = sqrt(color.red**2 + color.green**2 + color.blue**2) / 3
        if intensity < 90: l.foreground = colors.white
        p.add(l)

test(p, size=(700, 500))