[PyQt4] 0x03. QYolk I

Programming 2016. 11. 15. 14:42

Python package 중에는 Yolk라고 하는 것이 있다.

이 사이트에 설명이 되어 있는데

자신의 시스템에 설치된 PyPI(Python Package Index)를 관리할 수 있는 툴이다.




보다시피 커맨드라인 기반 툴이기 때문에 GUI로는 볼 수 없는데, 이를 Qt로 GUI화한 것이 QYolk이다.

사실 이미 만들어져 있는 툴이기는 하다. (https://www.linux-apps.com/content/show.php/QYolk?content=107046)


처음엔 일단 List로 현재 설치된 package와 그 버전, 상태를 보도록 했다.


우선 pip install yolk 를 통해 yolk를 설치해야 하고, 파이썬 내에서 yolklib을 가져와서 사용한다.


++ 2016.11.18

- Yolk 라이브러리를 https://pypi.python.org/pypi/yolk3k 로 업데이트하면서 함수를 일부 변경하였습니다. 






 [ Source ]


- Main.py


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# -*- coding: utf-8 -*-
 
# Form implementation generated from reading ui file 'Main.ui'
#
# Created by: PyQt4 UI code generator 4.11.4
#
# WARNING! All changes made in this file will be lost!
 
from PyQt4 import QtCore, QtGui
 
try:
    _fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
    def _fromUtf8(s):
        return s
 
try:
    _encoding = QtGui.QApplication.UnicodeUTF8
    def _translate(context, text, disambig):
        return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
    def _translate(context, text, disambig):
        return QtGui.QApplication.translate(context, text, disambig)
 
class Ui_QYolk(object):
    def setupUi(self, QYolk):
        QYolk.setObjectName(_fromUtf8("QYolk"))
        QYolk.resize(565321)
        self.centralwidget = QtGui.QWidget(QYolk)
        self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
        self.treeList = QtGui.QTreeWidget(self.centralwidget)
        self.treeList.setGeometry(QtCore.QRect(1010541271))
        self.treeList.setMaximumSize(QtCore.QSize(54116777215))
        self.treeList.setObjectName(_fromUtf8("treeList"))
        self.treeList.headerItem().setTextAlignment(0, QtCore.Qt.AlignHCenter|QtCore.Qt.AlignVCenter|QtCore.Qt.AlignCenter)
        self.treeList.headerItem().setBackground(0, QtGui.QColor(230230230))
        self.treeList.headerItem().setTextAlignment(1, QtCore.Qt.AlignHCenter|QtCore.Qt.AlignVCenter|QtCore.Qt.AlignCenter)
        self.treeList.headerItem().setBackground(1, QtGui.QColor(230230230))
        self.treeList.headerItem().setTextAlignment(2, QtCore.Qt.AlignHCenter|QtCore.Qt.AlignVCenter|QtCore.Qt.AlignCenter)
        self.treeList.headerItem().setBackground(2, QtGui.QColor(230230230))
        self.treeList.header().setCascadingSectionResizes(True)
        self.treeList.header().setHighlightSections(True)
        self.treeList.header().setSortIndicatorShown(False)
        QYolk.setCentralWidget(self.centralwidget)
        self.menubar = QtGui.QMenuBar(QYolk)
        self.menubar.setGeometry(QtCore.QRect(0056521))
        self.menubar.setObjectName(_fromUtf8("menubar"))
        QYolk.setMenuBar(self.menubar)
        self.statusbar = QtGui.QStatusBar(QYolk)
        self.statusbar.setObjectName(_fromUtf8("statusbar"))
        QYolk.setStatusBar(self.statusbar)
 
        self.retranslateUi(QYolk)
        QtCore.QMetaObject.connectSlotsByName(QYolk)
 
    def retranslateUi(self, QYolk):
        QYolk.setWindowTitle(_translate("QYolk""QYolk", None))
        self.treeList.headerItem().setText(0, _translate("QYolk""Package Name", None))
        self.treeList.headerItem().setText(1, _translate("QYolk""Version", None))
        self.treeList.headerItem().setText(2, _translate("QYolk""Status", None))
 
 
cs


- Start.py


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import sys
from PyQt4 import QtCore, QtGui
from Main import Ui_QYolk
from yolk import yolklib
 
class StartQT4(QtGui.QMainWindow):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_QYolk()
        self.ui.setupUi(self)
 
        # set Column Width
        self.ui.treeList.setColumnWidth(0200)
        self.ui.treeList.setColumnWidth(1200)
 
        packages = yolklib.get_distributions('all')
        for pkg in packages:
            newItem = QtGui.QTreeWidgetItem(self.ui.treeList)
            pk = str(pkg[0]).split(' ')
            if pkg[1]:
                status = 'Active'
            else:
                status = 'Not Active'
                newItem.setTextColor(0, QtGui.QColor(128128128))
                newItem.setTextColor(1, QtGui.QColor(128128128))
                newItem.setTextColor(2, QtGui.QColor(128128128))
                
            newItem.setText(0, pk[0])
            newItem.setText(1, pk[1])
            newItem.setText(2, status)
 
if __name__ == "__main__":
    app = QtGui.QApplication(sys.argv)
    myapp = StartQT4()
    myapp.show()
    sys.exit(app.exec_())
cs


github : https://github.com/skyclad0x7b7/StudyPyQt4/tree/master/0x03.%20QYolk%20I

'Programming' 카테고리의 다른 글

[PyQt4] 0x05. Final Text Editor  (0) 2016.11.17
[PyQt4] 0x04. QYolk II  (0) 2016.11.16
[PyQt4] 0x02. Extended Text Editor  (0) 2016.11.15
[PyQt4] 0x01. PyQt4 설치, Simple text editor  (0) 2016.11.15
[Go] Defer, Panic, Recovery  (0) 2016.10.09
블로그 이미지

__미니__

E-mail : skyclad0x7b7@gmail.com 나와 계약해서 슈퍼 하-카가 되어 주지 않을래?

,