From fd53b79fdbcdb1539adc7b7a86584d4739b22334 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Tue, 13 Nov 2018 15:00:35 -0500 Subject: [PATCH 1/2] Can use BOTH PyQt5 and PySide2 --- PySimpleGUIQt/PySimpleGUIQt.py | 39 +++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/PySimpleGUIQt/PySimpleGUIQt.py b/PySimpleGUIQt/PySimpleGUIQt.py index 24e2a349..0ffab510 100644 --- a/PySimpleGUIQt/PySimpleGUIQt.py +++ b/PySimpleGUIQt/PySimpleGUIQt.py @@ -6,17 +6,31 @@ import textwrap import pickle import base64 import calendar -from PySide2.QtWidgets import QApplication, QLabel, QWidget, QLineEdit, QComboBox, QFormLayout, QVBoxLayout, \ - QHBoxLayout, QListWidget, QDial, QTableWidget -from PySide2.QtWidgets import QSlider, QCheckBox, QRadioButton, QSpinBox, QPushButton, QTextEdit, QMainWindow, QDialog, QAbstractItemView -from PySide2.QtWidgets import QSpacerItem, QFrame, QGroupBox, QTextBrowser, QPlainTextEdit, QButtonGroup, QFileDialog, QTableWidget, QTabWidget, QTabBar, QTreeWidget, QTreeWidgetItem, QLayout, QTreeWidgetItemIterator, QProgressBar -# from PySide2.QtWidgets import -from PySide2.QtWidgets import QTableWidgetItem, QGraphicsView, QGraphicsScene, QGraphicsItemGroup, QMenu, QMenuBar, QAction -from PySide2.QtGui import QPainter, QPixmap, QPen, QColor, QBrush, QPainterPath, QFont, QImage, QIcon -from PySide2.QtCore import Qt,QProcess, QEvent -import PySide2.QtGui as QtGui -import PySide2.QtCore as QtCore -import PySide2.QtWidgets as QtWidgets +try: + from PyQt5.QtWidgets import QApplication, QLabel, QWidget, QLineEdit, QComboBox, QFormLayout, QVBoxLayout, \ + QHBoxLayout, QListWidget, QDial, QTableWidget + from PyQt5.QtWidgets import QSlider, QCheckBox, QRadioButton, QSpinBox, QPushButton, QTextEdit, QMainWindow, QDialog, QAbstractItemView + from PyQt5.QtWidgets import QSpacerItem, QFrame, QGroupBox, QTextBrowser, QPlainTextEdit, QButtonGroup, QFileDialog, QTableWidget, QTabWidget, QTabBar, QTreeWidget, QTreeWidgetItem, QLayout, QTreeWidgetItemIterator, QProgressBar + from PyQt5.QtWidgets import QTableWidgetItem, QGraphicsView, QGraphicsScene, QGraphicsItemGroup, QMenu, QMenuBar, QAction + from PyQt5.QtGui import QPainter, QPixmap, QPen, QColor, QBrush, QPainterPath, QFont, QImage, QIcon + from PyQt5.QtCore import Qt,QProcess, QEvent + import PyQt5.QtGui as QtGui + import PyQt5.QtCore as QtCore + import PyQt5.QtWidgets as QtWidgets + using_pyqt5 = True +except: + from PySide2.QtWidgets import QApplication, QLabel, QWidget, QLineEdit, QComboBox, QFormLayout, QVBoxLayout, \ + QHBoxLayout, QListWidget, QDial, QTableWidget + from PySide2.QtWidgets import QSlider, QCheckBox, QRadioButton, QSpinBox, QPushButton, QTextEdit, QMainWindow, QDialog, QAbstractItemView + from PySide2.QtWidgets import QSpacerItem, QFrame, QGroupBox, QTextBrowser, QPlainTextEdit, QButtonGroup, QFileDialog, QTableWidget, QTabWidget, QTabBar, QTreeWidget, QTreeWidgetItem, QLayout, QTreeWidgetItemIterator, QProgressBar + from PySide2.QtWidgets import QTableWidgetItem, QGraphicsView, QGraphicsScene, QGraphicsItemGroup, QMenu, QMenuBar, QAction + from PySide2.QtGui import QPainter, QPixmap, QPen, QColor, QBrush, QPainterPath, QFont, QImage, QIcon + from PySide2.QtCore import Qt,QProcess, QEvent + import PySide2.QtGui as QtGui + import PySide2.QtCore as QtCore + import PySide2.QtWidgets as QtWidgets + using_pyqt5 = False + """ The QT version if PySimpleGUI. @@ -4418,6 +4432,7 @@ def stop_timer(timer): # ----====----====----====----====----==== STARTUP TK ====----====----====----====----====----# def StartupTK(window): global _my_windows + global using_pyqt5 ow = _my_windows.NumOpenWindows @@ -4445,7 +4460,7 @@ def StartupTK(window): flags |= QtCore.Qt.Tool if window.KeepOnTop: flags |= Qt.WindowStaysOnTopHint - if flags is not None: + if not using_pyqt5 and flags is not None: window.QT_QMainWindow.setWindowFlags(flags) if window.AlphaChannel: window.QT_QMainWindow.setWindowOpacity(window.AlphaChannel) From 052db64ad512367bead593fa0b2205b1a65d0e0b Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 14 Nov 2018 09:13:39 -0500 Subject: [PATCH 2/2] Update method for Output Element --- PySimpleGUI.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 8ebeda03..4bc205d0 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -190,7 +190,6 @@ class MyWindows(): self.NumOpenWindows = 0 self.user_defined_icon = None self.hidden_master_root = None - self.window_being_closed = None def Decrement(self): self.NumOpenWindows -= 1 * (self.NumOpenWindows != 0) # decrement if not 0 @@ -1204,6 +1203,16 @@ class Output(Element): print('*** form = sg.Window("My Form").Layout(layout).Finalize() ***') return self._TKOut + + def Update(self, value=None): + if value is not None: + # try: + self._TKOut.output.delete('1.0', tk.END) + self._TKOut.output.insert(tk.END, value) + # except: + # pass + + def __del__(self): try: self._TKOut.__del__() @@ -3228,7 +3237,6 @@ class Window: global _my_windows if self.DisableClose: return - _my_windows.window_being_closed = self # print('Got closing callback') if self.CurrentlyRunningMainloop: # quit if this is the current mainloop, otherwise don't quit! self.TKroot.quit() # kick the users out of the mainloop