Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.


+2 votes

I am trying to figure out how to get the background placed after the user clicks. Right now with my code it just places a plain white screen after instead of the picture it is supposed to be.
Below is my code i am using to place the picture. What can I change?
win = GraphWin("Train your dragon", WINDOW_WIDTH, WINDOW_WIDTH)
backgroundImage = Image(Point(WINDOW_WIDTH, WINDOW_WIDTH), "bgNum")

asked in CSC201 Spring 2021 by (1 point)

3 Answers

+2 votes

You can only use win.setBackground(...) to use a background color

To use a background image, just create an Image and draw it in the center of the window.

answered by (508 points)
0 votes

Don't forget to do backgroundImage.draw(win) That might be your issue.

answered by (1 point)
0 votes

Moreover, remember that you need to address the name of the file of the background image and not bgNum by itself. bgNum is just an integer that the user types in order to choose the background they want. Think about how can you make that integer the user types in to choose the desired background they want?

answered by (1 point)