#145 Method create_text in tkinter
#!/usr/bin/env python3
from tkinter import Tk, Canvas, Frame, BOTH, W
class Example(Frame):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.master.title("Method create_text in tkinter")
self.pack(fill=BOTH, expand=1)
canvas = Canvas(self)
canvas.create_text(20, 30, anchor=W, font="Comix", text="First line")
canvas.create_text(20, 60, anchor=W, font="Comix", text="Second line")
canvas.create_text(20, 130, anchor=W, font="Comix", text="Third line")
canvas.create_text(20, 160, anchor=W, font="Comix", text="Fourth line")
canvas.pack(fill=BOTH, expand=1)
def main():
root = Tk()
ex = Example()
root.geometry("420x250+300+300")
root.mainloop()
if __name__ == '__main__':
main()
Last Updated on 2021-02-09 by gantovnik

Recent Comments