Merge pull request #4980 from PySimpleGUI/Dev-latest

Dev latest
This commit is contained in:
PySimpleGUI 2021-11-25 14:12:40 -05:00 committed by GitHub
commit 2a84d92488
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 983 additions and 365 deletions

View File

@ -1,5 +1,5 @@
#!/usr/bin/python3
version = __version__ = "4.55.1.4 Unreleased"
version = __version__ = "4.55.1.6 Unreleased"
_change_log = """
Changelog since 4.55.1 released to PyPI on 7-Nov-2021
@ -15,6 +15,11 @@ _change_log = """
Better error reporting when a problem with the layout detected
4.55.1.4
Removed import of site and now get the information from os.path.dirname(sys.executable). I like simpler!
4.55.1.5
Combo - added parameters to control the colors on the button used to display the items. Parms are button_background_color and button_arrow_color
Default values continue to be the same the theme's button color if nothing is set.
4.55.1.6
Fixed missing docstring item for Table value so that the new documentation will be accurate
"""
__version__ = version.split()[0] # For PEP 396 and PEP 345
@ -1764,9 +1769,7 @@ class Combo(Element):
ComboBox Element - A combination of a single-line input and a drop-down menu. User can type in their own value or choose from list.
"""
def __init__(self, values, default_value=None, size=(None, None), s=(None, None), auto_size_text=None, background_color=None,
text_color=None, bind_return_key=False, change_submits=False, enable_events=False, disabled=False, key=None, k=None, pad=None, p=None, expand_x=False, expand_y=False,
tooltip=None, readonly=False, font=None, visible=True, metadata=None):
def __init__(self, values, default_value=None, size=(None, None), s=(None, None), auto_size_text=None, background_color=None, text_color=None, button_background_color=None, button_arrow_color=None, bind_return_key=False, change_submits=False, enable_events=False, disabled=False, key=None, k=None, pad=None, p=None, expand_x=False, expand_y=False, tooltip=None, readonly=False, font=None, visible=True, metadata=None):
"""
:param values: values to choose. While displayed as text, the items returned are what the caller supplied, not text
:type values: List[Any] or Tuple[Any]
@ -1782,6 +1785,10 @@ class Combo(Element):
:type background_color: (str)
:param text_color: color of the text
:type text_color: (str)
:param button_background_color: The color of the background of the button on the combo box
:type button_background_color: (str)
:param button_arrow_color: The color of the arrow on the button on the combo box
:type button_arrow_color: (str)
:param bind_return_key: If True, then the return key will cause a the Combo to generate an event
:type bind_return_key: (bool)
:param change_submits: DEPRICATED DO NOT USE. Use `enable_events` instead
@ -1801,7 +1808,8 @@ class Combo(Element):
:param expand_x: If True the element will automatically expand in the X direction to fill available space
:type expand_x: (bool)
:param expand_y: If True the element will automatically expand in the Y direction to fill available space
:type expand_y: (bool) :param tooltip: text that will appear when mouse hovers over this element
:type expand_y: (bool)
:param tooltip: text that will appear when mouse hovers over this element
:type tooltip: (str)
:param readonly: make element readonly (user can't change). True means user cannot change
:type readonly: (bool)
@ -1812,6 +1820,8 @@ class Combo(Element):
:param metadata: User metadata that can be set to ANYTHING
:type metadata: (Any)
"""
self.Values = values
self.DefaultValue = default_value
self.ChangeSubmits = change_submits or enable_events
@ -1826,6 +1836,15 @@ class Combo(Element):
pad = pad if pad is not None else p
self.expand_x = expand_x
self.expand_y = expand_y
if button_background_color is None:
self.button_background_color = theme_button_color()[1]
else:
self.button_background_color = button_background_color
if button_arrow_color is None:
self.button_arrow_color = theme_button_color()[0]
else:
self.button_arrow_color = button_arrow_color
super().__init__(ELEM_TYPE_INPUT_COMBO, size=sz, auto_size_text=auto_size_text, background_color=bg,
text_color=fg, key=key, pad=pad, tooltip=tooltip, font=font or DEFAULT_FONT, visible=visible, metadata=metadata)
@ -2010,6 +2029,7 @@ class OptionMenu(Element):
self.expand_x = expand_x
self.expand_y = expand_y
super().__init__(ELEM_TYPE_INPUT_OPTION_MENU, size=sz, auto_size_text=auto_size_text, background_color=bg,
text_color=fg, key=key, pad=pad, tooltip=tooltip, visible=visible, metadata=metadata)
@ -3422,6 +3442,111 @@ class Text(Element):
print('Error retrieving font information', e)
return size
def _print_to_element(self, *args, end=None, sep=None, text_color=None, background_color=None, autoscroll=None, justification=None, font=None, append=None):
"""
Print like Python normally prints except route the output to a multiline element and also add colors if desired
:param multiline_element: The multiline element to be output to
:type multiline_element: (Multiline)
:param args: The arguments to print
:type args: List[Any]
:param end: The end char to use just like print uses
:type end: (str)
:param sep: The separation character like print uses
:type sep: (str)
:param text_color: color of the text
:type text_color: (str)
:param background_color: The background color of the line
:type background_color: (str)
:param autoscroll: If True (the default), the element will scroll to bottom after updating
:type autoscroll: (bool)
:param font: specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike for the value being updated
:type font: str | (str, int)
"""
end_str = str(end) if end is not None else '\n'
sep_str = str(sep) if sep is not None else ' '
outstring = ''
num_args = len(args)
for i, arg in enumerate(args):
outstring += str(arg)
if i != num_args - 1:
outstring += sep_str
outstring += end_str
if append:
outstring = self.get() + outstring
self.update(outstring, text_color=text_color, background_color=background_color, font=font)
try: # if the element is set to autorefresh, then refresh the parent window
if self.AutoRefresh:
self.ParentForm.refresh()
except:
pass
def print(self, *args, end=None, sep=None, text_color=None, background_color=None, justification=None, font=None, colors=None, t=None, b=None, c=None, autoscroll=True, append=True):
"""
Print like Python normally prints except route the output to a multiline element and also add colors if desired
colors -(str, str) or str. A combined text/background color definition in a single parameter
There are also "aliases" for text_color, background_color and colors (t, b, c)
t - An alias for color of the text (makes for shorter calls)
b - An alias for the background_color parameter
c - (str, str) - "shorthand" way of specifying color. (foreground, backgrouned)
c - str - can also be a string of the format "foreground on background" ("white on red")
With the aliases it's possible to write the same print but in more compact ways:
cprint('This will print white text on red background', c=('white', 'red'))
cprint('This will print white text on red background', c='white on red')
cprint('This will print white text on red background', text_color='white', background_color='red')
cprint('This will print white text on red background', t='white', b='red')
:param args: The arguments to print
:type args: (Any)
:param end: The end char to use just like print uses
:type end: (str)
:param sep: The separation character like print uses
:type sep: (str)
:param text_color: The color of the text
:type text_color: (str)
:param background_color: The background color of the line
:type background_color: (str)
:param justification: text justification. left, right, center. Can use single characters l, r, c. Sets only for this value, not entire element
:type justification: (str)
:param font: specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike for the args being printed
:type font: (str or (str, int[, str]) or None)
:param colors: Either a tuple or a string that has both the text and background colors. Or just the text color
:type colors: (str) or (str, str)
:param t: Color of the text
:type t: (str)
:param b: The background color of the line
:type b: (str)
:param c: Either a tuple or a string that has both the text and background colors or just tex color (same as the color parm)
:type c: (str) or (str, str)
:param autoscroll: If True the contents of the element will automatically scroll as more data added to the end
:type autoscroll: (bool)
"""
kw_text_color = text_color or t
kw_background_color = background_color or b
dual_color = colors or c
try:
if isinstance(dual_color, tuple):
kw_text_color = dual_color[0]
kw_background_color = dual_color[1]
elif isinstance(dual_color, str):
if ' on ' in dual_color: # if has "on" in the string, then have both text and background
kw_text_color = dual_color.split(' on ')[0]
kw_background_color = dual_color.split(' on ')[1]
else: # if no "on" then assume the color string is just the text color
kw_text_color = dual_color
except Exception as e:
print('* multiline print warning * you messed up with color formatting', e)
self._print_to_element( *args, end=end, sep=sep, text_color=kw_text_color, background_color=kw_background_color, justification=justification, autoscroll=autoscroll, font=font, append=append)
Get = get
Update = update
@ -7660,7 +7785,7 @@ class Table(Element):
size=(None, None), s=(None, None), change_submits=False, enable_events=False, enable_click_events=False, bind_return_key=False, pad=None, p=None,
key=None, k=None, tooltip=None, right_click_menu=None, expand_x=False, expand_y=False, visible=True, metadata=None):
"""
:param values: ???
:param values: Your table data represented as a 2-dimensions table... a list of rows, with each row representing a row in your table.
:type values: List[List[str | int | float]]
:param headings: The headings to show on the top line
:type headings: List[str]
@ -14225,7 +14350,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
# ------------------------- COMBO placement element ------------------------- #
elif element_type == ELEM_TYPE_INPUT_COMBO:
element = element # type: InputCombo
element = element # type: Combo
max_line_len = max([len(str(l)) for l in element.Values]) if len(element.Values) else 0
if auto_size_text is False:
width = element_size[0]
@ -14233,75 +14358,42 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
width = max_line_len + 1
element.TKStringVar = tk.StringVar()
style_name = _make_ttk_style_name('.TCombobox', element)
# style_name = 'TCombobox'
s = ttk.Style()
if _valid_theme(s, toplevel_form.TtkTheme):
s.theme_use(toplevel_form.TtkTheme)
# s.theme_use('default')
if element.TextColor is not None and element.TextColor != COLOR_SYSTEM_DEFAULT:
# Creates 1 style per Text Color/ Background Color combination
# style_name = str(element.Key) + '.TCombobox'
combostyle = ttk.Style()
element.ttk_style = combostyle
if _valid_theme(combostyle, toplevel_form.TtkTheme):
combostyle.theme_use(toplevel_form.TtkTheme)
# Creates a unique name for each field element(Sure there is a better way to do this)
# unique_field = str(element.Key) + '.TCombobox.field'
unique_field = _make_ttk_style_name('.TCombobox.field', element)
# Clones over the TCombobox.field element from the "alt" theme.
# This is what will allow us to change the background color without altering the whole programs theme
# try: # if this element is in a window that's shown TWICE, will get an error here, so skip error
# combostyle.element_create(unique_field, "from", "alt")
# except:
# pass
# Create widget layout using cloned "alt" field
# combostyle.layout(style_name, [
# (unique_field, {'children': [('Combobox.downarrow', {'side': 'right', 'sticky': 'ns'}),
# ('Combobox.padding',
# {'children': [('Combobox.focus',
# {'children': [('Combobox.textarea',
# {'sticky': 'nswe'})],
# 'expand': '1',
# 'sticky': 'nswe'})],
# 'expand': '1',
# 'sticky': 'nswe'})],
# 'sticky': 'nswe'})])
# Copy default TCombobox settings
# Getting an error on this line of code
# combostyle.configure(style_name, *combostyle.configure("TCombobox"))
# Set individual widget options
try:
if element.TextColor not in (None, COLOR_SYSTEM_DEFAULT):
combostyle.configure(style_name, foreground=element.TextColor)
combostyle.configure(style_name, selectforeground=element.TextColor)
combostyle.configure(style_name, insertcolor=element.TextColor)
if element.BackgroundColor not in (None, COLOR_SYSTEM_DEFAULT):
combostyle.configure(style_name, selectbackground=element.BackgroundColor)
combostyle.map(style_name, fieldbackground=[('readonly', element.BackgroundColor)])
combostyle.configure(style_name, fieldbackground=element.BackgroundColor)
combostyle.configure(style_name, selectforeground=element.TextColor)
combostyle.configure(style_name, insertcolor=element.TextColor)
try:
combostyle.configure(style_name, arrowcolor=theme_button_color()[0])
combostyle.configure(style_name, background=theme_button_color()[1])
if element.button_arrow_color not in (None, COLOR_SYSTEM_DEFAULT):
combostyle.configure(style_name, arrowcolor=element.button_arrow_color)
if element.button_background_color not in (None, COLOR_SYSTEM_DEFAULT):
combostyle.configure(style_name, background=element.button_background_color)
except Exception as e:
_error_popup_with_traceback('Combo Element error {}'.format(e),
'Combo element key: {}'.format(element.Key),
'The theme button color is used to make the arrows. theme_button_color= {}'.format(theme_button_color()),
'One of your colors is bad. Check the text, background, button background and button arrow colors',
"Parent Window's Title: {}".format(toplevel_form.Title))
# print('* Problem setting combobox button color *', e)
# Strange code that is needed to set the font for the drop-down list
element._newfont = tkinter.font.Font(font=font)
tk_row_frame.option_add("*TCombobox*Listbox*Font", element._newfont)
element.TKCombo = element.Widget = ttk.Combobox(tk_row_frame, width=width,
textvariable=element.TKStringVar, font=font,
style=style_name)
element.TKCombo = element.Widget = ttk.Combobox(tk_row_frame, width=width, textvariable=element.TKStringVar, font=font, style=style_name)
# Chr0nic
element.TKCombo.bind("<Enter>", lambda event, em=element: testMouseHook2(em))
@ -15096,6 +15188,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
style_name = _make_ttk_style_name( '.customtable.Treeview', element)
table_style = ttk.Style()
element.ttk_style = table_style
table_style.theme_use(toplevel_form.TtkTheme)
if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT:

View File

@ -1850,6 +1850,8 @@ Combo(values,
auto_size_text = None,
background_color = None,
text_color = None,
button_background_color = None,
button_arrow_color = None,
bind_return_key = False,
change_submits = False,
enable_events = False,
@ -1878,6 +1880,8 @@ Parameter Descriptions:
| bool | auto_size_text | True if element should be the same size as the contents |
| str | background_color | color of background |
| str | text_color | color of the text |
| str | button_background_color | The color of the background of the button on the combo box |
| str | button_arrow_color | The color of the arrow on the button on the combo box |
| bool | bind_return_key | If True, then the return key will cause a the Combo to generate an event |
| bool | change_submits | DEPRICATED DO NOT USE. Use `enable_events` instead |
| bool | enable_events | Turns on the element specific events. Combo event is when a choice is made |
@ -1887,7 +1891,8 @@ Parameter Descriptions:
| (int, int or (int, int),(int,int) or int,(int,int)) or ((int, int),int) or int | pad | Amount of padding to put around element in pixels (left/right, top/bottom) or ((left, right), (top, bottom)) or an int. If an int, then it's converted into a tuple (int, int) |
| (int, int or (int, int),(int,int) or int,(int,int)) or ((int, int),int) or int | p | Same as pad parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, pad will be used |
| bool | expand_x | If True the element will automatically expand in the X direction to fill available space |
| bool) :param tooltip: text that will appear when mouse hovers over this element | expand_y | If True the element will automatically expand in the Y direction to fill available space |
| bool | expand_y | If True the element will automatically expand in the Y direction to fill available space |
| str | tooltip | text that will appear when mouse hovers over this element |
| bool | readonly | make element readonly (user can't change). True means user cannot change |
| (str or (str, int[, str]) or None) | font | specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike |
| bool | visible | set visibility state of the element |
@ -6632,7 +6637,7 @@ Parameter Descriptions:
|Type|Name|Meaning|
|--|--|--|
| List[Column] | pane_list | Must be a list of Column Elements. Each Column supplied becomes one pane that's shown |
| List[Column] or Tuple[Column] | pane_list | Must be a list of Column Elements. Each Column supplied becomes one pane that's shown |
| str | background_color | color of background |
| (int, int) | size | (width, height) w=characters-wide, h=rows-high How much room to reserve for the Pane |
| (int, int) or (None, None) | s | Same as size parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, size will be used |
@ -7683,8 +7688,14 @@ Parameter Descriptions:
It should be placed on the last row of your window along with any other elements on that row.
The color will match the theme's background color.
Sizegrip Element
```
Sizegrip(background_color = None, key = None)
Sizegrip(background_color = None,
pad = None,
p = (0, 0),
key = None,
k = None)
```
Parameter Descriptions:
@ -7692,6 +7703,10 @@ Parameter Descriptions:
|Type|Name|Meaning|
|--|--|--|
| str | background_color | color to use for the background of the grip |
| (int, int or (int, int),(int,int) or int,(int,int)) or ((int, int),int) or int | pad | Amount of padding to put around element in pixels (left/right, top/bottom) or ((left, right), (top, bottom)) or an int. If an int, then it's converted into a tuple (int, int) |
| (int, int or (int, int),(int,int) or int,(int,int)) or ((int, int),int) or int | p | Same as pad parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, pad will be used |
| str or int or tuple or object | key | Value that uniquely identifies this element from all other elements. Used when Finding an element or in return values. Must be unique to the window |
| str or int or tuple or object | k | Same as the Key. You can use either k or key. Which ever is set will be used. |
### bind
@ -9733,7 +9748,7 @@ Parameter Descriptions:
|Type|Name|Meaning|
|--|--|--|
| List[List[str or int or float]] | values | ??? |
| List[List[str or int or float]] | values | Your table data represented as a list of rows, with each row representing a row in your table. |
| List[str] | headings | The headings to show on the top line |
| List[bool] | visible_column_map | One entry for each column. False indicates the column is not shown |
| List[int] | col_widths | Number of characters that each column will occupy |
@ -11196,7 +11211,7 @@ Parameter Descriptions:
|Type|Name|Meaning|
|--|--|--|
| str | title | The title that will be displayed in the Titlebar and on the Taskbar |
| List[List[Elements]] | layout | The layout for the window. Can also be specified in the Layout method |
| List[List[Element]] or Tuple[Tuple[Element]] | layout | The layout for the window. Can also be specified in the Layout method |
| (int, int) - (width, height) | default_element_size | size in characters (wide) and rows (high) for all elements in this window |
| (int, int) | default_button_element_size | (width, height) size in characters (wide) and rows (high) for all Button elements in this window |
| bool | auto_size_text | True if Elements in Window should be sized to exactly fir the length of text |
@ -17459,7 +17474,8 @@ execute_command_subprocess(command,
wait = False,
cwd = None,
pipe_output = False,
merge_stderr_with_stdout = True)
merge_stderr_with_stdout = True,
stdin = None)
```
Parameter Descriptions:
@ -17472,6 +17488,7 @@ Parameter Descriptions:
| str | cwd | Working directory to use when executing the subprocess |
| bool | pipe_output | If True then output from the subprocess will be piped. You MUST empty the pipe by calling execute_get_results or your subprocess will block until no longer full |
| bool | merge_stderr_with_stdout | If True then output from the subprocess stderr will be merged with stdout. The result is ALL output will be on stdout. |
| bool | stdin | Value passed to the Popen call. Defaults to subprocess.DEVNULL so that the pyinstaller created executable work correctly |
| (subprocess.Popen) | **RETURN** | Popen object
Runs the editor that was configured in the global settings and opens the file to a specific line number.

View File

@ -3496,9 +3496,61 @@ And the window it creates looks like this:
# Elements
You will find information on Elements and all other classes and functions are located near the end of this manual. They are in 1 large section of the readme, in alphabetical order for easy lookups. This section's discussion of Elements is meant to teach you how they work. The other section has detailed call signatures and parameter definitions.
You will find information on Elements and all other classes and functions are located in the Call Reference Tab of the documentation.
"Elements" are the building blocks used to create windows. Some GUI APIs use the term "Widget" to describe these graphic elements.
"Elements" are the building blocks used to create windows. Some GUI APIs use the term "Widget" to describe these graphic elements. So that it's clear when a PySimpleGUI *Element* is being referenced versus an underlying GUI Framework's *Widget*. PySimpleGUI Elements map to a GUI Framework Widget, usually in a 1-to-1 manner. For example, a Text Element is implemented in tkinter using a Label Widget.
## Table of Elements in Tkinter Port
Each port of PySimpleGUI has a core set of Elements as well as port-specific elements. Some port-specific elements include the Dial element in the Qt port, and the Pane element in the tkinter port.
| Element Name | Aliases | tkinter Widget | Description |
| :------------------ | :----------------------------- | :------------- | :------------------------ |
| Text | T, Txt | tk.Label | One or more lines of Text |
| Input | I, In, InputText | tk.Entry | Single line text input |
| Combo | DD, Drop, DropDown, InputCombo | | |
| OptionMenu | InputOptionMenu | | |
| Multiline | ML, MLine | | |
| Output | | | |
| Radio | R, Rad | | |
| Checkbox | CB, CBox, Check | | |
| Spin | Sp | | |
| Button | B, Btn | | |
| Image | Im | | |
| Canvas | | | |
| Column | Col | | |
| Frame | Fr | | |
| Tab | | | |
| TabGroup | | | |
| Pane | | | |
| Graph | G | | |
| Slider | Sl | | |
| Listbox | LB, LBox | | |
| Menu | MenuBar, Menubar | | |
| MenubarCustom | | | |
| ButtonMenu | BM, BMenu | | |
| Titlebar | | | |
| ProgressBar | PBar, Prog, Progress | | |
| Table | | | |
| Tree | | | |
| VerticalSeparator | VSep, VSeparator | | |
| HorizontalSeparator | HSep, HSeparator | | |
| StatusBar | SBar | | |
| Sizegrip | SGrip | | |
| Push | P, Stretch | | |
| VPush | VP, VStretch | | |
| Sizer | | | |
## Layout Helper Functions
Your Window's layout is composed of lists of Elements. In addition to elements, these Layout Help Functions may also be present in a layout definition
| Layout Helper | Description |
| :------------ | :---------------------------------------------------------------------------------------------------------------------------------------- |
| pin | "Pins" an element to a location in a layout. If element transitions from invisible to visible, pin ensures element is in correct location |
| vtop | Vertically align element or row of elements to the top of the row |
| vbottom | Vertically align element or row of elements to the bottom of the row |
| vcenter | Vertically align element or row of elements to the center of the row |
- Text
- Single Line Input
@ -3510,29 +3562,6 @@ You will find information on Elements and all other classes and functions are lo
- Read window
- Close window ("Button" & all shortcut buttons)
- Realtime
- Checkboxes
- Radio Buttons
- Listbox
- Slider
- Multi-line Text Input/Output
- Multi-line Text Output (not on tkinter version)
- Scroll-able Output
- Vertical Separator
- Progress Bar
- Option Menu
- Menu
- ButtonMenu
- Frame
- Column
- Graph
- Image
- Table
- Tree
- Tab, TabGroup
- StatusBar
- Pane
- Stretch (Qt only)
- Sizer (plain PySimpleGUI only)
## Keys
@ -5568,29 +5597,159 @@ You can also set the cursor for the Window as a whole, including the margins and
## Valid Cursor Strings
`X_cursor, arrow, based_arrow_down, based_arrow_up, boat, bogosity, bottom_left_corner, bottom_right_corner, bottom_side, bottom_tee, box_spiral, center_ptr, circle, clock, coffee_mug, cross, cross_reverse, crosshair, diamond_cross, dot, dotbox, double_arrow, draft_large, draft_small, draped_box, exchange, fleur, gobbler, gumby, hand1, hand2, heart, icon, iron_cross, left_ptr, left_side, left_tee, leftbutton, ll_angle, lr_angle, man, middlebutton, mouse, pencil, pirate, plus, question_arrow, right_ptr, right_side, right_tee, rightbutton, rtl_logo, sailboat, sb_down_arrow, sb_h_double_arrow, sb_left_arrow, sb_right_arrow, sb_up_arrow, sb_v_double_arrow, shuttle, sizing, spider, spraycan, star, target, tcross, top_left_arrow, top_left_corner, top_right_corner, top_side, top_tee, trek, ul_angle, umbrella, ur_angle, watch, xterm`
```
X_cursor
arrow
based_arrow_down
based_arrow_up
boat
bogosity
bottom_left_corner
bottom_right_corner
bottom_side
bottom_tee
box_spiral
center_ptr
circle
clock
coffee_mug
cross
cross_reverse
crosshair
diamond_cross
dot
dotbox
double_arrow
draft_large
draft_small
draped_box
exchange
fleur
gobbler
gumby
hand1
hand2
heart
icon
iron_cross
left_ptr
left_side
left_tee
leftbutton
ll_angle
lr_angle
man
middlebutton
mouse
pencil
pirate
plus
question_arrow
right_ptr
right_side
right_tee
rightbutton
rtl_logo
sailboat
sb_down_arrow
sb_h_double_arrow
sb_left_arrow
sb_right_arrow
sb_up_arrow
sb_v_double_arrow
shuttle
sizing
spider
spraycan
star
target
tcross
top_left_arrow
top_left_corner
top_right_corner
top_side
top_tee
trek
ul_angle
umbrella
ur_angle
watch
xterm
```
## No Cursor
To specify no cursor should be shown, the cursor `'no'` can be used on some platforms
If you want your mouse cursor to be invisible, then use the **string** `"none"` and your element or window will not show any cursor.
## Windows OS Specific
One windows, these cursors map to native Windows cursors:
`arrow, center_ptr, crosshair, fleur, ibeam, icon, sb_h_double_arrow, sb_v_double_arrow, watch, xterm`
```
arrow
center_ptr
crosshair
fleur
ibeam
icon
sb_h_double_arrow
sb_v_double_arrow
watch
xterm
```
And these are also available:
These are also available:
`no, starting, size, size_ne_sw, size_ns, size_nw_se, size_we, uparrow, wait`
```
no
starting
size
size_ne_sw
size_ns
size_nw_se
size_we
uparrow
wait
```
## Mac OS Specific
`arrow, cross, crosshair, ibeam, plus, watch, xterm`
```
arrow
cross
crosshair
ibeam
plus
watch
xterm
```
And these additional native cursors are available for the Mac
These additional native cursors are available for the Mac
`copyarrow, aliasarrow, contextualmenuarrow, text, cross-hair, closedhand, openhand, pointinghand, resizeleft, resizeright, resizeleftright, resizeup, resizedown, resizeupdown, none, notallowed, poof, countinguphand, countingdownhand, countingupanddownhand, spinning`
```
copyarrow
aliasarrow
contextualmenuarrow
text
cross-hair
closedhand
openhand
pointinghand
resizeleft
resizeright
resizeleftright
resizeup
resizedown
resizeupdown
none
notallowed
poof
countinguphand
countingdownhand
countingupanddownhand
spinning
```
# Keyboard & Mouse Capture

View File

@ -1835,9 +1835,68 @@ And the window it creates looks like this:
# Elements
You will find information on Elements and all other classes and functions are located near the end of this manual. They are in 1 large section of the readme, in alphabetical order for easy lookups. This section's discussion of Elements is meant to teach you how they work. The other section has detailed call signatures and parameter definitions.
You will find information on Elements and all other classes and functions are located in the Call Reference Tab of the documentation.
"Elements" are the building blocks used to create windows. Some GUI APIs use the term "Widget" to describe these graphic elements. So that it's clear when a PySimpleGUI *Element* is being referenced versus an underlying GUI Framework's *Widget*. PySimpleGUI Elements map to a GUI Framework Widget, usually in a 1-to-1 manner. For example, a Text Element is implemented in tkinter using a Label Widget.
## Table of Elements in Tkinter Port
Each port of PySimpleGUI has a core set of Elements as well as port-specific elements. Some port-specific elements include the Dial element in the Qt port, and the Pane element in the tkinter port.
| Element Name | Aliases | tkinter Widget | Description |
| :------------------ | :----------------------------- | :------------- | :------------------------ |
| Text | T, Txt | tk.Label | One or more lines of Text |
| Input | I, In, InputText | tk.Entry | Single line text input |
| Combo | DD, Drop, DropDown, InputCombo | | |
| OptionMenu | InputOptionMenu | | |
| Multiline | ML, MLine | | |
| Output | | | |
| Radio | R, Rad | | |
| Checkbox | CB, CBox, Check | | |
| Spin | Sp | | |
| Button | B, Btn | | |
| Image | Im | | |
| Canvas | | | |
| Column | Col | | |
| Frame | Fr | | |
| Tab | | | |
| TabGroup | | | |
| Pane | | | |
| Graph | G | | |
| Slider | Sl | | |
| Listbox | LB, LBox | | |
| Menu | MenuBar, Menubar | | |
| MenubarCustom | | | |
| ButtonMenu | BM, BMenu | | |
| Titlebar | | | |
| ProgressBar | PBar, Prog, Progress | | |
| Table | | | |
| Tree | | | |
| VerticalSeparator | VSep, VSeparator | | |
| HorizontalSeparator | HSep, HSeparator | | |
| StatusBar | SBar | | |
| Sizegrip | SGrip | | |
| Push | P, Stretch | | |
| VPush | VP, VStretch | | |
| Sizer | | | |
## Layout Helper Functions
Your Window's layout is composed of lists of Elements. In addition to elements, these Layout Help Functions may also be present in a layout definition
| Layout Helper | Description |
| :------------ | :---------------------------------------------------------------------------------------------------------------------------------------- |
| pin | "Pins" an element to a location in a layout. If element transitions from invisible to visible, pin ensures element is in correct location |
| vtop | Vertically align element or row of elements to the top of the row |
| vbottom | Vertically align element or row of elements to the bottom of the row |
| vcenter | Vertically align element or row of elements to the center of the row |
"Elements" are the building blocks used to create windows. Some GUI APIs use the term "Widget" to describe these graphic elements.
- Text
- Single Line Input
@ -1849,29 +1908,7 @@ You will find information on Elements and all other classes and functions are lo
- Read window
- Close window ("Button" & all shortcut buttons)
- Realtime
- Checkboxes
- Radio Buttons
- Listbox
- Slider
- Multi-line Text Input/Output
- Multi-line Text Output (not on tkinter version)
- Scroll-able Output
- Vertical Separator
- Progress Bar
- Option Menu
- Menu
- ButtonMenu
- Frame
- Column
- Graph
- Image
- Table
- Tree
- Tab, TabGroup
- StatusBar
- Pane
- Stretch (Qt only)
- Sizer (plain PySimpleGUI only)
## Keys
@ -4057,30 +4094,166 @@ You can also set the cursor for the Window as a whole, including the margins and
## Valid Cursor Strings
`X_cursor, arrow, based_arrow_down, based_arrow_up, boat, bogosity, bottom_left_corner, bottom_right_corner, bottom_side, bottom_tee, box_spiral, center_ptr, circle, clock, coffee_mug, cross, cross_reverse, crosshair, diamond_cross, dot, dotbox, double_arrow, draft_large, draft_small, draped_box, exchange, fleur, gobbler, gumby, hand1, hand2, heart, icon, iron_cross, left_ptr, left_side, left_tee, leftbutton, ll_angle, lr_angle, man, middlebutton, mouse, pencil, pirate, plus, question_arrow, right_ptr, right_side, right_tee, rightbutton, rtl_logo, sailboat, sb_down_arrow, sb_h_double_arrow, sb_left_arrow, sb_right_arrow, sb_up_arrow, sb_v_double_arrow, shuttle, sizing, spider, spraycan, star, target, tcross, top_left_arrow, top_left_corner, top_right_corner, top_side, top_tee, trek, ul_angle, umbrella, ur_angle, watch, xterm`
```
X_cursor
arrow
based_arrow_down
based_arrow_up
boat
bogosity
bottom_left_corner
bottom_right_corner
bottom_side
bottom_tee
box_spiral
center_ptr
circle
clock
coffee_mug
cross
cross_reverse
crosshair
diamond_cross
dot
dotbox
double_arrow
draft_large
draft_small
draped_box
exchange
fleur
gobbler
gumby
hand1
hand2
heart
icon
iron_cross
left_ptr
left_side
left_tee
leftbutton
ll_angle
lr_angle
man
middlebutton
mouse
pencil
pirate
plus
question_arrow
right_ptr
right_side
right_tee
rightbutton
rtl_logo
sailboat
sb_down_arrow
sb_h_double_arrow
sb_left_arrow
sb_right_arrow
sb_up_arrow
sb_v_double_arrow
shuttle
sizing
spider
spraycan
star
target
tcross
top_left_arrow
top_left_corner
top_right_corner
top_side
top_tee
trek
ul_angle
umbrella
ur_angle
watch
xterm
```
## No Cursor
To specify no cursor should be shown, the cursor `'no'` can be used on some platforms
If you want your mouse cursor to be invisible, then use the **string** `"none"` and your element or window will not show any cursor.
## Windows OS Specific
One windows, these cursors map to native Windows cursors:
`arrow, center_ptr, crosshair, fleur, ibeam, icon, sb_h_double_arrow, sb_v_double_arrow, watch, xterm`
```
arrow
center_ptr
crosshair
fleur
ibeam
icon
sb_h_double_arrow
sb_v_double_arrow
watch
xterm
```
And these are also available:
These are also available:
```
no
starting
size
size_ne_sw
size_ns
size_nw_se
size_we
uparrow
wait
```
`no, starting, size, size_ne_sw, size_ns, size_nw_se, size_we, uparrow, wait`
## Mac OS Specific
`arrow, cross, crosshair, ibeam, plus, watch, xterm`
And these additional native cursors are available for the Mac
```
arrow
cross
crosshair
ibeam
plus
watch
xterm
```
`copyarrow, aliasarrow, contextualmenuarrow, text, cross-hair, closedhand, openhand, pointinghand, resizeleft, resizeright, resizeleftright, resizeup, resizedown, resizeupdown, none, notallowed, poof, countinguphand, countingdownhand, countingupanddownhand, spinning`
These additional native cursors are available for the Mac
```
copyarrow
aliasarrow
contextualmenuarrow
text
cross-hair
closedhand
openhand
pointinghand
resizeleft
resizeright
resizeleftright
resizeup
resizedown
resizeupdown
none
notallowed
poof
countinguphand
countingdownhand
countingupanddownhand
spinning
```
# Keyboard & Mouse Capture

View File

@ -1850,6 +1850,8 @@ Combo(values,
auto_size_text = None,
background_color = None,
text_color = None,
button_background_color = None,
button_arrow_color = None,
bind_return_key = False,
change_submits = False,
enable_events = False,
@ -1878,6 +1880,8 @@ Parameter Descriptions:
| bool | auto_size_text | True if element should be the same size as the contents |
| str | background_color | color of background |
| str | text_color | color of the text |
| str | button_background_color | The color of the background of the button on the combo box |
| str | button_arrow_color | The color of the arrow on the button on the combo box |
| bool | bind_return_key | If True, then the return key will cause a the Combo to generate an event |
| bool | change_submits | DEPRICATED DO NOT USE. Use `enable_events` instead |
| bool | enable_events | Turns on the element specific events. Combo event is when a choice is made |
@ -1887,7 +1891,8 @@ Parameter Descriptions:
| (int, int or (int, int),(int,int) or int,(int,int)) or ((int, int),int) or int | pad | Amount of padding to put around element in pixels (left/right, top/bottom) or ((left, right), (top, bottom)) or an int. If an int, then it's converted into a tuple (int, int) |
| (int, int or (int, int),(int,int) or int,(int,int)) or ((int, int),int) or int | p | Same as pad parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, pad will be used |
| bool | expand_x | If True the element will automatically expand in the X direction to fill available space |
| bool) :param tooltip: text that will appear when mouse hovers over this element | expand_y | If True the element will automatically expand in the Y direction to fill available space |
| bool | expand_y | If True the element will automatically expand in the Y direction to fill available space |
| str | tooltip | text that will appear when mouse hovers over this element |
| bool | readonly | make element readonly (user can't change). True means user cannot change |
| (str or (str, int[, str]) or None) | font | specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike |
| bool | visible | set visibility state of the element |
@ -6632,7 +6637,7 @@ Parameter Descriptions:
|Type|Name|Meaning|
|--|--|--|
| List[Column] | pane_list | Must be a list of Column Elements. Each Column supplied becomes one pane that's shown |
| List[Column] or Tuple[Column] | pane_list | Must be a list of Column Elements. Each Column supplied becomes one pane that's shown |
| str | background_color | color of background |
| (int, int) | size | (width, height) w=characters-wide, h=rows-high How much room to reserve for the Pane |
| (int, int) or (None, None) | s | Same as size parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, size will be used |
@ -7683,8 +7688,14 @@ Parameter Descriptions:
It should be placed on the last row of your window along with any other elements on that row.
The color will match the theme's background color.
Sizegrip Element
```
Sizegrip(background_color = None, key = None)
Sizegrip(background_color = None,
pad = None,
p = (0, 0),
key = None,
k = None)
```
Parameter Descriptions:
@ -7692,6 +7703,10 @@ Parameter Descriptions:
|Type|Name|Meaning|
|--|--|--|
| str | background_color | color to use for the background of the grip |
| (int, int or (int, int),(int,int) or int,(int,int)) or ((int, int),int) or int | pad | Amount of padding to put around element in pixels (left/right, top/bottom) or ((left, right), (top, bottom)) or an int. If an int, then it's converted into a tuple (int, int) |
| (int, int or (int, int),(int,int) or int,(int,int)) or ((int, int),int) or int | p | Same as pad parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, pad will be used |
| str or int or tuple or object | key | Value that uniquely identifies this element from all other elements. Used when Finding an element or in return values. Must be unique to the window |
| str or int or tuple or object | k | Same as the Key. You can use either k or key. Which ever is set will be used. |
### bind
@ -9733,7 +9748,7 @@ Parameter Descriptions:
|Type|Name|Meaning|
|--|--|--|
| List[List[str or int or float]] | values | ??? |
| List[List[str or int or float]] | values | Your table data represented as a list of rows, with each row representing a row in your table. |
| List[str] | headings | The headings to show on the top line |
| List[bool] | visible_column_map | One entry for each column. False indicates the column is not shown |
| List[int] | col_widths | Number of characters that each column will occupy |
@ -11196,7 +11211,7 @@ Parameter Descriptions:
|Type|Name|Meaning|
|--|--|--|
| str | title | The title that will be displayed in the Titlebar and on the Taskbar |
| List[List[Elements]] | layout | The layout for the window. Can also be specified in the Layout method |
| List[List[Element]] or Tuple[Tuple[Element]] | layout | The layout for the window. Can also be specified in the Layout method |
| (int, int) - (width, height) | default_element_size | size in characters (wide) and rows (high) for all elements in this window |
| (int, int) | default_button_element_size | (width, height) size in characters (wide) and rows (high) for all Button elements in this window |
| bool | auto_size_text | True if Elements in Window should be sized to exactly fir the length of text |
@ -17459,7 +17474,8 @@ execute_command_subprocess(command,
wait = False,
cwd = None,
pipe_output = False,
merge_stderr_with_stdout = True)
merge_stderr_with_stdout = True,
stdin = None)
```
Parameter Descriptions:
@ -17472,6 +17488,7 @@ Parameter Descriptions:
| str | cwd | Working directory to use when executing the subprocess |
| bool | pipe_output | If True then output from the subprocess will be piped. You MUST empty the pipe by calling execute_get_results or your subprocess will block until no longer full |
| bool | merge_stderr_with_stdout | If True then output from the subprocess stderr will be merged with stdout. The result is ALL output will be on stdout. |
| bool | stdin | Value passed to the Popen call. Defaults to subprocess.DEVNULL so that the pyinstaller created executable work correctly |
| (subprocess.Popen) | **RETURN** | Popen object
Runs the editor that was configured in the global settings and opens the file to a specific line number.

View File

@ -3496,9 +3496,61 @@ And the window it creates looks like this:
# Elements
You will find information on Elements and all other classes and functions are located near the end of this manual. They are in 1 large section of the readme, in alphabetical order for easy lookups. This section's discussion of Elements is meant to teach you how they work. The other section has detailed call signatures and parameter definitions.
You will find information on Elements and all other classes and functions are located in the Call Reference Tab of the documentation.
"Elements" are the building blocks used to create windows. Some GUI APIs use the term "Widget" to describe these graphic elements.
"Elements" are the building blocks used to create windows. Some GUI APIs use the term "Widget" to describe these graphic elements. So that it's clear when a PySimpleGUI *Element* is being referenced versus an underlying GUI Framework's *Widget*. PySimpleGUI Elements map to a GUI Framework Widget, usually in a 1-to-1 manner. For example, a Text Element is implemented in tkinter using a Label Widget.
## Table of Elements in Tkinter Port
Each port of PySimpleGUI has a core set of Elements as well as port-specific elements. Some port-specific elements include the Dial element in the Qt port, and the Pane element in the tkinter port.
| Element Name | Aliases | tkinter Widget | Description |
| :------------------ | :----------------------------- | :------------- | :------------------------ |
| Text | T, Txt | tk.Label | One or more lines of Text |
| Input | I, In, InputText | tk.Entry | Single line text input |
| Combo | DD, Drop, DropDown, InputCombo | | |
| OptionMenu | InputOptionMenu | | |
| Multiline | ML, MLine | | |
| Output | | | |
| Radio | R, Rad | | |
| Checkbox | CB, CBox, Check | | |
| Spin | Sp | | |
| Button | B, Btn | | |
| Image | Im | | |
| Canvas | | | |
| Column | Col | | |
| Frame | Fr | | |
| Tab | | | |
| TabGroup | | | |
| Pane | | | |
| Graph | G | | |
| Slider | Sl | | |
| Listbox | LB, LBox | | |
| Menu | MenuBar, Menubar | | |
| MenubarCustom | | | |
| ButtonMenu | BM, BMenu | | |
| Titlebar | | | |
| ProgressBar | PBar, Prog, Progress | | |
| Table | | | |
| Tree | | | |
| VerticalSeparator | VSep, VSeparator | | |
| HorizontalSeparator | HSep, HSeparator | | |
| StatusBar | SBar | | |
| Sizegrip | SGrip | | |
| Push | P, Stretch | | |
| VPush | VP, VStretch | | |
| Sizer | | | |
## Layout Helper Functions
Your Window's layout is composed of lists of Elements. In addition to elements, these Layout Help Functions may also be present in a layout definition
| Layout Helper | Description |
| :------------ | :---------------------------------------------------------------------------------------------------------------------------------------- |
| pin | "Pins" an element to a location in a layout. If element transitions from invisible to visible, pin ensures element is in correct location |
| vtop | Vertically align element or row of elements to the top of the row |
| vbottom | Vertically align element or row of elements to the bottom of the row |
| vcenter | Vertically align element or row of elements to the center of the row |
- Text
- Single Line Input
@ -3510,29 +3562,6 @@ You will find information on Elements and all other classes and functions are lo
- Read window
- Close window ("Button" & all shortcut buttons)
- Realtime
- Checkboxes
- Radio Buttons
- Listbox
- Slider
- Multi-line Text Input/Output
- Multi-line Text Output (not on tkinter version)
- Scroll-able Output
- Vertical Separator
- Progress Bar
- Option Menu
- Menu
- ButtonMenu
- Frame
- Column
- Graph
- Image
- Table
- Tree
- Tab, TabGroup
- StatusBar
- Pane
- Stretch (Qt only)
- Sizer (plain PySimpleGUI only)
## Keys
@ -5568,29 +5597,159 @@ You can also set the cursor for the Window as a whole, including the margins and
## Valid Cursor Strings
`X_cursor, arrow, based_arrow_down, based_arrow_up, boat, bogosity, bottom_left_corner, bottom_right_corner, bottom_side, bottom_tee, box_spiral, center_ptr, circle, clock, coffee_mug, cross, cross_reverse, crosshair, diamond_cross, dot, dotbox, double_arrow, draft_large, draft_small, draped_box, exchange, fleur, gobbler, gumby, hand1, hand2, heart, icon, iron_cross, left_ptr, left_side, left_tee, leftbutton, ll_angle, lr_angle, man, middlebutton, mouse, pencil, pirate, plus, question_arrow, right_ptr, right_side, right_tee, rightbutton, rtl_logo, sailboat, sb_down_arrow, sb_h_double_arrow, sb_left_arrow, sb_right_arrow, sb_up_arrow, sb_v_double_arrow, shuttle, sizing, spider, spraycan, star, target, tcross, top_left_arrow, top_left_corner, top_right_corner, top_side, top_tee, trek, ul_angle, umbrella, ur_angle, watch, xterm`
```
X_cursor
arrow
based_arrow_down
based_arrow_up
boat
bogosity
bottom_left_corner
bottom_right_corner
bottom_side
bottom_tee
box_spiral
center_ptr
circle
clock
coffee_mug
cross
cross_reverse
crosshair
diamond_cross
dot
dotbox
double_arrow
draft_large
draft_small
draped_box
exchange
fleur
gobbler
gumby
hand1
hand2
heart
icon
iron_cross
left_ptr
left_side
left_tee
leftbutton
ll_angle
lr_angle
man
middlebutton
mouse
pencil
pirate
plus
question_arrow
right_ptr
right_side
right_tee
rightbutton
rtl_logo
sailboat
sb_down_arrow
sb_h_double_arrow
sb_left_arrow
sb_right_arrow
sb_up_arrow
sb_v_double_arrow
shuttle
sizing
spider
spraycan
star
target
tcross
top_left_arrow
top_left_corner
top_right_corner
top_side
top_tee
trek
ul_angle
umbrella
ur_angle
watch
xterm
```
## No Cursor
To specify no cursor should be shown, the cursor `'no'` can be used on some platforms
If you want your mouse cursor to be invisible, then use the **string** `"none"` and your element or window will not show any cursor.
## Windows OS Specific
One windows, these cursors map to native Windows cursors:
`arrow, center_ptr, crosshair, fleur, ibeam, icon, sb_h_double_arrow, sb_v_double_arrow, watch, xterm`
```
arrow
center_ptr
crosshair
fleur
ibeam
icon
sb_h_double_arrow
sb_v_double_arrow
watch
xterm
```
And these are also available:
These are also available:
`no, starting, size, size_ne_sw, size_ns, size_nw_se, size_we, uparrow, wait`
```
no
starting
size
size_ne_sw
size_ns
size_nw_se
size_we
uparrow
wait
```
## Mac OS Specific
`arrow, cross, crosshair, ibeam, plus, watch, xterm`
```
arrow
cross
crosshair
ibeam
plus
watch
xterm
```
And these additional native cursors are available for the Mac
These additional native cursors are available for the Mac
`copyarrow, aliasarrow, contextualmenuarrow, text, cross-hair, closedhand, openhand, pointinghand, resizeleft, resizeright, resizeleftright, resizeup, resizedown, resizeupdown, none, notallowed, poof, countinguphand, countingdownhand, countingupanddownhand, spinning`
```
copyarrow
aliasarrow
contextualmenuarrow
text
cross-hair
closedhand
openhand
pointinghand
resizeleft
resizeright
resizeleftright
resizeup
resizedown
resizeupdown
none
notallowed
poof
countinguphand
countingdownhand
countingupanddownhand
spinning
```
# Keyboard & Mouse Capture