[Twisted-Python] qt5 and twisted, reactor already installed, python 2.x

steven meier commercials24 at yahoo.de
Wed Jun 29 16:39:02 MDT 2016


hi,


ive got some twisted code that runs on its own
and some python code that also runs on its own,

now i would like to combine the two, so i added:

if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv) # your code to init QtCore
    import qt5reactor
    qt5reactor.install()
    from twisted.internet import reactor
   


to use some qt reactor with twisted.
running the qt code with those lines also works.
but as soon as i import other code into this one i get:


python main_code.py 
Gtk-Message: Failed to load module "canberra-gtk-module"
Traceback (most recent call last):
  File "main_code.py", line 29, in <module>
    qt5reactor.install()
  File "/home/julius/.local/lib/python2.7/site-packages/qt5reactor.py",
line 412, in posixinstall
    installReactor(p)
  File
"/home/julius/.local/lib/python2.7/site-packages/twisted/internet/main.py", line 32, in installReactor
    raise error.ReactorAlreadyInstalledError("reactor already
installed")
twisted.internet.error.ReactorAlreadyInstalledError: reactor already
installed




here is my code:
when importing get_main_page i get the error above...

import sys
from PyQt5 import QtWidgets
from untitled import Ui_MainWindow
#from webchat import get_main_page

class Main(QtWidgets.QMainWindow):

    def __init__(self):
        QtWidgets.QMainWindow.__init__(self)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.setupSignals()

    def button_1_Clicked(self):
        self.ui.textbox_2.setText(self.ui.textbox_1.text())

    def setupSignals(self):
        #self.ui.textbox_1.textChanged.connect(self.textbox_1_Changed)
        self.ui.button_1.clicked.connect(self.button_1_Clicked)




if __name__ == '__main__':
    #app = QtWidgets.QApplication(sys.argv)
    
    app = QtWidgets.QApplication(sys.argv) # your code to init QtCore
    import qt5reactor
    qt5reactor.install()
    from twisted.internet import reactor
    print "testing..."

    #get_main_page()
    window = Main()
    window.show()
    #sys.exit(app.exec_())
    def printMe(argument):
        print argument

    def lala():
        reactor.callLater(5, printMe, '123')


    lala()
    reactor.run()






webchat.py (containing get_main_page) starts with the lines:

from twisted.web.client import Agent, CookieAgent, getPage,
HTTPClientFactory
from bs4 import BeautifulSoup
import json
import urllib
import random
from myglobals import *
from twisted.internet.task import LoopingCall




how can i get a more "refined" error message, that actually tells me
which line is causing the error?

because as i said, the line 29 in main_code works when i do not import
get_main_page




More information about the Twisted-Python mailing list