import sys
from PyQt4 import QtCore,QtGui
from Windows.intro_win import Ui_Introduction
from Windows.post_adder_win import Ui_postTool
import win32clipboard
import pyHook
class Intro(QtGui.QMainWindow):
def __init__(self,parent=None):
QtGui.QWidget.__init__(self,parent)
self.ui = Ui_Introduction()
self.ui.setupUi(self)
class postTool(QtGui.QMainWindow):
def __init__(self,parent=None):
QtGui.QWidget.__init__(self,parent)
self.ui2 = Ui_postTool()
self.ui2.setupUi(self)
def setModPosition(self):
self.ui2.lineEdit_2.setText("something")
print "nomnom"
def OnKeyboardEvent(event):
KeyClicked = event.KeyID
if KeyClicked == 121:
print "Debug from keyboardEvent"
OMD_post.show()
postTool().setModPosition()
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
OMD_intro = Intro()
OMD_post = postTool()
OMD_intro.show()
eventkey = pyHook.HookManager()
eventkey.KeyDown = OnKeyboardEvent
eventkey.HookKeyboard()
sys.exit(app.exec_())
它並不真正起作用 - 文本沒有改變 - 爲什麼它不起作用?它不給我任何錯誤(但打印打印什麼應該) https://dl.dropbox.com/u/21125662/compilation/_00398.jpgsetText()實際上並不工作Python
它看起來並不像你調用'setModPosition()' –
是啊,我也通過onkeyboardevent,它打印調試 「nomnom」,我忘記提及。 –
啊,我沒有看到。你是否檢查過其他插槽是否有效,比如'setMaxLength()'或者'selectAll()'? –