余録:worldCup/jython/ex06/wcFrame.py

#! /usr/bin/env python
# coding: utf-8
## ----------------------------------------
##
## (C) Copyright 2000-2010, 小粒ちゃん《監修》小泉ひよ子とタマゴ倶楽部
##
## ----------------------------------------
## History: Swing Example "2010 FIFA World Cup South Africa™"
##      2003/07, Java/Jython
##      2006/07, Jython
##      2008/02, Jython 2.2.1
##      2010/06, Jython 2.5.0
#...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
"""
>>> tips()

>>> ## ----------------------------------------
>>> None
version: #1.0.10
"""
from __init__ import *

## ---------------------------------------- demo: jython
"""
$ cd /Users/sketch/home_sketch/worldCup/jython/
$ jython -i ex06/wcFrame.py

"""
## ----------------------------------------
from javax.swing import ImageIcon
from javax.swing import JFrame
from javax.swing import JLabel
from javax.swing import JPanel
from javax.swing import JSplitPane
from javax.swing import JScrollPane

class TopPanel(JPanel):
    def __init__(self, master, *args, **keys):
        master.contentPane = self

        def leftComponent():
            view = JLabel(
                icon = ImageIcon("matches/wc2010logo.png"),
                text = u"2010 FIFA World Cup South Africa™",
                horizontalAlignment = JLabel.CENTER,
                verticalTextPosition = JLabel.TOP,
                horizontalTextPosition = JLabel.CENTER,
                )
            comp = JScrollPane(
                viewportView = view,
                preferredSize = (120,150),
                )
            return comp

        def rightComponent():
            view = JLabel(
                icon = ImageIcon("matches/fifa.png"),
                )
            comp = JScrollPane(
                viewportView = view,
                preferredSize = (180,0),
                )
            return comp

        def splitPane():
            comp = JSplitPane(
                orientation = JSplitPane.HORIZONTAL_SPLIT,
                oneTouchExpandable = True,
                dividerLocation = 100,
                leftComponent  = leftComponent(),
                rightComponent = rightComponent(),
                )
            return comp

        comp = splitPane()
        self.add(comp)
        master.pack()

## ----------------------------------------
def tips():
    global Qt; Qt = \
    frame = JFrame(
        title = "FIFA World Cup #06",
        size = (320,180),
        locationRelativeTo = None,
        defaultCloseOperation = JFrame.EXIT_ON_CLOSE,
        )
    TopPanel(frame)
    frame.visible = True

## ----------------------------------------
if __name__=='__main__':
    inform()
    testmod()

## ========================================