私はこのことについてお詫びします。私は今日、pythonを学び始めました。私はそれを周りに探しました。は私の問題のようにがかなり簡単に解決できるように見えますが、私は問題を抱えています。私の現在のコード:Pythonのキーバインディング:TypeError:引数を受け取りません(1件あり)
master = Tk()
master.wm_title("V3")
w = Label(master, text="Code:")
w.pack()
master.resizable(width=False, height=False)
e = Entry(master, width = 35, justify = CENTER)
master.geometry('{}x{}'.format(240, 235))
e.pack()
e.focus_set()
def decode():
textField.configure(state="normal")
textField.delete(1.0,END)
hint = e.get()
for i, c in enumerate(hint):
if i<5:
textField.insert(END,cypher1[c])
if i>=5:
textField.insert(END,cypher2[c])
master.clipboard_clear()
master.clipboard_append(textField.get("1.0",'end-1c'))
textField.configure(state="disabled")
copyLabel.config(text = "Code Copied!")
b = Button(master, text = "Generate and Copy Key", width = 25, height = 2, command = decode)
b.pack()
textField = Text(master, height=3, width=35)
textField.pack()
copyLabel = Label(master, text="")
copyLabel.pack()
master.bind('<Return>', decode)
mainloop()
それは素晴らしい作品です! ...私はenterを押すことを除いて。そして、それは私が
master.bind('<Return>', decode())
にそれを変更しようとした TypeError: decode() takes no arguments (1 given)
になり、それがエラーをスローしませんが、それだけで何もしません。私はオブジェクトの不足がおそらく問題を引き起こしていると思う。
お手数ですが、ありがとうございます。
の任意の数を食べるであろう。 'master.bind( ''、decode())の問題は' decode'によって返された*値をバインドすることです。これは 'None'です。 –
'bind'コマンドを書いているほとんどの参考文献は、バインドされた関数に渡される引数について説明しています。 –