【问题标题】:Detecting key presses is not working in tkinter检测按键在 tkinter 中不起作用
【发布时间】:2012-10-21 21:24:29
【问题描述】:

我正在尝试制作我的前半部分 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,它可以工作,但这并不.

【问题讨论】:

  • 要从其他文件访问python代码,使用import gui.john; gui.john.foo会更惯用

标签: python user-interface tkinter


【解决方案1】:

如果我替换代码对我来说很好用

os.system("python Gui/aircrack.py")

只需一些打印声明...它对您有用吗? 你的 aircrack.py 是什么?确保它在同一路径中。

【讨论】:

    猜你喜欢
    • 2018-12-10
    • 2020-12-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多