检测按键在tkinter中不起作用

时间:2012-11-01 09:53:08

标签: python user-interface tkinter

我正在尝试制作我的上半部GUI程序,我正在使用tkinter,但我无法弄清楚它为什么不起作用。

import Tkinter
import tkMessageBox
import os 
from Tkinter import *
import Tkinter
import tkMessageBox

root = Tkinter.Tk()

#text

text = Text(root)
text.insert(INSERT, "EASY hacktool for Linux\n\n1.john\n2.Crack wep\n3.Crack wpa/wpa2\n q to quit\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n  \n\n\n\n\n\n\n\n\n\n\n", )
text.tag_add("here", "1.0", "25.50")
text.tag_config("here", background="black", foreground="green")
text.pack()


def key(event):
    if event.keysym == 'q':
        root.destroy()
    elif event.keysym == '\x31':
        os.system("python Gui/john.py")
    elif event.keysym == '\x32':
        os.system("python Gui/aircrack.py")

root.bind_all('<Key>', key)


root.mainloop()

当我按下1(\ x31)时,它完美地工作,但是当我按下'2'(\ x32)时,没有任何反应,我已经尝试了我的aircrack.py,它可以工作,但这不是“T

1 个答案:

答案 0 :(得分:0)

如果我替换

,代码对我来说很好
os.system("python Gui/aircrack.py")

只有一些印刷声明......它对你有用吗? 什么是你的aircrack.py?确保它在同一条路上。