#!/usr/bin/env python3
# coding: utf-8
from tkinter import *
# init our application's root window
root = Tk()
root.geometry('480x480')
# let's provide same sample coordinates with the desired text as tuples in a list
coords = [(30,30,'X'), (90,90,'X'), (120,120,'X'), (240,240,'X'), (270,270,'X'), (360,360,'O')]
# interate through the coords list and read the coordinates and the text of each tuple
for c in coords:
l = Label(root, text=c[2])
l.place(x=c[0], y=c[1])
# start a loop over the application
root.mainloop()
我只是拼凑了一些代码来简要介绍一下如何使用
place
几何管理器。如需进一步解释,请参阅代码中的注释:我使用的是python3。如果您使用的是python2,则需要将
tkinter
更改为Tkinter
。如果您需要将我的代码移植到python2,那么这应该可以实现。在使用.place函数。在
像下面这样
相关问题 更多 >
编程相关推荐