2
我試圖做一個菜單或類似的如何修改.textinput中的按鈕?
的東西在這裏是代碼:
from turtle import TurtleScreen, RawTurtle, TK
root = TK.Tk()
root.title("ArMoon")
canvas = TK.Canvas(root, width=1000, height=700)
canvas.pack()
win = TurtleScreen(canvas)
dali = RawTurtle(win)
def Entrada():
return win.textinput("Figura"," 1. Operando\n 2. Sumar operandos\
\n 3. Reiniciar\n 4. Salir\n ")
while True:
x = Entrada()
if x == "4" or x == "":
break
oper = x.split()
print(oper)
x = oper[0]
print(x)
#if x <= 0:
win.mainloop()
的問題是,當我運行該程序,在文字輸入的小窗口,它們顯示我兩個按鈕,我不介意,我喜歡他們,但是有沒有辦法修改他們做什麼?
「確定」按鈕,似乎很好地工作,但是當我按下「取消」按鈕,我得到一個錯誤
> Traceback (most recent call last):
>
> File "C:\Users\Lobo\Desktop\TORTUGA\Borrador v2.py", line 21, in
> <module>
>
> oper = x.split()
>
> AttributeError: 'NoneType' object has no attribute 'split'
我想修改它,當我按下它只是運行「破」來結束。
謝謝你,工作 – Sev
請不要忘記接受答案=)(在投票欄下打勾)。你也贏得了+2的代表。 – Alexei