[英]How I can integrate crossbar client (python3,asyncio) with tkinter
[英]How Can I integrate Python Turtle into Tkinter
from tkinter import *
import turtle
def RunTurtle():
import turtle
window = turtle.Screen()
window.bgcolor("light green")
window.title("Turtle")
t = turtle.Turtle()
t.speed(20)
def MyTurtleFunc(Fl, Sl, f, rin, ro, c, w):
t.color(c)
t.width(w)
for _ in range(Fl):
for _ in range(Sl):
t.forward(f)
t.right(rin)
t.right(ro)
MyTurtleFunc(36, 4, 100, 90, 10, "blue", 4)
def RunGUI():
master = Tk()
master.title("Project")
canvas = Canvas(master, height=1080, width=1920)
canvas.pack()
def RUN():
RunTurle()
TopFrame = Frame(master, bg='light green')
TopFrame.place(relx=0.04, rely=0.04, relwidth=0.91, relheight=0.6)
MiddleFrame = Frame(master, bg='light blue')
MiddleFrame.place(relx=0.04, rely=0.66, relwidth=0.91, relheight=0.06)
BottomFrame = Frame(master, bg='orange')
BottomFrame.place(relx=0.04, rely=0.74, relwidth=0.91, relheight=0.25)
TopLabel = Label(TopFrame, bg='light green', text="Drawing Robot", font="calibri 15 bold", foreground="black")
TopLabel.pack(padx=5, pady=5)
LabelBottom = Label(BottomFrame, bg='orange', text="Debug Area ", font="vendara 15 bold ", foreground="black")
LabelBottom.pack(padx=0.1, pady=0.1)
LabelBottomText = Text(BottomFrame, height=10.5, width=180)
LabelBottomText.tag_configure('style', foreground='grey', font=('calibri', 10, 'bold'))
LabelBottomText.pack()
fronttext = "..."
LabelBottomText.insert(END, fronttext, 'style')
RunProgram = Button(MiddleFrame, text="RUN PROGRAM", foreground="black", command=RUN)
RunProgram.pack(padx=0.2, pady=0.2, side=LEFT)
master.mainloop()
我设计了我的入门级程序的界面。我分为这三个部分。TopFrame必须显示turtle。Middle Frame有帮助我们启动程序的按钮。Bottom Frame有调试区域。 我想将“RunTurtle()”功能集成到 TopFrame 中。当用户单击“RUN PROGRAM”按钮时,界面将打开,turtle 将在 TopFrame 中绘制图案。我该怎么做? 谢谢你...
def RUN():
RunTurle()
应该
def RUN():
RunTurtle()
并运行函数 RunGUI() 其工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.