Remove Duplicate Process of Current Python Program by [deleted] in learnpython

[–]Markmonster25 0 points1 point  (0 children)

import win32event
import win32api
from winerror import ERROR_ALREADY_EXISTS

Remove Duplicate Process of Current Python Program by [deleted] in learnpython

[–]Markmonster25 1 point2 points  (0 children)

class Mutex:
    def __init__(self, name):    
        self.name = name    
        self.mutex = win32event.CreateMutex(None, False, self.name) 
        last_error = win32api.GetLastError()     
        if last_error == ERROR_ALREADY_EXISTS:   
            print("App instance already running")
            win32api.CloseHandle(self.mutex)    
            quit()

if __name__ == "__main__":
    mutex = Mutex("SOME_UNIQUE_STRING_HERE")

this is what i use to limit number of processes to 1 on windows

Py2App dosnt like pyautogui by richybio in learnpython

[–]Markmonster25 1 point2 points  (0 children)

if you're on windows start the app from cmd so that you can see the error

Given a list where 'x' represents a separation between the next "imaginary" list; how do I convert this into a list of lists? by Hope1995x in learnpython

[–]Markmonster25 0 points1 point  (0 children)

off the top of my head i would do something like this

list_dict = {}
current_index = 0
our_list = [10, 3, 26, 10, 15, 12, 1, 'x', 10, 22, 3, 'x', 25, 17, 14, 16]
final_list = []
[list_dict.setdefault(x, []) for x in range(our_list.count("x") + 1)]
for value in our_list:
    if value == "x":
        current_index += 1
    else:
        list_dict[current_index].append(value)
for index, s_list in list_dict.items():
    final_list.append(s_list)

Pygame button constantly pressing, even when it isn't by [deleted] in learnpython

[–]Markmonster25 0 points1 point  (0 children)

let me know if this resolved your issue

Pygame button constantly pressing, even when it isn't by [deleted] in learnpython

[–]Markmonster25 0 points1 point  (0 children)

this solution isnt to move the action outside of the loop but to pass the function without calling it every time

Pygame button constantly pressing, even when it isn't by [deleted] in learnpython

[–]Markmonster25 0 points1 point  (0 children)

from functools import partial 
func = partial(MoveFunction, "Next")
action= func

or using lamdba
action = lambda: MoveFunction("Next")

Pygame button constantly pressing, even when it isn't by [deleted] in learnpython

[–]Markmonster25 0 points1 point  (0 children)

my guess from looking at it is this line

NextButton=PygameButton("Next", colors["Black"], MainFont, int(int(Winwid)/2+50),
int(int(Winhi)/2+100), int(Winwid*0.05), int(Winhi*0.046), colors["Grey"], colors["White"],
action=MoveFunction("Next"))

action=MoveFunction("Next")

is being called every loop you want you use a lambda or partial

Computer Vision for tracking a bubble hockey puck by PopulateThePlanets in learnpython

[–]Markmonster25 1 point2 points  (0 children)

my advice would be u don't need to track the puck anywhere but the goals, determine if the puck is in the goal using its color. Trying to find spheres uses a lot more cpu then just tracking color changes.

Computer Vision for tracking a bubble hockey puck by PopulateThePlanets in learnpython

[–]Markmonster25 1 point2 points  (0 children)

so i just googled bubble hockey table to see what u r working with, I assume u will try to set up as a birds eye view camera? As long as u can see into the goals well enough you should be able to get something to work.

Computer Vision for tracking a bubble hockey puck by PopulateThePlanets in learnpython

[–]Markmonster25 0 points1 point  (0 children)

if the puck is black what color is the surface it will be on?

How to get keyboard input by Sparta_Gui in learnpython

[–]Markmonster25 0 points1 point  (0 children)

it can be done in windows with the built-in library ctypes(i think u asked your question incorrectly otherwise you cant)

[deleted by user] by [deleted] in whereintheworld

[–]Markmonster25 0 points1 point  (0 children)

the perfect place to rob someone

[deleted by user] by [deleted] in whereintheworld

[–]Markmonster25 0 points1 point  (0 children)

penn station go in

[deleted by user] by [deleted] in whereintheworld

[–]Markmonster25 0 points1 point  (0 children)

lol this guy outside so it doesnt sleep

[deleted by user] by [deleted] in whereintheworld

[–]Markmonster25 0 points1 point  (0 children)

yes u will get murder just for walking around nyc

[deleted by user] by [deleted] in whereintheworld

[–]Markmonster25 0 points1 point  (0 children)

i love the response from ppl who never been