0.9.0 Alpha Release

This commit is contained in:
MikeTheWatchGuy 2018-11-12 16:04:54 -05:00
parent 99b4ba6d67
commit 3b63c8213c
2 changed files with 181 additions and 140 deletions

View File

@ -9,18 +9,15 @@ import calendar
from PySide2.QtWidgets import QApplication, QLabel, QWidget, QLineEdit, QComboBox, QFormLayout, QVBoxLayout, \ from PySide2.QtWidgets import QApplication, QLabel, QWidget, QLineEdit, QComboBox, QFormLayout, QVBoxLayout, \
QHBoxLayout, QListWidget, QDial, QTableWidget QHBoxLayout, QListWidget, QDial, QTableWidget
from PySide2.QtWidgets import QSlider, QCheckBox, QRadioButton, QSpinBox, QPushButton, QTextEdit, QMainWindow, QDialog, QAbstractItemView 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 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
from PySide2.QtWidgets import QTableWidgetItem, QGraphicsView, QGraphicsScene, QGraphicsItemGroup 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.QtGui import QPainter, QPixmap, QPen, QColor, QBrush, QPainterPath, QFont, QImage, QIcon
from PySide2.QtCore import Qt,QProcess, QEvent from PySide2.QtCore import Qt,QProcess, QEvent
import PySide2.QtGui as QtGui import PySide2.QtGui as QtGui
import PySide2.QtCore as QtCore import PySide2.QtCore as QtCore
import PySide2.QtWidgets as QtWidgets import PySide2.QtWidgets as QtWidgets
""" """
The QT version if PySimpleGUI. The QT version if PySimpleGUI.
Still being developed. Very limited features. Been in development for less than 2 days so don't expect much!! Still being developed. Very limited features. Been in development for less than 2 days so don't expect much!!
@ -127,7 +124,7 @@ RELIEF_GROOVE = 'groove'
RELIEF_SOLID = 'solid' RELIEF_SOLID = 'solid'
DEFAULT_PROGRESS_BAR_COLOR = (GREENS[0], '#D0D0D0') # a nice green progress bar DEFAULT_PROGRESS_BAR_COLOR = (GREENS[0], '#D0D0D0') # a nice green progress bar
DEFAULT_PROGRESS_BAR_SIZE = (25, 20) # Size of Progress Bar (characters for length, pixels for width) DEFAULT_PROGRESS_BAR_SIZE = (250, 20) # Size of Progress Bar (characters for length, pixels for width)
DEFAULT_PROGRESS_BAR_BORDER_WIDTH = 1 DEFAULT_PROGRESS_BAR_BORDER_WIDTH = 1
DEFAULT_PROGRESS_BAR_RELIEF = RELIEF_GROOVE DEFAULT_PROGRESS_BAR_RELIEF = RELIEF_GROOVE
PROGRESS_BAR_STYLES = ('default', 'winnative', 'clam', 'alt', 'classic', 'vista', 'xpnative') PROGRESS_BAR_STYLES = ('default', 'winnative', 'clam', 'alt', 'classic', 'vista', 'xpnative')
@ -1301,7 +1298,7 @@ class Button(Element):
self.ParentForm._Close() self.ParentForm._Close()
if self.ParentForm.CurrentlyRunningMainloop: if self.ParentForm.CurrentlyRunningMainloop:
self.ParentForm.QTApplication.exit() # Exit the mainloop self.ParentForm.QTApplication.exit() # Exit the mainloop
self.ParentForm.QTWindow.close() self.ParentForm.QT_QMainWindow.close()
if self.ParentForm.NonBlocking: if self.ParentForm.NonBlocking:
# TODO DESTROY WIN # TODO DESTROY WIN
_my_windows.Decrement() _my_windows.Decrement()
@ -1317,7 +1314,7 @@ class Button(Element):
self.ParentForm.QTApplication.exit() self.ParentForm.QTApplication.exit()
elif self.BType == BUTTON_TYPE_CLOSES_WIN_ONLY: # special kind of button that does not exit main loop elif self.BType == BUTTON_TYPE_CLOSES_WIN_ONLY: # special kind of button that does not exit main loop
self.ParentForm._Close() self.ParentForm._Close()
self.ParentForm.QTWindow.close() self.ParentForm.QT_QMainWindow.close()
if self.ParentForm.CurrentlyRunningMainloop: # if this window is running the mainloop, kick out if self.ParentForm.CurrentlyRunningMainloop: # if this window is running the mainloop, kick out
self.ParentForm.QTApplication.exit() self.ParentForm.QTApplication.exit()
_my_windows.Decrement() _my_windows.Decrement()
@ -1383,7 +1380,7 @@ class Button(Element):
# ProgreessBar # # ProgreessBar #
# ---------------------------------------------------------------------- # # ---------------------------------------------------------------------- #
class ProgressBar(Element): class ProgressBar(Element):
def __init__(self, max_value, orientation=None, size=(None, None), auto_size_text=None, bar_color=(None, None), def __init__(self, max_value, orientation=None, size=(None, None),start_value=0, auto_size_text=None, bar_color=(None, None),
style=None, border_width=None, relief=None, key=None, pad=None): style=None, border_width=None, relief=None, key=None, pad=None):
''' '''
ProgressBar Element ProgressBar Element
@ -1408,11 +1405,14 @@ class ProgressBar(Element):
self.BorderWidth = border_width if border_width else DEFAULT_PROGRESS_BAR_BORDER_WIDTH self.BorderWidth = border_width if border_width else DEFAULT_PROGRESS_BAR_BORDER_WIDTH
self.Relief = relief if relief else DEFAULT_PROGRESS_BAR_RELIEF self.Relief = relief if relief else DEFAULT_PROGRESS_BAR_RELIEF
self.BarExpired = False self.BarExpired = False
self.StartValue = start_value
super().__init__(ELEM_TYPE_PROGRESS_BAR, size=size, auto_size_text=auto_size_text, key=key, pad=pad) super().__init__(ELEM_TYPE_PROGRESS_BAR, size=size, auto_size_text=auto_size_text, key=key, pad=pad)
# returns False if update failed # returns False if update failed
def UpdateBar(self, current_count, max=None): def UpdateBar(self, current_count, max=None):
pass self.QT_QProgressBar.setValue(current_count)
self.ParentForm.QTApplication.processEvents() # refresh the window
return True return True
def __del__(self): def __del__(self):
@ -1447,19 +1447,19 @@ class Image(Element):
def Update(self, filename=None, data=None, size=(None, None)): def Update(self, filename=None, data=None, size=(None, None)):
if filename is not None: if filename is not None:
pass qlabel = self.QT_QLabel
qlabel.setText('')
w = QtGui.QPixmap(filename).width()
h = QtGui.QPixmap(filename).height()
qlabel.setGeometry(QtCore.QRect(0, 0, w, h))
qlabel.setPixmap(QtGui.QPixmap(filename))
elif data is not None: elif data is not None:
qlabel = self.QT_QLabel
qlabel.setText('')
ba = QtCore.QByteArray.fromBase64(data) ba = QtCore.QByteArray.fromBase64(data)
image = QImage() pixmap = QtGui.QPixmap()
image.loadFromData(ba) pixmap.loadFromData(ba)
pixmap = QPixmap() qlabel.setPixmap(pixmap)
pixmap.fromImage(image)
w = image.width()
h = image.height()
self.QT_QLabel.setGeometry(QtCore.QRect(0, 0, w, h))
self.QT_QLabel.setPixmap(pixmap)
else:
return
def __del__(self): def __del__(self):
@ -2194,15 +2194,18 @@ class Menu(Element):
self.TKMenu = None self.TKMenu = None
self.Tearoff = tearoff self.Tearoff = tearoff
super().__init__(ELEM_TYPE_MENUBAR, background_color=background_color, size=size, pad=pad, key=key) super().__init__(ELEM_TYPE_MENUBAR, background_color=background_color, size=size, pad=pad, key=key)
return return
def MenuItemChosenCallback(self, item_chosen): def QT_MenuItemChosenCallback(self, item_chosen):
# print('IN MENU ITEM CALLBACK', item_chosen) # print('IN MENU ITEM CALLBACK', item_chosen)
self.ParentForm.LastButtonClicked = item_chosen self.Key = item_chosen.replace('&','') # fool the quit function into thinking this was a key
self.ParentForm.FormRemainedOpen = True element_callback_quit_mainloop(self)
if self.ParentForm.CurrentlyRunningMainloop: # self.ParentForm.LastButtonClicked = item_chosen
pass # TODO # kick the users out of the mainloop # self.ParentForm.FormRemainedOpen = True
# if self.ParentForm.CurrentlyRunningMainloop:
# pass # TODO # kick the users out of the mainloop
def __del__(self): def __del__(self):
super().__del__() super().__del__()
@ -2410,17 +2413,31 @@ class Tree(Element):
if self.ParentForm.CurrentlyRunningMainloop: if self.ParentForm.CurrentlyRunningMainloop:
self.ParentForm.TKroot.quit() self.ParentForm.TKroot.quit()
def add_treeview_data(self, node):
# print(f'Inserting {node.key} under parent {node.parent}')
if node.key != '':
pass # Insert in tree
for node in node.children:
self.add_treeview_data(node)
def Update(self, values=None, key=None, value=None, text=None): def Update(self, values=None, key=None, value=None, text=None):
if values is not None: if values is not None:
self.TreeData = values self.TreeData = values
self.SelectedRows = [] self.SelectedRows = []
# self.QT_QTreeWidget = QTreeWidget()
TreeWidgetItems = QTreeWidgetItemIterator(self.QT_QTreeWidget)
for item in TreeWidgetItems.Enabled:
self.QT_QTreeWidget.removeItemWidget(item, 0)
def add_treeview_data(node, widget):
# print(f'Inserting {node.key} under parent {node.parent}')
child = QTreeWidgetItem(widget)
if node.key != '':
child.setText(0, str(node.text))
# child.setData(0,0,node.values)
if node.icon is not None:
qicon = QIcon(node.icon)
child.setIcon(0, qicon)
for node in node.children:
add_treeview_data(node, child)
add_treeview_data(self.TreeData.root_node, self.QT_QTreeWidget)
if key is not None: if key is not None:
pass pass
return self return self
@ -2903,7 +2920,7 @@ class Window:
if self.TKrootDestroyed: if self.TKrootDestroyed:
return return
try: try:
self.QTWindow.close() self.QT_QMainWindow.close()
except: except:
print('error closing window') print('error closing window')
@ -2953,7 +2970,7 @@ class Window:
''' '''
self._AlphaChannel = alpha self._AlphaChannel = alpha
if self._AlphaChannel: if self._AlphaChannel:
self.QTWindow.setWindowOpacity(self._AlphaChannel) self.QT_QMainWindow.setWindowOpacity(self._AlphaChannel)
@property @property
def AlphaChannel(self): def AlphaChannel(self):
@ -2963,7 +2980,7 @@ class Window:
def AlphaChannel(self, alpha): def AlphaChannel(self, alpha):
self._AlphaChannel = alpha self._AlphaChannel = alpha
if self._AlphaChannel: if self._AlphaChannel:
self.QTWindow.setWindowOpacity(self._AlphaChannel) self.QT_QMainWindow.setWindowOpacity(self._AlphaChannel)
def BringToFront(self): def BringToFront(self):
try: try:
@ -2975,6 +2992,36 @@ class Window:
return int(self.TKroot.winfo_x()), int(self.TKroot.winfo_y()) return int(self.TKroot.winfo_x()), int(self.TKroot.winfo_y())
class QTMainWindow(QWidget): class QTMainWindow(QWidget):
def __init__(self,enable_key_events, window):
self.KeyEventsEnabled = enable_key_events
self.Window = window
super().__init__(window.QT_QMainWindow)
def eventFilter(self, widget, event):
# print(event.type())
if event.type() == QEvent.MouseButtonPress and self.Window.GrabAnywhere:
self.mouse_offset = event.pos()
if event.type() == QEvent.MouseMove and self.Window.GrabAnywhere:
x = event.globalX()
y = event.globalY()
x_w = self.mouse_offset.x()
y_w = self.mouse_offset.y()
self.move(x - x_w, y - y_w)
if event.type() == QEvent.KeyRelease and self.KeyEventsEnabled:
# print("got key event")
key = event.key()
try:
self.Window.LastButtonClicked = chr(key).lower()
except:
self.Window.LastButtonClicked = "special %s" % key
self.Window.FormRemainedOpen = True
if self.Window.CurrentlyRunningMainloop:
self.Window.QTApplication.exit()
return QWidget.eventFilter(self, widget, event)
class QT_QMainWindowClass(QMainWindow):
def __init__(self,enable_key_events, window): def __init__(self,enable_key_events, window):
self.KeyEventsEnabled = enable_key_events self.KeyEventsEnabled = enable_key_events
self.Window = window self.Window = window
@ -3003,6 +3050,7 @@ class Window:
self.Window.QTApplication.exit() self.Window.QTApplication.exit()
return QWidget.eventFilter(self, widget, event) return QWidget.eventFilter(self, widget, event)
def __enter__(self): def __enter__(self):
return self return self
@ -3581,32 +3629,24 @@ def _FindElementWithFocusInSubForm(form):
return element return element
if sys.version_info[0] >= 3: def AddMenuItem(top_menu, sub_menu_info, element, is_sub_menu=False, skip=False):
def AddMenuItem(top_menu, sub_menu_info, element, is_sub_menu=False, skip=False):
if type(sub_menu_info) is str: if type(sub_menu_info) is str:
if not is_sub_menu and not skip: if not is_sub_menu and not skip:
# print(f'Adding command {sub_menu_info}') # print(f'Adding command {sub_menu_info}')
pos = sub_menu_info.find('&') action = QAction(top_menu)
if pos != -1: action.setText(sub_menu_info)
if pos == 0 or sub_menu_info[pos - 1] != "\\": top_menu.addAction(action)
sub_menu_info = sub_menu_info[:pos] + sub_menu_info[pos + 1:] action.triggered.connect(lambda: Menu.QT_MenuItemChosenCallback(element, sub_menu_info))
if sub_menu_info == '---':
top_menu.add('separator')
else:
top_menu.add_command(label=sub_menu_info, underline=pos,
command=lambda: Menu.MenuItemChosenCallback(element, sub_menu_info))
else: else:
i = 0 i = 0
while i < (len(sub_menu_info)): while i < (len(sub_menu_info)):
item = sub_menu_info[i] item = sub_menu_info[i]
if i != len(sub_menu_info) - 1: if i != len(sub_menu_info) - 1:
if type(sub_menu_info[i + 1]) == list: if type(sub_menu_info[i + 1]) == list:
new_menu = 000000 # TODO Get a menu new_menu = QMenu(top_menu)
pos = sub_menu_info[i].find('&') new_menu.setTitle(sub_menu_info[i])
if pos != -1: top_menu.addAction(new_menu.menuAction())
if pos == 0 or sub_menu_info[i][pos - 1] != "\\": # print(f'Adding submenu {sub_menu_info[i]}')
sub_menu_info[i] = sub_menu_info[i][:pos] + sub_menu_info[i][pos + 1:]
top_menu.add_cascade(label=sub_menu_info[i], menu=new_menu, underline=pos)
AddMenuItem(new_menu, sub_menu_info[i + 1], element, is_sub_menu=True) AddMenuItem(new_menu, sub_menu_info[i + 1], element, is_sub_menu=True)
i += 1 # skip the next one i += 1 # skip the next one
else: else:
@ -3614,40 +3654,6 @@ if sys.version_info[0] >= 3:
else: else:
AddMenuItem(top_menu, item, element) AddMenuItem(top_menu, item, element)
i += 1 i += 1
else:
def AddMenuItem(top_menu, sub_menu_info, element, is_sub_menu=False, skip=False):
if isinstance(sub_menu_info, types.StringType):
if not is_sub_menu and not skip:
# print(f'Adding command {sub_menu_info}')
pos = sub_menu_info.find('&')
if pos != -1:
if pos == 0 or sub_menu_info[pos - 1] != "\\":
sub_menu_info = sub_menu_info[:pos] + sub_menu_info[pos + 1:]
if sub_menu_info == '---':
top_menu.add('separator')
else:
top_menu.add_command(label=sub_menu_info, underline=pos,
command=lambda: Menu.MenuItemChosenCallback(element, sub_menu_info))
else:
i = 0
while i < (len(sub_menu_info)):
item = sub_menu_info[i]
if i != len(sub_menu_info) - 1:
if not isinstance(sub_menu_info[i + 1], types.StringType):
new_menu = 000000
pos = sub_menu_info[i].find('&')
if pos != -1:
if pos == 0 or sub_menu_info[i][pos - 1] != "\\":
sub_menu_info[i] = sub_menu_info[i][:pos] + sub_menu_info[i][pos + 1:]
top_menu.add_cascade(label=sub_menu_info[i], menu=new_menu, underline=pos)
AddMenuItem(new_menu, sub_menu_info[i + 1], element, is_sub_menu=True)
i += 1 # skip the next one
else:
AddMenuItem(top_menu, item, element)
else:
AddMenuItem(top_menu, item, element)
i += 1
# ------------------------------------------------------------------------------------------------------------------ # # ------------------------------------------------------------------------------------------------------------------ #
# ------------------------------------------------------------------------------------------------------------------ # # ------------------------------------------------------------------------------------------------------------------ #
@ -3760,7 +3766,6 @@ def PackFormIntoFrame(window, containing_frame, toplevel_win):
element.QT_Label.setToolTip(element.Tooltip) element.QT_Label.setToolTip(element.Tooltip)
element.QT_Label.setMargin(full_element_pad[0]) element.QT_Label.setMargin(full_element_pad[0])
element.QT_Label.setIndent(full_element_pad[1]) element.QT_Label.setIndent(full_element_pad[1])
# qt_row_layout.setContentsMargins(*full_element_pad)
qt_row_layout.addWidget(element.QT_Label) qt_row_layout.addWidget(element.QT_Label)
# ------------------------- BUTTON element ------------------------- # # ------------------------- BUTTON element ------------------------- #
elif element_type == ELEM_TYPE_BUTTON: elif element_type == ELEM_TYPE_BUTTON:
@ -3773,24 +3778,32 @@ def PackFormIntoFrame(window, containing_frame, toplevel_win):
style += 'font-size: %spt;'%font[1] style += 'font-size: %spt;'%font[1]
if element.TextColor is not None: if element.TextColor is not None:
style += 'color: %s;' % element.TextColor style += 'color: %s;' % element.TextColor
if element.BackgroundColor is not None: if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT:
style += 'background-color: %s;' % element.BackgroundColor style += 'background-color: %s;' % element.BackgroundColor
if element.BorderWidth == 0:
style += 'border: none;'
element.QT_QPushButton.setStyleSheet(style) element.QT_QPushButton.setStyleSheet(style)
if element.AutoSizeButton is False or toplevel_win.AutoSizeButtons is False or element_size[0] is not None: if (element.AutoSizeButton is False or toplevel_win.AutoSizeButtons is False or element_size[0] is not None) and element.ImageData is None:
if element_size[0] is not None: if element_size[0] is not None:
element.QT_QPushButton.setFixedWidth(element_size[0]) element.QT_QPushButton.setFixedWidth(element_size[0])
if element_size[1] is not None: if element_size[1] is not None:
element.QT_QPushButton.setFixedHeight(element_size[1]) element.QT_QPushButton.setFixedHeight(element_size[1])
if element.ImageData:
ba = QtCore.QByteArray.fromBase64(element.ImageData)
pixmap = QtGui.QPixmap()
pixmap.loadFromData(ba)
element.QT_QPushButton.setIcon(pixmap)
element.QT_QPushButton.setIconSize(pixmap.rect().size())
if element.Disabled: if element.Disabled:
element.QT_QPushButton.setDisabled(True) element.QT_QPushButton.setDisabled(True)
qt_row_layout.addWidget(element.QT_QPushButton)
element.QT_QPushButton.setContentsMargins(*full_element_pad) element.QT_QPushButton.setContentsMargins(*full_element_pad)
if element.Tooltip: if element.Tooltip:
element.QT_QPushButton.setToolTip(element.Tooltip) element.QT_QPushButton.setToolTip(element.Tooltip)
element.QT_QPushButton.clicked.connect(element.ButtonCallBack) element.QT_QPushButton.clicked.connect(element.ButtonCallBack)
# element.QT_QPushButton.clicked.connect(window.QTApplication.exit) qt_row_layout.addWidget(element.QT_QPushButton)
# ------------------------- INPUT (Single Line) element ------------------------- # # ------------------------- INPUT (Single Line) element ------------------------- #
elif element_type == ELEM_TYPE_INPUT_TEXT: elif element_type == ELEM_TYPE_INPUT_TEXT:
default_text = element.DefaultText default_text = element.DefaultText
@ -3988,8 +4001,18 @@ def PackFormIntoFrame(window, containing_frame, toplevel_win):
qt_row_layout.addWidget(element.QT_Checkbox) qt_row_layout.addWidget(element.QT_Checkbox)
# ------------------------- PROGRESS BAR element ------------------------- # # ------------------------- PROGRESS BAR element ------------------------- #
elif element_type == ELEM_TYPE_PROGRESS_BAR: elif element_type == ELEM_TYPE_PROGRESS_BAR:
# save this form because it must be 'updated' (refreshed) solely for the purpose of updating bar element.QT_QProgressBar = QProgressBar()
width = element_size[0]
if element.Size[0] is not None:
if element_size[0] is not None:
element.QT_QProgressBar.setFixedWidth(element_size[0])
if element_size[1] is not None:
element.QT_QProgressBar.setFixedHeight(element_size[1])
element.QT_QProgressBar.setMaximum(element.MaxValue)
element.QT_QProgressBar.setValue(element.StartValue)
qt_row_layout.addWidget(element.QT_QProgressBar)
# ------------------------- INPUT RADIO BUTTON element ------------------------- # # ------------------------- INPUT RADIO BUTTON element ------------------------- #
elif element_type == ELEM_TYPE_INPUT_RADIO: elif element_type == ELEM_TYPE_INPUT_RADIO:
width = 0 if auto_size_text else element_size[0] width = 0 if auto_size_text else element_size[0]
@ -4088,14 +4111,10 @@ def PackFormIntoFrame(window, containing_frame, toplevel_win):
elif element.Data: elif element.Data:
qlabel = QLabel() qlabel = QLabel()
qlabel.setText('') qlabel.setText('')
ba = QtCore.QByteArray.fromBase64(element.Data) ba = QtCore.QByteArray.fromBase64(element.Data)
image = QImage() pixmap = QtGui.QPixmap()
image.loadFromData(ba) pixmap.loadFromData(ba)
pixmap = QPixmap()
pixmap.fromImage(image)
w = image.width()
h = image.height()
qlabel.setGeometry(QtCore.QRect(0, 0, w, h))
qlabel.setPixmap(pixmap) qlabel.setPixmap(pixmap)
element.QT_QLabel = qlabel element.QT_QLabel = qlabel
@ -4117,6 +4136,17 @@ def PackFormIntoFrame(window, containing_frame, toplevel_win):
# ------------------------- MENUBAR element ------------------------- # # ------------------------- MENUBAR element ------------------------- #
elif element_type == ELEM_TYPE_MENUBAR: elif element_type == ELEM_TYPE_MENUBAR:
menu_def = element.MenuDefinition menu_def = element.MenuDefinition
element.QT_QMenuBar = QMenuBar(toplevel_win.QT_QMainWindow)
for menu_entry in menu_def:
print(f'Adding a Menubar ENTRY {menu_entry}')
baritem = QMenu(element.QT_QMenuBar)
baritem.setTitle(menu_entry[0])
element.QT_QMenuBar.addAction(baritem.menuAction())
AddMenuItem(baritem, menu_entry[1], element)
toplevel_win.QT_QMainWindow.setMenuBar(element.QT_QMenuBar)
# ------------------------- Frame element ------------------------- # # ------------------------- Frame element ------------------------- #
elif element_type == ELEM_TYPE_FRAME: elif element_type == ELEM_TYPE_FRAME:
column_widget = QGroupBox() column_widget = QGroupBox()
@ -4295,7 +4325,6 @@ def PackFormIntoFrame(window, containing_frame, toplevel_win):
for node in node.children: for node in node.children:
add_treeview_data(node, child) add_treeview_data(node, child)
element.TreeData.root_node
add_treeview_data(element.TreeData.root_node, element.QT_QTreeWidget) add_treeview_data(element.TreeData.root_node, element.QT_QTreeWidget)
qt_row_layout.addWidget(element.QT_QTreeWidget) qt_row_layout.addWidget(element.QT_QTreeWidget)
@ -4367,10 +4396,14 @@ def StartupTK(window):
# window.QTWindow = QWidget() # window.QTWindow = QWidget()
window.QTWindow = window.QTMainWindow(window.ReturnKeyboardEvents, window)
window.QTWindow.installEventFilter(window.QTWindow)
window.QTApplication.setActiveWindow(window.QTWindow) window.QT_QMainWindow = window.QT_QMainWindowClass(window.ReturnKeyboardEvents, window)
window.QTWindow = window.QTMainWindow(window.ReturnKeyboardEvents, window)
window.QT_QMainWindow.setCentralWidget(window.QTWindow)
window.QT_QMainWindow.installEventFilter(window.QT_QMainWindow)
window.QTApplication.setActiveWindow(window.QT_QMainWindow)
flags = 0 flags = 0
if window.NoTitleBar: if window.NoTitleBar:
@ -4379,13 +4412,13 @@ def StartupTK(window):
if window.KeepOnTop: if window.KeepOnTop:
flags |= Qt.WindowStaysOnTopHint flags |= Qt.WindowStaysOnTopHint
if flags is not None: if flags is not None:
window.QTWindow.setWindowFlags(flags) window.QT_QMainWindow.setWindowFlags(flags)
if window.AlphaChannel: if window.AlphaChannel:
window.QTWindow.setWindowOpacity(window.AlphaChannel) window.QT_QMainWindow.setWindowOpacity(window.AlphaChannel)
if window.Size != (None, None): if window.Size != (None, None):
window.QTWindow.resize(window.Size[0], window.Size[1]) window.QT_QMainWindow.resize(window.Size[0], window.Size[1])
if window.WindowIcon is not None: if window.WindowIcon is not None:
window.QTWindow.setWindowIcon(QtGui.QIcon(window.WindowIcon)) window.QT_QMainWindow.setWindowIcon(QtGui.QIcon(window.WindowIcon))
# window.QTWindow.setAttribute(Qt.WA_TranslucentBackground) # window.QTWindow.setAttribute(Qt.WA_TranslucentBackground)
# shadow = QtWidgets.QGraphicsDropShadowEffect() # shadow = QtWidgets.QGraphicsDropShadowEffect()
@ -4400,10 +4433,10 @@ def StartupTK(window):
style = '' style = ''
if window.BackgroundColor is not None and window.BackgroundColor != COLOR_SYSTEM_DEFAULT: if window.BackgroundColor is not None and window.BackgroundColor != COLOR_SYSTEM_DEFAULT:
style += 'background-color: %s;' % window.BackgroundColor style += 'background-color: %s;' % window.BackgroundColor
window.QTWindow.setStyleSheet(style) window.QT_QMainWindow.setStyleSheet(style)
if window.BackgroundImage is not None: if window.BackgroundImage is not None:
qlabel = QLabel(window.QTWindow) qlabel = QLabel(window.QT_QMainWindow)
qlabel.setText('') qlabel.setText('')
w = QtGui.QPixmap(window.BackgroundImage).width() w = QtGui.QPixmap(window.BackgroundImage).width()
h = QtGui.QPixmap(window.BackgroundImage).height() h = QtGui.QPixmap(window.BackgroundImage).height()
@ -4413,7 +4446,7 @@ def StartupTK(window):
# style += 'background-image: url(%s);' % window.BackgroundImage # style += 'background-image: url(%s);' % window.BackgroundImage
window.QTWindow.setWindowTitle(window.Title) window.QT_QMainWindow.setWindowTitle(window.Title)
if (window.GrabAnywhere is not False and not ( if (window.GrabAnywhere is not False and not (
@ -4450,13 +4483,13 @@ def StartupTK(window):
if not window.NonBlocking: if not window.NonBlocking:
timer = start_timer(window, window.Timeout) if window.Timeout else None timer = start_timer(window, window.Timeout) if window.Timeout else None
window.QTWindow.show() ####### The thing that causes the window to be visible ###### window.QT_QMainWindow.show() ####### The thing that causes the window to be visible ######
#### ------------------------------ RUN MAIN LOOP HERE ------------------------------ ##### #### ------------------------------ RUN MAIN LOOP HERE ------------------------------ #####
window.QTApplication.exec_() window.QTApplication.exec_()
if timer: if timer:
stop_timer(timer) stop_timer(timer)
else: # Non-blocking window else: # Non-blocking window
window.QTWindow.show() ####### The thing that causes the window to be visible ###### window.QT_QMainWindow.show() ####### The thing that causes the window to be visible ######
window.QTApplication.processEvents() window.QTApplication.processEvents()
@ -4467,7 +4500,7 @@ def StartupTK(window):
if not window.FormRemainedOpen: if not window.FormRemainedOpen:
_my_windows.Decrement() _my_windows.Decrement()
if window.RootNeedsDestroying: if window.RootNeedsDestroying:
window.QTWindow.close() # destroy the window window.QT_QMainWindow.close() # destroy the window
window.RootNeedsDestroying = False window.RootNeedsDestroying = False
return return
@ -4535,7 +4568,7 @@ def _ProgressMeter(title, max_value, *args, orientation=None, bar_color=(None, N
bar2.TextToDisplay = single_line_message bar2.TextToDisplay = single_line_message
bar2.MaxValue = max_value bar2.MaxValue = max_value
bar2.CurrentValue = 0 bar2.CurrentValue = 0
bar_text = Text(single_line_message, size=(width, height + 3), auto_size_text=True) bar_text = Text(single_line_message, size=(width*10, height*25 + 70), auto_size_text=True)
form.AddRow(bar_text) form.AddRow(bar_text)
form.AddRow((bar2)) form.AddRow((bar2))
form.AddRow((CloseButton('Cancel', button_color=button_color))) form.AddRow((CloseButton('Cancel', button_color=button_color)))
@ -4544,7 +4577,7 @@ def _ProgressMeter(title, max_value, *args, orientation=None, bar_color=(None, N
bar2.TextToDisplay = single_line_message bar2.TextToDisplay = single_line_message
bar2.MaxValue = max_value bar2.MaxValue = max_value
bar2.CurrentValue = 0 bar2.CurrentValue = 0
bar_text = Text(single_line_message, size=(width, height + 3), auto_size_text=True) bar_text = Text(single_line_message, size=(width*10, height*25 + 3), auto_size_text=True)
form.AddRow(bar2, bar_text) form.AddRow(bar2, bar_text)
form.AddRow((CloseButton('Cancel', button_color=button_color))) form.AddRow((CloseButton('Cancel', button_color=button_color)))
@ -4576,7 +4609,9 @@ def _ProgressMeterUpdate(bar, value, text_elem, *args):
_my_windows.Decrement() _my_windows.Decrement()
if bar.ParentForm.RootNeedsDestroying: if bar.ParentForm.RootNeedsDestroying:
try: try:
bar.ParentForm.TKroot.destroy() bar.ParentForm.QT_QMainWindow.close()
# bar.ParentForm.TKroot.destroy()
# there is a bug with progress meters not decrementing the number of windows # there is a bug with progress meters not decrementing the number of windows
# correctly when the X is used to close the window # correctly when the X is used to close the window
# uncommenting this line fixes that problem, but causes a double-decrement when # uncommenting this line fixes that problem, but causes a double-decrement when

View File

@ -23,7 +23,7 @@
# PySimpleGUIQt # PySimpleGUIQt
## The Pre-Alpha Release ## The Alpha Release
[Announcements of Latest Developments](https://github.com/MikeTheWatchGuy/PySimpleGUI/issues/142) [Announcements of Latest Developments](https://github.com/MikeTheWatchGuy/PySimpleGUI/issues/142)
@ -32,7 +32,7 @@
----- -----
## Getting Started with PySimpleGUIQt ## Getting Started with PySimpleGUIQt
Welcome to the Pre-Alpha Release of PySimpleGUI for Qt! Welcome to the Alpha Release of PySimpleGUI for Qt!
You can use the exact same code that you are running on the older, tkinter, version of PySimpleGUI. You can use the exact same code that you are running on the older, tkinter, version of PySimpleGUI.
@ -98,6 +98,13 @@ Then use the exact same code as any other PySimpleGUI program that runs on tkint
## Status ## Status
### FEATURE COMPLETE!
All of the major features are DONE. They may not have all of their options working, but they can be added to your windows. It's been an amazing week to get here.
I hope you enjoy this ALPHA release! Please post a screenshot on the GitHub site. There is an Issue where users have been posting their applications. It's a place for you to show-off and a place for others to learn from your designs. Your window does not have to be complex.... all GUIs, no matter how simple, are something we can learn from.
### Functioning features ### Functioning features
Features are being added daily to this Qt port of PySimpleGUI. Features are being added daily to this Qt port of PySimpleGUI.
These Elements are "complete" (a relative term... more are more complete than others): These Elements are "complete" (a relative term... more are more complete than others):
@ -130,21 +137,20 @@ These Elements are "complete" (a relative term... more are more complete than ot
* Updates * Updates
* Image as a background (new feature) * Image as a background (new feature)
* Graph - Draw line, draw circle, draw text * Graph - Draw line, draw circle, draw text
* Image Element
* Tree Element
* Tabs
* Menus
## Missing Features ## Missing Features
Notable MISSING features at the moment include: Notable MISSING features at the moment include:
* Graphs Element - erasing, draw arc, etc * Graphs Element Methods - erasing, draw arc, etc
* Image Element
* Tree Element - the more complex Elements have not yet been ported. Stay tuned, new ones being added daily!
* Tab & tab group Elements
* Menus
* Change submits - for radio buttons * Change submits - for radio buttons
## Design ## Design
## Author ## Author