commit
2736e6a2b8
|
@ -2128,20 +2128,24 @@ class Slider(Element):
|
||||||
# TkScrollableFrame (Used by Column) #
|
# TkScrollableFrame (Used by Column) #
|
||||||
# ---------------------------------------------------------------------- #
|
# ---------------------------------------------------------------------- #
|
||||||
class TkScrollableFrame(tk.Frame):
|
class TkScrollableFrame(tk.Frame):
|
||||||
def __init__(self, master, **kwargs):
|
def __init__(self, master, vertical_only, **kwargs):
|
||||||
tk.Frame.__init__(self, master, **kwargs)
|
tk.Frame.__init__(self, master, **kwargs)
|
||||||
|
|
||||||
# create a canvas object and a vertical scrollbar for scrolling it
|
# create a canvas object and a vertical scrollbar for scrolling it
|
||||||
self.vscrollbar = tk.Scrollbar(self, orient=tk.VERTICAL)
|
self.vscrollbar = tk.Scrollbar(self, orient=tk.VERTICAL)
|
||||||
self.vscrollbar.pack(side='right', fill="y", expand="false")
|
self.vscrollbar.pack(side='right', fill="y", expand="false")
|
||||||
|
|
||||||
|
if not vertical_only:
|
||||||
self.hscrollbar = tk.Scrollbar(self, orient=tk.HORIZONTAL)
|
self.hscrollbar = tk.Scrollbar(self, orient=tk.HORIZONTAL)
|
||||||
self.hscrollbar.pack(side='bottom', fill="x", expand="false")
|
self.hscrollbar.pack(side='bottom', fill="x", expand="false")
|
||||||
|
|
||||||
self.canvas = tk.Canvas(self, yscrollcommand=self.vscrollbar.set, xscrollcommand=self.hscrollbar.set)
|
self.canvas = tk.Canvas(self, yscrollcommand=self.vscrollbar.set, xscrollcommand=self.hscrollbar.set)
|
||||||
|
else:
|
||||||
|
self.canvas = tk.Canvas(self, yscrollcommand=self.vscrollbar.set)
|
||||||
|
|
||||||
self.canvas.pack(side="left", fill="both", expand=True)
|
self.canvas.pack(side="left", fill="both", expand=True)
|
||||||
|
|
||||||
self.vscrollbar.config(command=self.canvas.yview)
|
self.vscrollbar.config(command=self.canvas.yview)
|
||||||
|
if not vertical_only:
|
||||||
self.hscrollbar.config(command=self.canvas.xview)
|
self.hscrollbar.config(command=self.canvas.xview)
|
||||||
|
|
||||||
# reset the view
|
# reset the view
|
||||||
|
@ -2164,6 +2168,7 @@ class TkScrollableFrame(tk.Frame):
|
||||||
self.bind('<Configure>', self.set_scrollregion)
|
self.bind('<Configure>', self.set_scrollregion)
|
||||||
|
|
||||||
self.bind_mouse_scroll(self.canvas, self.yscroll)
|
self.bind_mouse_scroll(self.canvas, self.yscroll)
|
||||||
|
if not vertical_only:
|
||||||
self.bind_mouse_scroll(self.hscrollbar, self.xscroll)
|
self.bind_mouse_scroll(self.hscrollbar, self.xscroll)
|
||||||
self.bind_mouse_scroll(self.vscrollbar, self.yscroll)
|
self.bind_mouse_scroll(self.vscrollbar, self.yscroll)
|
||||||
|
|
||||||
|
@ -2198,7 +2203,7 @@ class TkScrollableFrame(tk.Frame):
|
||||||
# Column #
|
# Column #
|
||||||
# ---------------------------------------------------------------------- #
|
# ---------------------------------------------------------------------- #
|
||||||
class Column(Element):
|
class Column(Element):
|
||||||
def __init__(self, layout, background_color=None, size=(None, None), pad=None, scrollable=False, key=None):
|
def __init__(self, layout, background_color=None, size=(None, None), pad=None, scrollable=False, vertical_scroll_only=False, key=None):
|
||||||
'''
|
'''
|
||||||
Column Element
|
Column Element
|
||||||
:param layout:
|
:param layout:
|
||||||
|
@ -2217,6 +2222,7 @@ class Column(Element):
|
||||||
self.Rows = []
|
self.Rows = []
|
||||||
self.TKFrame = None
|
self.TKFrame = None
|
||||||
self.Scrollable = scrollable
|
self.Scrollable = scrollable
|
||||||
|
self.VerticalScrollOnly = vertical_scroll_only
|
||||||
# self.ImageFilename = image_filename
|
# self.ImageFilename = image_filename
|
||||||
# self.ImageData = image_data
|
# self.ImageData = image_data
|
||||||
# self.ImageSize = image_size
|
# self.ImageSize = image_size
|
||||||
|
@ -3968,7 +3974,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
|
||||||
# ------------------------- COLUMN element ------------------------- #
|
# ------------------------- COLUMN element ------------------------- #
|
||||||
if element_type == ELEM_TYPE_COLUMN:
|
if element_type == ELEM_TYPE_COLUMN:
|
||||||
if element.Scrollable:
|
if element.Scrollable:
|
||||||
col_frame = TkScrollableFrame(tk_row_frame) # do not use yet! not working
|
col_frame = TkScrollableFrame(tk_row_frame, element.VerticalScrollOnly) # do not use yet! not working
|
||||||
PackFormIntoFrame(element, col_frame.TKFrame, toplevel_form)
|
PackFormIntoFrame(element, col_frame.TKFrame, toplevel_form)
|
||||||
col_frame.TKFrame.update()
|
col_frame.TKFrame.update()
|
||||||
if element.Size == (None, None): # if no size specified, use column width x column height/2
|
if element.Size == (None, None): # if no size specified, use column width x column height/2
|
||||||
|
|
|
@ -2570,7 +2570,7 @@ class Window:
|
||||||
|
|
||||||
def Read(self, timeout=None, timeout_key=TIMEOUT_KEY):
|
def Read(self, timeout=None, timeout_key=TIMEOUT_KEY):
|
||||||
if timeout == 0: # timeout of zero runs the old readnonblocking
|
if timeout == 0: # timeout of zero runs the old readnonblocking
|
||||||
event, values = self.ReadNonBlocking()
|
event, values = self._ReadNonBlocking()
|
||||||
if event is None:
|
if event is None:
|
||||||
event = timeout_key
|
event = timeout_key
|
||||||
if values is None:
|
if values is None:
|
||||||
|
@ -2636,11 +2636,13 @@ class Window:
|
||||||
else:
|
else:
|
||||||
return self.ReturnValues
|
return self.ReturnValues
|
||||||
|
|
||||||
def ReadNonBlocking(self):
|
def _ReadNonBlocking(self):
|
||||||
if self.TKrootDestroyed:
|
if self.TKrootDestroyed:
|
||||||
return None, None
|
return None, None
|
||||||
if not self.Shown:
|
if not self.Shown:
|
||||||
self.Show(non_blocking=True)
|
self.Show(non_blocking=True)
|
||||||
|
else:
|
||||||
|
self.QTApplication.processEvents() # refresh the window
|
||||||
if 0: # TODO add window closed with X logic
|
if 0: # TODO add window closed with X logic
|
||||||
self.TKrootDestroyed = True
|
self.TKrootDestroyed = True
|
||||||
_my_windows.Decrement()
|
_my_windows.Decrement()
|
||||||
|
@ -3267,7 +3269,7 @@ def BuildResultsForSubform(form, initialize_only, top_level_form):
|
||||||
value = 0
|
value = 0
|
||||||
elif element.Type == ELEM_TYPE_INPUT_LISTBOX:
|
elif element.Type == ELEM_TYPE_INPUT_LISTBOX:
|
||||||
try:
|
try:
|
||||||
value= [element.QT_ListWidget.currentItem().text(),]
|
value= [item.text() for item in element.QT_ListWidget.selectedItems()]
|
||||||
except:
|
except:
|
||||||
value = []
|
value = []
|
||||||
elif element.Type == ELEM_TYPE_INPUT_SPIN:
|
elif element.Type == ELEM_TYPE_INPUT_SPIN:
|
||||||
|
@ -3552,7 +3554,9 @@ def PackFormIntoFrame(window, containing_frame, toplevel_win):
|
||||||
element_pad = full_element_pad
|
element_pad = full_element_pad
|
||||||
# ------------------------- COLUMN element ------------------------- #
|
# ------------------------- COLUMN element ------------------------- #
|
||||||
if element_type == ELEM_TYPE_COLUMN:
|
if element_type == ELEM_TYPE_COLUMN:
|
||||||
column_widget = QWidget()
|
# column_widget = QWidget()
|
||||||
|
column_widget = QGroupBox()
|
||||||
|
# column_widget.setFrameShape(QtWidgets.QFrame.NoFrame)
|
||||||
|
|
||||||
style = ''
|
style = ''
|
||||||
if font is not None:
|
if font is not None:
|
||||||
|
@ -3560,14 +3564,21 @@ def PackFormIntoFrame(window, containing_frame, toplevel_win):
|
||||||
style += 'font-size: %spt;'%font[1]
|
style += 'font-size: %spt;'%font[1]
|
||||||
if element.BackgroundColor is not None:
|
if element.BackgroundColor is not None:
|
||||||
style += 'background-color: %s;' % element.BackgroundColor
|
style += 'background-color: %s;' % element.BackgroundColor
|
||||||
|
style += 'border: 0px solid gray; '
|
||||||
column_widget.setStyleSheet(style)
|
column_widget.setStyleSheet(style)
|
||||||
|
|
||||||
# print(style)
|
# print(style)
|
||||||
column_layout = QFormLayout()
|
column_layout = QFormLayout()
|
||||||
column_vbox = QVBoxLayout()
|
column_vbox = QVBoxLayout()
|
||||||
|
|
||||||
PackFormIntoFrame(element, column_layout, toplevel_win)
|
PackFormIntoFrame(element, column_layout, toplevel_win)
|
||||||
|
|
||||||
|
|
||||||
column_vbox.addLayout(column_layout)
|
column_vbox.addLayout(column_layout)
|
||||||
column_widget.setLayout(column_vbox)
|
column_widget.setLayout(column_vbox)
|
||||||
|
|
||||||
|
column_widget.setStyleSheet(style)
|
||||||
|
|
||||||
qt_row_layout.addWidget(column_widget)
|
qt_row_layout.addWidget(column_widget)
|
||||||
# ------------------------- TEXT element ------------------------- #
|
# ------------------------- TEXT element ------------------------- #
|
||||||
elif element_type == ELEM_TYPE_TEXT:
|
elif element_type == ELEM_TYPE_TEXT:
|
||||||
|
@ -3623,7 +3634,8 @@ def PackFormIntoFrame(window, containing_frame, toplevel_win):
|
||||||
|
|
||||||
qt_row_layout.addWidget(element.QT_QPushButton)
|
qt_row_layout.addWidget(element.QT_QPushButton)
|
||||||
element.QT_QPushButton.setContentsMargins(*full_element_pad)
|
element.QT_QPushButton.setContentsMargins(*full_element_pad)
|
||||||
|
if 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)
|
# element.QT_QPushButton.clicked.connect(window.QTApplication.exit)
|
||||||
# ------------------------- INPUT (Single Line) element ------------------------- #
|
# ------------------------- INPUT (Single Line) element ------------------------- #
|
||||||
|
@ -4118,10 +4130,13 @@ def StartupTK(window):
|
||||||
if window.FocusElement is not None:
|
if window.FocusElement is not None:
|
||||||
window.FocusElement.setFocus()
|
window.FocusElement.setFocus()
|
||||||
|
|
||||||
|
if not window.NonBlocking:
|
||||||
window.QTWindow.show() ####### The thing that causes the window to be visible ######
|
window.QTWindow.show() ####### The thing that causes the window to be visible ######
|
||||||
|
|
||||||
|
|
||||||
window.QTApplication.exec_()
|
window.QTApplication.exec_()
|
||||||
|
else:
|
||||||
|
window.QTWindow.show() ####### The thing that causes the window to be visible ######
|
||||||
|
window.QTApplication.processEvents()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
window.CurrentlyRunningMainloop = False
|
window.CurrentlyRunningMainloop = False
|
||||||
|
|
Loading…
Reference in New Issue