[PyQt] Join my network on LinkedIn
LinkedIn Yaşar Arabacı requested to add you as a connection on LinkedIn: -- I'd like to add you to my professional network on LinkedIn. Accept invitation from Yaşar Arabacı http://www.linkedin.com/e/3fiogj-grmxlmc1-2n/qruN_W-97m539Ud1_CXNH-Qg5C5ZrnpKp7duMjcDwM/blk/I88840257_65/pmpxnSRJrSdvj4R5fnhv9ClRsDgZp6lQs6lzoQ5AomZIpn8_djpvdPkOc3gUe3x9bQBetkR7kk5zbPgMd3cQcz4PejcLrCBxbOYWrSlI/EML_comm_afe/ View invitation from Yaşar Arabacı http://www.linkedin.com/e/3fiogj-grmxlmc1-2n/qruN_W-97m539Ud1_CXNH-Qg5C5ZrnpKp7duMjcDwM/blk/I88840257_65/0RdBYTdj8Md3wUe4ALqnpPbOYWrSlI/svi/ -- DID YOU KNOW LinkedIn can help you find the right service providers using recommendations from your trusted network? Using LinkedIn Services, you can take the risky guesswork out of selecting service providers by reading the recommendations of credible, trustworthy members of your network. http://www.linkedin.com/e/3fiogj-grmxlmc1-2n/svp/inv-25/ -- (c) 2011, LinkedIn Corporation___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Fwd: QFileDialog error
-- Yönlendirilmiş ileti -- Kimden: Yaşar Arabacı yasar11...@gmail.com Tarih: 23 Temmuz 2011 08:07 Konu: Re: [PyQt] QFileDialog error Kime: Martin Airs camberw...@gmail.com What happens when you assign it to its own string. Do you get error while assigning it to string or when using that string with file dialog? 2011/7/23 Martin Airs camberw...@gmail.com Good day all, In this test case script I have added at the bottom, It bombs with this error... [martin@desktop python]$ python testcase.py Traceback (most recent call last): File testcase.py, line 17, in pressed filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file', os.path.split(self.lineedit.text())[0], logs) File /usr/lib64/python2.7/posixpath.py, line 83, in split i = p.rfind('/') + 1 AttributeError: 'QString' object has no attribute 'rfind' I cant quite work out why, if I take the *os.path.split(self.lineedit.text())* out and put it on a seperate line assigning it to its own string it still doesn't work I wonder if anyone could show me how to get round this, please Thanks in advance Martin Airs -- import sys, os from PyQt4 import QtCore, QtGui class Window(QtGui.QWidget): def __init__(self, parent=None): QtGui.QMainWindow.__init__(self, parent) self.hbox = QtGui.QHBoxLayout() self.lineedit = QtGui.QLineEdit(, self) self.lineedit.setText(/var/log/test.log) self.button = QtGui.QPushButton(open file, self) self.hbox.addWidget(self.lineedit) self.hbox.addWidget(self.button) self.setLayout(self.hbox) self.button.clicked.connect(self.pressed) def pressed(self): filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file', os.path.split(self.lineedit.text())[0], logs) app = QtGui.QApplication(sys.argv) window = Window() window.show() app.exec_() -- ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] translation of ui
Hi, I was wondering how can I generate translation file for a ui generated by QtDesigner. I have no early experience of using translations, so I can't figure it out how to make this work. Should I mark strings in my main module or does QtDesigner somehow provide it for me? ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Fwd: translation of ui
I accidentally mailed below message only to Sebastian, repostion to groups. -- Yönlendirilmiş ileti -- Kimden: Yaşar Arabacı yasar11...@gmail.com Tarih: 01 Temmuz 2011 12:07 Konu: Re: [PyQt] translation of ui Kime: Sebastian Wiesner lunary...@googlemail.com Thanks, appearantly I also needed to create a .pro file for pylupdate to know which files to convert to. I created a language file and translated it, but how would my application use that translation file? 01 Temmuz 2011 11:44 tarihinde Sebastian Wiesner lunary...@googlemail.comyazdı: 2011/7/1 Yaşar Arabacı yasar11...@gmail.com: Hi, I was wondering how can I generate translation file for a ui generated by QtDesigner. I have no early experience of using translations, so I can't figure it out how to make this work. Should I mark strings in my main module or does QtDesigner somehow provide it for me? You don't need to mark strings in UI files. Just use pylupdate4 on UI files as you would use it on python files, and translations will be extracted from UI files, too. If you load or compile UI files, PyQt generates the necessary code to translate the user interface. Sebastian Wiesner ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Fwd: translation of ui
That works like a charm thanks :) 01 Temmuz 2011 12:17 tarihinde Sebastian Wiesner lunary...@googlemail.comyazdı: 2011/7/1 Yaşar Arabacı yasar11...@gmail.com: Thanks, appearantly I also needed to create a .pro file for pylupdate to know which files to convert to. Alternatively you can specifiy the files to translate and the translations to update on the command line: pylupdate4 ui_files python_files -ts translation_files I created a language file and translated it, but how would my application use that translation file? Use lrelease from Qt [1] to compile the translations, and deploy the compiled translations along with your program. In your program you need to create a QTranslator [2] to load these compiled translations. There a different ways of deploying the translations (e.g. as distutils package data), but the easiest is probably to include them as resource (using pyrcc4). You should read the Qt Linguist manual [3], which describes the Qt translation process in detail, and the corresponding chapter in the PyQt Reference Guide [4], which describes the PyQt specific differences to this process. [1] http://doc.qt.nokia.com/latest/linguist-manager.html#lrelease [2] http://doc.qt.nokia.com/latest/qtranslator.html#details [3] http://doc.qt.nokia.com/latest/linguist-manual.html [4] http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/i18n.html ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Fwd: translation of ui
Hi, me again :) I got it working but wanted to get an affimation, what do you think of this approach? if __name__ == __main__: from locale import getlocale from os.path import exists app = QtGui.QApplication(sys.argv) if getlocale()[0]: if exists(translations/ + getlocale()[0] + .qm): translator = QtCore.QTranslator(app) translator.load(getlocale()[0] + .qm, translations) app.installTranslator(translator) window = MainWindow() window.show() sys.exit(app.exec_()) 01 Temmuz 2011 12:37 tarihinde Yaşar Arabacı yasar11...@gmail.com yazdı: That works like a charm thanks :) 01 Temmuz 2011 12:17 tarihinde Sebastian Wiesner lunary...@googlemail.com yazdı: 2011/7/1 Yaşar Arabacı yasar11...@gmail.com: Thanks, appearantly I also needed to create a .pro file for pylupdate to know which files to convert to. Alternatively you can specifiy the files to translate and the translations to update on the command line: pylupdate4 ui_files python_files -ts translation_files I created a language file and translated it, but how would my application use that translation file? Use lrelease from Qt [1] to compile the translations, and deploy the compiled translations along with your program. In your program you need to create a QTranslator [2] to load these compiled translations. There a different ways of deploying the translations (e.g. as distutils package data), but the easiest is probably to include them as resource (using pyrcc4). You should read the Qt Linguist manual [3], which describes the Qt translation process in detail, and the corresponding chapter in the PyQt Reference Guide [4], which describes the PyQt specific differences to this process. [1] http://doc.qt.nokia.com/latest/linguist-manager.html#lrelease [2] http://doc.qt.nokia.com/latest/qtranslator.html#details [3] http://doc.qt.nokia.com/latest/linguist-manual.html [4] http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/i18n.html ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] QLineEdit vs. menu keyboard shortcuts
Wow, I can't describe epicness of this :) Didn't know such thing existed :) 2011/7/1 Baz Walter baz...@ftml.net On 30/06/11 16:56, Nathan Weston wrote: On 6/30/2011 10:44 AM, Nathan Weston wrote: On 6/29/2011 6:16 PM, Baz Walter wrote: I updated to the latest Qt/PyQt and it's working now. My original application is working correctly as well. glad you got it working. one final thought: rather stupidly, i completely forgot about QEvent.ShortcutOverride, which may well be exactly what you were originally looking for. it could be used something like this: def event(self, event): if (not self._editable and event.type() == QEvent.ShortcutOverride): return False return QLineEdit.event(self, event) better late than never, i suppose :/ ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] QString, QTextEdit and Encoding problem
Thanks. Appereantly package for my distro didn't include them so I downloaded original source files. 2011/6/28 Andreas Pakulat ap...@gmx.de On 28.06.11 08:37:06, Yaşar Arabacı wrote: Thanks for the info. Do you know any decent example, tutorial, documents etc. about qt network stack? There should be examples coming with PyQt, including a small chat-app. In addition look at http://doc.qt.nokia.com/4.7/qtnetwork.html and the check out the corresponding PyQt api docs for the classes mentioned there. Andreas ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] safely closing QThread when application exits.
hi, I am pyqt beginner and followed tutorials on the internet to learn it until recently. Then I have wanted to develop my own application. I am developing a simple chat application. I want to have 2 windows running independently (in other words two separate applications), one for server and one for client. When server starts to run, it is going to wait for client to run, and they will chat. So far, I could only start doing server side. I am using QThread, which is a subject rather unclear to me. I am getting this error when I close my application from X button: QThread: Destroyed while thread is still running I am guessing that this occurs because I am not closing the thread safely before application exists. I was wondering how I can make my thread respond to application exist so that it can close itself. Here is my code: chat_server.py import sys from PyQt4 import QtCore,QtGui from chat_ui import Ui_MainWindow import socket class Server(QtGui.QMainWindow): def __init__(self,parent=None): super(Server,self).__init__() self.ui = Ui_MainWindow() self.ui.setupUi(self) self.ui.textEdit.append(Waiting for inbound connections) self.netconnector = NetConnectWorker(self) self.netconnector.attemptConnect() self.connect(self.netconnector,QtCore.SIGNAL(Connected()),self.connected) self.connect(self.netconnector,QtCore.SIGNAL(dataRecieved(QString)),self.messageRecieved) self.connect(self.netconnector,QtCore.SIGNAL(socketError(QString)),self.socketError) def connected(self): self.ui.textEdit.append(Connected) def messageRecieved(self,data): self.ui.textEdit.append(data) def socketError(self,msg): print msg self.ui.textEdit.append(Encountered a socket error:\n %s % msg) class NetConnectWorker(QtCore.QThread): def __init__(self,parent=None): super(NetConnectWorker,self).__init__(parent) self.exiting = False self.socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM) self.host = '' self.port = 5 self.backlog = 5 self.address = self.client = def __del__(self): self.exiting = True self.wait() if self.client: self.client.close() def attemptConnect(self): self.start() def run(self): try: self.socket.bind((self.host,self.port)) except socket.error,error: print dir(error) self.emit(QtCore.SIGNAL(socketError(QString)),error.message) self.exit() self.socket.listen(self.backlog) self.client , self.address = self.socket.accept() if self.client: self.emit(QtCore.SIGNAL(Connected())) while not self.exiting: data = self.client.recv(1024) if data: self.emit(QtCore.SIGNAL(dataRecieved(QString)),data) if __name__ == __main__: app = QtGui.QApplication(sys.argv) ex=Server() ex.show() sys.exit(app.exec_()) #!/usr/bin/python # -*- coding: utf-8 -*- # chat_server import sys from PyQt4 import QtCore,QtGui from chat_ui import Ui_MainWindow import socket class Server(QtGui.QMainWindow): def __init__(self,parent=None): super(Server,self).__init__() self.ui = Ui_MainWindow() self.ui.setupUi(self) self.ui.textEdit.append(Waiting for inbound connections) self.netconnector = NetConnectWorker(self) self.netconnector.attemptConnect() self.connect(self.netconnector,QtCore.SIGNAL(Connected()),self.connected) self.connect(self.netconnector,QtCore.SIGNAL(dataRecieved(QString)),self.messageRecieved) self.connect(self.netconnector,QtCore.SIGNAL(socketError(QString)),self.socketError) def connected(self): self.ui.textEdit.append(Connected) def messageRecieved(self,data): self.ui.textEdit.append(data) def socketError(self,msg): print msg self.ui.textEdit.append(Encountered a socket error:\n %s % msg) class NetConnectWorker(QtCore.QThread): def __init__(self,parent=None): super(NetConnectWorker,self).__init__(parent) self.exiting = False self.socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM) self.host = '' self.port = 5 self.backlog = 5 self.address = self.client = def __del__(self): self.exiting = True self.wait() if self.client: self.client.close() def attemptConnect(self): self.start() def run(self): try: self.socket.bind((self.host,self.port)) except socket.error,error: print dir(error) self.emit(QtCore.SIGNAL(socketError(QString)),error.message) self.exit() self.socket.listen(self.backlog) self.client ,
[PyQt] QString, QTextEdit and Encoding problem
Hi, I am havin an encoding problem. If you have read my earlier post, I was doing a simple chat application. Here is how it goes. === Client Class === def on_lineEdit_returnPressed(self): text= self.ui.lineEdit.text() self.ui.lineEdit.selectAll() self.ui.lineEdit.cut() self.ui.textEdit.paste() self.netconnector.sendMessage(text) === netconnector === def sendMessage(self,msg): if self.isConnected: self.socket.send(msg.toUtf8().trimmed()) === Server Side: === === Server Class === self.connect(self.netconnector,QtCore.SIGNAL(dataRecieved(QString)),self.messageRecieved) === server side netconnector: === def messageRecieved(self,data): self.ui.textEdit.append(data) What happens is that, when I type non-ascii characters into client side line edit, it becomes distorted at server side, like şğü -- ÅÄü Any idea how to fix this? You can find whole code as attachment. #!/usr/bin/python # -*- coding: utf-8 -*- # chat_server import sys from PyQt4 import QtCore,QtGui from chat_ui import Ui_MainWindow import socket class Client(QtGui.QMainWindow): def __init__(self,parent=None): super(Client,self).__init__() self.ui = Ui_MainWindow() self.ui.setupUi(self) self.ui.textEdit.append(Trying to connect to server) self.netconnector = NetConnectWorker(self) self.netconnector.attemptConnect() self.connect(self.netconnector,QtCore.SIGNAL(Connected()),self.connected) #self.connect(self.netconnector,QtCore.SIGNAL(dataRecieved(QString)),self.messageRecieved) self.connect(self.netconnector,QtCore.SIGNAL(socketError()),self.socketError) self.ui.lineEdit def on_lineEdit_returnPressed(self): text= self.ui.lineEdit.text() self.ui.lineEdit.selectAll() self.ui.lineEdit.cut() self.ui.textEdit.paste() self.netconnector.sendMessage(text) def connected(self): self.ui.textEdit.append(Connected) #def messageRecieved(self,data): #self.ui.textEdit.append(data) # def socketError(self): self.ui.textEdit.append(Couldn't connect lol :S) class NetConnectWorker(QtCore.QThread): def __init__(self,parent=None): super(NetConnectWorker,self).__init__(parent) self.exiting = False self.socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM) self.host = 'localhost' self.port = 5 self.size = 5 self.isConnected=False def __del__(self): self.exiting = True self.wait() def attemptConnect(self): self.start() def sendMessage(self,msg): if self.isConnected: self.socket.send(msg.toUtf8().trimmed()) def run(self): try: self.socket.connect((self.host,self.port)) self.isConnected = True except socket.error: self.emit(QtCore.SIGNAL(socketError())) return self.emit(QtCore.SIGNAL(Connected())) if __name__ == __main__: app = QtGui.QApplication(sys.argv) sv=Client() sv.show() sys.exit(app.exec_())#!/usr/bin/python # -*- coding: utf-8 -*- # chat_server import sys from PyQt4 import QtCore,QtGui from chat_ui import Ui_MainWindow import socket class Server(QtGui.QMainWindow): def __init__(self,parent=None): super(Server,self).__init__() self.ui = Ui_MainWindow() self.ui.setupUi(self) self.ui.textEdit.append(Waiting for inbound connections) self.netconnector = NetConnectWorker(self) self.netconnector.attemptConnect() self.connect(self.netconnector,QtCore.SIGNAL(Connected()),self.connected) self.connect(self.netconnector,QtCore.SIGNAL(dataRecieved(QString)),self.messageRecieved) self.connect(self.netconnector,QtCore.SIGNAL(socketError(QString)),self.socketError) def connected(self): self.ui.textEdit.append(Connected) def messageRecieved(self,data): self.ui.textEdit.append(data) def socketError(self,msg): print msg self.ui.textEdit.append(Encountered a socket error:\n %s % msg) class NetConnectWorker(QtCore.QThread): def __init__(self,parent=None): super(NetConnectWorker,self).__init__(parent) self.exiting = False self.socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM) self.host = '' self.port = 5 self.backlog = 5 self.address = self.client = def __del__(self): self.exiting = True self.wait() if self.client: self.client.close() def attemptConnect(self): self.start() def run(self): try: self.socket.bind((self.host,self.port)) except
Re: [PyQt] QString, QTextEdit and Encoding problem
Thanks for the info. Do you know any decent example, tutorial, documents etc. about qt network stack? 2011/6/28 Andreas Pakulat ap...@gmx.de On 28.06.11 06:26:24, Yaşar Arabacı wrote: Hi, I am havin an encoding problem. If you have read my earlier post, I was doing a simple chat application. Here is how it goes. You're not converting your data correctly. On the sending side you do it properly, decoding to utf-8 and then sending the bytes through the network. On the receiving side you're using Python's socket API, which gives you a byte-stream and then create a QString from it implicitly. That uses whatever your systems default-encoding is to decode the bytes into a string. The error is in NetConnectorWorker.run, but its not that easy to fix since you currently do not send the amount of bytes you cannot know on the receiving side wether all data has been received or not and hence you cannot do a correct decoding. I suggest to switch to use Qt's network stack, that'll make these things a bit easier since you can use QDataStream on the network socket which handles sending QString's just fine. If thats not possible, you'll have to add the length of the message into the byte-stream or always read up to the first \n and decode the content then and make sure the sender always sends at least 1 \n. Andreas ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt