Window
Represents a single Window
Window(
title,
layout = None,
default_element_size = None,
default_button_element_size = (None, None),
auto_size_text = None,
auto_size_buttons = None,
location = (None, None),
relative_location = (None, None),
auto_save_location = False,
size = (None, None),
element_padding = None,
margins = (None, None),
button_color = None,
font = None,
progress_bar_color = (None, None),
background_color = None,
border_depth = None,
auto_close = False,
auto_close_duration = 3,
icon = None,
force_toplevel = False,
alpha_channel = None,
return_keyboard_events = False,
use_default_focus = True,
text_justification = None,
no_titlebar = False,
grab_anywhere = False,
grab_anywhere_using_control = True,
keep_on_top = None,
resizable = False,
disable_close = False,
disable_minimize = False,
right_click_menu = None,
transparent_color = None,
debugger_enabled = False,
right_click_menu_background_color = None,
right_click_menu_text_color = None,
right_click_menu_disabled_text_color = None,
right_click_menu_selected_colors = (None, None),
right_click_menu_font = None,
right_click_menu_tearoff = False,
finalize = False,
element_justification = "left",
ttk_theme = None,
use_ttk_buttons = None,
modal = False,
enable_close_attempted_event = False,
enable_window_config_events = False,
repeating_timer_ms = None,
titlebar_background_color = None,
titlebar_text_color = None,
titlebar_font = None,
titlebar_icon = None,
use_custom_titlebar = None,
scaling = None,
sbar_trough_color = None,
sbar_background_color = None,
sbar_arrow_color = None,
sbar_width = None,
sbar_arrow_width = None,
sbar_frame_color = None,
sbar_relief = None,
watermark = None,
print_event_values = None,
metadata = None
)
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
alpha_channel | float | None | Sets the opacity of the window. 0 = invisible 1 = completely visible. Values bewteen 0 & 1 will produce semi-transparent windows in SOME environments (The Raspberry Pi always has this value at 1 and cannot change. |
auto_close | bool | False | If True, the window will automatically close itself |
auto_close_duration | int | 3 | Number of seconds to wait before closing the window |
auto_save_location | bool | False | If True the windows location will be automatically saved to a settings file and will be reloaded next time the program is run. Save happens when window close is detected |
auto_size_buttons | bool | None | True if Buttons in this Window should be sized to exactly fit the text on this. |
auto_size_text | bool | None | True if Elements in Window should be sized to exactly fir the length of text |
background_color | str | None | color of background |
border_depth | int | None | Default border depth (width) for all elements in the window |
button_color | (str, str) or str | None | Default button colors for all buttons in the window |
debugger_enabled | bool | False | If True then the internal debugger will be enabled. Also controllable via the global settings. If global settings is true then will be enabled for all windows |
default_button_element_size | (int, int) | (None, None) | (width, height) size in characters (wide) and rows (high) for all Button elements in this window |
default_element_size | (int, int) - (width, height) | None | size in characters (wide) and rows (high) for all elements in this window |
disable_close | bool | False | If True, the X button in the top right corner of the window will no work. Use with caution and always give a way out toyour users |
disable_minimize | bool | False | if True the user won't be able to minimize window. Good for taking over entire screen and staying that way. |
element_justification | str | left | All elements in the Window itself will have this justification 'left', 'right', 'center' are valid values |
element_padding | (int, int or (int, int),(int,int)) or int | None | Default amount of padding to put around elements in window (left/right, top/bottom) or ((left, right), (top, bottom)), or an int. If an int, then it's converted into a tuple (int, int) |
enable_close_attempted_event | bool | False | If True then the window will not close when "X" clicked. Instead an event WINDOW_CLOSE_ATTEMPTED_EVENT if returned from window.read |
enable_window_config_events | bool | False | If True then window configuration events (resizing or moving the window) will return WINDOW_CONFIG_EVENT from window.read. Note you will get several when Window is created. |
finalize | bool | False | If True then the Finalize method will be called. Use this rather than chaining .Finalize for cleaner code |
font | (str or (str, int[, str]) or None) | None | specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike |
force_toplevel | bool | False | If True will cause this window to skip the normal use of a hidden master window |
grab_anywhere | bool | False | If True can use mouse to click and drag to move the window. Almost every location of the window will work except input fields on some systems |
grab_anywhere_using_control | bool | True | If True can use CONTROL key + left mouse mouse to click and drag to move the window. DEFAULT is TRUE. Unlike normal grab anywhere, it works on all elements. |
icon | (str or bytes) | None | Can be either a filename or Base64 value. For Windows if filename, it MUST be ICO format. For Linux, must NOT be ICO. Most portable is to use a Base64 of a PNG file. This works universally across all OS's |
keep_on_top | bool | None | If True, window will be created on top of all other windows on screen. It can be bumped down if another window created with this parm |
layout | List[List[Element]] or Tuple[Tuple[Element]] | None | The layout for the window. Can also be specified in the Layout method |
location | (int, int or None, None) or None | (None, None) | (x,y) location, in pixels, to locate the upper left corner of the window on the screen. Default is to center on screen. None will not set any location meaning the OS will decide |
margins | (int, int) | (None, None) | (left/right, top/bottom) Amount of pixels to leave inside the window's frame around the edges before your elements are shown. |
metadata | Any | None | User metadata that can be set to ANYTHING |
modal | bool | False | If True then this window will be the only window a user can interact with until it is closed |
no_titlebar | bool | False | If true, no titlebar nor frame will be shown on window. This means you cannot minimize the window and it will not show up on the taskbar |
print_event_values | bool | None | If True then the event and values will be automatically printed when you call the window's read method. GREAT for debugging! Global setting also available to control this. |
progress_bar_color | (str, str) | (None, None) | (bar color, background color) Sets the default colors for all progress bars in the window |
relative_location | (int, int) | (None, None) | (x,y) location relative to the default location of the window, in pixels. Normally the window centers. This location is relative to the location the window would be created. Note they can be negative. |
repeating_timer_ms | int | None | Causes a repeating timer to start when Window is created. The default EVENT_TIMER will be used for the timer event. Setting will cause window to be Finalized |
resizable | bool | False | If True, allows the user to resize the window. Note the not all Elements will change size or location when resizing. |
return_keyboard_events | bool | False | if True key presses on the keyboard will be returned as Events from Read calls |
right_click_menu | List[List[ List[str] or str ]] | None | A list of lists of Menu items to show when this element is right clicked. See user docs for exact format. |
right_click_menu_background_color | str | None | Background color for right click menus |
right_click_menu_disabled_text_color | str | None | Text color for disabled right click menu items |
right_click_menu_font | (str or (str, int[, str]) or None) | None | Font for right click menus |
right_click_menu_selected_colors | (str, str) or str or Tuple | (None, None) | Text AND background colors for a selected item. Can be a Tuple OR a color string. simplified-button-color-string "foreground on background". Can be a single color if want to set only the background. Normally a tuple, but can be a simplified-dual-color-string "foreground on background". Can be a single color if want to set only the background. |
right_click_menu_tearoff | bool | False | If True then all right click menus can be torn off |
right_click_menu_text_color | str | None | Text color for right click menus |
sbar_arrow_color | str | None | Scrollbar color of the arrow at the ends of the scrollbar (it looks like a button). Switches to background color when mouse is over |
sbar_arrow_width | int | None | Scrollbar width of the arrow on the scrollbar. It will potentially impact the overall width of the scrollbar |
sbar_background_color | str | None | Scrollbar color of the background of the arrow buttons at the ends AND the color of the "thumb" (the thing you grab and slide). Switches to arrow color when mouse is over |
sbar_frame_color | str | None | Scrollbar Color of frame around scrollbar (available only on some ttk themes) |
sbar_relief | str | None | Scrollbar relief that will be used for the "thumb" of the scrollbar (the thing you grab that slides). Should be a constant that is defined at starting with "RELIEF_" - RELIEF_RAISED, RELIEF_SUNKEN, RELIEF_FLAT, RELIEF_RIDGE, RELIEF_GROOVE, RELIEF_SOLID |
sbar_trough_color | str | None | Scrollbar color of the trough |
sbar_width | int | None | Scrollbar width in pixels |
scaling | float | None | Apply scaling to the elements in the window. Can be set on a global basis using set_options |
size | (int, int) | (None, None) | (width, height) size in pixels for this window. Normally the window is autosized to fit contents, not set to an absolute size by the user. Try not to set this value. You risk, the contents being cut off, etc. Let the layout determine the window size instead |
text_justification | 'left' or 'right' or 'center' | None | Default text justification for all Text Elements in window |
title | str | The title that will be displayed in the Titlebar and on the Taskbar | |
titlebar_background_color | (str or None) | None | If custom titlebar indicated by use_custom_titlebar, then use this as background color |
titlebar_font | (str or (str, int[, str]) or None) | None | If custom titlebar indicated by use_custom_titlebar, then use this as title font |
titlebar_icon | (bytes or str) | None | If custom titlebar indicated by use_custom_titlebar, then use this as the icon (file or base64 bytes) |
titlebar_text_color | (str or None) | None | If custom titlebar indicated by use_custom_titlebar, then use this as text color |
transparent_color | str | None | Any portion of the window that has this color will be completely transparent. You can even click through these spots to the window under this window. |
ttk_theme | str | None | Set the tkinter ttk "theme" of the window. Default = DEFAULT_TTK_THEME. Sets all ttk widgets to this theme as their default |
use_custom_titlebar | bool | None | If True, then a custom titlebar will be used instead of the normal titlebar |
use_default_focus | bool | True | If True will use the default focus algorithm to set the focus to the "Correct" element |
use_ttk_buttons | bool | None | Affects all buttons in window. True = use ttk buttons. False = do not use ttk buttons. None = use ttk buttons only if on a Mac |
watermark | bool | None | If True, then turns on watermarking temporarily for ALL windows created from this point forward. See global settings doc for more info |
Class Properties
alpha_channel
key_dict
metadata
right_click_menu_element
size
alpha_channel
A property that changes the current alpha channel value (internal value)
Parameter DescriptionsName | Type | Default | Description |
---|---|---|---|
RETURN | float | the current alpha channel setting according to self, not read directly from tkinter |
key_dict
Returns a dictionary with all keys and their corresponding elements { key : Element }
Parameter DescriptionsName | Type | Default | Description |
---|---|---|---|
RETURN | Dict[Any, Element] | Dictionary of keys and elements |
metadata
Metadata is available for all windows. You can set to any value.
Parameter DescriptionsName | Type | Default | Description |
---|---|---|---|
RETURN | Any | the current metadata value |
right_click_menu_element
The element that produced a right click meny event (if one did). If can't find the element, None is returned.
Parameter DescriptionsName | Type | Default | Description |
---|---|---|---|
RETURN | (Element or None) | Element that generated a right click menu event. If one can't be found, then None is returned |
size
Return the current size of the window in pixels
Parameter DescriptionsName | Type | Default | Description |
---|---|---|---|
RETURN | Tuple[(int), (int)] or Tuple[None, None] | (width, height) of the window |
Class Methods
def add_row
def add_rows
def bind
def bring_to_front
def close
def current_location
def current_size_accurate
def ding
def disable
def disable_debugger
def disappear
def element_list
def enable
def enable_debugger
def extend_layout
def fill
def finalize
def find_element
def find_element_with_focus
def force_focus
def get_scaling
def get_screen_dimensions
def get_screen_size
def grab_any_where_off
def grab_any_where_on
def hide
def is_closed
def is_hidden
def keep_on_top_clear
def keep_on_top_set
def key_is_good
def last_location
def layout
def load_from_disk
def make_modal
def maximize
def minimize
def mouse_location
def move
def move_to_center
def normal
def perform_long_operation
def read
def reappear
def refresh
def save_to_disk
def save_window_screenshot_to_disk
def send_to_back
def set_alpha
def set_cursor
def set_icon
def set_min_size
def set_resizable
def set_size
def set_title
def set_transparent_color
def settings_restore
def settings_save
def start_thread
def timer_get_active_timers
def timer_start
def timer_stop
def timer_stop_all
def un_hide
def unbind
def visibility_changed
def was_closed
def widget_to_element
def write_event_value
add_row
Adds a single row of elements to a window's self.Rows variables. Generally speaking this is NOT how users should be building Window layouts. Users, create a single layout (a list of lists) and pass as a parameter to Window object, or call Window.Layout(layout)
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
*args | List[Elements] |
add_rows
Loops through a list of lists of elements and adds each row, list, to the layout. This is NOT the best way to go about creating a window. Sending the entire layout at one time and passing it as a parameter to the Window call is better.
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
rows | List[List[Elements]] | A list of a list of elements |
bind
Used to add tkinter events to a Window. The tkinter specific data is in the Window's member variable user_bind_event
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
bind_string | str | The string tkinter expected in its bind function | |
key | str or int or tuple or object | The event that will be generated when the tkinter event occurs | |
propagate | bool | True | If True then tkinter will be told to propagate the event |
bring_to_front
Brings this window to the top of all other windows (perhaps may not be brought before a window made to "stay on top")
close
Closes window. Users can safely call even if window has been destroyed. Should always call when done with a window so that resources are properly freed up within your thread.
current_location
Get the current location of the window's top left corner. Sometimes, depending on the environment, the value returned does not include the titlebar,etc A new option, more_accurate, can be used to get the theoretical upper leftmost corner of the window. The titlebar and menubar are crated by the OS. It gets really confusing when running in a webpage (repl, trinket) Thus, the values can appear top be "off" due to the sometimes unpredictable way the location is calculated. If without_titlebar is set then the location of the root x,y is used which should not include the titlebar but may be OS dependent.
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
more_accurate | bool | False | If True, will use the window's geometry to get the topmost location with titlebar, menubar taken into account |
without_titlebar | bool | False | If True, return location of top left of main window area without the titlebar (may be OS dependent?) |
RETURN | Tuple[(int or None), (int or None)] | The x and y location in tuple form (x,y) |
current_size_accurate
Get the current location of the window based on tkinter's geometry setting
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
RETURN | Tuple[(int or None), (int or None)] | The x and y size in tuple form (x,y) |
ding
Make a "bell" sound. A capability provided by tkinter. Your window needs to be finalized prior to calling. Ring a display's bell is the tkinter description of the call.
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
display_number | int | 0 | Passed to tkinter's bell method as parameter "displayof". |
disable
Disables window from taking any input from the user
disable_debugger
Disable the internal debugger. By default the debugger is ENABLED
disappear
Causes a window to "disappear" from the screen, but remain on the taskbar. It does this by turning the alpha channel to 0. NOTE that on some platforms alpha is not supported. The window will remain showing on these platforms. The Raspberry Pi for example does not have an alpha setting
element_list
Returns a list of all elements in the window
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
RETURN | List[Element] | List of all elements in the window and container elements in the window |
enable
Re-enables window to take user input after having it be Disabled previously
enable_debugger
Enables the internal debugger. By default, the debugger IS enabled
extend_layout
Adds new rows to an existing container element inside of this window If the container is a scrollable Column, you need to also call the contents_changed() method
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
container | Frame or Column or Tab | The container Element the layout will be placed inside of | |
rows | (List[List[Element]]) | The layout to be added | |
RETURN | Window | (Window) self so could be chained |
fill
Fill in elements that are input fields with data based on a 'values dictionary'
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
values_dict | (Dict[Any, Any]) - {Element_key : value} | pairs | |
RETURN | Window | returns self so can be chained with other methods |
finalize
Use this method to cause your layout to built into a real tkinter window. In reality this method is like Read(timeout=0). It doesn't block and uses your layout to create tkinter widgets to represent the elements. Lots of action!
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
RETURN | Window | Returns 'self' so that method "Chaining" can happen (read up about it as it's very cool!) |
find_element
Find element object associated with the provided key. THIS METHOD IS NO LONGER NEEDED to be called by the user
You can perform the same operation by writing this statement: element = window[key]
You can drop the entire "find_element" function name and use [ ] instead.
However, if you wish to perform a lookup without error checking, and don't have error popups turned off globally, you'll need to make this call so that you can disable error checks on this call.
find_element is typically used in combination with a call to element's update method (or any other element method!): window[key].update(new_value)
Versus the "old way" window.FindElement(key).Update(new_value)
This call can be abbreviated to any of these: find_element = FindElement == Element == Find With find_element being the PEP8 compliant call that should be used.
Rememeber that this call will return None if no match is found which may cause your code to crash if not checked for.
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
key | str or int or tuple or object | Used with window.find_element and with return values to uniquely identify this element | |
silent_on_error | bool | False | If True do not display popup nor print warning of key errors |
supress_guessing | (bool or None) | None | Override for the global key guessing setting. |
supress_raise | (bool or None) | None | Override for the global setting that determines if a key error should raise an exception |
RETURN | Element or ErrorElement or None | Return value can be: the Element that matches the supplied key if found; an Error Element if silent_on_error is False; None if silent_on_error True |
find_element_with_focus
Returns the Element that currently has focus as reported by tkinter. If no element is found None is returned!
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
RETURN | Element or None | An Element if one has been found with focus or None if no element found |
force_focus
Forces this window to take focus
get_scaling
Returns the current scaling value set for this window
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
RETURN | float | Scaling according to tkinter. Returns DEFAULT_SCALING if error |
get_screen_dimensions
Get the screen dimensions. NOTE - you must have a window already open for this to work (blame tkinter not me)
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
RETURN | Tuple[None, None] or Tuple[width, height] | Tuple containing width and height of screen in pixels |
get_screen_size
This is a class method (implements the @classmethod decorator).
This is a "Class Method" meaning you call it by writing: width, height = Window.get_screen_size() 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.
To call the method without creating an instance of the object:Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
RETURN | (int, int) | Size of the screen in pixels as determined by tkinter |
grab_any_where_off
Turns off Grab Anywhere functionality AFTER a window has been created. Don't try on a window that's not yet been Finalized or Read.
grab_any_where_on
Turns on Grab Anywhere functionality AFTER a window has been created. Don't try on a window that's not yet been Finalized or Read.
hide
Hides the window from the screen and the task bar
is_closed
Returns True is the window is maybe closed. Can be difficult to tell sometimes NOTE - the call to TKroot.update was taking over 500 ms sometimes so added a flag to bypass the lengthy call.
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
quick_quick | bool | If True, then don't use the root.update call, only check the flags | |
RETURN | bool | True if the window was closed or destroyed |
is_hidden
Returns True if the window is currently hidden
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
RETURN | bool | Returns True if the window is currently hidden |
keep_on_top_clear
Clears keep_on_top after a window has been created. Effect is the same as if the window was created with this set.
keep_on_top_set
Sets keep_on_top after a window has been created. Effect is the same as if the window was created with this set. The Window is also brought to the front
key_is_good
Checks to see if this is a good key for this window If there's an element with the key provided, then True is returned
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
key | str or int or tuple or object | The key to check | |
RETURN | bool | True if key is an element in this window |
last_location
The last known location of the window (x,y). Set by config events from tkinter
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
RETURN | (int, int) | The last location of the window |
layout
Second of two preferred ways of telling a Window what its layout is. The other way is to pass the layout as a parameter to Window object. The parameter method is the currently preferred method. This call to Layout has been removed from examples contained in documents and in the Demo Programs. Trying to remove this call from history and replace with sending as a parameter to Window.
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
rows | List[List[Elements]] | Your entire layout | |
RETURN | Window | self so that you can chain method calls |
load_from_disk
Restore values from a previous call to SaveToDisk which saves the returned values dictionary in Pickle format
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
filename | str | Pickle Filename to load |
make_modal
Makes a window into a "Modal Window" This means user will not be able to interact with other windows until this one is closed
NOTE - Sorry Mac users - you can't have modal windows.... lobby your tkinter Mac devs
maximize
Maximize the window. This is done differently on a windows system versus a linux or mac one. For non-Windows the root attribute '-fullscreen' is set to True. For Windows the "root" state is changed to "zoomed" The reason for the difference is the title bar is removed in some cases when using fullscreen option
minimize
Minimize this window to the task bar
mouse_location
Return the (x,y) location of the mouse relative to the entire screen. It's the same location that you would use to create a window, popup, etc.
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
RETURN | (int, int) | The location of the mouse pointer |
move
Move the upper left corner of this window to the x,y coordinates provided
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
x | int | x coordinate in pixels | |
y | int | y coordinate in pixels |
move_to_center
Recenter your window after it's been moved or the size changed.
This is a conveinence method. There are no tkinter calls involved, only pure PySimpleGUI API calls.
normal
Restore a window to a non-maximized state. Does different things depending on platform. See Maximize for more.
perform_long_operation
Call your function that will take a long time to execute. When it's complete, send an event specified by the end_key.
Starts a thread on your behalf.
This is a way for you to "ease into" threading without learning the details of threading. Your function will run, and when it returns 2 things will happen: 1. The value you provide for end_key will be returned to you when you call window.read() 2. If your function returns a value, then the value returned will also be included in your windows.read call in the values dictionary
IMPORTANT - This method uses THREADS... this means you CANNOT make any PySimpleGUI calls from the function you provide with the exception of one function, Window.write_event_value.
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
end_key | (Any or None) | None | Optional key that will be generated when the function returns |
func | Any | A lambda or a function name with no parms | |
RETURN | threading.Thread | The id of the thread |
read
THE biggest deal method in the Window class! This is how you get all of your data from your Window. Pass in a timeout (in milliseconds) to wait for a maximum of timeout milliseconds. Will return timeout_key if no other GUI events happen first.
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
close | bool | False | if True the window will be closed prior to returning |
timeout | int | None | Milliseconds to wait until the Read will return IF no other GUI events happen first |
timeout_key | Any | TIMEOUT | The value that will be returned from the call if the timer expired |
RETURN | Tuple[(Any), Dict[Any, Any], List[Any], None] | (event, values) |
reappear
Causes a window previously made to "Disappear" (using that method). Does this by restoring the alpha channel
refresh
Refreshes the window by calling tkroot.update(). Can sometimes get away with a refresh instead of a Read. Use this call when you want something to appear in your Window immediately (as soon as this function is called). If you change an element in a window, your change will not be visible until the next call to Window.read or a call to Window.refresh()
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
RETURN | Window | self so that method calls can be easily "chained" |
save_to_disk
Saves the values contained in each of the input areas of the form. Basically saves what would be returned from a call to Read. It takes these results and saves them to disk using pickle. Note that every element in your layout that is to be saved must have a key assigned to it.
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
filename | str | Filename to save the values to in pickled form |
save_window_screenshot_to_disk
Saves an image of the PySimpleGUI window provided into the filename provided
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
RETURN | (PIL.ImageGrab or None) | A PIL ImageGrab object that can be saved or manipulated |
send_to_back
Pushes this window to the bottom of the stack of windows. It is the opposite of BringToFront
set_alpha
Sets the Alpha Channel for a window. Values are between 0 and 1 where 0 is completely transparent
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
alpha | float | 0 to 1. 0 is completely transparent. 1 is completely visible and solid (can't see through) |
set_cursor
Sets the cursor for the window. If you do not want any mouse pointer, then use the string "none"
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
cursor | str | The tkinter cursor name |
set_icon
Changes the icon that is shown on the title bar and on the task bar. NOTE - The file type is IMPORTANT and depends on the OS! Can pass in: * filename which must be a .ICO icon file for windows, PNG file for Linux * bytes object * BASE64 encoded file held in a variable
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
icon | str | None | Filename or bytes object |
pngbase64 | bytes | None | Base64 encoded image |
set_min_size
Changes the minimum size of the window. Note Window must be read or finalized first.
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
size | (int, int) | (width, height) tuple (int, int) of the desired window size in pixels |
set_resizable
Changes if a window can be resized in either the X or the Y direction. Note Window must be read or finalized first.
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
x_axis_enable | bool | If True, the window can be changed in the X-axis direction. If False, it cannot | |
y_axis_enable | bool | If True, the window can be changed in the Y-axis direction. If False, it cannot |
set_size
Changes the size of the window, if possible. You can also use the Window.size prooerty to set/get the size.
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
size | (int, int) | (width, height) of the desired window size |
set_title
Change the title of the window
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
title | str | The string to set the title to |
set_transparent_color
Set the color that will be transparent in your window. Areas with this color will be SEE THROUGH.
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
color | str | Color string that defines the transparent color |
settings_restore
Reads settings and sets the window's Elements to those values.
TODO - NOTE - may have trouble on some elements due to how update calls work
settings_save
Saves settings to settings file using the values dictionary that is passed in.
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
values | Dict | Dictionary of values to potentially save |
start_thread
This method is an alias for perform_long_operation
timer_get_active_timers
Returns a list of currently active timers for a window
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
RETURN | List[int] | List of timers for the window |
timer_start
Starts a timer that gnerates Timer Events. The default is to repeat the timer events until timer is stopped. You can provide your own key or a default key will be used. The default key is defined with the constants EVENT_TIMER or TIMER_KEY. They both equal the same value. The values dictionary will contain the timer ID that is returned from this function.
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
frequency_ms | int | How often to generate timer events in milliseconds | |
key | str or int or tuple or object | TIMER EVENT | Key to be returned as the timer event |
repeating | bool | True | If True then repeat timer events until timer is explicitly stopped |
RETURN | int | Timer ID for the timer |
timer_stop
Stops a timer with a given ID
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
timer_id | int | Timer ID of timer to stop |
timer_stop_all
Stops all timers for THIS window
un_hide
Used to bring back a window that was previously hidden using the Hide method
unbind
Used to remove tkinter events to a Window. This implementation removes ALL of the binds of the bind_string from the Window. If there are multiple binds for the Window itself, they will all be removed. This can be extended later if there is a need.
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
bind_string | str | The string tkinter expected in its bind function |
visibility_changed
When making an element in a column or someplace that has a scrollbar, then you'll want to call this function prior to the column's contents_changed() method.
was_closed
Returns True if the window was closed
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
RETURN | bool | True if the window is closed |
widget_to_element
Returns the element that matches a supplied tkinter widget. If no matching element is found, then None is returned.
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
RETURN | Element or None | Element that uses the specified widget |
write_event_value
Adds a key & value tuple to the queue that is used by threads to communicate with the window
Parameter Descriptions
Name | Type | Default | Description |
---|---|---|---|
key | Any | The key that will be returned as the event when reading the window | |
value | Any | The value that will be in the values dictionary |