파이썬으로 대문자 모드로 모든 알파벳을 어떻게 그릴 수 tkinter
있습니까? 캔버스 다각형을 사용하면 도움이 되나요? 다음과 같은 것 A
:
w = Canvas(master, width=canvas_width, height=canvas_height).pack()
points = [100,0, 0, 100, 200,100]
w.create_polygon(points, outline=python_green, fill='yellow', width=3)
그리고 python tkinter 또는 다른 라이브러리로 간단한 LED 도트 매트릭스 디스플레이를 어떻게 만들 수 있습니까?
대문자의 경우 매우 큰 글꼴을 사용하여 대문자를 쓸 수 있습니다 (왜 그리 려는지 모르겠습니다).
from tkinter import Tk, Canvas
master = Tk()
canvas = Canvas(master, bg="white", width=200, height=200)
canvas.pack()
canvas.create_text(50,50, text="A", fill="red", font="Arial 100")
master.mainloop()
LED 도트 매트릭스 디스플레이의 경우 다음과 같이 할 수 있습니다.
from tkinter import Tk, Canvas
import numpy as np
dot_matrix = np.array([[0,0,0,0,0,0,0],
[0,0,1,1,1,0,0],
[0,1,0,0,0,1,0],
[0,0,0,0,0,1,0],
[0,0,0,0,1,0,0],
[0,0,0,1,0,0,0],
[0,0,1,0,0,0,0],
[0,1,1,1,1,1,0],
[0,0,0,0,0,0,0]])
master = Tk()
canvas = Canvas(master, bg="black", width=200, height=200)
canvas.pack()
def display_matrix(matrix):
h,l = matrix.shape
for i in range(h):
for j in range(l):
if matrix[i,j]:
canvas.create_oval(5 + 12*j , 5 + 12*i, 15 + 12*j, 15 + 12*i, fill="red")
display_matrix(dot_matrix)
master.mainloop()
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다