[PyQt] Crash (assert fail) in 'sip_api_convert_from_new_type'
Hi, A SIP-generated binding (python-poppler-qt4) causes a crash with the following message on the console: python: /build/buildd/sip4-4.13.2/siplib/siplib.c:8164: sip_api_convert_from_new_type: Assertion `(((td)-td_flags 0x0007) == 0x)' failed. Aborted (core dumped) The StacktraceTop is: __assert_fail_base (fmt=optimized out, assertion=0x7f9a6665d058 (((td)-td_flags 0x0007) == 0x), file=0x7f9a6665ceb0 /build/buildd/sip4-4.13.2/siplib/siplib.c, line=optimized out, function=optimized out) at assert.c:94 __GI___assert_fail (assertion=0x7f9a6665d058 (((td)-td_flags 0x0007) == 0x), file=0x7f9a6665ceb0 /build/buildd/sip4-4.13.2/siplib/siplib.c, line=8164, function=0x7f9a6665c7f0 sip_api_convert_from_new_type) at assert.c:103 sip_api_convert_from_new_type (cpp=0x2cb8320, td=0x7f9a665f63b0, transferObj=0x0) at /build/buildd/sip4-4.13.2/siplib/siplib.c:8164 meth_Poppler_LinkBrowse_url (sipSelf=LinkBrowse at remote 0x285fb00, sipArgs=optimized out) at build/temp.linux-x86_64-2.7/sippopplerqt4PopplerLinkBrowse.cpp:91 PyEval_EvalFrameEx () Sip 4.13.2 is used, more stacktraces are available here: https://bugs.launchpad.net/ubuntu/+source/frescobaldi/+bug/939196 The binding code is here: http://code.google.com/p/python-poppler-qt4/source/browse/#svn%2Ftrunk%2Fpython-poppler-qt4 What could be the cause of the failed assertion? Is it a bug in the binding code of python-poppler-qt4, or in SIP itself? Thanks for any enlightment :) -- Wilbert Berendsen (http://www.wilbertberendsen.nl) ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Crash (assert fail) in 'sip_api_convert_from_new_type'
On Mon, 27 Feb 2012 11:41:06 +0100, Wilbert Berendsen wbs...@xs4all.nl wrote: Hi, A SIP-generated binding (python-poppler-qt4) causes a crash with the following message on the console: python: /build/buildd/sip4-4.13.2/siplib/siplib.c:8164: sip_api_convert_from_new_type: Assertion `(((td)-td_flags 0x0007) == 0x)' failed. Aborted (core dumped) The StacktraceTop is: __assert_fail_base (fmt=optimized out, assertion=0x7f9a6665d058 (((td)-td_flags 0x0007) == 0x), file=0x7f9a6665ceb0 /build/buildd/sip4-4.13.2/siplib/siplib.c, line=optimized out, function=optimized out) at assert.c:94 __GI___assert_fail (assertion=0x7f9a6665d058 (((td)-td_flags 0x0007) == 0x), file=0x7f9a6665ceb0 /build/buildd/sip4-4.13.2/siplib/siplib.c, line=8164, function=0x7f9a6665c7f0 sip_api_convert_from_new_type) at assert.c:103 sip_api_convert_from_new_type (cpp=0x2cb8320, td=0x7f9a665f63b0, transferObj=0x0) at /build/buildd/sip4-4.13.2/siplib/siplib.c:8164 meth_Poppler_LinkBrowse_url (sipSelf=LinkBrowse at remote 0x285fb00, sipArgs=optimized out) at build/temp.linux-x86_64-2.7/sippopplerqt4PopplerLinkBrowse.cpp:91 PyEval_EvalFrameEx () Sip 4.13.2 is used, more stacktraces are available here: https://bugs.launchpad.net/ubuntu/+source/frescobaldi/+bug/939196 The binding code is here: http://code.google.com/p/python-poppler-qt4/source/browse/#svn%2Ftrunk%2Fpython-poppler-qt4 What could be the cause of the failed assertion? Is it a bug in the binding code of python-poppler-qt4, or in SIP itself? Thanks for any enlightment :) The stack traces aren't helpful as they don't include symbols. What's the value of td-td_flags when the assertion fails? Phil ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] [SOLVED]Re: pylupdate4 issue
On 26/02/2012 06:54 م, Detlev Offenbach wrote: Am Sonntag, 26. Februar 2012, 15:56:54 schrieb Vincent Vande Vyvre: Le 26/02/12 15:16, ad...@mbnoimi.net a écrit : On 19/02/2012 09:55 م, Vincent Vande Vyvre wrote: Le 19/02/12 19:55, ad...@mbnoimi.net a écrit : On 19/02/2012 08:22 م, ad...@mbnoimi.net wrote: Hi all, I tried to create *.ts file for my project by using pylupdate4 so I tried the following commad but it didn't work! pylupdate4 *.py -ts %CD%\ui\l10n\ar.ts pylupdate4 error: Cannot open file '*.py': No error Could you please guide me to the correct path? PS I successfully created *.ts file for single *.py file. I forgot to mention that I want to create single *.ts file for many *.py files You must provide a .pro file to pyludate4 exemple of .pro file SOURCES= main.py\ ui_mainWindow.py\ otherFile.py\ etc TRANSLATIONS= appName_ar.ts CODECFORTR = UTF-8 CODECFORSRC = UTF-8 I don't want to use .pro because I've many files in many subdirecories which is very exhausting to write manually. Any ideas guys? -- Best Regards Muhammad Bashir Al-Noimi My Blog: http://mbnoimi.net So, You can easily write a python script which will create the .pro file for you. No? You could copy the relevant code from the eric4/eric5 sources (module ProjectLanguagesBrowser). Thanks... it works. -- Best Regards Muhammad Bashir Al-Noimi My Blog: http://mbnoimi.net ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Gui best practice
Hello I'm trying to understand how to manage ui files from qtdesigner in the best way. I see in the examples that i have 2 options: - use pyuic4.bat utility to translate ui file in a python class (included in a module) that create the graphical interface through the setupUi() method - load the ui file directly in the class definition with the functions uic.loadUiType()or uic.loadUi() (like in the example\pyuic directory) As i see that few peoples like the second option i'm asking myself why. It looks for me faster, what's wrong with this ? ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] i18n
I found in the mailing list archive this old post. As i have the same problem is there anything new about this ? I want to use a short form for QCoreApplication.translate(MyContext, My String) but if i set: tr = QCoreApplication.translate(context, string) and use tr(MyContext, My String) in the generated .ts files i see a wrong @default context and confusing strings. The same happens if i use QT_TRANSLATE_NOOP On Wednesday 29 September 2010, 22:39:44 Eric Frederich wrote: After trying a bunch of different ways I finally got the translate function to work. I am now having a hard time trying to shorten it up. This ... QCoreApplication.translate(MyContext, My String) ... is a bit much. Is there any way to shorten it? I forget where I have seen it, but I think other translation schemes will import the translator function as an underscore so you can have text like _(my String) Is there any way to shorten it? I run into problems with either pylupdate4 not picking it up, or into problems with linguist. If I do... from PyQt4.QtCore import QCoreApplication mytr = QCoreApplication.translate ... then pylupdate4 doesn't pick them up. If I try to do something like... from functools import partial translate = partial(QCoreApplication.translate, MyContext) ... then linguist doesn't pick up the right context. Any help is appreciated. I do have it working now, but I don't like how long this is... QCoreApplication.translate(MyContext, My String) You can always define a helper method like this: def tr(self, msg, ctx = None, n = -1): return QtGui.QApplication.translate(YourForm, msg, ctx, QtGui.QApplication.UnicodeUTF8, n) Unfortunately, with a module global helper function, which would get us en par with C++ at least on module level, all strings are collected in a context @default: def tr(msg, ctx = None, n = -1): return QtGui.QApplication.translate(YourForm, msg, ctx, QtGui.QApplication.UnicodeUTF8,n) pylupdate4 is written in python, hence these issues should be solvable.. I guess, Phil will happily take patches. I also noticed, that there are path related issues, if you work across subdirs, but I never got around looking into it (yet). Pete ___ 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] Text write on effect
okay, this may seem a bit superfluous, but would be a very nice animation effect to have in one's toolbox.. For those that don't know what a write on animation is,...you probably see them on TV everyday,.. but it's when a whole sentence is displayed a character at time, with just a fraction of a second delay in-between each character... Thought this would be trivial at first,...but there's something going on in Qt that senses there's about to be a bunch of fast updates, so it waits until everything is done and updates *once*, which defeats the purpose Here's how the madness unfolds,.. text = Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet accum = QString() for i in range(0, len(text)): accum = accum + text[i] self.label.setText(accum) self.label.update() sleep(.1) So, I accumulate the string char by char calling update() and sleep() at each interval,...a button triggers this function. But instead of seeing the effect progress as expected, it just display the whole string at once... Anybody got any ideas how to achieve this effect ? I've attached a short example script... Cheers, Jim http://python.6.n6.nabble.com/file/n4518350/writeon_v01.py writeon_v01.py -- View this message in context: http://python.6.n6.nabble.com/Text-write-on-effect-tp4518350p4518350.html Sent from the PyQt mailing list archive at Nabble.com. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Text write on effect
Op Mon, 27 Feb 2012 17:02:01 -0800 (PST) JPolk jpolk5...@yahoo.com schreef: okay, this may seem a bit superfluous, but would be a very nice animation effect to have in one's toolbox.. For those that don't know what a write on animation is,...you probably see them on TV everyday,.. but it's when a whole sentence is displayed a character at time, with just a fraction of a second delay in-between each character... Thought this would be trivial at first,...but there's something going on in Qt that senses there's about to be a bunch of fast updates, so it waits until everything is done and updates *once*, which defeats the purpose Here's how the madness unfolds,.. text = Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet accum = QString() for i in range(0, len(text)): accum = accum + text[i] self.label.setText(accum) self.label.update() sleep(.1) So, I accumulate the string char by char calling update() and sleep() at each interval,...a button triggers this function. But instead of seeing the effect progress as expected, it just display the whole string at once... Anybody got any ideas how to achieve this effect ? the sleep function causes the main thread (GUI thread) to be blocked, so the widget is not repainted. It only repaints when the for-loop has terminated, and thus shows the full string at once. A solution would be to use a timer that regularly updates the label text (attached). -- Wilbert Berendsen (http://www.wilbertberendsen.nl) #!/usr/bin/env python import os import sys from PyQt4 import QtCore, QtGui, uic from PyQt4.QtCore import ( QString ) class BasicWindow(QtGui.QMainWindow): def __init__(self, parent=None): super(BasicWindow, self).__init__(parent) #self.setupUi(self) self.label = QtGui.QLabel(self) self.label.setGeometry(QtCore.QRect(73, 110, 574, 331)) self.pushButton = QtGui.QPushButton(self) self.pushButton.setGeometry(QtCore.QRect(66, 30, 75, 27)) self.pushButton.setText(DoIt) scrX = 2048 scrY = 1150 winX = 720 winY = 530 pX = (scrX - winX) / 2 pY = (scrY - winY) / 2 self.setGeometry(pX, pY, winX, winY) self.label.setText('') self.pushButton.clicked.connect(self.DoIt) self.timer = QtCore.QTimer(interval=50, timeout=self.timeout) def DoIt(self): self.textGen = self.generateText() self.timer.start() def generateText(self): text = Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna for i in range(len(text)): yield text[:i] def timeout(self): for accum in self.textGen: self.label.setText(accum) return self.timer.stop() def main(): app = QtGui.QApplication(sys.argv) form = BasicWindow() form.show() app.exec_() if __name__ == '__main__': main() ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt