Reworked the look and feel preivew, browser, new table simulation with arrow keyskkkkkkkkkk
This commit is contained in:
parent
ca35f72ad6
commit
34d8b3c9d1
|
@ -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:
|
||||
|
|
|
@ -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()
|
|
@ -8,16 +8,17 @@ 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
|
|
@ -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
|
|
@ -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'):
|
||||
|
|
Loading…
Reference in New Issue