0

I'm trying to create a simple slideshow using Tkinter and Python 3.7.2. I want the slide show to display images on secondary screen and in fullscreen mode. I have tried to use only one window and two windows as suggested here. This is the code I have written:

import tkinter as tk
from PIL import Image, ImageTk

class App(tk.Tk):
    '''Tk window/label adjusts to size of image'''
    def __init__(self, image_files, x, y, delay):
        # the root will be self
        tk.Tk.__init__(self)

        # set width. height, x, y position
        self.geometry('%dx%d+%d+%d'%(912,1140,0,0)) #Window on main screen

        #create second screen window
        self.top2 = tk.Toplevel(self,bg="grey85")
        self.top2.geometry('%dx%d+%d+%d'%(912,1140,-912,0)) # The resolution of the second screen is 912x1140. 
        #The screen is on the left of the main screen
        self.top2.attributes('-fullscreen', False) #Fullscreen mode

        self.pictures = image_files
        self.picture_display = tk.Label(self.top2, width=912, height=1140)
        self.picture_display.pack()
        self.delay = delay
        self.index = 1
        self.nImages = len(image_files)

    def start_acquisition(self):

        if self.index == self.nImages+1:
            self.destroy()
            return

        self.load = Image.open(self.pictures[self.index-1])
        self.render = ImageTk.PhotoImage(self.load)
        self.picture_display['image'] = self.render
        self.index += 1
        self.after(self.delay, self.start_acquisition)


    def run(self):
        self.mainloop()



# set milliseconds time between slides
delay = 3500

image_files = [
'1805Circle Test Output.bmp', #images resolution is 912x1140
'8233Circle Test Input.bmp',
'cross.bmp'
]
x = 0 #Not used currently
y = 0 #Not used currently
app = App(image_files, x, y, delay)
app.start_acquisition()
app.run()

print('Finished')

The code works as expected when the fullscreen attribute is "False". As soon as I put this attribute "True" the "top2" window appears on the main screen. The same thing happen if only one window is used. Could you please help me find a solution for this problem? thx

PVaz
  • 140
  • 1
  • 2
  • 7

0 Answers0