Skip to content

Commit

Permalink
Addeed background color to multiline element update
Browse files Browse the repository at this point in the history
  • Loading branch information
PySimpleGUI committed Dec 1, 2019
1 parent 578ea55 commit 924ba36
Showing 1 changed file with 41 additions and 20 deletions.
61 changes: 41 additions & 20 deletions PySimpleGUIQt/PySimpleGUIQt.py
Expand Up @@ -138,7 +138,7 @@ def TimerStop():
DEFAULT_SCROLLBAR_COLOR = None

# A transparent button is simply one that matches the background
TRANSPARENT_BUTTON = ('#F0F0F0', '#F0F0F0')
TRANSPARENT_BUTTON = 'This constant has been depricated. You must set your button background = background it is on for it to be transparent appearing'
# --------------------------------------------------------------------------------
# Progress Bar Relief Choices
RELIEF_RAISED = 'raised'
Expand Down Expand Up @@ -982,7 +982,7 @@ def _QtCallbackFocusInEvent(self):
_element_callback_quit_mainloop(self)


def Update(self, value=None, disabled=None, append=False, background_color=None, text_color=None, font=None, text_color_for_value=None, visible=None):
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):
"""
Changes some of the settings for the Multiline Element. Must call `Window.read` or `Window.finalize` or "finalize" the window using finalize parameter prior
Expand All @@ -1006,10 +1006,13 @@ def Update(self, value=None, disabled=None, append=False, background_color=None,
# self.QT_TextEdit.append(str(value)) # can't use because adds a newline
if text_color_for_value is not None:
self.QT_TextEdit.setTextColor(text_color_for_value)
self.QT_TextEdit.insertPlainText(str(value)) # code that retains color for a single update
if background_color_for_value is not None:
self.QT_TextEdit.setTextBackgroundColor(background_color_for_value)
self.QT_TextEdit.insertPlainText(str(value))
if text_color_for_value is not None:
self.QT_TextEdit.setTextColor(self.TextColor)
else:
self.QT_TextEdit.insertPlainText(str(value)) # code that retains color for a single update
if background_color_for_value is not None:
self.QT_TextEdit.setTextBackgroundColor(self.BackgroundColor)
if disabled == True:
self.QT_TextEdit.setDisabled(True)
elif disabled == False:
Expand Down Expand Up @@ -2705,15 +2708,27 @@ def __init__(self, data=None, headings=None, visible_column_map=None, col_widths
def _treeview_selected(self, event):
selections = 000000
self.SelectedRows = [x for x in selections]
print('Got selection')
if self.ChangeSubmits:
MyForm = self.ParentForm
if self.Key is not None:
self.ParentForm.LastButtonClicked = self.Key
else:
self.ParentForm.LastButtonClicked = ''
self.ParentForm.FormRemainedOpen = True
if self.ParentForm.CurrentlyRunningMainloop:
self.ParentForm.TKroot.quit()
_element_callback_quit_mainloop(self)

def _QtCallbackCellActivated(self, value=None):
# print('CELL ACTIVATED ', value)
# first, get the results table built
# modify the Results table in the parent FlexForm object
if not self.ChangeSubmits:
return
_element_callback_quit_mainloop(self)

# if self.ChangeSubmits:
# MyForm = self.ParentForm
# if self.Key is not None:
# self.ParentForm.LastButtonClicked = self.Key
# else:
# self.ParentForm.LastButtonClicked = ''
# self.ParentForm.FormRemainedOpen = True
# if self.ParentForm.CurrentlyRunningMainloop:
# self.ParentForm.TKroot.quit()


def Update(self, values=None, key=None, value=None, text=None, visible=None):
Expand Down Expand Up @@ -4325,7 +4340,10 @@ def BuildResultsForSubform(form, initialize_only, top_level_form):
for index in sorted(indexes):
value.append(index.row())
elif element.Type == ELEM_TYPE_TREE:
value = 0
value = []
indexes = element.QT_QTreeWidget.selectionModel().selectedRows()
for index in sorted(indexes):
value.append(index.row())
elif element.Type == ELEM_TYPE_BUTTONMENU:
value = element.MenuItemChosen
element.MenuItemChosen = None
Expand Down Expand Up @@ -5679,6 +5697,9 @@ def add_treeview_data(node, widget):
style += '}'
element.QT_QTreeWidget.setStyleSheet(style)

if element.ChangeSubmits:
element.QT_QTreeWidget.itemSelectionChanged.connect(element._QtCallbackCellActivated)

if element.ShowExpanded:
element.QT_QTreeWidget.expandAll()
element.QT_QTreeWidget.show()
Expand Down Expand Up @@ -8008,10 +8029,10 @@ def main():

frame5 = [
[Table(values=matrix, max_col_width=25, headings=('aaa', 'bbb', 'ccc', 'ddd'),
auto_size_columns=True, display_row_numbers=True, change_submits=False, bind_return_key=True,
auto_size_columns=True, display_row_numbers=True, enable_events=True, bind_return_key=True,
justification='right', num_rows=6, alternating_row_color='lightblue', key='_table_',
text_color='black', tooltip='Table'),
Tree(data=treedata, headings=['col1', 'col2', 'col3'], change_submits=True, auto_size_columns=True,
Tree(data=treedata, headings=['col1', 'col2', 'col3'], enable_events=True, auto_size_columns=True,
num_rows=10, col0_width=10, key='_TREE_', show_expanded=True, size=(200, 150), tooltip='Tree'),
Stretch()],
]
Expand Down Expand Up @@ -8046,21 +8067,21 @@ def main():
Button('Button'), Button('Exit', tooltip='Exit button')],
]

window = Window('Window Title',
window = Window('Window Title', layout,
font=('Helvetica', 13),
default_button_element_size=(100, 30),
auto_size_buttons=False,
default_element_size=(200, 22),
border_depth=1,
).Layout(layout).Finalize()
graph_elem.DrawCircle((200, 200), 50, 'blue')
)
# graph_elem.DrawCircle((200, 200), 50, 'blue')
i = 0
graph_paused = False

# window.Element('_LISTBOX_').SetValue(['Listbox 1','Listbox 3'])
while True: # Event Loop
# TimerStart()
event, values = window.Read(timeout=0)
event, values = window.Read()
print(event, values) if event != TIMEOUT_KEY else None
if event is None or event == 'Exit':
break
Expand Down

0 comments on commit 924ba36

Please sign in to comment.