-1
python tk로 3D 상자를 만들었지 만, 모서리 화면과 창 전체 화면에 그려진 상자가 반복되어 여러 개를 만듭니다.python 상자의 좌표 Tkinter (3d)
왜 이런 일이 일어나고 있는지 확실하지 않지만 하나의 상자 만 있어야합니다.
왜 캔버스의 다른 위치에 상자가 생성됩니까? 당신이 (프로그램 충돌 ...까지) 상자의 무한한 수를 얻기 위하여려고하고있다, 그래서 당신은 무한 루프에 main()
전화
from tkinter import *
window = Tk()
window.title("Game.py")
window.geometry("800x500")
canvas = Canvas(window, width = window.winfo_width(), height = window.winfo_height())
canvas.configure(background='#5d90e2')
canvas.pack()
verts = ((-1,-1,-1), (1,-1,-1), (1,1,-1), (-1,1,-1), (-1,-1,1), (1,-1,1),(1,1,1), (-1,1,1))
edges = (0,1), (1,2), (2,3), (3,0), (4,5), (5,6), (6,7), (7,4), (0,4),(1,5), (2,6), (3,7)
def fit_canvas():
canvas.config(width= window.winfo_width(), height=window.winfo_height())
def main():
fit_canvas()
hw = window.winfo_width()/2
hh = window.winfo_height()/2
for edge in edges:
points = []
a = verts[edge[0]]
b = verts[edge[1]]
for x,y,z in (a,b):
z += 5
f = int(200/z)
x,y = x*f, y*f
points += [(hw+x, hh+y)]
print(points[0] , points[1])
canvas.create_line(points[0][0],points[0][1],points[1][0],points[1}[1])
loop_no = 0
while True:
loop_no += 1
main()
canvas.update()
이 코드에는 구문 오류가 있으므로 실행되지 않습니다. 또한 캔버스의 너비와 높이가 1 픽셀이므로 보이지 않습니다. –