Skip to content
← Back to Community
Background in python
Profile icon
AhmadAyyeh

I am trying to add a background image in python but I cannot figure out how to do so, I am using python 3.0. I am new to programming :)

Voters
Profile icon
MakaylaSutherla
Profile icon
Oreo21
Profile icon
IndiraPatnam
Profile icon
AaravGupta17
Profile icon
MohamadAboabdul
Profile icon
William-Jacobse
Profile icon
Sammu8302
Profile icon
AlexaChabot
Profile icon
OXGaming
Profile icon
LilianCrean
Comments
hotnewtop
Profile icon
mwilki7

I have put together driver code for a pygame application from stuff I found on the internet here: https://repl.it/@mwilki7/python-game

Replace
[line 31] BackGround = Background('your_background_image_here.png', [0,0])
with whatever name your background image is.

You might need to resize the window:
[line 12] size = (700, 500)
so that your background image fits inside

Profile icon
AhmadAyyeh

@mwilki7 Thanks a lot! But just a quick question, where should I type my code?
I have coded my whole program using functions so I only have to call for main() in order for the program to run.
Here's my program:
https://repl.it/@AhmadAyyeh/Drivers-license-program

Profile icon
finnegan

Nice blog, I will keep visiting this blog very often.Nft games

Profile icon
WowisKinG

wow

Profile icon
JustARatherRidi

Hey, please share your repl so that we can help you out :)

Profile icon
AhmadAyyeh

@JustARatherRidi here it is:
https://repl.it/@AhmadAyyeh/soundex-2
This is only a part of the program, I've been trying on this one because I didn't want to mess my project up.....if you want the whole code just let me know!

Profile icon
AhmadAyyeh
Profile icon
JustARatherRidi

@AhmadAyyeh Okay, so it looks like both of your programs runs on the terminal (meaning that you print to the terminal and you get input from the terminal), and there really isn't any way to stick an image onto the terminal. All it can do is display characters.

But in your first program, it looks like you're trying to make a GUI using tkinter, which is what you should do if you really wanted to show that image.

How you would go about making a GUI in tkinter is by using textboxes instead of inputs and using a button to submit, and maybe lists or comboboxes if you want to make it look better.

If you decide that it is worth learning tkinter for the sake of the image, here's an answer that will help

Good luck!

Profile icon
AhmadAyyeh

@JustARatherRidi Hello,
Thanks alot for your help, I kind of understood how to work with tkinter but I have another problem, whenever I run the program, for some reason it keeps showing soundex_code as p160 and cannot figure out how to fix it....
can you please help me figure it out? here's my code with tkinter:
https://repl.it/@AhmadAyyeh/soundex-with-Tk
and here's my original code:
https://repl.it/@AhmadAyyeh/soundex-2
(by the way, for some reason when I run the code on repl and press on get data it does not always output data (probably connection issues) but when I run it on IDLE on my desktop it works)
Thanks again!

Profile icon
PYer

You can't put an image in the terminal. Are you using flask, or something else?

Profile icon
AhmadAyyeh

@PYer I'm only using python....