Python Forum
cv2.imshow Python is not opening the window on top
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
cv2.imshow Python is not opening the window on top
#1
I'm using python 3.8 and I'm creating a game, where a user is shown a picture and based on that picture he has stuff to do, the problem is, that I have a loop and when the cv2.imshow is before the loop, the picture is opened on top, you don't have to click on the icon, but I need to put the picture after the loop and that's where the problem starts, the image is opening in a window, but I have to click on that window to see the picture. Problem is, the game I've created requires image to be shown for 5 seconds, and the user loses seconds by manually clicking on the window to see the image.

The code is:


while True:

start = input('Press < Y > to start the game or < N > to exit \nDo you want to start the game? ')
print(start)
if start.upper() == "Y":
print("Starting the game")
break
elif start.upper() == "N":
print("End Game \nMaze runner v1.0")
quit()
else:
print("You must choose < Y > or < N >")


img = cv2.imread('maze.jpg', 0)
window_name = 'image'
cv2.imshow(window_name, img)
cv2.waitKey(5000)
cv2.destroyAllWindows()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Is there a way to call and focus any popup window outside of the main window app? Valjean 6 1,736 Oct-02-2023, 04:11 PM
Last Post: deanhystad
  Why is IDLE not opening on a MacOS Montery 12.6 and using Python 3.10.7? Merlin385 7 1,668 Oct-08-2022, 08:36 PM
Last Post: Merlin385
  Opening CMD from Python Oshadha 2 1,269 Jul-17-2022, 11:22 PM
Last Post: Skaperen
  Pyspark Window: perform sum over a window with specific conditions Shena76 0 1,164 Jun-13-2022, 08:59 AM
Last Post: Shena76
Question Opening small size browser with python selenium not work, need help greenpine 0 1,612 Feb-07-2022, 11:36 AM
Last Post: greenpine
  python keeps opening script directory Tyrel 5 2,993 Aug-06-2021, 10:43 PM
Last Post: snippsat
  Python OpenCV window not opening in fullscreen mode Zman350x 0 3,288 Apr-29-2021, 07:54 PM
Last Post: Zman350x
  Keep getting Session management error when running imshow in pycharm pace 0 2,090 Mar-25-2021, 10:06 AM
Last Post: pace
  Python opening a new command window m_lokeshkumar 1 1,850 Jan-05-2020, 09:01 PM
Last Post: Larz60+
  Error -3 when opening matlab file in python python_newbie09 0 2,288 Aug-02-2019, 11:51 AM
Last Post: python_newbie09

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020