diff --git a/DemoPrograms/Demo_Color_Names.py b/DemoPrograms/Demo_Color_Names.py index 39f40962..60bd7574 100644 --- a/DemoPrograms/Demo_Color_Names.py +++ b/DemoPrograms/Demo_Color_Names.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -import PySimpleGUI as sg +import PySimpleGUIQt as sg """ @@ -688,13 +688,13 @@ for rows in range(40): try: color = color_list[rows+40*i] row.append(sg.Button(color, button_color=('black', color), - key=color, tooltip=color_map[color])) + key=color, tooltip=color_map[color], border_width=0)) except: pass layout.append(row) -window = sg.Window('Color Viewer', layout, grab_anywhere=False, font=('any 9')) +window = sg.Window('Color Viewer', layout, grab_anywhere=False, font=('any 9'), element_padding=(0,0), border_depth=0) # -- Event loop -- while True: diff --git a/DemoPrograms/Demo_LookAndFeel_Previewer.py b/DemoPrograms/Demo_LookAndFeel_Previewer.py deleted file mode 100644 index efb250a0..00000000 --- a/DemoPrograms/Demo_LookAndFeel_Previewer.py +++ /dev/null @@ -1,23 +0,0 @@ -import PySimpleGUI as sg; web=False -# import PySimpleGUIWeb as sg; web=True -# import PySimpleGUIQT as sg; web=False - -WINDOW_BACKGROUND = 'lightblue' - -def sample_layout(): - return [[sg.Text('Text element'), sg.InputText('Input data here', size=(15,1))], - [sg.Button('Ok'), sg.Button('Cancel'), sg.Slider((1,10), orientation='h', size=(10,15)) ]] - -layout = [[sg.Text('Here is a complete list of themes', font='Default 18', background_color=WINDOW_BACKGROUND)]] - -row = [] -for count, theme in enumerate(sg.ListOfLookAndFeelValues()): - sg.change_look_and_feel(theme) - if not count % 3: - layout += [row] - row = [] - row += [sg.Frame(theme, sample_layout() if not web else [[sg.T(theme)]]+sample_layout())] -if row: - layout += [row] - -sg.Window('Preview of all Look and Feel choices', layout, background_color=WINDOW_BACKGROUND).read() diff --git a/DemoPrograms/Demo_Change_Look_And_Feel_Browser.py b/DemoPrograms/Demo_Look_And_Feel_Theme_Browser.py similarity index 84% rename from DemoPrograms/Demo_Change_Look_And_Feel_Browser.py rename to DemoPrograms/Demo_Look_And_Feel_Theme_Browser.py index 4a10e440..1665f362 100644 --- a/DemoPrograms/Demo_Change_Look_And_Feel_Browser.py +++ b/DemoPrograms/Demo_Look_And_Feel_Theme_Browser.py @@ -8,20 +8,21 @@ import PySimpleGUI as sg """ sg.change_look_and_feel('GreenTan') - +color_list = sg.list_of_look_and_feel_values() +color_list.sort() layout = [[sg.Text('Look and Feel Browser')], [sg.Text('Click a look and feel color to see demo window')], - [sg.Listbox(values=sg.list_of_look_and_feel_values(), + [sg.Listbox(values=color_list, size=(20, 12), key='-LIST-', enable_events=True)], - [sg.Button('Show Window'), sg.Button('Exit')]] + [sg.Button('Exit')]] window = sg.Window('Look and Feel Browser', layout) -while True: # Event Loop +while True: # Event Loop event, values = window.read() if event in (None, 'Exit'): break sg.change_look_and_feel(values['-LIST-'][0]) sg.popup_get_text('This is {}'.format(values['-LIST-'][0])) - + window.close() diff --git a/DemoPrograms/Demo_Look_And_Feel_Theme_Dump.py b/DemoPrograms/Demo_Look_And_Feel_Theme_Dump.py new file mode 100644 index 00000000..0c5d60fe --- /dev/null +++ b/DemoPrograms/Demo_Look_And_Feel_Theme_Dump.py @@ -0,0 +1,45 @@ +import PySimpleGUI as sg; web=False +# import PySimpleGUIWeb as sg; web=True +# import PySimpleGUIQT as sg; web=False + +""" + If you're using the PySimpleGUI color themes, then your code will a line that looks something like this: + sg.change_look_and_feel('Light Green 1') or sg.change_look_and_feel('LightGreen1') +""" + +# Use the built-in Theme Viewer to show all of the themes and their names +sg.preview_all_look_and_feel_themes() + +# The remainder of the program duplicates the built-in Theme Viewer, allowing you to create your +# own custom theme viewer window. You can configure the number of frames per row for example. Or maybe you only +# want to see the dark themes + +WINDOW_BACKGROUND = 'lightblue' +web = False + +sg.change_look_and_feel('Default') + +def sample_layout(): + return [[sg.Text('Text element'), sg.InputText('Input data here', size=(15, 1))], + [sg.Button('Ok'), sg.Button('Cancel'), sg.Slider((1, 10), orientation='h', size=(10, 15))]] + + +layout = [[sg.Text('List of Themes Provided by PySimpleGUI', font='Default 18', background_color=WINDOW_BACKGROUND)]] + +FRAMES_PER_ROW = 9 +names = sg.list_of_look_and_feel_values() +names.sort() +row = [] +for count, theme in enumerate(names): + sg.change_look_and_feel(theme) + if not count % FRAMES_PER_ROW: + layout += [row] + row = [] + row += [sg.Frame(theme, sample_layout() if not web else [[sg.T(theme)]] + sample_layout())] +if row: + layout += [row] + +window = sg.Window('Custom Preview of Themes', layout, background_color=WINDOW_BACKGROUND) +window.read() +window.close() +del window diff --git a/DemoPrograms/Demo_Table_Simulation_Arrow_Keys.py b/DemoPrograms/Demo_Table_Simulation_Arrow_Keys.py index 863874a1..13656953 100644 --- a/DemoPrograms/Demo_Table_Simulation_Arrow_Keys.py +++ b/DemoPrograms/Demo_Table_Simulation_Arrow_Keys.py @@ -1,17 +1,17 @@ -import PySimpleGUI as sg +import PySimpleGUIWeb as sg +from random import randint """ Another simple table created from Input Text Elements. This demo adds the ability to "navigate" around the drawing using the arrow keys. The tab key works automatically, but the arrow keys are done in the code below. """ +sg.change_look_and_feel('Light green 5') # No excuse for gray windows + MAX_COLS = MAX_ROWS = 5 - -sg.change_look_and_feel('Dark Brown 1') # No excuse for gray windows - # Create an Excel style window layout quickly and easily using list comprehensions layout = [[sg.Text(' '*11)]+[sg.Text(s+ ' '*19) for s in 'ABCDE'] ] + \ - [[sg.T(r)] + [sg.Input('0', justification='r', key=(r,c)) for c in range(MAX_COLS)] for r in range(MAX_ROWS)] + \ + [[sg.T(r)] + [sg.Input(randint(0,100), justification='r', key=(r,c)) for c in range(MAX_COLS)] for r in range(MAX_ROWS)] + \ [[sg.Button('Table Values'), sg.Button('Exit')]] # Create the window and show it @@ -21,7 +21,8 @@ while True: # Event Loop event, values = window.read() if event in (None, 'Exit'): # If user closed the window break - current_cell = window.find_element_with_focus().Key + elem = window.find_element_with_focus() + current_cell = elem.Key if elem else (0,0) r,c = current_cell # Process arrow keys if event.startswith('Down'):