提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
文章目录
前言
基于官方链接:Call reference - PySimpleGUI
一、Button Element
按钮元素 - 定义所有可能的按钮。 Submit、FileBrowse 等可创建快捷一个 Button。
二、使用步骤
1.参数
Button(button_text = "",
button_type = 7,
target = (None, None),
tooltip = None,
file_types = (('ALL Files', '*.* *'),),
initial_folder = None,
default_extension = "",
disabled = False,
change_submits = False,
enable_events = False,
image_filename = None,
image_data = None,
image_size = (None, None),
image_subsample = None,
border_width = None,
size = (None, None),
s = (None, None),
auto_size_button = None,
button_color = None,
disabled_button_color = None,
highlight_colors = None,
mouseover_colors = (None, None),
use_ttk_buttons = None,
font = None,
bind_return_key = False,
focus = False,
pad = None,
p = None,
key = None,
k = None,
right_click_menu = None,
expand_x = False,
expand_y = False,
visible = True,
metadata = None)
2.参数说明
Type | Name | Meaning |
---|---|---|
str | button_text | Text to be displayed on the button 按钮上显示的文本 |
int | button_type | You should NOT be setting this directly. ONLY the shortcut functions set this |
str or (int, int) | target | key or (row,col) target for the button. Note that -1 for column means 1 element to the left of this one. The constant ThisRow is used to indicate the current row. The Button itself is a valid target for some types of button |
str | tooltip | text, that will appear when mouse hovers over the element |
Tuple[(str, str), ...] | file_types | the filetypes that will be used to match files. To indicate all files: (("ALL Files", ". *"),). Note - NOT SUPPORTED ON MAC |
str | initial_folder | starting path for folders and files |
str | default_extension | If no extension entered by user, add this to filename (only used in saveas dialogs) |
(bool or str) | disabled | If True button will be created disabled. If BUTTON_DISABLED_MEANS_IGNORE then the button will be ignored rather than disabled using tkinter |
bool | change_submits | DO NOT USE. Only listed for backwards compat - Use enable_events instead |
bool | enable_events | Turns on the element specific events. If this button is a target, should it generate an event when filled in |
str | image_filename | image filename if there is a button image. GIFs and PNGs only. |
bytes or str | image_data | Raw or Base64 representation of the image to put on button. Choose either filename or data |
(int, int) | image_size | Size of the image in pixels (width, height) |
int | image_subsample | amount to reduce the size of the image. Divides the size by this number. 2=1/2, 3=1/3, 4=1/4, etc |
int | border_width | width of border around button in pixels |
(int or None, int or None) or (None, None) or int | size | (w, h) w=characters-wide, h=rows-high. If an int instead of a tuple is supplied, then height is auto-set to 1 |
(int or None, int or None) or (None, None) or int | 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 |
bool | auto_size_button | if True the button size is sized to fit the text |
(str, str) or str or (int, int) or None | button_color | Color of button. default is from theme or the window. Easy to remember which is which if you say "ON" between colors. "red" on "green". Normally a tuple, but can be a simplified-button-color-string "foreground on background". Can be a single color if want to set only the background. |
(str, str) or str | disabled_button_color | colors to use when button is disabled (text, background). Use None for a color if don't want to change. Only ttk buttons support both text and background colors. tk buttons only support changing text color |
(str, str) | highlight_colors | colors to use when button has focus (has focus, does not have focus). None will use colors based on theme. Only used by Linux and only for non-TTK button |
(str, str) or str | mouseover_colors | Important difference between Linux & Windows! Linux - Colors when mouse moved over button. Windows - colors when button is pressed. The default is to switch the text and background colors (an inverse effect) |
bool | use_ttk_buttons | True = use ttk buttons. False = do not use ttk buttons. None (Default) = use ttk buttons only if on a Mac and not with button images |
(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 | bind_return_key | If True the return key will cause this button to be pressed |
bool | focus | if True, initial focus will be put on this button |
(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 | Used with window.find_element and with return values to uniquely identify this element to uniquely identify this element |
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. |
List[List[ List[str] or str ]] | right_click_menu | A list of lists of Menu items to show when this element is right clicked. See user docs for exact format. |
bool | expand_x | If True the element will automatically expand in the X direction to fill available space |
bool | expand_y | If True the element will automatically expand in the Y direction to fill available space |
bool | visible | set visibility state of the element |
Any | metadata | User metadata that can be set to ANYTHING |
总结
提示:这里对文章进行总结:
例如:以上就是今天要讲的内容,本文仅仅简单介绍了pandas的使用,而pandas提供了大量能使我们快速便捷地处理数据的函数和方法。