Gold King
Posts: 15
Joined: Tue Nov 26, 2019 5:09 am

Display full screen image using Python?

Tue Nov 26, 2019 2:58 pm

Hi, I am new to Python and Raspberry.
Can someone please teach me how to code Python to display full screen image?
Thanks in advance.

gordon77
Posts: 4292
Joined: Sun Aug 05, 2012 3:12 pm

Re: Display full screen image using Python?

Tue Nov 26, 2019 8:48 pm

What are you using pygame, opencv?

Gold King
Posts: 15
Joined: Tue Nov 26, 2019 5:09 am

Re: Display full screen image using Python?

Wed Nov 27, 2019 2:15 am

gordon77 wrote:
Tue Nov 26, 2019 8:48 pm
What are you using pygame, opencv?
I am using Thonny.
Right now I am learning Tiknter

gordon77
Posts: 4292
Joined: Sun Aug 05, 2012 3:12 pm

Re: Display full screen image using Python?

Wed Nov 27, 2019 8:44 am

removed
Last edited by gordon77 on Wed Nov 27, 2019 9:52 am, edited 1 time in total.

User avatar
paddyg
Posts: 2422
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: Display full screen image using Python?

Wed Nov 27, 2019 9:46 am

I can't see a ref to this in that example code, but you can get tk to use fullscreen (rather than maximized which I think the geometry(wxh+0+0) does) using something like

Code: Select all

import tkinter
tk = tkinter.Tk()
tk.attributes("-fullscreen", True)
and here's some slightly complicated code to fill the screen with a scaled image using a blurred version of the same image to fill any letter/pillar box
PS, and just above the scale/blurring code in that example there's a bit showing how to rotate (say phone pictures) using EXIF info. Uses PIL as in Gordon's link.
PPS NB if you do make the tk window full screen you need to make sure you can close it using the escape key (for instance) before you test it out!
Last edited by paddyg on Wed Nov 27, 2019 3:35 pm, edited 1 time in total.
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

User avatar
RogerW
Posts: 286
Joined: Sat Dec 20, 2014 12:15 pm
Location: London UK

Re: Display full screen image using Python?

Wed Nov 27, 2019 10:30 am

Paddyg beat me to it but this should run

Code: Select all

import tkinter as tk

main = tk.Tk()
main.attributes('-fullscreen',True)
tk.Button(main,text='Quit',command=main.destroy).pack()
main.mainloop()

Return to “Python”