In python, create a series of 14 white bars separated by black regions. Each bar should be 11 pixels wide and 230 pixels high. The separation between the bars should be 19 pixels.
Code:
import tkinter as tk
# --- constants --- (UPPER_CASE_NAMES)
WHITEWIDTH = 11
# --- main --- (lower_case_names)
root = tk.Tk()
root.geometry("439x230")
canvas = tk.Canvas(root)
canvas.config(width=439, height=230,background='black')
canvas.pack()
for i in range(14):
x1 = 19*(i+1)+11*i
y1 = 0
x2 = x1 + WHITEWIDTH
y2 = y1 + 230
canvas.create_rectangle((x1, y1, x2, y2), fill='white')
root.mainloop()
Hope this helps.
Get Answers For Free
Most questions answered within 1 hours.