For my project based on Python and Qt I wanted to move expensive calculations and functions providing server/client functions into separate threads, to unfreeze my GUI. While leaving them running, I still want them to check periodically if there is new data from the main thread. For testing, I therefore implemented the following demo code: My main aim was to
Tag: events
What does ”event.pos[0]” mean in the pygame library? I saw an example using it to get the X axis of the cursor and ignore the Y axis
I don’t understand how it works. I don’t know if I understood the purpose of this function wrong. I tried to search what posx=event.pos[0] means but all I found was that if you want to take x, write the code of posx,posy=pygame.mouse.get_pos() and then take posx. But I still can’t understand the method he followed in the example I saw.
I would like to make a discord bot that sends a message when a member goes online but I can’t seem to make it work ? (python)
I would like to make it so when a member goes online my both will send a message in the server welcoming the member but I cannot find a way to do so if I could get the name of the user too it would help thank you. Here is my code that is not working Answer Here’s a snippet
pywintypes.com_error: (-2147221008, ‘CoInitialize has not been called.’, None, None)
When I try to run this code as is I get this error “IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) pywintypes.com_error: (-2147221008, ‘CoInitialize has not been called.’, None, None)” , however if I run stp_tracker alone it works fine and if I run notify stp’s alone it works just fine. I appreciate anyones input. Thanks Answer Apologize for that, but searching
Wait for timeout or event being set for asyncio.Event
I have a class with a method that looks like this: The idea is that several of these are run in their own thread and at some point one thread does stop_event.set(), which naturally stops all others. I want to switch to asyncio for this, because the tasks in run are mostly sleeping and doing IO. Thus, I got to:
asyncio: Wait for event from other thread
I’m designing an application in Python which should access a machine to perform some (lengthy) tasks. The asyncio module seems to be a good choice for everything that is network-related, but now I need to access the serial port for one specific component. I’ve implemented kind of an abstraction layer for the actual serial port stuff, but can’t figure out
Why doesn’t the .bind() method work with a frame widget in Tkinter?
This code is an attempt to bind a command to a frame, ie. when the “Escape” key is pressed, the window should be destroyed. if frame1.bind() is replaced by root.bind(), the code works as I would expect it to. Why doesn’t what I’ve written above work? Answer The bind works, but the event will only trigger if the frame has
How can I fire a Traits static event notification on a List?
I am working through the traits presentation from PyCon 2010. At about 2:30:45 the presenter starts covering trait event notifications, which allow (among other things) the ability to automatically call a subroutine any time a trait has changed. I am running a modified copy of the example he gave… In this trial, I am trying to see whether I can
Python Button Bind two functions and send arguments with the binding
I am somewhat new to python still, and am working on a project including a GUI. I using with Tkinter and buttons a lot, and am curious if there was a way to run a function with a bind because I want one thing to happen when it is presses and something else when it is released. I don’t understand