[PyQt4] 0x04. QYolk II

Programming 2016. 11. 16. 10:17

이전에 짰던 QYolk에 탭을 추가하여 Active상태인 것과 Not Active 상태인 것을 나눠서 볼 수 있게 하였다.

밑에 Label도 추가하여 탭을 변경 시 해당 탭에 대한 설명이 간략하게 나타나도록 설정하였다.



++ 2016.11.18

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

- ui에서 Version을 Package name이라고 잘못 작성하여 수정하였습니다.






 [ 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# -*- 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(565345)
        self.centralwidget = QtGui.QWidget(QYolk)
        self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
        self.tab_widget = QtGui.QTabWidget(self.centralwidget)
        self.tab_widget.setGeometry(QtCore.QRect(100551291))
        self.tab_widget.setObjectName(_fromUtf8("tab_widget"))
        self.tab_all_packages = QtGui.QWidget()
        self.tab_all_packages.setObjectName(_fromUtf8("tab_all_packages"))
        self.all_list = QtGui.QTreeWidget(self.tab_all_packages)
        self.all_list.setGeometry(QtCore.QRect(00541261))
        self.all_list.setObjectName(_fromUtf8("all_list"))
        self.tab_widget.addTab(self.tab_all_packages, _fromUtf8(""))
        self.tab_active = QtGui.QWidget()
        self.tab_active.setObjectName(_fromUtf8("tab_active"))
        self.active_list = QtGui.QTreeWidget(self.tab_active)
        self.active_list.setGeometry(QtCore.QRect(00541261))
        self.active_list.setObjectName(_fromUtf8("active_list"))
        self.tab_widget.addTab(self.tab_active, _fromUtf8(""))
        self.tab_not_active = QtGui.QWidget()
        self.tab_not_active.setObjectName(_fromUtf8("tab_not_active"))
        self.not_active_list = QtGui.QTreeWidget(self.tab_not_active)
        self.not_active_list.setGeometry(QtCore.QRect(00541261))
        self.not_active_list.setObjectName(_fromUtf8("not_active_list"))
        self.tab_widget.addTab(self.tab_not_active, _fromUtf8(""))
        self.info_label = QtGui.QLabel(self.centralwidget)
        self.info_label.setGeometry(QtCore.QRect(1028554131))
        self.info_label.setObjectName(_fromUtf8("info_label"))
        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)
        self.tab_widget.setCurrentIndex(0)
        QtCore.QMetaObject.connectSlotsByName(QYolk)
 
    def retranslateUi(self, QYolk):
        QYolk.setWindowTitle(_translate("QYolk""QYolk II", None))
        self.all_list.headerItem().setText(0, _translate("QYolk""Package Name", None))
        self.all_list.headerItem().setText(1, _translate("QYolk""Version", None))
        self.all_list.headerItem().setText(2, _translate("QYolk""Status", None))
        self.tab_widget.setTabText(self.tab_widget.indexOf(self.tab_all_packages), _translate("QYolk""All Packages", None))
        self.active_list.headerItem().setText(0, _translate("QYolk""Package Name", None))
        self.active_list.headerItem().setText(1, _translate("QYolk""Version", None))
        self.active_list.headerItem().setText(2, _translate("QYolk""Status", None))
        self.tab_widget.setTabText(self.tab_widget.indexOf(self.tab_active), _translate("QYolk""Active", None))
        self.not_active_list.headerItem().setText(0, _translate("QYolk""Package Name", None))
        self.not_active_list.headerItem().setText(1, _translate("QYolk""Version", None))
        self.not_active_list.headerItem().setText(2, _translate("QYolk""Status", None))
        self.tab_widget.setTabText(self.tab_widget.indexOf(self.tab_not_active), _translate("QYolk""Not Active", None))
        self.info_label.setText(_translate("QYolk""TextLabel", 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
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
63
64
65
66
67
68
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)
        self.ui.info_label.setText("")
 
        # set Column Width
        self.ui.all_list.setColumnWidth(0200)
        self.ui.all_list.setColumnWidth(1200)
        self.ui.active_list.setColumnWidth(0200)
        self.ui.active_list.setColumnWidth(1200)
        self.ui.not_active_list.setColumnWidth(0200)
        self.ui.not_active_list.setColumnWidth(1200)
 
        QtCore.QObject.connect(self.ui.tab_widget, QtCore.SIGNAL("currentChanged(int)"), self.tab_changed)
 
        packages = yolklib.get_distributions('all')
        for pkg in packages:
            newItem = QtGui.QTreeWidgetItem(self.ui.all_list)
            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)
 
        for pkg in yolklib.get_distributions('active'):
            newItem = QtGui.QTreeWidgetItem(self.ui.active_list)
            pk = str(pkg[0]).split(' ')
            newItem.setText(0, pk[0])
            newItem.setText(1, pk[1])
            newItem.setText(2'Active')
 
        for pkg in yolklib.get_distributions('nonactive'):
            newItem = QtGui.QTreeWidgetItem(self.ui.not_active_list)
            pk = str(pkg[0]).split(' ')
            newItem.setText(0, pk[0])
            newItem.setText(1, pk[1])
            newItem.setText(2'Not Active')
 
    def tab_changed(self, column):
        if column == 0:
            message = "<b>QYolk</b> : Browsing all installed cheeseshop packages"
        elif column == 1:
            message = "<b>QYolk</b> : Browsing active packages"
        elif column == 2:
            message = "<b>QYolk</b> : Browsing not active packages (older versions)"
 
        self.ui.info_label.setText(message)
 
 
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/0x04.%20QYolk%20II

'Programming' 카테고리의 다른 글

[PyQt4] 0x06. QYolk III  (0) 2016.11.18
[PyQt4] 0x05. Final Text Editor  (0) 2016.11.17
[PyQt4] 0x04. QYolk II  (0) 2016.11.16
[PyQt4] 0x03. QYolk I  (6) 2016.11.15
[PyQt4] 0x02. Extended Text Editor  (0) 2016.11.15
[PyQt4] 0x01. PyQt4 설치, Simple text editor  (0) 2016.11.15
블로그 이미지

__미니__

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

댓글을 달아 주세요