Re: [PyQt] Installing on Ubuntu non default Python

2012-02-15 Thread Sebastian Wiesner
2012/2/15 Tom Brander tombran...@tombrander.com:
 tom@tom-Satellite-A105:~$ whereis qmake
 qmake:
 tom@tom-Satellite-A105:~$
 It would appear not to be there, what installs it?

qt4-qmake

You could have found this out for yourself by searching on
http://packages.ubuntu.com...
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] QRunnable and emitting signals

2011-07-22 Thread Sebastian Wiesner
2011/7/19 Jeremy Sanders jer...@jeremysanders.net:
 Is there an easy way to signal a result from a QRunnable? I've worked
 around this problem by replacing the code with a worker thread and a
 semaphore.

It works for me with a separate QObject-derived class, which properly
declares the signal using the new-style signal-slot API.  See the
attached source code.

Hope, this helps
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *


class WorkerObject(QObject):
testsignal = pyqtSignal(int, int, int)

class Runnable(QRunnable):

def __init__(self):
QRunnable.__init__(self)
self.obj = WorkerObject()

def run(self):
self.obj.testsignal.emit(1, 2, 3)

class Win(QPushButton):
def __init__(self):
QPushButton.__init__(self, Push me)
self.tp = QThreadPool()
self.clicked.connect(self.slotClicked)

def slotClicked(self):
runnable = Runnable()
runnable.obj.testsignal.connect(self.slotTestSignal)
self.tp.start(runnable)

def slotTestSignal(self, a, b, c):
print Returning from runnable, a, b, c

if __name__ == '__main__':
app = QApplication(sys.argv)

w = Win()
w.show()

app.exec_()
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Fwd: translation of ui

2011-07-02 Thread Sebastian Wiesner
2011/7/1 Yaşar Arabacı yasar11...@gmail.com:
 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_())

I'd use QLocale.system().name() instead of locale.getlocale(), as
recommended in the Qt documentation.  The rest looks ok.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Fwd: translation of ui

2011-07-01 Thread Sebastian Wiesner
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] getting dip running

2011-02-07 Thread Sebastian Wiesner
2011/2/7 Achim Kisseler a...@jupiter.uni-freiburg.de:
 Hi,

 trying to use dip, I have some problems to install python 2.7.

 Because dip needs 2.7, I installed it from kubuntu backports on my ubuntu
 10.10 64bit OS.

 The error message:
 ImportError: No module named PyQt4.QtGui
 is due to not proper module linking, because that works with python 2.6.

Isn't this error message self-explanatory?  You obviously need to
install PyQt for Python 2.6.  Python 2.7 doesn't magically use modules
installed for Python 2.6.  This wouldn't work anyway, because CPython
has the habit of breaking ABI between minor versions, modules compiled
for older Python versions likely do not work on more recent versions.

Sebastian Wiesner
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] pyuic ignores translation comments

2010-12-31 Thread Sebastian Wiesner
Hello,

the C++ uic extracts the value of the comment of string
properties in UI files, and uses it as third argument disambiguation
in the generated C++ code.  However, in PyQt 4.8.2 pyuic and
uic.loadUi apparently ignore this attribute, and instead to always
pass None for this third argument.  According to the documentation
of QCoreApplication.translate() this argument is used to
disambiguate identical messages used in different contexts, so I
guess, that this behaviour actually introduces translation bugs, if a
single object contains two identical messages with different context.

It certainly leads to translation bugs in PyKDE, which uses gettext
instead of Qt's message format.  The standard KDE gettext toolchain
extracts the contents of the comment attribute and uses them as
message context (msgctxt field in gettext catalog files).  Now
gettext considers two identical messages with different contexts as
two different messages, and even more, it identifies messages through
the context and the message id.  So if a message has a context
attached, the context *must* also be given, when loading the
translation in the source code.  For instance, given a message foo
with context bar, the message *must* be loaded using i18nc(bar,
foo) (i18nc is the KDE function to load a message with context,
where the context is the first argument).  If just i18n(foo) is
used, the translation is *not* found (i18n is the KDE function to load
a message without context).

As uic now simply ignores this contexts, all messages in UI files,
which have a comment attached, are incorrectly loaded in KDE
applications, and consequently it can happen, that large parts of the
user interface file simply remain untranslated.  I hit this bug in my
program synaptiks, and was forced to dig into the uic code and write
a workaround [1], which modifies uic in such a way, that it respects
the comments.  Concerning the implementation, tr2i18n is nothing
special.  The line return tr2i18n(text, comment) could be replaced
with QtGui.QApplication.translate(self.uiname, text, comment.
QtGui.QApplication.UnicodeUTF8), I'm just using tr2i18n, because it
is shorter, and because it is the function, KDE uses in compiled UI
files.

I consider this a bug in PyQt4.uic and I'd like to see it fixed.  Any
other comments?

[1] https://github.com/lunaryorn/synaptiks/blob/master/synaptiks/kde/uic.py
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] StackedWidget bug in 4.8.2

2010-12-27 Thread Sebastian Wiesner
2010/12/27 Alexander Nestorov alexander...@gmail.com:
 After upgrading to 4.8.2 from 4.8.1 my app stopped working. I'm pretty sure
 that the bug is not mine as
 my app just loads an .ui file generated with QtDesigner.

 Here is the log: http://pastebin.ca/2030773

To fix this issue, just open
/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py, move to line
161 and replace QtGui.StackedWidget with QtGui.QStackedWidget.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] pyuic4 vs uic.loadUI

2010-09-28 Thread Sebastian Wiesner
Hi,

I prefer uic.loadUi, it's simply much more convenient and much easier to use.

It saves the tedious invocation of pyuic4 during development.  And no
risk of weird errors caused by a forgotten compilation of your user
interface ... the application automatically uses the user interface,
that you just saved in the designer.  And you can deploy UI files with
standard distutils as package data along with the application code
(pyuic4 would require some custom solution to compile UI files during
installation or packaging, unless you want to have generated could
lingering around in the source tree).

So basically it just works, whereas pyuic4 means additional work.
UI compilers are fine for C++, where you have to compile anyway, but
in Python things are easier.   Just my opinion ...

Sebastian Wiesner
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt