Skip to content

Commit 305ce75

Browse files
committed
Multiline colors fixed (broke when fixing another problem), added Multiline, MultilineOutput print method. Renamed print_to_element to be internal only
1 parent 8895fe7 commit 305ce75

1 file changed

Lines changed: 35 additions & 4 deletions

File tree

PySimpleGUIQt/PySimpleGUIQt.py

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/python3
2-
version = __version__ = "0.31.0.10 Unreleased - fix for Listbox.update, Graph.change_coordinates, Added Image.Widget, return correct value with ComboBox has manual data entry, added print_to_element, multlineline update moves cursor to end, scrollable columns, listbox.get, fix for visible ignored in Text Element, Window.read close parm, move cursor to end when default text in Multiline, Multiline readonly parm"
2+
version = __version__ = "0.31.0.11 Unreleased - fix for Listbox.update, Graph.change_coordinates, Added Image.Widget, return correct value with ComboBox has manual data entry, added print_to_element, multlineline update moves cursor to end, scrollable columns, listbox.get, fix for visible ignored in Text Element, Window.read close parm, move cursor to end when default text in Multiline, Multiline readonly parm"
33

44
port = 'PySimpleGUIQt'
55

@@ -1040,7 +1040,6 @@ def Update(self, value=None, disabled=None, append=False, background_color=None,
10401040
self.QT_TextEdit.setTextColor(text_color_for_value)
10411041
if background_color_for_value is not None:
10421042
self.QT_TextEdit.setTextBackgroundColor(background_color_for_value)
1043-
self.QT_TextEdit.moveCursor(QtGui.QTextCursor.End)
10441043
self.QT_TextEdit.insertPlainText(str(value))
10451044
if self.Autoscroll:
10461045
self.QT_TextEdit.moveCursor(QtGui.QTextCursor.End)
@@ -1065,6 +1064,22 @@ def Get(self):
10651064
def SetFocus(self):
10661065
self.QT_TextEdit.setFocus()
10671066

1067+
1068+
def print(self, *args, end=None, sep=None, text_color=None, background_color=None):
1069+
"""
1070+
Print like Python normally prints except route the output to a multline element and also add colors if desired
1071+
1072+
:param args: List[Any] The arguments to print
1073+
:param end: (str) The end char to use just like print uses
1074+
:param sep: (str) The separation character like print uses
1075+
:param text_color: The color of the text
1076+
:param background_color: The background color of the line
1077+
"""
1078+
_print_to_element(self, *args, end=end, sep=sep, text_color=text_color, background_color=background_color)
1079+
1080+
1081+
1082+
10681083
get = Get
10691084
set_focus = SetFocus
10701085
update = Update
@@ -1111,7 +1126,7 @@ def __init__(self, default_text='', enter_submits=False, disabled=False, autoscr
11111126
return
11121127

11131128

1114-
def Update(self, value=None, disabled=None, append=False, background_color=None, text_color=None, font=None, visible=None):
1129+
def Update(self, value=None, disabled=None, append=False, background_color=None, text_color=None, font=None, text_color_for_value=None, background_color_for_value=None, visible=None):
11151130
if value is not None and not append:
11161131
self.QT_TextBrowser.setText(str(value))
11171132
elif value is not None and append:
@@ -1127,6 +1142,21 @@ def Update(self, value=None, disabled=None, append=False, background_color=None,
11271142
def Get(self):
11281143
self.QT_TextBrowser.toPlainText()
11291144

1145+
1146+
def print(self, *args, end=None, sep=None, text_color=None, background_color=None):
1147+
"""
1148+
Print like Python normally prints except route the output to a multline element and also add colors if desired
1149+
1150+
:param args: List[Any] The arguments to print
1151+
:param end: (str) The end char to use just like print uses
1152+
:param sep: (str) The separation character like print uses
1153+
:param text_color: The color of the text
1154+
:param background_color: The background color of the line
1155+
"""
1156+
_print_to_element(self, *args, end=end, sep=sep, text_color=text_color, background_color=background_color)
1157+
1158+
1159+
11301160
get = Get
11311161
update = Update
11321162

@@ -5151,6 +5181,7 @@ def PackFormIntoFrame(window, containing_frame, toplevel_win):
51515181
toplevel_win.FocusElement = element.QT_TextEdit
51525182

51535183
element.QT_TextEdit.setText(str(default_text))
5184+
element.QT_TextEdit.moveCursor(QtGui.QTextCursor.End)
51545185
if element.Tooltip:
51555186
element.QT_TextEdit.setToolTip(element.Tooltip)
51565187
# qt_row_layout.setContentsMargins(*full_element_pad)
@@ -6295,7 +6326,7 @@ def EasyPrintClose():
62956326
# A print-like call that can be used to output to a multiline element as if it's an Output element #
62966327
# ------------------------------------------------------------------------------------------------ #
62976328

6298-
def print_to_element(multiline_element, *args, end=None, sep=None, text_color=None, background_color=None):
6329+
def _print_to_element(multiline_element, *args, end=None, sep=None, text_color=None, background_color=None):
62996330
"""
63006331
Print like Python normally prints except route the output to a multline element and also add colors if desired
63016332

0 commit comments

Comments
 (0)