Created
June 9, 2015 18:57
-
-
Save whoiscarlo/6d71be4529b426c051bf to your computer and use it in GitHub Desktop.
PyQt Examples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## Color Changer | |
| from PyQt4 import QtCore, QtGui | |
| # import re | |
| # import os | |
| import sys | |
| class TestUI(QtGui.QDialog): | |
| def __init__(self, *args, **kws): | |
| parent = kws.get('parent', None) | |
| super(TestUI, self).__init__(parent=parent) | |
| ## Class variables | |
| # self.logic = Logic() | |
| ## Class Functions | |
| self.create_window() | |
| # self.setup_connections() | |
| def create_window(self): | |
| main_layout = QtGui.QHBoxLayout() | |
| self.setLayout(main_layout) | |
| ## Font | |
| fontsize = QtGui.QFont() | |
| fontsize.setPointSize(10) | |
| qTable = QtGui.QTableWidget() | |
| qTable.setFont(fontsize) | |
| qTable.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) | |
| qTable.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers) | |
| qTable.verticalHeader().hide() | |
| qTable.setColumnCount(3) | |
| main_layout.addWidget(qTable) | |
| item = QtGui.QTableWidgetItem() | |
| item.setText('Column 1') | |
| item.setTextColor(QtGui.QColor(255, 51, 0)) | |
| item.setBackgroundColor(QtGui.QColor(43, 43, 43)) | |
| qTable.setHorizontalHeaderItem(0, item) | |
| item = QtGui.QTableWidgetItem() | |
| item.setText('Column 2') | |
| item.setTextColor(QtGui.QColor(255, 51, 0)) | |
| item.setBackgroundColor(QtGui.QColor(43, 43, 43)) | |
| qTable.setHorizontalHeaderItem(1, item) | |
| def main(): | |
| Dialog = TestUI() | |
| Dialog.show() | |
| sys.exit(app.exec_()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment