From 5f8b316e283525faa64d0f652c3aa5a54c038de1 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 9 Nov 2018 10:08:42 -0500 Subject: [PATCH] Table Element support --- PySimpleGUIQt/PySimpleGUIQt.py | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/PySimpleGUIQt/PySimpleGUIQt.py b/PySimpleGUIQt/PySimpleGUIQt.py index 7098783d..43dc1491 100644 --- a/PySimpleGUIQt/PySimpleGUIQt.py +++ b/PySimpleGUIQt/PySimpleGUIQt.py @@ -7,8 +7,9 @@ import pickle import calendar from PySide2.QtWidgets import QApplication, QLabel, QWidget, QLineEdit, QComboBox, QFormLayout, QVBoxLayout, QHBoxLayout, QListWidget, QDial from PySide2.QtWidgets import QSlider, QCheckBox, QRadioButton, QSpinBox, QPushButton, QTextEdit, QMainWindow, QDialog, QAbstractItemView -from PySide2.QtWidgets import QSpacerItem, QFrame, QGroupBox, QTextBrowser, QPlainTextEdit, QButtonGroup, QFileDialog +from PySide2.QtWidgets import QSpacerItem, QFrame, QGroupBox, QTextBrowser, QPlainTextEdit, QButtonGroup, QFileDialog, QTableWidget # from PySide2.QtWidgets import +from PySide2.QtWidgets import QTableWidgetItem from PySide2.QtCore import Qt,QProcess, QEvent import PySide2.QtGui as QtGui import PySide2.QtCore as QtCore @@ -4002,7 +4003,29 @@ def PackFormIntoFrame(window, containing_frame, toplevel_win): qt_row_layout.addStretch(1) # ------------------------- TABLE element ------------------------- # elif element_type == ELEM_TYPE_TABLE: - pass + + element.QT_TableWidget = QTableWidget() + style = '' + if font is not None: + style += 'font-family: %s;'%font[0] + style += 'font-size: %spt;'%font[1] + if element.TextColor is not None: + style += 'color: %s;' % element.TextColor + if element.BackgroundColor is not None: + style += 'background-color: %s;' % element.BackgroundColor + element.QT_TableWidget.setStyleSheet(style) + + element.QT_TableWidget.setRowCount(len(element.Values)) + element.QT_TableWidget.setColumnCount(len(element.Values[0])) + for rownum, rows in enumerate(element.Values): + # element.QT_TableWidget.insertRow(rownum) + for colnum, columns in enumerate(rows): + element.QT_TableWidget.setItem(rownum, colnum, QTableWidgetItem(element.Values[rownum][colnum])) + + element.QT_TableWidget.setSizeAdjustPolicy(QtWidgets.QAbstractScrollArea.AdjustToContents) + + qt_row_layout.addWidget(element.QT_TableWidget) + # ------------------------- Tree element ------------------------- # elif element_type == ELEM_TYPE_TREE: element.QT_QGraphicsLineItem = QtWidgets.QGraphicsLineItem