[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: [PyQt] Help! I can't get my program to exit (using qt4reactor)
From: inhahe <inhahe () gmail ! com>
Date: 2015-05-22 22:19:00
Message-ID: CAPeSgWrH4i+-48S3DU=8WDKb5soPFQV+YjsR-FjGmw51Wz7NVA () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
When I close the one window this program creates, the program doesn't
finish. How do I make it finish and return me to cmd.exe?
I tried calling exit() in closeEvent(), but that just makes the program
stop responding.
Here's my code.
And here's a pastebin link to the same code: http://pastebin.com/hWJQ3S86
import os, sys, time
import Queue
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import qt4reactor
qt4reactor.install()
#from twistedclient import SocketClientFactory
from twisted.words.protocols import irc
from twisted.internet import protocol
class qttmwirc_conn(irc.IRCClient):
nickname = "qttmwirc"
def signedOn(self):
print "signed on"
def privmsg(self, user, channel, msg):
print "privmsg:", [user, channel, msg]
class qttmwirc_factory(protocol.ClientFactory):
def __init__(self):
pass
def buildProtocol(self, addr):
p = qttmwirc_conn()
p.factory = self
return p
def clientConnectionLost(self, connector, reason):
"""If we get disconnected, reconnect to server."""
connector.connect()
def clientConnectionFailed(self, connector, reason):
print "connection failed:", reason
reactor.stop()
instance = qttmwirc_factory()
class qttmwirc_gui(QMainWindow):
def __init__(self, reactor, parent=None):
super(qttmwirc_gui, self).__init__(parent)
self.reactor = reactor
def closeEvent(self, event):
reactor.stop()
def lastWindowClosed(self, *args):
print "last windo closed"
app = QApplication(sys.argv)
from twisted.internet import reactor
mainwindow = qttmwirc_gui(reactor)
mainwindow.showMaximized()
reactor.connectTCP("irc.freenode.net", 6667, instance)
reactor.run()
[Attachment #5 (text/html)]
<div dir="ltr">When I close the one window this program creates, the program \
doesn't finish. How do I make it finish and return me to cmd.exe?<div>I tried \
calling exit() in closeEvent(), but that just makes the program stop \
responding.</div><div><br></div><div>Here's my code.</div><div>And here's a \
pastebin link to the same code: <a \
href="http://pastebin.com/hWJQ3S86">http://pastebin.com/hWJQ3S86</a></div><div><br></div><div><div>import \
os, sys, time</div><div>import Queue</div><div>from PyQt4.QtCore import \
*</div><div>from PyQt4.QtGui import *</div><div><br></div><div>import \
qt4reactor</div><div>qt4reactor.install()</div><div><br></div><div><br></div><div>#from \
twistedclient import SocketClientFactory</div><div>from twisted.words.protocols \
import irc</div><div>from twisted.internet import \
protocol</div><div><br></div><div>class qttmwirc_conn(irc.IRCClient):</div><div> \
nickname = "qttmwirc"</div><div> def signedOn(self):</div><div> \
print "signed on"</div><div> def privmsg(self, user, channel, \
msg):</div><div> print "privmsg:", [user, channel, msg]</div><div> \
</div><div>class qttmwirc_factory(protocol.ClientFactory):</div><div> def \
__init__(self):</div><div> pass</div><div> def buildProtocol(self, \
addr):</div><div> p = qttmwirc_conn()</div><div> p.factory = \
self</div><div> return p</div><div><br></div><div> def \
clientConnectionLost(self, connector, reason):</div><div> \
"""If we get disconnected, reconnect to \
server."""</div><div> \
connector.connect()</div><div><br></div><div> def clientConnectionFailed(self, \
connector, reason):</div><div> print "connection failed:", \
reason</div><div> reactor.stop()</div><div> </div><div>instance = \
qttmwirc_factory()</div><div><br></div><div>class \
qttmwirc_gui(QMainWindow):</div><div> def __init__(self, reactor, \
parent=None):</div><div> super(qttmwirc_gui, \
self).__init__(parent)</div><div> self.reactor = reactor</div><div> \
</div><div> def closeEvent(self, event):</div><div> \
reactor.stop()</div><div> </div><div> def lastWindowClosed(self, \
*args):</div><div> print "last windo closed"</div><div> \
</div><div> </div><div>app = \
QApplication(sys.argv)</div><div><br></div><div><br></div><div>from twisted.internet \
import reactor</div><div>mainwindow = \
qttmwirc_gui(reactor)</div><div>mainwindow.showMaximized()</div><div><br></div><div>reactor.connectTCP("<a \
href="http://irc.freenode.net">irc.freenode.net</a>", 6667, \
instance)</div><div><br></div><div>reactor.run()</div></div><div><br></div></div>
[Attachment #6 (text/plain)]
_______________________________________________
PyQt mailing list PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic