I'm trying to create a launcher (like Albert or Spotlight). To do so, I need to connect a shortcut to the show() function of my window. I'm using the keyboard library for this.
This is where I am:
import sys
from PySide import QtGui
import keyboard
class Example(QtGui.QWidget):
def __init__(self):
super(Example, self).__init__()
self.setGeometry(300, 300, 250, 150)
self.setWindowTitle('Example')
def main():
app = QtGui.QApplication(sys.argv)
window = Example()
keyboard.add_hotkey('ctrl+alt+9', window.show, args=[])
sys.exit(app.exec_())
if __name__ == '__main__':
main()
But when calling the shortcut, I'm getting the following Qt error:
QCoreApplication::sendPostedEvents: Cannot send posted events for objects in another thread
Does someone have an idea of what may cause this?