Merge pull request #2182 from PySimpleGUI/Dev-latest

docstring fixes, more PEP8 bindings - for newer Element methods, fix …
This commit is contained in:
PySimpleGUI 2019-11-13 22:23:02 -05:00 committed by GitHub
commit e5e69c6517
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 51 additions and 18 deletions

View File

@ -1,6 +1,6 @@
#!/usr/bin/python3 #!/usr/bin/python3
version = __version__ = "4.6.0.2 Unreleased - Added border to Graph.draw_rectangle, Image.Update data parm can be tk.PhotoImage obj" version = __version__ = "4.6.0.4 Unreleased - Added border to Graph.draw_rectangle, Image.Update data parm can be tk.PhotoImage obj, more PEP8 bindings for Element, Slider trough color fix"
# 888888ba .d88888b oo dP .88888. dP dP dP # 888888ba .d88888b oo dP .88888. dP dP dP
@ -805,6 +805,10 @@ class Element():
def hide_row(self): def hide_row(self):
"""
Hide the entire row an Element is located on.
Use this if you must have all space removed when you are hiding an element, including the row container
"""
try: try:
self.ParentRowFrame.pack_forget() self.ParentRowFrame.pack_forget()
except: except:
@ -812,6 +816,10 @@ class Element():
def unhide_row(self): def unhide_row(self):
"""
Unhides (makes visible again) the row container that the Element is located on.
Note that it will re-appear at the bottom of the window / container, most likely.
"""
try: try:
self.ParentRowFrame.pack() self.ParentRowFrame.pack()
except: except:
@ -853,6 +861,10 @@ class Element():
""" """
return self.Update(*args, **kwargs) return self.Update(*args, **kwargs)
button_rebound_callback = ButtonReboundCallback
set_tooltip = SetTooltip
set_focus = SetFocus
# ---------------------------------------------------------------------- # # ---------------------------------------------------------------------- #
# Input Class # # Input Class #
@ -3849,6 +3861,7 @@ class Slider(Element):
self.Disabled = disabled self.Disabled = disabled
self.TickInterval = tick_interval self.TickInterval = tick_interval
self.DisableNumericDisplay = disable_number_display self.DisableNumericDisplay = disable_number_display
self.TroughColor = DEFAULT_SCROLLBAR_COLOR
temp_size = size temp_size = size
if temp_size == (None, None): if temp_size == (None, None):
temp_size = (20, 20) if self.Orientation.startswith('h') else (8, 20) temp_size = (20, 20) if self.Orientation.startswith('h') else (8, 20)
@ -5322,6 +5335,11 @@ class Window:
@classmethod @classmethod
def get_screen_size(self): def get_screen_size(self):
"""
Returns the size of the "screen" as determined by tkinter. This can vary depending on your operating system and the number of monitors installed on your system. For Windows, the primary monitor's size is returns. On some multi-monitored Linux systems, the monitors are combined and the total size is reported as if one screen.
:return: Tuple[int, int] - Size of the screen in pixels as determined by tkinter
"""
root = tk.Tk() root = tk.Tk()
screen_width = root.winfo_screenwidth() # get window info to move to middle of screen screen_width = root.winfo_screenwidth() # get window info to move to middle of screen
screen_height = root.winfo_screenheight() screen_height = root.winfo_screenheight()
@ -8596,6 +8614,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
# row_should_expand = True # row_should_expand = True
# ------------------------- SLIDER element ------------------------- # # ------------------------- SLIDER element ------------------------- #
elif element_type == ELEM_TYPE_INPUT_SLIDER: elif element_type == ELEM_TYPE_INPUT_SLIDER:
element = element # type: Slider
slider_length = element_size[0] * CharWidthInPixels() slider_length = element_size[0] * CharWidthInPixels()
slider_width = element_size[1] slider_width = element_size[1]
element.TKIntVar = tk.IntVar() element.TKIntVar = tk.IntVar()
@ -8627,8 +8646,8 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
tkscale.config(highlightthickness=0) tkscale.config(highlightthickness=0)
if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT: if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT:
tkscale.configure(background=element.BackgroundColor) tkscale.configure(background=element.BackgroundColor)
if DEFAULT_SCROLLBAR_COLOR != COLOR_SYSTEM_DEFAULT: if element.TroughColor != COLOR_SYSTEM_DEFAULT:
tkscale.config(troughcolor=DEFAULT_SCROLLBAR_COLOR) tkscale.config(troughcolor=element.TroughColor)
if element.DisableNumericDisplay: if element.DisableNumericDisplay:
tkscale.config(showvalue=0) tkscale.config(showvalue=0)
if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT: if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT:
@ -9674,31 +9693,43 @@ def SetOptions(icon=None, button_color=None, element_size=(None, None), button_e
LOOK_AND_FEEL_TABLE = {'SystemDefault': LOOK_AND_FEEL_TABLE = {'SystemDefault':
{'BACKGROUND': COLOR_SYSTEM_DEFAULT, {'BACKGROUND': COLOR_SYSTEM_DEFAULT,
'TEXT': COLOR_SYSTEM_DEFAULT, 'TEXT': COLOR_SYSTEM_DEFAULT,
'INPUT': COLOR_SYSTEM_DEFAULT, 'TEXT_INPUT': COLOR_SYSTEM_DEFAULT, 'INPUT': COLOR_SYSTEM_DEFAULT,
'TEXT_INPUT': COLOR_SYSTEM_DEFAULT,
'SCROLL': COLOR_SYSTEM_DEFAULT, 'SCROLL': COLOR_SYSTEM_DEFAULT,
'BUTTON': OFFICIAL_PYSIMPLEGUI_BUTTON_COLOR, 'BUTTON': OFFICIAL_PYSIMPLEGUI_BUTTON_COLOR,
'PROGRESS': COLOR_SYSTEM_DEFAULT, 'PROGRESS': COLOR_SYSTEM_DEFAULT,
'BORDER': 1, 'SLIDER_DEPTH': 1, 'BORDER': 1, 'SLIDER_DEPTH': 1,
'PROGRESS_DEPTH': 0}, 'PROGRESS_DEPTH': 0},
'SystemDefaultForReal':
{'BACKGROUND': COLOR_SYSTEM_DEFAULT,
'TEXT': COLOR_SYSTEM_DEFAULT,
'INPUT': COLOR_SYSTEM_DEFAULT,
'TEXT_INPUT': COLOR_SYSTEM_DEFAULT,
'SCROLL': COLOR_SYSTEM_DEFAULT,
'BUTTON': COLOR_SYSTEM_DEFAULT,
'PROGRESS': COLOR_SYSTEM_DEFAULT,
'BORDER': 1, 'SLIDER_DEPTH': 1,
'PROGRESS_DEPTH': 0},
'Material1': {'BACKGROUND': '#E3F2FD', 'Material1': {'BACKGROUND': '#E3F2FD',
'TEXT': '#000000', 'TEXT': '#000000',
'INPUT': '#86A8FF', 'INPUT': '#86A8FF',
'TEXT_INPUT': '#000000', 'TEXT_INPUT': '#000000',
'SCROLL': '#86A8FF', #I can't see it change, so I don't know it is good color. 'SCROLL': '#86A8FF',
'BUTTON': ('#FFFFFF', '#5079D3'), 'BUTTON': ('#FFFFFF', '#5079D3'),
'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR, 'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR,
'BORDER': 0, 'SLIDER_DEPTH': 0, 'BORDER': 0, 'SLIDER_DEPTH': 0,
'PROGRESS_DEPTH': 0, 'PROGRESS_DEPTH': 0,
'ACCENT1': '#FF0266', 'ACCENT1': '#FF0266',
'ACCENT2': '#FF5C93', 'ACCENT2': '#FF5C93',
'ACCENT3': '#C5003C'}, 'ACCENT3': '#C5003C'},
'Material2': {'BACKGROUND': '#FAFAFA', 'Material2': {'BACKGROUND': '#FAFAFA',
'TEXT': '#000000', 'TEXT': '#000000',
'INPUT': '#004EA1', 'INPUT': '#004EA1',
'TEXT_INPUT': '#FFFFFF', 'TEXT_INPUT': '#FFFFFF',
'SCROLL': '#5EA7FF', #I can't see it change, so I don't know it is good color. 'SCROLL': '#5EA7FF',
'BUTTON': ('#FFFFFF', '#0079D3'), #based on Reddit color 'BUTTON': ('#FFFFFF', '#0079D3'), #based on Reddit color
'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR, 'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR,
'BORDER': 0, 'SLIDER_DEPTH': 0, 'BORDER': 0, 'SLIDER_DEPTH': 0,
@ -9728,7 +9759,8 @@ LOOK_AND_FEEL_TABLE = {'SystemDefault':
'SCROLL': '#E7C855', 'SCROLL': '#E7C855',
'BUTTON': ('#E7C855', '#284B5A'), 'BUTTON': ('#E7C855', '#284B5A'),
'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR, 'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR,
'BORDER': 1, 'SLIDER_DEPTH': 0, 'BORDER': 1,
'SLIDER_DEPTH': 0,
'PROGRESS_DEPTH': 0, 'PROGRESS_DEPTH': 0,
'ACCENT1': '#c15226', 'ACCENT1': '#c15226',
'ACCENT2': '#7a4d5f', 'ACCENT2': '#7a4d5f',
@ -9966,7 +9998,8 @@ LOOK_AND_FEEL_TABLE = {'SystemDefault':
'TealMono': {'BACKGROUND': '#a8cfdd', 'TealMono': {'BACKGROUND': '#a8cfdd',
'TEXT': 'black', 'TEXT': 'black',
'INPUT': '#dfedf2', 'SCROLL': '#dfedf2', 'INPUT': '#dfedf2',
'SCROLL': '#dfedf2',
'TEXT_INPUT': 'black', 'TEXT_INPUT': 'black',
'BUTTON': ('white', '#183440'), 'BUTTON': ('white', '#183440'),
'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR, 'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR,