Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7662651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:51:19+00:00 2026-05-31T13:51:19+00:00

I’ve made a pathfinding visualizer using python and pygame. As of now, it can

  • 0

I’ve made a pathfinding visualizer using python and pygame. As of now, it can simulate only one algorithm at a time. I want to spawn multiple windows, each simulating different algorithm, side by side so that algorithms can be analyzed against each other. I have a function client.run() that draws the GUI. I’m trying to spawn multiple instances like this:

p=threading.Thread(target = client.run)
q=threading.Thread(target = client.run)
p.start()
q.start()    

But by doing so my program hangs! Is there any way to rectify this problem, or any alternative way of running multiple instances/windows?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T13:51:20+00:00Added an answer on May 31, 2026 at 1:51 pm

    Pygame is built in a way to have a single window by process, you can’t avoid that. The pygame.display module sets you a “display” and that is what you get.

    You are in good look, as you have designed you software to work with threads, and have each thread control a display.. Just change the “threading” Python module for the multiprocessing, and use multiprocessing.Process instead of threading.Threads — as long as you initialize pygame and its display from within each subprocess you should be ok.

    I just teste here and teh example bellow works fine:

    # -*- coding: utf-8 -*-
    import pygame
    import multiprocessing
    from time import sleep
    
    
    
    def init():
        pygame.init()
        screen = pygame.display.set_mode((320,240))
        return screen
    
    def main():
        screen = init()
        while True:
            pygame.event.pump()
            event =  pygame.event.poll()
            if event.type != pygame.NOEVENT:
                print event
    
    
    class Multigame(multiprocessing.Process):
        def run(self):
            return main()
    
    for i in range(3):
        Multigame().start()
    
    while True:
        sleep(1)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I am reading a book about Javascript and jQuery and using one of the
I want use html5's new tag to play a wav file (currently only supported
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.