ultimatelistctrl: item in ULC becomes invisible when SetItemWindow function is called in a thread

When I try to add a widged to ULC using SetItemWindow or SetWindow, it works normally. However, if I attempt to call these functions in a thread function, embedded widgets do not become visible (created invisible). I am sure that they are created successfully, and they are just invisible, because when I pause (time.sleep) the thread function they are shown for a while. I am not sure if it is a known bug or threading is supported by ULC.

IIRC - The majority of wx, and many other GUIs, are NOT thread safe -
your GUI events should all be handled in your main loop and either
polling from the GUI loop or callbacks and events should be used to
update your GUI from any background threads. Personally often I raise
events in my threads to pass information back to the GUI.

Hope that helps.

Gadget/Steve

···

On 16/09/2015 08:34, Ferhat KURTULMUŞ wrote:

When I try to add a widged to ULC using SetItemWindow or SetWindow, it
works normally. However, if I attempt to call these functions in a
thread function, embedded widgets do not become visible (created
invisible). I am sure that they are created successfully, and they are
just invisible, because when I pause (time.sleep) the thread function
they are shown for a while. I am not sure if it is a known bug or
threading is supported by ULC.

--
You received this message because you are subscribed to the Google
Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to wxpython-users+unsubscribe@googlegroups.com
<mailto:wxpython-users+unsubscribe@googlegroups.com>.
For more options, visit https://groups.google.com/d/optout.

Steve,

IIRC - The majority of wx, and many other GUIs, are NOT thread safe -
your GUI events should all be handled in your main loop and either
polling from the GUI loop or callbacks and events should be used to
update your GUI from any background threads. Personally often I raise
events in my threads to pass information back to the GUI.

You remember correctly. :wink:
No GUI calls should be used from the secondary thread!
Also I believe wxTimer shouldn't be used from a secondary thread as well.

Thank you.

···

On Wed, Sep 16, 2015 at 10:39 AM, Steve (Gadget) Barnes <gadgetsteve@live.co.uk> wrote:

Hope that helps.

Gadget/Steve

On 16/09/2015 08:34, Ferhat KURTULMUŞ wrote:

When I try to add a widged to ULC using SetItemWindow or SetWindow, it
works normally. However, if I attempt to call these functions in a
thread function, embedded widgets do not become visible (created
invisible). I am sure that they are created successfully, and they are
just invisible, because when I pause (time.sleep) the thread function
they are shown for a while. I am not sure if it is a known bug or
threading is supported by ULC.

--
You received this message because you are subscribed to the Google
Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to wxpython-users+unsubscribe@googlegroups.com
<mailto:wxpython-users+unsubscribe@googlegroups.com>.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Others have answered the basic question, but I wanted to take a
moment to explain WHY this is the case, because it’s important.
All of the windowing systems where wx operates are message-based.
The vast majority of the APIs you call do not take direct action.
Instead, they put a message in a message queue. Later, a message
loop will pull out that message and dispatch it to be handled.
The subtle point that is easily missed is that message queues are a
THREAD resource. Each window is owned by the thread that created
it, and all messages for that window are sent to its owning thread.
When you create a window in a secondary thread, its creation
messages get sent to the secondary thread’s message queue, but you
aren’t running a message loop in that queue, so the messages will
never be handled.
All GUI operations have to be done in the owning thread, which is
usually the application’s main thread. You certainly CAN create
windows in a second thread, but you need to run another message loop
to handle them, and that usually defeats the purpose of having a
second thread.

···

Ferhat KURTULMUŞ wrote:

      When I try to add a widged to ULC using SetItemWindow or SetWindow          , it works normally.

However, if I attempt to call these functions in a thread
function, embedded widgets do not become visible (created
invisible). I am sure that they are created successfully, and
they are just invisible, because when I pause (time.sleep) the
thread function they are shown for a while. I am not sure if
it is a known bug or threading is supported by ULC.

-- Tim Roberts, Providenza & Boekelheide, Inc.

timr@probo.com