diff --git a/PySimpleGUI_Qt/Demo_HowDoI.py b/PySimpleGUIQt/Demo_HowDoI.py similarity index 99% rename from PySimpleGUI_Qt/Demo_HowDoI.py rename to PySimpleGUIQt/Demo_HowDoI.py index 56f152d7..0eaa947a 100644 --- a/PySimpleGUI_Qt/Demo_HowDoI.py +++ b/PySimpleGUIQt/Demo_HowDoI.py @@ -1,6 +1,6 @@ #!/usr/bin/env python import sys -import PySimpleGUI_Qt as sg +import PySimpleGUIQt as sg import subprocess diff --git a/PySimpleGUI_Qt/PySimpleGUI_Qt.py b/PySimpleGUIQt/PySimpleGUIQt.py similarity index 99% rename from PySimpleGUI_Qt/PySimpleGUI_Qt.py rename to PySimpleGUIQt/PySimpleGUIQt.py index f806ef72..a1836557 100644 --- a/PySimpleGUI_Qt/PySimpleGUI_Qt.py +++ b/PySimpleGUIQt/PySimpleGUIQt.py @@ -441,7 +441,7 @@ class InputText(Element): fg = text_color if text_color is not None else DEFAULT_INPUT_TEXT_COLOR self.Focus = focus self.do_not_clear = do_not_clear - self.Justification = justification + self.Justification = justification or 'left' self.Disabled = disabled self.ChangeSubmits = change_submits super().__init__(ELEM_TYPE_INPUT_TEXT, size=size, background_color=bg, text_color=fg, key=key, pad=pad, @@ -2782,10 +2782,9 @@ class Window: if self.TKrootDestroyed: return try: - self.TKroot.destroy() - _my_windows.Decrement() + self.QTWindow.close() except: - pass + print('error closing window') CloseNonBlockingForm = Close CloseNonBlocking = Close @@ -3595,8 +3594,9 @@ def PackFormIntoFrame(window, containing_frame, toplevel_win): if element.Tooltip: element.QT_Label.setToolTip(element.Tooltip) - - qt_row_layout.setContentsMargins(*full_element_pad) + element.QT_Label.setMargin(full_element_pad[0]) + element.QT_Label.setIndent(full_element_pad[1]) + # qt_row_layout.setContentsMargins(*full_element_pad) qt_row_layout.addWidget(element.QT_Label) # ------------------------- BUTTON element ------------------------- # elif element_type == ELEM_TYPE_BUTTON: @@ -3620,17 +3620,22 @@ def PackFormIntoFrame(window, containing_frame, toplevel_win): if element.Disabled: element.QT_QPushButton.setDisabled(True) - qt_row_layout.setContentsMargins(*full_element_pad) qt_row_layout.addWidget(element.QT_QPushButton) - # if element.Pad[0] is not None: - # element.QT_QPushButton.setContentsMargins(*full_element_pad) + element.QT_QPushButton.setContentsMargins(*full_element_pad) + element.QT_QPushButton.clicked.connect(element.ButtonCallBack) # element.QT_QPushButton.clicked.connect(window.QTApplication.exit) # ------------------------- INPUT (Single Line) element ------------------------- # elif element_type == ELEM_TYPE_INPUT_TEXT: default_text = element.DefaultText element.QT_QLineEdit = QLineEdit() + + if element.Justification[0] == 'c': + element.QT_QLineEdit.setAlignment(Qt.AlignCenter) + elif element.Justification[0] == 'r': + element.QT_QLineEdit.setAlignment(Qt.AlignRight) + element.QT_QLineEdit.setPlaceholderText(default_text) style = '' if font is not None: @@ -3640,6 +3645,7 @@ def PackFormIntoFrame(window, containing_frame, toplevel_win): style += 'color: %s;' % element.TextColor if element.BackgroundColor is not None: style += 'background-color: %s;' % element.BackgroundColor + element.QT_QLineEdit.setStyleSheet(style) if element.AutoSizeText is False or toplevel_win.AutoSizeButtons is False or element.Size[0] is not None: @@ -5659,8 +5665,8 @@ def main(): layout = [[Text('You are running the PySimpleGUI.py file itself')], [Text('You should be importing it rather than running it')], [Text('Here is your sample input window....')], - [Text('Source File', size=(150, 20), justification='right'), InputText('Source', focus=True), FileBrowse(target=(ThisRow,-2))], - [Text('Destination Folder', size=(150, 20), justification='right'), InputText('Dest'), FolderBrowse()], + [Text('Source File', size=(150, 25), justification='right'), InputText('Source', focus=True), FileBrowse()], + [Text('Destination Folder', size=(150, 25), justification='right'), InputText('Dest'), FolderBrowse()], [Ok(), Cancel()]] window = Window('Demo window..',auto_size_buttons=False, default_element_size=(280,22), default_button_element_size=(80,20)).Layout(layout) diff --git a/PySimpleGUIQt/Qt_All_Widgets.py b/PySimpleGUIQt/Qt_All_Widgets.py new file mode 100644 index 00000000..a4299b4a --- /dev/null +++ b/PySimpleGUIQt/Qt_All_Widgets.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python +import sys +if sys.version_info[0] >= 3: + import PySimpleGUIQt as sg +else: + import PySimpleGUI27 as sg + +sg.ChangeLookAndFeel('Topanga') +# sg.SetOptions(element_padding=(0,0)) +# ------ Menu Definition ------ # +menu_def = [['&File', ['&Open', '&Save', 'E&xit', 'Properties']], + ['&Edit', ['Paste', ['Special', 'Normal', ], 'Undo'], ], + ['&Help', '&About...'], ] + +# ------ Column Definition ------ # +column1 = [[sg.Text('Column 1', background_color='lightblue',text_color='black', justification='center', size=(100,22))], + [sg.Spin((1,10), size=(100,22))], + [sg.Spin((1,10), size=(100,22))], + [sg.Spin((1,10), size=(100,22))],] + +layout = [ + [sg.Menu(menu_def, tearoff=True)], + [sg.Text('(Almost) All widgets in one Window!', justification='c', font=("Helvetica", 25), relief=sg.RELIEF_RIDGE)], + [sg.Text('Here is some text.... and a place to enter text')], + [sg.InputText('This is my text', size=(400,22))], + [sg.Frame(layout=[ + [sg.Checkbox('Checkbox', size=(185,22)), sg.Checkbox('My second checkbox!', default=True)], + [sg.Radio('My first Radio!', "RADIO1", default=True, size=(180,22), ),sg.Radio('My second Radio!', "RADIO1")], + [sg.Radio('Third Radio!', "RADIO2", default=True, size=(180,22), ),sg.Radio('Fourth Radio!', "RADIO2")] + + ], title='Options',title_color='red', relief=sg.RELIEF_SUNKEN, tooltip='Use these to set flags', ), sg.Stretch()], + [sg.Multiline(default_text='This is the default Text should you decide not to type anything', size=(220, 80)), + sg.Multiline(default_text='A second multi-line', size=(220, 80))], + [sg.InputCombo(('Combobox 1', 'Combobox 2'), size=(150, 22)), sg.Stretch(), + sg.Slider(range=(1, 100), orientation='h', size=(300, 22), default_value=85)], + [sg.InputOptionMenu(('Menu Option 1', 'Menu Option 2', 'Menu Option 3'))], + [sg.Listbox(values=('Listbox 1', 'Listbox 2', 'Listbox 3'), size=(200,100), select_mode=sg.LISTBOX_SELECT_MODE_SINGLE), sg.Stretch(), + sg.Frame('Labelled Group',[[ + sg.Slider(range=(1, 100), orientation='v', default_value=25, tick_interval=25), + sg.Slider(range=(1, 100), orientation='v', default_value=75), + sg.Slider(range=(1, 100), orientation='v', default_value=10), + sg.Column(column1, background_color='red')]]), sg.Stretch()], + [sg.Text('_' * 50, justification='c')], + [sg.Text('Choose A Folder')], + [sg.Text('Your Folder'), + sg.InputText('Default Folder', size=(300,22)), sg.FolderBrowse(), sg.Stretch()], + [sg.Submit(tooltip='Click to submit this form',), sg.Cancel()]] + +window = sg.Window('Everything bagel', + grab_anywhere=False, + font=('Helvetica', 12), + no_titlebar=False, + alpha_channel=1, + keep_on_top=False, + element_padding=(2,3), + default_element_size=(100, 23), + default_button_element_size=(120,30) + ).Layout(layout) +event, values = window.Read() + +window.Close() + +sg.Popup('Title', + 'The results of the window.', + 'The button clicked was "{}"'.format(event), + 'The values are', values) + + diff --git a/PySimpleGUI_Qt/Qt_Dial.py b/PySimpleGUIQt/Qt_Dial.py similarity index 93% rename from PySimpleGUI_Qt/Qt_Dial.py rename to PySimpleGUIQt/Qt_Dial.py index 4ac86e4b..8a9cb63c 100644 --- a/PySimpleGUI_Qt/Qt_Dial.py +++ b/PySimpleGUIQt/Qt_Dial.py @@ -1,4 +1,4 @@ -import PySimpleGUI_Qt as sg +import PySimpleGUIQt as sg layout = [ [sg.Text('This is the new Dial Element!')], diff --git a/PySimpleGUI_Qt/Qt_Test.py b/PySimpleGUIQt/Qt_Test.py similarity index 85% rename from PySimpleGUI_Qt/Qt_Test.py rename to PySimpleGUIQt/Qt_Test.py index 2476846b..c0034fa7 100644 --- a/PySimpleGUI_Qt/Qt_Test.py +++ b/PySimpleGUIQt/Qt_Test.py @@ -1,9 +1,9 @@ -import PySimpleGUI_Qt as sg +import PySimpleGUIQt as sg # sg.Popup('test 1') # sg.Popup('test 2') sg.ChangeLookAndFeel('GreenTan') layout = [ - [sg.Text('Hello From PySimpleGUI_Qt!', text_color='red', tooltip='This is my tooltip', justification='c', font=('Courier', 22), key='_TEXT_')], + [sg.Text('Hello From PySimpleGUIQt!', text_color='red', tooltip='This is my tooltip', justification='c', font=('Courier', 22), key='_TEXT_')], [sg.Text('Input something here'),sg.Stretch(), sg.Input('This is an InputText Element', key='_INPUT_', font=('Any', 14))], [sg.Text('This is the new Dial Element'), sg.Dial(background_color='red'), sg.Stretch()], [sg.Combo(['Combo 1', 'Combo 2', 'Combo 3'], key='+COMBO+', size=(150,30), text_color='green')], @@ -13,7 +13,7 @@ layout = [ [sg.Checkbox('Checkbox 3'), sg.Checkbox('Checkbox 4')], [sg.Radio('Radio1', group_id=1),sg.Radio('Radio2', group_id=1)], [sg.Spin((5,8), size=(100,30))], - [sg.Multiline('This is a Multiline Element', key='+MULTI+')], + [sg.Multiline('This is a Multiline Element', size=(300,300), key='+MULTI+')], [sg.Button('My Button', size=(120,30)), sg.Exit(), sg.Button('Change', key='_CHANGE_')], ] diff --git a/PySimpleGUIQt/__pycache__/PySimpleGUIQt.cpython-36.pyc b/PySimpleGUIQt/__pycache__/PySimpleGUIQt.cpython-36.pyc new file mode 100644 index 00000000..61ba1e1c Binary files /dev/null and b/PySimpleGUIQt/__pycache__/PySimpleGUIQt.cpython-36.pyc differ diff --git a/PySimpleGUI_Qt/question.ico b/PySimpleGUIQt/question.ico similarity index 100% rename from PySimpleGUI_Qt/question.ico rename to PySimpleGUIQt/question.ico diff --git a/PySimpleGUI_Qt/Qt_All_Widgets.py b/PySimpleGUI_Qt/Qt_All_Widgets.py deleted file mode 100644 index b6f913e5..00000000 --- a/PySimpleGUI_Qt/Qt_All_Widgets.py +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/env python -import sys -if sys.version_info[0] >= 3: - import PySimpleGUI_Qt as sg -else: - import PySimpleGUI27 as sg - -sg.ChangeLookAndFeel('GreenTan') - -# # Column layout -# col = [[sg.Text('col Row 1', text_color='white', background_color='blue')], -# [sg.Text('col Row 2', text_color='white', background_color='blue'), sg.Input('col input 1')], -# [sg.Text('col Row 3', text_color='white', background_color='blue'), sg.Input('col input 2')]] -# # Window layout -# layout = [ [sg.In()], -# [sg.Text('test'), sg.Column(col, background_color='blue')],] -# -# # Display the window and get values -# event, values = sg.Window('Compact 1-line form with column').Layout(layout).Read() -# -# exit() -# ------ Menu Definition ------ # -menu_def = [['&File', ['&Open', '&Save', 'E&xit', 'Properties']], - ['&Edit', ['Paste', ['Special', 'Normal', ], 'Undo'], ], - ['&Help', '&About...'], ] - -# ------ Column Definition ------ # -column1 = [[sg.Text('Column 1', background_color='lightblue',text_color='black', justification='center', size=(100,30))], - [sg.Spin((1,10), size=(100,30))], - [sg.Spin((1,10), size=(100,30))], - [sg.Spin((1,10), size=(100,30))],] - -layout = [ - [sg.Menu(menu_def, tearoff=True)], - [sg.Text('(Almost) All widgets in one Window!', size=(600, 50), justification='l', font=("Helvetica", 25), relief=sg.RELIEF_RIDGE)], - [sg.Text('Here is some text.... and a place to enter text')], - [sg.InputText('This is my text', size=(300,30))], - [sg.Frame(layout=[ - [sg.Checkbox('Checkbox', size=(185,30)), sg.Checkbox('My second checkbox!', default=True)], - [sg.Radio('My first Radio!', "RADIO1", default=True, size=(180,30), ),sg.Radio('My second Radio!', "RADIO1")]], title='Options',title_color='red', relief=sg.RELIEF_SUNKEN, tooltip='Use these to set flags', ), sg.Stretch()], - [sg.Multiline(default_text='This is the default Text should you decide not to type anything', size=(300, 80)), - sg.Multiline(default_text='A second multi-line', size=(300, 80))], - [sg.InputCombo(('Combobox 1', 'Combobox 2'), size=(150, 30)), - sg.Slider(range=(1, 100), orientation='h', size=(150, 30), default_value=85)], - [sg.InputOptionMenu(('Menu Option 1', 'Menu Option 2', 'Menu Option 3'))], - [sg.Listbox(values=('Listbox 1', 'Listbox 2', 'Listbox 3'), size=(200,100)), - sg.Frame('Labelled Group',[[ - sg.Slider(range=(1, 100), orientation='v', default_value=25, tick_interval=25), - sg.Slider(range=(1, 100), orientation='v', default_value=75), - sg.Slider(range=(1, 100), orientation='v', default_value=10), - sg.Column(column1, background_color='lightblue')]]), sg.Stretch()], - [sg.Text('_' * 80)], - [sg.Text('Choose A Folder')], - [sg.Text('Your Folder', auto_size_text=True, justification='right'), - sg.InputText('Default Folder', size=(300,30)), sg.FolderBrowse()], - [sg.Submit(tooltip='Click to submit this form', size=(120,30)), sg.Cancel(size=(120,30))]] - -window = sg.Window('Everything bagel', default_element_size=(40, 1), grab_anywhere=False, font=('Helvetica', 12)).Layout(layout) -event, values = window.Read() - -sg.Popup('Title', - 'The results of the window.', - 'The button clicked was "{}"'.format(event), - 'The values are', values) - -