1

Trying to change the background of the whole canvas, this is my code:

import tkinter as tk root = tk.Tk() screen = tk.Canvas(root) screen.grid() class Digit: def __init__(self, canvas, x=10, y=10, length=20, width=4, background='cyan'): self.canvas = canvas l = length self.segs = [] for x0, y0, x1, y1 in offsets: self.segs.append(canvas.create_line( x + x0*l, y + y0*l, x + x1*l, y + y1*l, width=width, state = 'hidden')) def show(self, num): for iid, on in zip(self.segs, digits[num]): self.canvas.itemconfigure(iid, state = 'normal' if on else 'hidden') 

I've have tried putting the defining the background colour in different places, however nothing will change the colour. I have tried defining the background in the canvas.create.line but still had no luck. I also had it defined as root.configure(background='cyan') but this also didn't work.

Running pyton 3.7 (if this helps)

Where should it be if where it is currently is not correct?

1 Answer 1

2

Do you want this? The following code changes background of the canvas-screen

import tkinter as tk root = tk.Tk() screen = tk.Canvas(root, bg="cyan") # <--- bg="cyan" screen.grid() root.mainloop() 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.