-1

So, my code is mean to display an image on a certain position of my screen with the size i want. i managed to make it work with matplotlib and PIL but i still can't display it where i want. Does anyone have an idea how i can make it work ? Could it be also possible to select which screen i want the image to be displayed on ? here is the funcion i wrote

def displayQR(self,image_directory):
    self.img = mpimg.imread(image_directory)
    fig, ax = plt.subplots(num=None, figsize=(self.img_width*0.0104166, 
        self.img_height*0.0104166), dpi=80, facecolor='w', edgecolor='k')
    ax.imshow(self.img)
    ax.axis('off')  # clear x-axis and y-axis
    plt.ion()
    plt.show(block=False)
    plt.draw()
    plt.pause(0.001)
martineau
  • 119,623
  • 25
  • 170
  • 301
Enivo
  • 3
  • 3

1 Answers1

0

The best way to show a image for my is using OpenCV library. From this link you can do it.

import cv2
img = cv2.imread("test.png") #Read de image
winname = "Test" #Window name
cv2.namedWindow(winname)        # Create a named window
cv2.resizeWindow(winname, 600,600) #Resize window
cv2.moveWindow(winname, 40,30)  # Move it to (40,30) screen place
cv2.imshow(winname, img) #Show the image
cv2.waitKey()
cv2.destroyAllWindows()

I hope this works for you :)

  • Thanks ! it actualy work quite well but there is one things i need to know. How can i make it work in backroung so the rest of my code can still running ? – Enivo Jul 29 '19 at 07:37