Macs can force buttons to be tk buttons rather than ttk only (use with care and good luck.. hope it works out for you!), listbbox now has highlight controls exposed, Element.block_focus method added but needs to be renamed before final release
This commit is contained in:
parent
a51bca66b7
commit
5458b64f08
|
@ -1679,9 +1679,9 @@ def main():
|
||||||
layout = [[sg.Text('Find color')],
|
layout = [[sg.Text('Find color')],
|
||||||
[sg.Text('Demonstration of colors')],
|
[sg.Text('Demonstration of colors')],
|
||||||
[sg.Text('Enter a color name in text or hex #RRGGBB format')],
|
[sg.Text('Enter a color name in text or hex #RRGGBB format')],
|
||||||
[sg.InputText(key='hex')],
|
[sg.InputText(key='-HEX-')],
|
||||||
[sg.Listbox(list_of_colors, size=(20, 30), bind_return_key=True, key='listbox'), sg.Text('Or choose from list')],
|
[sg.Listbox(list_of_colors, size=(20, 30), bind_return_key=True, key='-LISTBOX-'), sg.Text('Or choose from list')],
|
||||||
[sg.Submit(), sg.Button('Many buttons', button_color=('white', '#0e6251'), key='Many buttons'), sg.ColorChooserButton( 'Chooser', target=(3,0), key='Chooser'), sg.Quit(),],
|
[sg.Submit(), sg.Button('Many buttons', button_color=('white', '#0e6251'), key='-MANY BUTTONS-'), sg.ColorChooserButton( 'Chooser', target=(3,0), key='-CHOOSER-'), sg.Quit(),],
|
||||||
]
|
]
|
||||||
# [g.Multiline(DefaultText=str(printable), Size=(30,20))]]
|
# [g.Multiline(DefaultText=str(printable), Size=(30,20))]]
|
||||||
event, values = sg.Window('Color Demo', layout, auto_size_buttons=False).read()
|
event, values = sg.Window('Color Demo', layout, auto_size_buttons=False).read()
|
||||||
|
@ -1689,11 +1689,11 @@ def main():
|
||||||
# ------- OUTPUT results portion ------- #
|
# ------- OUTPUT results portion ------- #
|
||||||
if event == 'Quit' or event == sg.WIN_CLOSED:
|
if event == 'Quit' or event == sg.WIN_CLOSED:
|
||||||
exit(0)
|
exit(0)
|
||||||
elif event == 'Many buttons':
|
elif event == '-MANY BUTTONS-':
|
||||||
show_all_colors_on_buttons()
|
show_all_colors_on_buttons()
|
||||||
|
|
||||||
drop_down_value = values['listbox']
|
drop_down_value = values['-LISTBOX-']
|
||||||
hex_input = values['hex']
|
hex_input = values['-HEX-']
|
||||||
if hex_input == '' and len(drop_down_value) == 0:
|
if hex_input == '' and len(drop_down_value) == 0:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
138
PySimpleGUI.py
138
PySimpleGUI.py
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
version = __version__ = "4.38.0 Released 21-Mar-2021"
|
version = __version__ = "4.38.0.3 Unreleased\nAdded Element.block_focus to allow blocking an element from getting focus, Listbox now sets the selected colors to be opposite of normal text/background colors, added highlight parms to Listbox so that they can be directly set, gave Mac users the abliity to override the TTK-Buttons-Only rule for Macs so that if forced, a Button CAN use tk buttons on a Mac"
|
||||||
|
|
||||||
__version__ = version.split()[0] # For PEP 396 and PEP 345
|
__version__ = version.split()[0] # For PEP 396 and PEP 345
|
||||||
|
|
||||||
|
@ -130,6 +130,7 @@ try: # Because Raspberry Pi is still on 3.4....
|
||||||
except: pass
|
except: pass
|
||||||
|
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
import threading
|
||||||
import itertools
|
import itertools
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
|
@ -906,7 +907,7 @@ class Element():
|
||||||
"""
|
"""
|
||||||
# If this is a minimize button for a custom titlebar, then minimize the window
|
# If this is a minimize button for a custom titlebar, then minimize the window
|
||||||
if self.Key == TITLEBAR_MINIMIZE_KEY:
|
if self.Key == TITLEBAR_MINIMIZE_KEY:
|
||||||
# if sys.platform == 'linux':
|
# if running_linux():
|
||||||
if running_linux():
|
if running_linux():
|
||||||
print('* linix minimize *')
|
print('* linix minimize *')
|
||||||
self.ParentForm.TKroot.wm_attributes("-type", "normal")
|
self.ParentForm.TKroot.wm_attributes("-type", "normal")
|
||||||
|
@ -936,7 +937,7 @@ class Element():
|
||||||
|
|
||||||
|
|
||||||
def _titlebar_restore(self, event):
|
def _titlebar_restore(self, event):
|
||||||
# if sys.platform == 'linux':
|
# if running_linux():
|
||||||
if running_linux():
|
if running_linux():
|
||||||
print('linux restore')
|
print('linux restore')
|
||||||
# if self._skip_first_restore_callback:
|
# if self._skip_first_restore_callback:
|
||||||
|
@ -1137,6 +1138,28 @@ class Element():
|
||||||
print('Was unable to set focus. The Widget passed in was perhaps not present in this element? Check your elements .Widget property')
|
print('Was unable to set focus. The Widget passed in was perhaps not present in this element? Check your elements .Widget property')
|
||||||
|
|
||||||
|
|
||||||
|
def block_focus(self, block=True):
|
||||||
|
"""
|
||||||
|
Enable or disable the element from getting focus by using the keyboard.
|
||||||
|
If the block parameter is True, then this element will not be given focus by using
|
||||||
|
the keyboard to go from one element to another.
|
||||||
|
You CAN click on the element and utilize it.
|
||||||
|
|
||||||
|
:param block: if True the element will not get focus via the keyboard
|
||||||
|
:type block: bool
|
||||||
|
"""
|
||||||
|
if not self._widget_was_created(): # if widget hasn't been created yet, then don't allow
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
self.ParentForm.TKroot.focus_force()
|
||||||
|
if block:
|
||||||
|
self.Widget.configure(takefocus=0)
|
||||||
|
else:
|
||||||
|
self.Widget.configure(takefocus=1)
|
||||||
|
except:
|
||||||
|
print('Was unable to block the focus. Check your elements .Widget property')
|
||||||
|
|
||||||
|
|
||||||
def set_size(self, size=(None, None)):
|
def set_size(self, size=(None, None)):
|
||||||
"""
|
"""
|
||||||
Changes the size of an element to a specific size.
|
Changes the size of an element to a specific size.
|
||||||
|
@ -1314,6 +1337,8 @@ class Element():
|
||||||
print('* Base Element Class update was called. Your element does not seem to have an update method')
|
print('* Base Element Class update was called. Your element does not seem to have an update method')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
|
@ -1784,8 +1809,8 @@ class Listbox(Element):
|
||||||
|
|
||||||
def __init__(self, values, default_values=None, select_mode=None, change_submits=False, enable_events=False,
|
def __init__(self, values, default_values=None, select_mode=None, change_submits=False, enable_events=False,
|
||||||
bind_return_key=False, size=(None, None), disabled=False, auto_size_text=None, font=None, no_scrollbar=False,
|
bind_return_key=False, size=(None, None), disabled=False, auto_size_text=None, font=None, no_scrollbar=False,
|
||||||
background_color=None, text_color=None, key=None, k=None, pad=None, tooltip=None, right_click_menu=None,
|
background_color=None, text_color=None, highlight_background_color=None, highlight_text_color=None,
|
||||||
visible=True, metadata=None):
|
key=None, k=None, pad=None, tooltip=None, right_click_menu=None, visible=True, metadata=None):
|
||||||
"""
|
"""
|
||||||
:param values: list of values to display. Can be any type including mixed types as long as they have __str__ method
|
:param values: list of values to display. Can be any type including mixed types as long as they have __str__ method
|
||||||
:type values: List[Any] or Tuple[Any]
|
:type values: List[Any] or Tuple[Any]
|
||||||
|
@ -1808,12 +1833,16 @@ class Listbox(Element):
|
||||||
:param font: specifies the font family, size, etc
|
:param font: specifies the font family, size, etc
|
||||||
:type font: str | Tuple[str, int]
|
:type font: str | Tuple[str, int]
|
||||||
:param font: specifies the font family, size, etc
|
:param font: specifies the font family, size, etc
|
||||||
:param no_scrollbar: ???
|
:param no_scrollbar: Controls if a scrollbar should be shown. If True, no scrollbar will be shown
|
||||||
:type no_scrollbar: ??? (bool)
|
:type no_scrollbar: (bool)
|
||||||
:param background_color: color of background
|
:param background_color: color of background
|
||||||
:type background_color: (str)
|
:type background_color: (str)
|
||||||
:param text_color: color of the text
|
:param text_color: color of the text
|
||||||
:type text_color: (str)
|
:type text_color: (str)
|
||||||
|
:param highlight_background_color: color of the background when an item is selected. Defaults to normal text color (a reverse look)
|
||||||
|
:type highlight_background_color: (str)
|
||||||
|
:param highlight_text_color: color of the text when an item is selected. Defaults to the normal background color (a rerverse look)
|
||||||
|
:type highlight_text_color: (str)
|
||||||
:param key: Used with window.FindElement and with return values to uniquely identify this element
|
:param key: Used with window.FindElement and with return values to uniquely identify this element
|
||||||
:type key: str | int | tuple | object
|
:type key: str | int | tuple | object
|
||||||
:param k: Same as the Key. You can use either k or key. Which ever is set will be used.
|
:param k: Same as the Key. You can use either k or key. Which ever is set will be used.
|
||||||
|
@ -1845,8 +1874,10 @@ class Listbox(Element):
|
||||||
self.SelectMode = SELECT_MODE_SINGLE
|
self.SelectMode = SELECT_MODE_SINGLE
|
||||||
else:
|
else:
|
||||||
self.SelectMode = DEFAULT_LISTBOX_SELECT_MODE
|
self.SelectMode = DEFAULT_LISTBOX_SELECT_MODE
|
||||||
bg = background_color if background_color else DEFAULT_INPUT_ELEMENTS_COLOR
|
bg = background_color if background_color is not None else theme_input_background_color()
|
||||||
fg = text_color if text_color is not None else DEFAULT_INPUT_TEXT_COLOR
|
fg = text_color if text_color is not None else theme_input_text_color()
|
||||||
|
self.HighlightBackgroundColor = highlight_background_color if highlight_background_color is not None else fg
|
||||||
|
self.HighlightTextColor = highlight_text_color if highlight_text_color is not None else bg
|
||||||
self.RightClickMenu = right_click_menu
|
self.RightClickMenu = right_click_menu
|
||||||
self.vsb = None # type: tk.Scrollbar
|
self.vsb = None # type: tk.Scrollbar
|
||||||
self.TKListbox = self.Widget = None # type: tk.Listbox
|
self.TKListbox = self.Widget = None # type: tk.Listbox
|
||||||
|
@ -3574,7 +3605,7 @@ class Button(Element):
|
||||||
self.ChangeSubmits = change_submits or enable_events
|
self.ChangeSubmits = change_submits or enable_events
|
||||||
self.UseTtkButtons = use_ttk_buttons
|
self.UseTtkButtons = use_ttk_buttons
|
||||||
self._files_delimiter = BROWSE_FILES_DELIMITER # used by the file browse button. used when multiple files are selected by user
|
self._files_delimiter = BROWSE_FILES_DELIMITER # used by the file browse button. used when multiple files are selected by user
|
||||||
if sys.platform.startswith('darwin'):
|
if use_ttk_buttons is None and running_mac():
|
||||||
self.UseTtkButtons = True
|
self.UseTtkButtons = True
|
||||||
# if image_filename or image_data:
|
# if image_filename or image_data:
|
||||||
# self.UseTtkButtons = False # if an image is to be displayed, then force the button to not be a TTK Button
|
# self.UseTtkButtons = False # if an image is to be displayed, then force the button to not be a TTK Button
|
||||||
|
@ -3709,7 +3740,7 @@ class Button(Element):
|
||||||
filetypes = (("ALL Files", "*.*"),) if self.FileTypes is None else self.FileTypes
|
filetypes = (("ALL Files", "*.*"),) if self.FileTypes is None else self.FileTypes
|
||||||
|
|
||||||
if self.BType == BUTTON_TYPE_BROWSE_FOLDER:
|
if self.BType == BUTTON_TYPE_BROWSE_FOLDER:
|
||||||
if sys.platform == 'darwin': # macs don't like seeing the parent window (go firgure)
|
if running_mac(): # macs don't like seeing the parent window (go firgure)
|
||||||
folder_name = tk.filedialog.askdirectory(initialdir=self.InitialFolder) # show the 'get folder' dialog box
|
folder_name = tk.filedialog.askdirectory(initialdir=self.InitialFolder) # show the 'get folder' dialog box
|
||||||
else:
|
else:
|
||||||
folder_name = tk.filedialog.askdirectory(initialdir=self.InitialFolder, parent=self.ParentForm.TKroot) # show the 'get folder' dialog box
|
folder_name = tk.filedialog.askdirectory(initialdir=self.InitialFolder, parent=self.ParentForm.TKroot) # show the 'get folder' dialog box
|
||||||
|
@ -3720,7 +3751,7 @@ class Button(Element):
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
elif self.BType == BUTTON_TYPE_BROWSE_FILE:
|
elif self.BType == BUTTON_TYPE_BROWSE_FILE:
|
||||||
if sys.platform == 'darwin':
|
if running_mac():
|
||||||
file_name = tk.filedialog.askopenfilename(
|
file_name = tk.filedialog.askopenfilename(
|
||||||
initialdir=self.InitialFolder) # show the 'get file' dialog box
|
initialdir=self.InitialFolder) # show the 'get file' dialog box
|
||||||
else:
|
else:
|
||||||
|
@ -3735,7 +3766,7 @@ class Button(Element):
|
||||||
strvar.set(color)
|
strvar.set(color)
|
||||||
self.TKStringVar.set(color)
|
self.TKStringVar.set(color)
|
||||||
elif self.BType == BUTTON_TYPE_BROWSE_FILES:
|
elif self.BType == BUTTON_TYPE_BROWSE_FILES:
|
||||||
if sys.platform == 'darwin':
|
if running_mac():
|
||||||
file_name = tk.filedialog.askopenfilenames(initialdir=self.InitialFolder)
|
file_name = tk.filedialog.askopenfilenames(initialdir=self.InitialFolder)
|
||||||
else:
|
else:
|
||||||
file_name = tk.filedialog.askopenfilenames(filetypes=filetypes, initialdir=self.InitialFolder, parent=self.ParentForm.TKroot)
|
file_name = tk.filedialog.askopenfilenames(filetypes=filetypes, initialdir=self.InitialFolder, parent=self.ParentForm.TKroot)
|
||||||
|
@ -3744,7 +3775,7 @@ class Button(Element):
|
||||||
strvar.set(file_name)
|
strvar.set(file_name)
|
||||||
self.TKStringVar.set(file_name)
|
self.TKStringVar.set(file_name)
|
||||||
elif self.BType == BUTTON_TYPE_SAVEAS_FILE:
|
elif self.BType == BUTTON_TYPE_SAVEAS_FILE:
|
||||||
if sys.platform == 'darwin':
|
if running_mac():
|
||||||
file_name = tk.filedialog.asksaveasfilename(defaultextension=self.DefaultExtension,
|
file_name = tk.filedialog.asksaveasfilename(defaultextension=self.DefaultExtension,
|
||||||
initialdir=self.InitialFolder) # show the 'get file' dialog box
|
initialdir=self.InitialFolder) # show the 'get file' dialog box
|
||||||
else:
|
else:
|
||||||
|
@ -5375,7 +5406,7 @@ class Frame(Element):
|
||||||
continue
|
continue
|
||||||
if element.ParentContainer is not None:
|
if element.ParentContainer is not None:
|
||||||
warnings.warn('*** YOU ARE ATTEMPTING TO RESUSE AN ELEMENT IN YOUR LAYOUT! Once placed in a layout, an element cannot be used in another layout. ***', UserWarning)
|
warnings.warn('*** YOU ARE ATTEMPTING TO RESUSE AN ELEMENT IN YOUR LAYOUT! Once placed in a layout, an element cannot be used in another layout. ***', UserWarning)
|
||||||
PopupError('Error creating Frame layout',
|
_error_popup_with_traceback('Error creating Frame layout',
|
||||||
'The layout specified has already been used',
|
'The layout specified has already been used',
|
||||||
'You MUST start witha "clean", unused layout every time you create a window',
|
'You MUST start witha "clean", unused layout every time you create a window',
|
||||||
'The offensive Element = ',
|
'The offensive Element = ',
|
||||||
|
@ -5383,7 +5414,7 @@ class Frame(Element):
|
||||||
'and has a key = ', element.Key,
|
'and has a key = ', element.Key,
|
||||||
'This item will be stripped from your layout',
|
'This item will be stripped from your layout',
|
||||||
'Hint - try printing your layout and matching the IDs "print(layout)"',
|
'Hint - try printing your layout and matching the IDs "print(layout)"',
|
||||||
obj_to_string_single_obj(element), keep_on_top=True)
|
)
|
||||||
continue
|
continue
|
||||||
element.Position = (CurrentRowNumber, i)
|
element.Position = (CurrentRowNumber, i)
|
||||||
element.ParentContainer = self
|
element.ParentContainer = self
|
||||||
|
@ -7738,6 +7769,8 @@ class Window:
|
||||||
self.user_bind_event = None # Used when user defines a tkinter binding using bind method - event data from tkinter
|
self.user_bind_event = None # Used when user defines a tkinter binding using bind method - event data from tkinter
|
||||||
self.modal = modal
|
self.modal = modal
|
||||||
self.thread_queue = None # type: queue.Queue
|
self.thread_queue = None # type: queue.Queue
|
||||||
|
self.thread_lock = None # type: threading.Lock
|
||||||
|
self.thread_timer = None # type: tk.Misc
|
||||||
self.thread_strvar = None # type: tk.StringVar
|
self.thread_strvar = None # type: tk.StringVar
|
||||||
self.read_closed_window_count = 0
|
self.read_closed_window_count = 0
|
||||||
self.config_last_size = (None, None)
|
self.config_last_size = (None, None)
|
||||||
|
@ -7939,6 +7972,8 @@ class Window:
|
||||||
icon = self.titlebar_icon
|
icon = self.titlebar_icon
|
||||||
elif self.WindowIcon == DEFAULT_WINDOW_ICON:
|
elif self.WindowIcon == DEFAULT_WINDOW_ICON:
|
||||||
icon = DEFAULT_BASE64_ICON_16_BY_16
|
icon = DEFAULT_BASE64_ICON_16_BY_16
|
||||||
|
else:
|
||||||
|
icon = None
|
||||||
|
|
||||||
new_rows = [[Titlebar(title=self.Title, icon=icon, text_color=self.titlebar_text_color, background_color=self.titlebar_background_color, font=self.titlebar_font)]] + rows
|
new_rows = [[Titlebar(title=self.Title, icon=icon, text_color=self.titlebar_text_color, background_color=self.titlebar_background_color, font=self.titlebar_font)]] + rows
|
||||||
else:
|
else:
|
||||||
|
@ -8736,7 +8771,7 @@ class Window:
|
||||||
|
|
||||||
if not self._is_window_created():
|
if not self._is_window_created():
|
||||||
return
|
return
|
||||||
if sys.platform != 'linux':
|
if not running_linux():
|
||||||
self.TKroot.state('zoomed')
|
self.TKroot.state('zoomed')
|
||||||
else:
|
else:
|
||||||
self.TKroot.attributes('-fullscreen', True)
|
self.TKroot.attributes('-fullscreen', True)
|
||||||
|
@ -8753,7 +8788,7 @@ class Window:
|
||||||
if self.TKroot.state() == 'iconic':
|
if self.TKroot.state() == 'iconic':
|
||||||
self.TKroot.deiconify()
|
self.TKroot.deiconify()
|
||||||
else:
|
else:
|
||||||
if sys.platform != 'linux':
|
if not running_linux():
|
||||||
self.TKroot.state('normal')
|
self.TKroot.state('normal')
|
||||||
else:
|
else:
|
||||||
self.TKroot.attributes('-fullscreen', False)
|
self.TKroot.attributes('-fullscreen', False)
|
||||||
|
@ -9092,7 +9127,7 @@ class Window:
|
||||||
"""
|
"""
|
||||||
if not self._is_window_created():
|
if not self._is_window_created():
|
||||||
return
|
return
|
||||||
if sys.platform.startswith('win'):
|
if running_windows():
|
||||||
try:
|
try:
|
||||||
self.TKroot.wm_attributes("-topmost", 0)
|
self.TKroot.wm_attributes("-topmost", 0)
|
||||||
self.TKroot.wm_attributes("-topmost", 1)
|
self.TKroot.wm_attributes("-topmost", 1)
|
||||||
|
@ -9368,17 +9403,23 @@ class Window:
|
||||||
print('Warning bad cursor specified ', cursor)
|
print('Warning bad cursor specified ', cursor)
|
||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
def _window_tkvar_changed_callback(self, event, *args):
|
def _window_tkvar_changed_callback(self, *args):
|
||||||
"""
|
"""
|
||||||
Internal callback function for when the thread
|
Internal callback function for when the thread
|
||||||
|
|
||||||
:param event: Information from tkinter about the callback
|
:param event: Information from tkinter about the callback
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# print('Thread callback info')
|
# print('Thread callback info', threading.current_thread())
|
||||||
# print(event)
|
# print(event)
|
||||||
# trace_details = traceback.format_stack()
|
# trace_details = traceback.format_stack()
|
||||||
# print(''.join(trace_details))
|
# print(''.join(trace_details))
|
||||||
|
# self.thread_lock.acquire()
|
||||||
|
# if self.thread_timer:
|
||||||
|
# self.TKroot.after_cancel(id=self.thread_timer)
|
||||||
|
# self.thread_timer = None
|
||||||
|
# self.thread_lock.release()
|
||||||
|
|
||||||
if self._queued_thread_event_available():
|
if self._queued_thread_event_available():
|
||||||
self.FormRemainedOpen = True
|
self.FormRemainedOpen = True
|
||||||
_exit_mainloop(self)
|
_exit_mainloop(self)
|
||||||
|
@ -9392,6 +9433,9 @@ class Window:
|
||||||
if self.thread_queue is None:
|
if self.thread_queue is None:
|
||||||
self.thread_queue = queue.Queue()
|
self.thread_queue = queue.Queue()
|
||||||
|
|
||||||
|
if self.thread_lock is None:
|
||||||
|
self.thread_lock = threading.Lock()
|
||||||
|
|
||||||
if self.thread_strvar is None:
|
if self.thread_strvar is None:
|
||||||
self.thread_strvar = tk.StringVar()
|
self.thread_strvar = tk.StringVar()
|
||||||
self.thread_strvar.trace('w', self._window_tkvar_changed_callback)
|
self.thread_strvar.trace('w', self._window_tkvar_changed_callback)
|
||||||
|
@ -9410,10 +9454,15 @@ class Window:
|
||||||
if self.thread_queue is None:
|
if self.thread_queue is None:
|
||||||
print('*** Warning Window.write_event_value - no thread queue found ***')
|
print('*** Warning Window.write_event_value - no thread queue found ***')
|
||||||
return
|
return
|
||||||
|
# self.thread_lock.acquire() # first lock the critical section
|
||||||
self.thread_queue.put(item=(key, value))
|
self.thread_queue.put(item=(key, value))
|
||||||
self.thread_strvar.set('new item')
|
self.thread_strvar.set('new item')
|
||||||
|
# March 28 2021 - finally found a solution! It needs a little more work and a lock
|
||||||
|
# if no timer is running, then one should be started
|
||||||
|
# if self.thread_timer is None:
|
||||||
|
# print('Starting a timer')
|
||||||
|
# self.thread_timer = self.TKroot.after(1, self._window_tkvar_changed_callback)
|
||||||
|
# self.thread_lock.release()
|
||||||
|
|
||||||
def _queued_thread_event_read(self):
|
def _queued_thread_event_read(self):
|
||||||
if self.thread_queue is None:
|
if self.thread_queue is None:
|
||||||
|
@ -9431,8 +9480,11 @@ class Window:
|
||||||
|
|
||||||
if self.thread_queue is None:
|
if self.thread_queue is None:
|
||||||
return False
|
return False
|
||||||
|
# self.thread_lock.acquire()
|
||||||
qsize = self.thread_queue.qsize()
|
qsize = self.thread_queue.qsize()
|
||||||
|
if qsize == 0:
|
||||||
|
self.thread_timer = None
|
||||||
|
# self.thread_lock.release()
|
||||||
return qsize != 0
|
return qsize != 0
|
||||||
|
|
||||||
|
|
||||||
|
@ -12246,7 +12298,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
|
||||||
print('Button with text: ', btext, 'key:', element.Key,'has a bad color string', bc)
|
print('Button with text: ', btext, 'key:', element.Key,'has a bad color string', bc)
|
||||||
elif bc[1] == COLOR_SYSTEM_DEFAULT and bc[0] != COLOR_SYSTEM_DEFAULT:
|
elif bc[1] == COLOR_SYSTEM_DEFAULT and bc[0] != COLOR_SYSTEM_DEFAULT:
|
||||||
tkbutton.config(foreground=bc[0])
|
tkbutton.config(foreground=bc[0])
|
||||||
if bd == 0 and not sys.platform.startswith('darwin'):
|
if bd == 0 and not running_mac():
|
||||||
tkbutton.config(relief=tk.FLAT)
|
tkbutton.config(relief=tk.FLAT)
|
||||||
|
|
||||||
element.TKButton = tkbutton # not used yet but save the TK button in case
|
element.TKButton = tkbutton # not used yet but save the TK button in case
|
||||||
|
@ -12343,7 +12395,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
|
||||||
button_style.configure(style_name, foreground=bc[0], background=bc[1])
|
button_style.configure(style_name, foreground=bc[0], background=bc[1])
|
||||||
elif bc[1] == COLOR_SYSTEM_DEFAULT:
|
elif bc[1] == COLOR_SYSTEM_DEFAULT:
|
||||||
button_style.configure(style_name, foreground=bc[0])
|
button_style.configure(style_name, foreground=bc[0])
|
||||||
if bd == 0 and not sys.platform.startswith('darwin'):
|
if bd == 0 and not running_mac():
|
||||||
button_style.configure(style_name, relief=tk.FLAT)
|
button_style.configure(style_name, relief=tk.FLAT)
|
||||||
button_style.configure(style_name, borderwidth=0)
|
button_style.configure(style_name, borderwidth=0)
|
||||||
else:
|
else:
|
||||||
|
@ -12434,7 +12486,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
|
||||||
tkbutton.config(foreground=bc[0], background=bc[1], activebackground=bc[1])
|
tkbutton.config(foreground=bc[0], background=bc[1], activebackground=bc[1])
|
||||||
elif bc[1] == COLOR_SYSTEM_DEFAULT:
|
elif bc[1] == COLOR_SYSTEM_DEFAULT:
|
||||||
tkbutton.config(foreground=bc[0])
|
tkbutton.config(foreground=bc[0])
|
||||||
if bd == 0 and not sys.platform.startswith('darwin'):
|
if bd == 0 and not running_mac():
|
||||||
tkbutton.config(relief=RELIEF_FLAT)
|
tkbutton.config(relief=RELIEF_FLAT)
|
||||||
elif bd != 0:
|
elif bd != 0:
|
||||||
tkbutton.config(relief=RELIEF_RAISED)
|
tkbutton.config(relief=RELIEF_RAISED)
|
||||||
|
@ -12686,8 +12738,12 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
|
||||||
element.TKListbox.selection_set(index)
|
element.TKListbox.selection_set(index)
|
||||||
if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT:
|
if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT:
|
||||||
element.TKListbox.configure(background=element.BackgroundColor)
|
element.TKListbox.configure(background=element.BackgroundColor)
|
||||||
|
if element.HighlightBackgroundColor is not None and element.HighlightBackgroundColor != COLOR_SYSTEM_DEFAULT:
|
||||||
|
element.TKListbox.config(selectbackground=element.HighlightBackgroundColor)
|
||||||
if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT:
|
if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT:
|
||||||
element.TKListbox.configure(fg=text_color)
|
element.TKListbox.configure(fg=text_color)
|
||||||
|
if element.HighlightTextColor is not None and element.HighlightTextColor != COLOR_SYSTEM_DEFAULT:
|
||||||
|
element.TKListbox.config(selectforeground=element.HighlightTextColor)
|
||||||
if element.ChangeSubmits:
|
if element.ChangeSubmits:
|
||||||
element.TKListbox.bind('<<ListboxSelect>>', element._ListboxSelectHandler)
|
element.TKListbox.bind('<<ListboxSelect>>', element._ListboxSelectHandler)
|
||||||
if not element.NoScrollbar:
|
if not element.NoScrollbar:
|
||||||
|
@ -13626,13 +13682,13 @@ def _convert_window_to_tk(window):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if window.NoTitleBar:
|
if window.NoTitleBar:
|
||||||
if sys.platform == 'linux':
|
if running_linux():
|
||||||
# window.TKroot.wm_attributes("-type", 'splash')
|
# window.TKroot.wm_attributes("-type", 'splash')
|
||||||
window.TKroot.wm_attributes("-type", 'dock')
|
window.TKroot.wm_attributes("-type", 'dock')
|
||||||
else:
|
else:
|
||||||
window.TKroot.wm_overrideredirect(True)
|
window.TKroot.wm_overrideredirect(True)
|
||||||
# Special case for Mac. Need to clear flag again if not tkinter version 8.6.10+
|
# Special case for Mac. Need to clear flag again if not tkinter version 8.6.10+
|
||||||
if sys.platform.startswith('darwin') and ENABLE_MAC_NOTITLEBAR_PATCH and (sum([int(i) for i in tclversion_detailed.split('.')]) < 24):
|
if running_mac() and ENABLE_MAC_NOTITLEBAR_PATCH and (sum([int(i) for i in tclversion_detailed.split('.')]) < 24):
|
||||||
print('* Applying Mac no_titlebar patch *')
|
print('* Applying Mac no_titlebar patch *')
|
||||||
window.TKroot.wm_overrideredirect(False)
|
window.TKroot.wm_overrideredirect(False)
|
||||||
except:
|
except:
|
||||||
|
@ -13667,7 +13723,7 @@ def StartupTK(window):
|
||||||
Window._IncrementOpenCount()
|
Window._IncrementOpenCount()
|
||||||
Window.hidden_master_root = tk.Tk()
|
Window.hidden_master_root = tk.Tk()
|
||||||
Window.hidden_master_root.attributes('-alpha', 0) # HIDE this window really really really
|
Window.hidden_master_root.attributes('-alpha', 0) # HIDE this window really really really
|
||||||
# if not sys.platform.startswith('darwin'):
|
# if not running_mac():
|
||||||
try:
|
try:
|
||||||
Window.hidden_master_root.wm_overrideredirect(True)
|
Window.hidden_master_root.wm_overrideredirect(True)
|
||||||
except:
|
except:
|
||||||
|
@ -15366,7 +15422,7 @@ def change_look_and_feel(index, force=False):
|
||||||
"""
|
"""
|
||||||
global CURRENT_LOOK_AND_FEEL
|
global CURRENT_LOOK_AND_FEEL
|
||||||
|
|
||||||
# if sys.platform.startswith('darwin') and not force:
|
# if running_mac() and not force:
|
||||||
# print('*** Changing look and feel is not supported on Mac platform ***')
|
# print('*** Changing look and feel is not supported on Mac platform ***')
|
||||||
# return
|
# return
|
||||||
|
|
||||||
|
@ -15418,7 +15474,7 @@ def change_look_and_feel(index, force=False):
|
||||||
element_background_color=colors['BACKGROUND'],
|
element_background_color=colors['BACKGROUND'],
|
||||||
text_color=colors['TEXT'],
|
text_color=colors['TEXT'],
|
||||||
input_elements_background_color=colors['INPUT'],
|
input_elements_background_color=colors['INPUT'],
|
||||||
# button_color=colors['BUTTON'] if not sys.platform.startswith('darwin') else None,
|
# button_color=colors['BUTTON'] if not running_mac() else None,
|
||||||
button_color=colors['BUTTON'],
|
button_color=colors['BUTTON'],
|
||||||
progress_meter_color=colors['PROGRESS'],
|
progress_meter_color=colors['PROGRESS'],
|
||||||
border_width=colors['BORDER'],
|
border_width=colors['BORDER'],
|
||||||
|
@ -16441,7 +16497,7 @@ def popup_get_folder(message, title=None, default_path='', no_window=False, size
|
||||||
Window.hidden_master_root = tk.Tk()
|
Window.hidden_master_root = tk.Tk()
|
||||||
Window.hidden_master_root.attributes('-alpha', 0) # HIDE this window really really really
|
Window.hidden_master_root.attributes('-alpha', 0) # HIDE this window really really really
|
||||||
|
|
||||||
# if not sys.platform.startswith('darwin'):
|
# if not running_mac():
|
||||||
try:
|
try:
|
||||||
Window.hidden_master_root.wm_overrideredirect(True)
|
Window.hidden_master_root.wm_overrideredirect(True)
|
||||||
except:
|
except:
|
||||||
|
@ -16451,7 +16507,7 @@ def popup_get_folder(message, title=None, default_path='', no_window=False, size
|
||||||
|
|
||||||
try:
|
try:
|
||||||
root.attributes('-alpha', 0) # hide window while building it. makes for smoother 'paint'
|
root.attributes('-alpha', 0) # hide window while building it. makes for smoother 'paint'
|
||||||
# if not sys.platform.startswith('darwin'):
|
# if not running_mac():
|
||||||
try:
|
try:
|
||||||
root.wm_overrideredirect(True)
|
root.wm_overrideredirect(True)
|
||||||
except:
|
except:
|
||||||
|
@ -16564,7 +16620,7 @@ def popup_get_file(message, title=None, default_path='', default_extension='', s
|
||||||
Window._IncrementOpenCount()
|
Window._IncrementOpenCount()
|
||||||
Window.hidden_master_root = tk.Tk()
|
Window.hidden_master_root = tk.Tk()
|
||||||
Window.hidden_master_root.attributes('-alpha', 0) # HIDE this window really really really
|
Window.hidden_master_root.attributes('-alpha', 0) # HIDE this window really really really
|
||||||
# if not sys.platform.startswith('darwin'):
|
# if not running_mac():
|
||||||
try:
|
try:
|
||||||
Window.hidden_master_root.wm_overrideredirect(True)
|
Window.hidden_master_root.wm_overrideredirect(True)
|
||||||
except:
|
except:
|
||||||
|
@ -16574,7 +16630,7 @@ def popup_get_file(message, title=None, default_path='', default_extension='', s
|
||||||
|
|
||||||
try:
|
try:
|
||||||
root.attributes('-alpha', 0) # hide window while building it. makes for smoother 'paint'
|
root.attributes('-alpha', 0) # hide window while building it. makes for smoother 'paint'
|
||||||
# if not sys.platform.startswith('darwin'):
|
# if not running_mac():
|
||||||
try:
|
try:
|
||||||
root.wm_overrideredirect(True)
|
root.wm_overrideredirect(True)
|
||||||
except:
|
except:
|
||||||
|
@ -17120,7 +17176,7 @@ def shell_with_animation(command, args=None, image_source=DEFAULT_BASE64_LOADING
|
||||||
for arg in args:
|
for arg in args:
|
||||||
real_args.append(arg)
|
real_args.append(arg)
|
||||||
# real_args.append(args)
|
# real_args.append(args)
|
||||||
thread = Thread(target=_process_thread, args=real_args, daemon=True)
|
thread = threading.Thread(target=_process_thread, args=real_args, daemon=True)
|
||||||
thread.start()
|
thread.start()
|
||||||
|
|
||||||
# Poll to see if the thread is still running. If so, then continue showing the animation
|
# Poll to see if the thread is still running. If so, then continue showing the animation
|
||||||
|
@ -17275,11 +17331,11 @@ class UserSettings:
|
||||||
path = os.path.expanduser(self.path) # expand user provided path in case it has user ~ in it. Don't think it'll hurt
|
path = os.path.expanduser(self.path) # expand user provided path in case it has user ~ in it. Don't think it'll hurt
|
||||||
elif DEFAULT_USER_SETTINGS_PATH is not None: # if user set the path manually system-wide using set options
|
elif DEFAULT_USER_SETTINGS_PATH is not None: # if user set the path manually system-wide using set options
|
||||||
path = os.path.expanduser(DEFAULT_USER_SETTINGS_PATH)
|
path = os.path.expanduser(DEFAULT_USER_SETTINGS_PATH)
|
||||||
elif sys.platform.startswith('win'):
|
elif running_windows():
|
||||||
path = os.path.expanduser(DEFAULT_USER_SETTINGS_WIN_PATH)
|
path = os.path.expanduser(DEFAULT_USER_SETTINGS_WIN_PATH)
|
||||||
elif sys.platform.startswith('linux'):
|
elif running_linux():
|
||||||
path = os.path.expanduser(DEFAULT_USER_SETTINGS_LINUX_PATH)
|
path = os.path.expanduser(DEFAULT_USER_SETTINGS_LINUX_PATH)
|
||||||
elif sys.platform.startswith('darwin'):
|
elif running_mac():
|
||||||
path = os.path.expanduser(DEFAULT_USER_SETTINGS_MAC_PATH)
|
path = os.path.expanduser(DEFAULT_USER_SETTINGS_MAC_PATH)
|
||||||
else:
|
else:
|
||||||
path = '.'
|
path = '.'
|
||||||
|
@ -18985,7 +19041,7 @@ def main_global_pysimplegui_settings():
|
||||||
[In(settings.get('-explorer program-', ''),k='-EXPLORER PROGRAM-', tooltip=tooltip_file_explorer)],
|
[In(settings.get('-explorer program-', ''),k='-EXPLORER PROGRAM-', tooltip=tooltip_file_explorer)],
|
||||||
[T('Theme', font='_ 16')],
|
[T('Theme', font='_ 16')],
|
||||||
[T('Leave blank for "official" PySimpleGUI default theme: {}'.format(OFFICIAL_PYSIMPLEGUI_THEME))],
|
[T('Leave blank for "official" PySimpleGUI default theme: {}'.format(OFFICIAL_PYSIMPLEGUI_THEME))],
|
||||||
[T('Default Theme For All Programs:'), Combo([''] + theme_list(), settings.get('-theme-', None), k='-THEME-', tooltip=tooltip_theme)],
|
[T('Default Theme For All Programs:'), Combo([''] + theme_list(), settings.get('-theme-', None), readonly=True, k='-THEME-', tooltip=tooltip_theme)],
|
||||||
[B('Ok', bind_return_key=True), B('Cancel')],
|
[B('Ok', bind_return_key=True), B('Cancel')],
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue