You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
443 B
18 lines
443 B
import tkinter as tk
|
|
|
|
|
|
class MyCanvas(tk.Canvas):
|
|
def __init__(self, master=None, **kwargs):
|
|
super().__init__(master, **kwargs)
|
|
|
|
# 在画布上绘制一些文本
|
|
self.create_text(50, 50, text="Hello, Tkinter!")
|
|
self.create_text(100, 100, text="This is a text example.")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
root = tk.Tk()
|
|
canvas = MyCanvas(root, width=200, height=150)
|
|
canvas.pack()
|
|
root.mainloop()
|