diff --git a/docs/call reference.md b/docs/call reference.md index dc5fc706..b6b6f79c 100644 --- a/docs/call reference.md +++ b/docs/call reference.md @@ -25,9 +25,9 @@ apply coupon for discount: - 5C14671AABA040B06FDC + BE7BDF4D74791CDC1BF6 - @@ -12284,6 +12284,33 @@ Return the current size of the window in pixels |---|---|---| |Tuple[(int), (int)] or Tuple[None, None]| **return** | (width, height) of the window | +### start_thread + +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. + +``` +start_thread(func, end_key) +``` + +Parameter Descriptions: + +|Type|Name|Meaning| +|--|--|--| +| Any | func | A lambda or a function name with no parms | +| Any | end_key | The key that will be generated when the function returns | +| threading.Thread | **RETURN** | The id of the thread + ### un_hide Used to bring back a window that was previously hidden using the Hide method diff --git a/docs/cookbook.md b/docs/cookbook.md index 3bfed744..c3e234bd 100644 --- a/docs/cookbook.md +++ b/docs/cookbook.md @@ -25,9 +25,9 @@ apply coupon for discount: - 0D50D92ADEDA243A4A4B + BE7BDF4D74791CDC1BF6 - diff --git a/readme_creator/markdown input files/5_call_reference.md b/readme_creator/markdown input files/5_call_reference.md index 7fa1dce3..0bcee44f 100644 --- a/readme_creator/markdown input files/5_call_reference.md +++ b/readme_creator/markdown input files/5_call_reference.md @@ -25,9 +25,9 @@ apply coupon for discount: - 5C14671AABA040B06FDC + BE7BDF4D74791CDC1BF6 - @@ -2702,6 +2702,9 @@ Example: If first row has a `VPush`, then your layout will be At the bottom of ### size +### start_thread + + ### un_hide diff --git a/readme_creator/output/call reference.md b/readme_creator/output/call reference.md index dc5fc706..b6b6f79c 100644 --- a/readme_creator/output/call reference.md +++ b/readme_creator/output/call reference.md @@ -25,9 +25,9 @@ apply coupon for discount: - 5C14671AABA040B06FDC + BE7BDF4D74791CDC1BF6 - @@ -12284,6 +12284,33 @@ Return the current size of the window in pixels |---|---|---| |Tuple[(int), (int)] or Tuple[None, None]| **return** | (width, height) of the window | +### start_thread + +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. + +``` +start_thread(func, end_key) +``` + +Parameter Descriptions: + +|Type|Name|Meaning| +|--|--|--| +| Any | func | A lambda or a function name with no parms | +| Any | end_key | The key that will be generated when the function returns | +| threading.Thread | **RETURN** | The id of the thread + ### un_hide Used to bring back a window that was previously hidden using the Hide method