【发布时间】:2020-05-15 02:53:30
【问题描述】:
我正在使用 Python 的 turtle 模块创建一个计算器。 我需要用户在窗口中输入信息,而不是在运行程序时弹出的命令行界面中输入信息,然后将信息打印到屏幕上 有点像如何在命令提示符中输入信息,而无需将信息放在辅助窗口中。
import turtle
import pyglet
import time
def pen_message(message = "", font = "", font_size = 0, loc_x = 0, loc_y = 0):
pen = turtle.Turtle()
pen.speed(0)
pen.penup()
pen.color("sky blue")
pen.goto(loc_x, loc_y)
pen.write(message, align = "center", font = (font, font_size, "normal"))
def main():
# Main program window
win = turtle.Screen()
win.cv._rootwindow.resizable(False, False)
win.screensize()
win.setup(width = 1.0, height = 1.0)
win.title("Geometric & Algabraic Calculator by @_c0d3_x_")
win.bgcolor("black")
win.setup(width = 800, height = 600)
win.tracer(0)
# Pen for text
title = pen_message("Geometric & Algabraic Calculator", "Tech Noir", 15, 0, 200)
msg = pen_message("Welcome User", "Courier", 15, 0, 150)
userInput = pen_message(input("Your name: "), "Courier", 15, 0, 100)
main()
【问题讨论】:
标签: python oop user-interface input turtle-graphics