简体   繁体   English

Python Tkinter 按钮/输入方向

[英]Python Tkinter Button/Entry Orientation

I'm trying to set the position of 3 entries/buttons.我正在尝试设置 3 个条目/按钮的位置。 I know that it needs to be done with anchor and side,however I doesn't really understand how it works.我知道它需要用锚点和侧面来完成,但是我并不真正了解它是如何工作的。 I was trying to get them in one line, the first on the left the second on the center and the third one on the right.我试图将它们排成一行,左边的第一个,中间的第二个,右边的第三个。 I managed to accomplish this,however they are in 3 different lines.我设法做到了这一点,但是它们在 3 个不同的行中。 Please,could someone explain it to me,how this works?拜托,有人可以向我解释一下,这是如何工作的? Are the side and anchor values related to the previous ones? side 和 anchor 值是否与之前的值相关?

import tkinter
import random
canvas=tkinter.Canvas(width=500,height=500)
canvas.pack()

def symbol(x,y,z,color):
    name=entry1.get()        
    for i in range(1,z+1):
        canvas.create_text(x,y,text='                     '+name,angle=(360/z)*i,fill=color,font='Arial 19')

def draw(coordinates):
    x=coordinates.x
    y=coordinates.y
    z=int(entry2.get())
    color=entry3.get()
    symbol(x,y,z,color)


canvas.bind('<Button-1>',draw)

entry1=tkinter.Entry(bg='red')
entry1.pack(side=tkinter.BOTTOM,anchor=tkinter.W)

entry2=tkinter.Entry(bg='green')
entry2.pack(side=tkinter.BOTTOM,anchor=tkinter.CENTER)

entry3=tkinter.Entry(bg='blue')
entry3.pack(side=tkinter.RIGHT,anchor=tkinter.S)
import tkinter
import random
canvas=tkinter.Canvas(width=500,height=500)
canvas.pack()

def symbol(x,y,z,color):
    name=entry1.get()        
    for i in range(1,z+1):
        canvas.create_text(x,y,text='                     '+name,angle=(360/z)*i,fill=color,font='Arial 19')

def draw(coordinates):
    x=coordinates.x
    y=coordinates.y
    z=int(entry2.get())
    color=entry3.get()
    symbol(x,y,z,color)


canvas.bind('<Button-1>',draw)

entry1=tkinter.Entry(bg='red')
entry1.place(x=0,y=485)

entry2=tkinter.Entry(bg='green')
entry2.place(x=181,y=485)

entry3=tkinter.Entry(bg='blue')
entry3.place(x=360,y=485)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM