From e78ae0424a648013488c695140b2dbf4629f8729 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Sat, 10 Nov 2018 17:26:59 -0500 Subject: [PATCH] Table - change_submits parameter, Slider enable/disable, update. --- PySimpleGUIQt/PySimpleGUIQt.py | 15 +++++++------- PySimpleGUIQt/Qt_Dial.py | 9 ++++++-- PySimpleGUIQt/Qt_Widget_Summary.py | 33 ++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 9 deletions(-) create mode 100644 PySimpleGUIQt/Qt_Widget_Summary.py diff --git a/PySimpleGUIQt/PySimpleGUIQt.py b/PySimpleGUIQt/PySimpleGUIQt.py index ff6c5a4f..d5475aba 100644 --- a/PySimpleGUIQt/PySimpleGUIQt.py +++ b/PySimpleGUIQt/PySimpleGUIQt.py @@ -1964,12 +1964,12 @@ class Slider(Element): def Update(self, value=None, range=(None, None), disabled=None): if value is not None: - pass + self.QT_Slider.setValue(int(value)) self.DefaultValue = value if disabled == True: - pass + self.QT_Slider.setDisabled(True) elif disabled == False: - pass + self.QT_Slider.setDisabled(False) def SliderChangedHandler(self, event): # first, get the results table built @@ -2236,7 +2236,7 @@ class Table(Element): return - def QtCallbackCellActivated(self, value): + def QtCallbackCellActivated(self, value=None): print('CELL ACTIVATED ', value) # first, get the results table built # modify the Results table in the parent FlexForm object @@ -4148,11 +4148,12 @@ def PackFormIntoFrame(window, containing_frame, toplevel_win): element.QT_TableWidget.setStyleSheet(style) if element.ChangeSubmits: - element.QT_TableWidget.itemClicked.connect(element.QtCallbackCellActivated) + # element.QT_TableWidget.itemClicked.connect(element.QtCallbackCellActivated) + # element.QT_TableWidget.itemActivated.connect(element.QtCallbackCellActivated) + # element.QT_TableWidget.itemEntered.connect(element.QtCallbackCellActivated) element.QT_TableWidget.itemSelectionChanged.connect(element.QtCallbackCellActivated) # QObject::connect(ui->table->verticalHeader(), SIGNAL(sectionDoubleClicked(int)), this, SLOT( termSelect(int))); - - element.QT_TableWidget.verticalHeader().connect(element.QtCallbackVerticalHeader) + # element.QT_TableWidget.verticalHeader().connect(element.QtCallbackVerticalHeader) element.QT_TableWidget.setRowCount(len(element.Values)) element.QT_TableWidget.setColumnCount(len(element.Values[0])) for rownum, rows in enumerate(element.Values): diff --git a/PySimpleGUIQt/Qt_Dial.py b/PySimpleGUIQt/Qt_Dial.py index 8a9cb63c..fa4ca7c1 100644 --- a/PySimpleGUIQt/Qt_Dial.py +++ b/PySimpleGUIQt/Qt_Dial.py @@ -2,7 +2,11 @@ import PySimpleGUIQt as sg layout = [ [sg.Text('This is the new Dial Element!')], - [sg.Dial(range=(1,100), key='_DIAL_')], + [sg.T(' ', size=(70,10)), sg.T('0', key='+DIAL_VALUE+', font=('Helvetica', 15))], + [sg.Dial(range=(1,100), key='_DIAL_', change_submits=True)], + [sg.Slider((1,100), orientation='h', key='_SLIDER_', change_submits=True), + sg.T(' 1', key='+SLIDER_VALUE+', font=('Helvetica', 15))], + [sg.T('1' + 30*' ' + '100')], [sg.Button('Show'), sg.Button('Exit')] ] @@ -10,8 +14,9 @@ window = sg.Window('Window Title').Layout(layout) while True: # Event Loop event, values = window.Read() - print(event, values) if event is None or event == 'Exit': break + window.FindElement('+DIAL_VALUE+').Update(values['_DIAL_']) + window.FindElement('+SLIDER_VALUE+').Update(values['_SLIDER_']) window.Close() diff --git a/PySimpleGUIQt/Qt_Widget_Summary.py b/PySimpleGUIQt/Qt_Widget_Summary.py new file mode 100644 index 00000000..8d58360a --- /dev/null +++ b/PySimpleGUIQt/Qt_Widget_Summary.py @@ -0,0 +1,33 @@ +import PySimpleGUIQt as sg + +sg.ChangeLookAndFeel('LightGreen') + +layout = [ + [sg.Text('Widgets Currently Supported By PySimpleGUIQt')], + [sg.Text('Text', size=(200,35)), sg.Text('Text In Any Color/Font', font=('Courier', 15), text_color='red')], + [sg.Text('Single Line Input', size=(200,35)), sg.Input(size=(200,25))], + [sg.Text('Multi Line\nInput/Output', size=(200,60)), sg.Multiline(size=(200,75))], + [sg.Text('ListBox', size=(200,35)),sg.Listbox(['Listbox 1','Listbox 2','Listbox 3'], size=(200,85)) ], + [sg.Text('ComboBox / Dropdown', size=(200,25)),sg.Combo(['Combo item 1',], size=(200,35)) ], + [sg.Text('Spinner', size=(200,35)),sg.Spin([1,2,3], size=(40,30)) ], + [sg.Text('Checkbox', size=(200,35)), sg.Checkbox('Checkbox', change_submits=True) ], + [sg.Text('RadioButton', size=(200,35)), sg.Radio('Radio Button', 1) ], + [sg.Text('Slider', size=(200,35)), sg.Slider(orientation='h') ], + [sg.Text('Button', size=(200,35)), sg.Button('Button') ], + [sg.Text('Table', size=(200,35)), sg.Table([[0,1,3,4]])], + [sg.Text('Frame', size=(200,35)), sg.Frame('Frame',[[sg.T('')],[sg.T('')]])], + [sg.Text('Stdout Output', size=(200,35)), sg.Output(size=(200,75)) ], + [sg.Text('Dial', size=(200,35)),sg.Dial(size=(150,75)), sg.Stretch() ], + [sg.Button('Blank'), sg.Button('Exit')] + ] + +window = sg.Window('Window Title', + font=('Helvetica', 13)).Layout(layout) + +while True: # Event Loop + event, values = window.Read() + print(event, values) + if event is None or event == 'Exit': + break + +window.Close()