MCPcopy Index your code
hub / github.com/PySimpleGUI/PySimpleGUI / write_event_value

Method write_event_value

PySimpleGUI/PySimpleGUI.py:12234–12259  ·  view source on GitHub ↗

Adds a key & value tuple to the queue that is used by threads to communicate with the window :param key: The key that will be returned as the event when reading the window :type key: Any :param value: The value that will be in the values dictionary :typ

(self, key, value)

Source from the content-addressed store, hash-verified

12232 self.thread_strvar.trace_add("write", self._window_tkvar_changed_callback)
12233
12234 def write_event_value(self, key, value):
12235 """
12236 Adds a key & value tuple to the queue that is used by threads to communicate with the window
12237
12238 :param key: The key that will be returned as the event when reading the window
12239 :type key: Any
12240 :param value: The value that will be in the values dictionary
12241 :type value: Any
12242 """
12243
12244 if self.thread_queue is None:
12245 print('*** Warning Window.write_event_value - no thread queue found ***')
12246 return
12247 # self.thread_lock.acquire() # first lock the critical section
12248 self.thread_queue.put(item=(key, value))
12249 self.TKroot.tk.willdispatch() # brilliant bit of code provided by Giuliano who I owe a million thank yous!
12250 self.thread_strvar.set('new item')
12251
12252 # self.thread_queue.put(item=(key, value))
12253 # self.thread_strvar.set('new item')
12254 # March 28 2021 - finally found a solution! It needs a little more work and a lock
12255 # if no timer is running, then one should be started
12256 # if self.thread_timer is None:
12257 # print('Starting a timer')
12258 # self.thread_timer = self.TKroot.after(1, self._window_tkvar_changed_callback)
12259 # self.thread_lock.release()
12260
12261 def _queued_thread_event_read(self):
12262 if self.thread_queue is None:

Callers 15

mainFunction · 0.95
the_threadFunction · 0.80
pip_install_threadFunction · 0.80
the_threadFunction · 0.80
the_threadFunction · 0.80
ping_threadFunction · 0.80
long_function_wrapperFunction · 0.80
the_threadFunction · 0.80
make_delegate_callFunction · 0.80
long_operation_threadFunction · 0.80
long_operation_threadFunction · 0.80
the_threadFunction · 0.80

Calls 1

setMethod · 0.45

Tested by

no test coverage detected