Help us understand the problem. What is going on with this article?

Pyside を使ったカラーピッカー(色選択ツール)のサンプル

More than 5 years have passed since last update.

ありがちですが、Pysideのサンプルとして作成しました。
習作程度の代物なのであまり実用的ではありません。

ColorPicker.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
from PySide import QtCore, QtGui
'''
ColorPicker.py
Pyside を使ったカラーピッカー(色選択ツール)
'''


class colorPicker (QtGui.QWidget):

    def __init__(self):
        super(colorPicker, self).__init__()
        self.initUI()

    def initUI(self):
        '''
        ユーザーインターフェースの初期化
        '''
        self.infoLabel = QtGui.QLabel()
        self.colorLabel = QtGui.QLabel()
        self.colorButton = QtGui.QPushButton('QColorDialog.get&Color()')
        self.colorButton.clicked.connect(self.setColor)

        layout = QtGui.QVBoxLayout()
        layout.addWidget(self.infoLabel)
        layout.addWidget(self.colorLabel)
        layout.addWidget(self.colorButton)

        self.setLayout(layout)
        self.resize(300, 150)
        self.setWindowTitle('Color Picker')

    def setColor(self):
        '''
        ダイアログを出して色選択
        '''
        color = QtGui.QColorDialog.getColor(QtCore.Qt.green, self)
        if color.isValid():
            self.colorLabel.setPalette(QtGui.QPalette(color))
            self.colorLabel.setAutoFillBackground(True)
            self.infoLabel.setText('color(#RGB) = ' + color.name())


def main():
    app = QtGui.QApplication(sys.argv)
    window = colorPicker()
    window.show()
    return app.exec_()

if __name__ == '__main__':
    main()
# EOF


Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away