Merge pull request #2405 from PySimpleGUI/Dev-latest

Dev latest
This commit is contained in:
PySimpleGUI 2019-12-19 12:53:23 -05:00 committed by GitHub
commit 0bef56dc87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 59 additions and 18 deletions

View File

@ -1,6 +1,6 @@
#!/usr/bin/python3 #!/usr/bin/python3
version = __version__ = "4.13.0 Released 18-Dec-2019" version = __version__ = "4.13.0.1 Unreleased - Element.set_cursor, theme(), Combo.update allows any value, beginning of theme reworking with theme() call, table & tree header font defaults to window font"
port = 'PySimpleGUI' port = 'PySimpleGUI'
@ -886,6 +886,19 @@ class Element():
self.Widget.pack(expand=True, fill=fill) self.Widget.pack(expand=True, fill=fill)
self.ParentRowFrame.pack(expand=expand_row, fill=fill) self.ParentRowFrame.pack(expand=expand_row, fill=fill)
def set_cursor(self,cursor):
"""
Sets the cursor for the current Element.
:param cursor: (str) The tkinter cursor name
"""
try:
self.Widget.config(cursor=cursor)
except Exception as e:
print('Warning bad cursor specified ', cursor)
print(e)
def __call__(self, *args, **kwargs): def __call__(self, *args, **kwargs):
""" """
Makes it possible to "call" an already existing element. When you do make the "call", it actually calls Makes it possible to "call" an already existing element. When you do make the "call", it actually calls
@ -1085,14 +1098,17 @@ class Combo(Element):
pass pass
self.Values = values self.Values = values
if value is not None: if value is not None:
for index, v in enumerate(self.Values): if value not in self.Values:
if v == value: self.TKCombo.set(value)
try: else:
self.TKCombo.current(index) for index, v in enumerate(self.Values):
except: if v == value:
pass try:
self.DefaultValue = value self.TKCombo.current(index)
break except:
pass
self.DefaultValue = value
break
if set_to_index is not None: if set_to_index is not None:
try: try:
self.TKCombo.current(set_to_index) self.TKCombo.current(set_to_index)
@ -8873,8 +8889,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
style.configure(custom_style + '.Tab', background=element.TabBackgroundColor) style.configure(custom_style + '.Tab', background=element.TabBackgroundColor)
if element.TextColor is not None and element.TextColor != COLOR_SYSTEM_DEFAULT: if element.TextColor is not None and element.TextColor != COLOR_SYSTEM_DEFAULT:
style.configure(custom_style + '.Tab', foreground=element.TextColor) style.configure(custom_style + '.Tab', foreground=element.TextColor)
if element.Font is not None: style.configure(custom_style + '.Tab', font=font)
style.configure(custom_style + '.Tab', font=element.Font)
element.TKNotebook = element.Widget = ttk.Notebook(tk_row_frame, style=custom_style) element.TKNotebook = element.Widget = ttk.Notebook(tk_row_frame, style=custom_style)
@ -9028,6 +9043,8 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
table_style.configure(style_name+'.Heading', background=element.HeaderBackgroundColor) table_style.configure(style_name+'.Heading', background=element.HeaderBackgroundColor)
if element.HeaderFont is not None: if element.HeaderFont is not None:
table_style.configure(style_name+'.Heading', font=element.HeaderFont) table_style.configure(style_name+'.Heading', font=element.HeaderFont)
else:
table_style.configure(style_name+'.Heading', font=font)
table_style.configure(style_name, font=font) table_style.configure(style_name, font=font)
treeview.configure(style=style_name) treeview.configure(style=style_name)
@ -9139,11 +9156,13 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
if element.TextColor is not None and element.TextColor != COLOR_SYSTEM_DEFAULT: if element.TextColor is not None and element.TextColor != COLOR_SYSTEM_DEFAULT:
tree_style.configure(style_name, foreground=element.TextColor) tree_style.configure(style_name, foreground=element.TextColor)
if element.HeaderTextColor is not None and element.HeaderTextColor != COLOR_SYSTEM_DEFAULT: if element.HeaderTextColor is not None and element.HeaderTextColor != COLOR_SYSTEM_DEFAULT:
table_style.configure(style_name+'.Heading', foreground=element.HeaderTextColor) tree_style.configure(style_name+'.Heading', foreground=element.HeaderTextColor)
if element.HeaderBackgroundColor is not None and element.HeaderBackgroundColor != COLOR_SYSTEM_DEFAULT: if element.HeaderBackgroundColor is not None and element.HeaderBackgroundColor != COLOR_SYSTEM_DEFAULT:
table_style.configure(style_name+'.Heading', background=element.HeaderBackgroundColor) tree_style.configure(style_name+'.Heading', background=element.HeaderBackgroundColor)
if element.HeaderFont is not None: if element.HeaderFont is not None:
table_style.configure(style_name+'.Heading', font=element.HeaderFont) tree_style.configure(style_name+'.Heading', font=element.HeaderFont)
else:
tree_style.configure(style_name+'.Heading', font=font)
tree_style.configure(style_name, font=font) tree_style.configure(style_name, font=font)
if element.RowHeight: if element.RowHeight:
tree_style.configure(style_name, rowheight=element.RowHeight) tree_style.configure(style_name, rowheight=element.RowHeight)
@ -10968,7 +10987,6 @@ LOOK_AND_FEEL_TABLE = {'SystemDefault':
'BUTTON': ('#e3e3e3', '#455d7a'), 'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR, 'BORDER': 1, 'SLIDER_DEPTH': 0, 'BUTTON': ('#e3e3e3', '#455d7a'), 'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR, 'BORDER': 1, 'SLIDER_DEPTH': 0,
'PROGRESS_DEPTH': 0, 'COLOR_LIST': ['#233142', '#455d7a', '#f95959', '#e3e3e3'], 'PROGRESS_DEPTH': 0, 'COLOR_LIST': ['#233142', '#455d7a', '#f95959', '#e3e3e3'],
'DESCRIPTION': ['Black', 'Blue', 'Red', 'Grey']}, 'DESCRIPTION': ['Black', 'Blue', 'Red', 'Grey']},
} }
@ -10980,6 +10998,28 @@ def ListOfLookAndFeelValues():
return sorted(list(LOOK_AND_FEEL_TABLE.keys())) return sorted(list(LOOK_AND_FEEL_TABLE.keys()))
def get_theme():
"""
Returns the current "Look and Feel" theme
:return:
"""
return CURRENT_LOOK_AND_FEEL
def theme(new_theme=None):
"""
Sets / Gets the current Theme. If none is specified then returns the current theme
:param new_theme: (str) the new theme name to use
:return: (str) the currently selected theme
"""
if new_theme is not None:
set_theme(new_theme)
return get_theme()
def ChangeLookAndFeel(index, force=False): def ChangeLookAndFeel(index, force=False):
""" """
Change the "color scheme" of all future PySimpleGUI Windows. Change the "color scheme" of all future PySimpleGUI Windows.
@ -12562,7 +12602,7 @@ def main():
from random import randint from random import randint
# preview_all_look_and_feel_themes() # preview_all_look_and_feel_themes()
look_and_feel = 'Anything' look_and_feel = 'Anything'
ChangeLookAndFeel(look_and_feel) set_theme(look_and_feel)
# ------ Menu Definition ------ # # ------ Menu Definition ------ #
menu_def = [['&File', ['!&Open', '&Save::savekey', '---', '&Properties', 'E&xit']], menu_def = [['&File', ['!&Open', '&Save::savekey', '---', '&Properties', 'E&xit']],
['!&Edit', ['!&Paste', ['Special', 'Normal', ], 'Undo'], ], ['!&Edit', ['!&Paste', ['Special', 'Normal', ], 'Undo'], ],
@ -12650,7 +12690,7 @@ def main():
layout = [[Column([[Menu(menu_def, key='_MENU_')]] + layout1), Column([[ProgressBar(max_value=800, size=(50, 25), orientation='v', key='+PROGRESS+')]])]] layout = [[Column([[Menu(menu_def, key='_MENU_')]] + layout1), Column([[ProgressBar(max_value=800, size=(50, 25), orientation='v', key='+PROGRESS+')]])]]
window = Window('Window Title', layout, window = Window('Window Title', layout,
font=('Helvetica', 13), font=('Helvetica', 18),
# background_color='black', # background_color='black',
right_click_menu=['&Right', ['Right', '!&Click', '&Menu', 'E&xit', 'Properties']], right_click_menu=['&Right', ['Right', '!&Click', '&Menu', 'E&xit', 'Properties']],
# transparent_color= '#9FB8AD', # transparent_color= '#9FB8AD',
@ -12693,13 +12733,14 @@ def main():
elif event == 'About...': elif event == 'About...':
popup_no_wait('About this program...', 'You are looking at the test harness for the PySimpleGUI program') popup_no_wait('About this program...', 'You are looking at the test harness for the PySimpleGUI program')
elif event.startswith('See'): elif event.startswith('See'):
window.set_transparent_color(LOOK_AND_FEEL_TABLE[look_and_feel]['BACKGROUND']) window.set_transparent_color(LOOK_AND_FEEL_TABLE[get_theme()]['BACKGROUND'])
window.close() window.close()
# ------------------------ PEP8-ify The SDK ------------------------# # ------------------------ PEP8-ify The SDK ------------------------#
change_look_and_feel = ChangeLookAndFeel change_look_and_feel = ChangeLookAndFeel
set_theme = ChangeLookAndFeel
convert_args_to_single_string = ConvertArgsToSingleString convert_args_to_single_string = ConvertArgsToSingleString
convert_flex_to_tk = ConvertFlexToTK convert_flex_to_tk = ConvertFlexToTK
easy_print = EasyPrint easy_print = EasyPrint