今天学习了python的图像处理,并手绘了一个算盘来进行运算
def initWindow():
rect = canvas.create_rectangle(25, 40, 450, 400, width=3) # 算盘边框
x0, y0, x1, y1 = 0, 0, 0, 0
for i in range(5): # 生成串算珠的线
line_shu = canvas.create_line(70 + x0, 40 + y0, 70 + x1, 400 + y1, width=3)
x0 += 80
x1 += 80
line_fenge = canvas.create_line(25, 100, 450, 100, width=3) # 生成上下珠的分割线
x0, y0, x1, y1 = 0, 0, 0, 0
for i in range(5): # 生成5个上珠
top_oval[i] = canvas.create_oval(40 + x0, 60 + y0, 100 + x1, 90 + y1, fill='orange', tags=f"top{i}")
x0 += 80
x1 += 80
x0, y0, x1, y1 = 0, 0, 0, 0
for i in range(4): # 生成4*5个下珠
for j in range(5):
below_oval[i][j] = canvas.create_oval(40 + x0, 160 + y0, 100 + x1, 190 + y1, fill='yellow', tags=f"below{i}{j}")
chushi[i][j] = canvas.coords(below_oval[i][j])
x0 += 80
x1 += 80
x0 = 0
x1 = 0
y0 += 60
y1 += 60
global start_button, label_sum, username, entry_username, username_text, window_showusername
global label_time, window_time, window_question
global var_username, var_question, var_msg, window_answer, window_msg
sum = Label(window, width=20, height=2, bg="grey", textvariable=var, font=('Arial', 14))
label_sum = canvas.create_window(750, 80, window=sum, anchor=NE)
canvas.itemconfigure(label_sum, state="hidden")
button = Button(window, width=30, height=4, bg="grey", text="开始测试吧!", command=adjust)
start_button = canvas.create_window(750, 300, window=button, anchor=NE)
text = Label(window, text="用户名:", width=10, height=2, bg="white")
username_text = canvas.create_window(500, 200, window=text, anchor=CENTER)
username = Entry(window, font=('Arial', 14))
entry_username = canvas.create_window(640, 200, window=username, anchor=CENTER)
label_showusername = Label(window, textvariable=var_username, width=15, height=2, bg="grey", font=('Arial', 14))
window_showusername = canvas.create_window(770, 0, window=label_showusername, anchor=NE)
canvas.itemconfigure(window_showusername, state="hidden")
label_time = Label(window, width=10, height=2, bg="grey", font=('Arial', 14))
window_time = canvas.create_window(600, 0, window=label_time, anchor=NE)
canvas.itemconfigure(window_time, state="hidden")
label_question = Label(window, width=30, height=2, bg="grey", font=('Arial', 14), textvariable=var_question)
window_question = canvas.create_window(630, 180, window=label_question, anchor=CENTER)
canvas.itemconfigure(window_question, state="hidden")
answer_button = Button(window, width=10, height=2, bg="grey", text="提交答案", command=judge, font=('Arial', 14))
window_answer = canvas.create_window(630, 400, window=answer_button, anchor=CENTER)
canvas.itemconfigure(window_answer, state="hidden")
msg_label = Label(window, width=30, height=6, bg="grey", font=('Arial', 14), textvariable=var_msg)
window_msg = canvas.create_window(630, 260, window=msg_label, anchor=CENTER)
标签:canvas,日报,软工,label,width,window,5.15,x0,create
From: https://www.cnblogs.com/drip3775/p/18192650