~/PyTour/DP/Swing/Color-Swing/step00/ColorTips.py

INDEX Python.use(better)

》作業中です《

#! /usr/bin/env python
# coding: utf-8
## ----------------------------------------
##
## (C) Copyright 2000-2010, 小粒ちゃん《監修》小泉ひよ子とタマゴ倶楽部
##
## ----------------------------------------
#...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
"""
>>> tips()

>>> ## ----------------------------------------
>>> None
version: #1.0.30
"""
## ---------------------------------------- bash
"""
stty erase ^H
PS1="$ "
alias jython="/Users/sketch/home_Jython/_release/jython2.5.0/bin/jython"
"""
## ---------------------------------------- Java/Jython
## ---------------------------------------- JFC/Swing
## ---------------------------------------- demo: java
## ---------------------------------------- demo: jython
"""
$ cd ~/PyTour/DP/Swing/Color-Swing/step03/
$ jython -i ColorTips.py

"""
## ----------------------------------------
Qmodel = Qview = Qwindow = None

def tips():
    global Qwindow; Qwindow = \
    window = Window("Color: step5")
    window.open(800, 100, 250, 100)

## ----------------------------------------
from javax.swing import DefaultListModel
from javax.swing import JFrame
from javax.swing import JScrollPane
from javax.swing import JSplitPane

from ColorModel import ColorModel
from ColorView import CanvasView, TextView, PopWindow
from ColorController import ListView

## ----------------------------------------
class Window(JFrame):
    def __init__(self, *args, **keys):
        super(self.__class__,self).__init__(
            contentPane = View(),
            defaultCloseOperation = JFrame.EXIT_ON_CLOSE,
            *args
            )

    def open(self, x=0, y=0, w=150, h=100):
        self.bounds = x, y, w, h
        self.visible = True

## ----------------------------------------
class View(JSplitPane):
    def __init__(self, *args, **keys):
        self.model = ColorModel()
        
        controlPane = self._controlPane(
            items = self.model.colorNames,
            )
        canvasPane = self._canvasPane(
            minimumSize = (50,100),
            )
        super(self.__class__,self).__init__(
            leftComponent = controlPane,
            rightComponent = canvasPane,
            orientation = JSplitPane.HORIZONTAL_SPLIT,
            dividerLocation = 150,
            )

        ## ----------------------------------------
        textView = TextView(
            subject = self.listView,
            )
        window = PopWindow(
            contentPane = textView,
            )
        textView.window = window
        window.open(800, 210, 150, 100)

    def _controlPane(self, items):
        model = DefaultListModel()
        for e in items:
            model.addElement(e)
        global Qview; Qview = \
        self.listView = \
        comp = ListView(
            client = self,
            model = model,
            )
        pane = JScrollPane(
            viewportView = comp,
            )
        return pane

    def _canvasPane(self, **keys):
        comp = CanvasView(
            subject = self.listView,
            )
        return comp

    def color(self, value):
        return self.model.color(value)

## ----------------------------------------
## ----------------------------------------
from time import ctime
from sys import argv, version

def inform(n=60):
    print("="*n)
    print("Version: %s"%version.split("\n")[0])
    print("Module : %s"%argv[0].split("/")[-1])
    print("Date   : %s"%ctime())
    print("="*n)

## ----------------------------------------
from doctest import testmod

if __name__=='__main__':
    inform()
    testmod()
##    testmod(name="ColorModel.py")

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

Last updated♪2010/04/01