diff --git a/readme_creator/app_configs.json b/readme_creator/app_configs.json index d67f9695..f27f7660 100644 --- a/readme_creator/app_configs.json +++ b/readme_creator/app_configs.json @@ -1,4 +1,13 @@ { - "README_FILENAME": "output/readme.md", - "CALL_REFERENCE_FILENAME": "output/call reference.md" + "show_time": false, + "use_psg_color": true, + "README_OFILE": "output/index.md", + "CALL_REF_OFILE": "output/call reference.md", + "_PyCharm_path_": "C:/Program Files/JetBrains/PyCharm Community Edition 2019.1.1/bin/pycharm.bat", + "_text_editor_combo_": 0, + "toggle_progressbar": false, + "_filter_empty_tables_ml_": "PrintClose\nEasyPrintClose\nmain\ntheme\nRead\n\n\n", + "_filter_tkinter_class_methods_": "SetFocus\nSetTooltip\nUpdate\n__init__\nbind\nexpand\nset_cursor\nset_size\n\n\n", + "checkbox_enable_empty_tables_filter": true, + "checkbox_enable_filter_tkinter_class_methods": true } \ No newline at end of file diff --git a/readme_creator/markdown input files/2_readme.md b/readme_creator/markdown input files/2_readme.md index 50073bfa..1a78fff9 100644 --- a/readme_creator/markdown input files/2_readme.md +++ b/readme_creator/markdown input files/2_readme.md @@ -4991,14 +4991,13 @@ Watch this space in the future for the more standardized variable name for this ## Binding tkiner "events" -If you wish to receive events directly from tkinter, but do it in a PySimpleGUI way, then you can do that and get those events returned to you via your standard `Window.read()` call. +If you wish to receive events directly from tkinter, but do it in a PySimpleGUI way, then you can do that and get those events returned to you via your standard `Window.read()` call. -Both the Elements and Window objects have a method called `bind`. You specify 2 parameters to this function. One is the string that is used to tell tkinter what events to bind. The other is a "key modifier" for Elements and a "key" for Windows. +Both the Elements and Window objects have a method called `bind`. You specify 2 parameters to this function. One is the string that is used to tell tkinter what events to bind. The other is a "key modifier" for Elements and a "key" for Windows. The `key_modifier` in the `Element.bind` call is something that is added to your key. If your key is a string, then this modifier will be appended to your key and the event will be a single string. -If your element's key is not a string, then a tuple will be returned as the event -(your_key, key_modifier) +If your element's key is not a string, then a tuple will be returned as the event (your_key, key_modifier) This will enable you to continue to use your weird, non-string keys. Just be aware that you'll be getting back a tuple instead of your key in these situations. @@ -5006,16 +5005,66 @@ The best example of when this can happen is in a Minesweeper game where each but It'll be tricky for the user to parse these events, but it's assumed you're an advanced user if you're using this capability and are also using non-string keys. -There are 2 member variables that have also been added as shown in the documentation for the bind methods. This added variable contains the tkinter specific event information. In other words, the 'event' that tkinter normally sends back when a callback happens. +An Element member variable `user_bind_event` will contain information that tkinter passed back along with the event. It's not required for most operations and none of the demos currently use this variable, but it's there just in case. The contents of the variable are tkinter specific and set by tkinter so you'll be digging into the tkinter docs if you're using an obscure binding of some kind. -Here is sample code that shows how to make these calls. +tkinter events must be in between angle brackets -Three events are being bound. +```python +window['-KEY-'].bind('', 'STRING TO APPEND') +``` + +Events can also be binded to the window +```python +window.bind('', 'STRING TO APPEND') +``` + + +List of tkinter events: + +| Event | Description | +| :------------------------------- | ------------------------------------------------------------ | +| Button-1 / ButtonPress-1 / 1 | Left button is pressed over an element. 1 corresponds to the left button, 2 to the middle button, 3 to the right button.
Buttons can go up to 5 | +| ButtonRelease-1 | Left button is released over an element. | +| Double-Button-1 | An element was double clicked. The 'Double' modifier was used. See below for more modifiers. | +| B1-Motion | Left button is held and moved around over an element. | +| Motion | Mouse pointer is moved over an element | +| Enter | Mouse pointer entered the element | +| Leave | Mouse pointer left the element | +| Key / KeyPress
Keypress-a / a | A key was pressed. [Keysyms](https://www.tcl.tk/man/tcl8.6/TkCmd/keysyms.htm) can be used to bind specific key/s.
When using keysyms, 'Key' or 'KeyPress' can be omitted.
| +| KeyReleased | A key was released. | +| FocusIn | Keyboard has focused on element. | +| FocusOut | Keyboard switched focus from element. | +| Visibility | Some part of the element is seen on screen | + +Modifier keys can be put in front of events. + +| Windows | MacOS | +| ------- | ------- | +| Control | Command | +| Alt | Option | +| Shift |<==| +| Double | <== | +| Triple | <== | +| Quadruple | <== | + +The following will bind Ctrl+z to the window: +```python +window.bind('', 'STRING TO APPEND') +``` + +To unbind an event from an element, use the `unbind` method. +```python +window['-KEY-'].unbind('TKINTER EVENT') +``` + +Here is sample code that shows these bindings in action. + +Four main things are occurring. 1. Any button clicks in the window will return an event "Window Click" from window.read() -2. Right clicking the "Go" buttons will return an event "Go+RIGHT CLICK+" from window.read() -3. When the Input Element receives focus, an event "-IN-+FOCUS+" will be returned from window.read() - +2. Right clicking the "Go" buttons will return an event "Go +RIGHT CLICK+" from window.read() +3. When the second Input Element receives focus, an event "-IN2- +FOCUS+" will be returned from window.read() +4. If the "Unbind " button is pressed, the right click binding of the "Go" button will be unbinded. ```python import PySimpleGUI as sg @@ -5023,27 +5072,29 @@ import PySimpleGUI as sg sg.theme('Dark Green 2') layout = [ [sg.Text('My Window')], - [sg.Input(key='-IN-'), sg.Text(size=(15,1), key='-OUT-')], - [sg.Button('Go'), sg.Button('Exit')] + [sg.Input(key='-IN1-')], + [sg.Input(key='-IN2-')], + [sg.Button('Go'), sg.Button('Unbind'),sg.Button('Exit')] ] window = sg.Window('Window Title', layout, finalize=True) -window['-IN-'].bind("", '+FOCUS+') window.bind("", 'Window Click') -window['Go'].bind("", '+RIGHT CLICK+') +window['Go'].bind("", ' +RIGHT CLICK+') +window['-IN2-'].bind("", ' +FOCUS+') while True: # Event Loop event, values = window.read() print(event, values) if event in (sg.WIN_CLOSED, 'Exit'): break + if event == 'Unbind': + window['Go'].unbind('') -window.close(); del window +window.close() ``` -There is no way to "unbind" and event at this time. (sorry, didn't think of it before releasing) ---- +[Tkinter bindings documentation](https://tcl.tk/man/tcl8.6/TkCmd/bind.htm#M18) ------------------ diff --git a/readme_creator/markdown input files/4_Release_notes.md b/readme_creator/markdown input files/4_Release_notes.md index 92570390..cb7bf01a 100644 --- a/readme_creator/markdown input files/4_Release_notes.md +++ b/readme_creator/markdown input files/4_Release_notes.md @@ -1639,6 +1639,25 @@ Custom Titlebars, Fix for Docstrings so PyCharm 2020 works correctly, New shortc +## 4.34.0 PySimpleGUI 18-Jan-2021 + +Fix popup_scrolled, big swap of PEP8 names from alias to def statements + +* Quick "Emergency" release since popup_scrolled crashes. BAD bad thing that has to be corrected ASAP +* Changed all of the functions and methods so that the definition is PEP8 compliant and and alias is not compliant +* Built-in SDK help + * Added a "Summary mode" + * Make window smaller to fit on more monitors + * Added aliases to end of help for each element +* metadata + * Changed into a class Property so that it shows up in the docs correctly + * The Element, Window and SystemTray classes all got this same change +* Added all elements to the docstring for window[key] style lookups to make PyCharm happier +* Moved all PEP8 function aliases to a centralized spot at the end of the code +* sdk_help alias of main_sdk_help +* Several new demos including a demo browser + + ## Upcoming The future for PySimpleGUI looks bright! diff --git a/readme_creator/markdown input files/5_call_reference.md b/readme_creator/markdown input files/5_call_reference.md index 3e7f11c1..47bd2003 100644 --- a/readme_creator/markdown input files/5_call_reference.md +++ b/readme_creator/markdown input files/5_call_reference.md @@ -2553,7 +2553,7 @@ These are the functions available for you to call -## Button No Longer To Be Used +## Button Functions No Longer Used (DO NOT USE) Note - These are no longer recommended! They are shown here in case you run into them in some old code. @@ -2590,7 +2590,38 @@ They are shown here in case you run into them in some old code. -## Popup Functions +## Popups PEP8 Versions + + + + + + + + + + + + + + + + + + + + + + +### Popup Alias - Same as popup_scrolled + + + + + +## Popup Not PEP8 Compliant names + +These versions of the popup functions are here only for backwards compatibility. You should not use these function names. Instead use the popup functions that have snake_case rather than CamelCase. @@ -2616,37 +2647,6 @@ They are shown here in case you run into them in some old code. -## Popups PEP8 Versions - - - - - - - - - - - - - - - - - - - - - - - - - - -Same as popup_scrolled - - - ## PEP8 Function Bindings @@ -2655,15 +2655,10 @@ Same as popup_scrolled -### Non PEP8 version (same as PEP8 version) - - - - ## The Test Harness -Used to test the installation, get information about the versions, upgrade from GitHub +Used to get SDK help, test the installation, get information about the versions, upgrade from GitHub @@ -2715,8 +2710,8 @@ Used to test the installation, get information about the versions, upgrade from ## Misc - + ## Layout Helper Funcs @@ -2726,12 +2721,20 @@ Used to test the installation, get information about the versions, upgrade from + ## Configuration / Settings / Extensions +### Non PEP8 versions + + + + + + ## Old Themes (Look and Feel) - Replaced by theme()