Re: [PyQt] Moving from Python 2 to Python 3: A 4 page cheat sheet

2009-12-02 Thread Mark Summerfield
On 2009-12-01, Glenn Linderman wrote:
 On approximately 12/1/2009 6:15 AM, came the following characters from
 
 the keyboard of Mark Summerfield:
  Here's the direct link:
  http://ptgmedia.pearsoncmg.com/imprint_downloads/informit/promotions/...
 
 Produces File not found. in a web page, when I click.
 
The link seems to have been mangled. Here it is in full:
http://ptgmedia.pearsoncmg.com/imprint_downloads/informit/promotions/python/python2python3.pdf



-- 
Mark Summerfield, Qtrac Ltd, www.qtrac.eu
C++, Python, Qt, PyQt - training and consultancy
Advanced Qt Programming - ISBN 0321635906
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] Corrupted data in QDataStream

2009-12-02 Thread Nick Gaens
Hello everyone,

I'm trying to send a python-string via a QTcpSocket. I am using this
structure:


block = QtCore.QByteArray()
stream = QtCore.QTextStream(block, QtCore.QIODevice.WriteOnly)
stream  myPythonString

if myTcpSocket.isWritable():
myTcpSocket.write(block)
-

However, it now seems that there are some corrupted characters at the
beginning of the bytearray (or textstream) :-S..

A solution for this can be to call stream.flush() just before I stream
myPythonString to it..
In code:


block = QtCore.QByteArray()
stream = QtCore.QTextStream(block, QtCore.QIODevice.WriteOnly)
stream.flush() # removes the ascii dump successfully
stream  myPythonString

if myTcpSocket.isWritable():
print writing data to , str(socket.peerAddress().toString())
myTcpSocket.write(block) # crashes here
-

But at this point, the program crashes at the last line when actually
writing to the socket.. How come? I found out that this crash can be
reproduced anywhere when calling stream.string() just after streaming
myPythonString to the textstream..
In code:


block = QtCore.QByteArray()
stream = QtCore.QTextStream(block, QtCore.QIODevice.WriteOnly)
stream.flush() # removes the ascii dump
stream  myPythonString
print str(stream.string()) # crashes here already..

if myTcpSocket.isWritable():
print writing data to , str(socket.peerAddress().toString())
myTcpSocket.write(block)
-

How on earth can this be?

-- 
Nick Gaens
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Moving from Python 2 to Python 3: A 4 page cheat sheet

2009-12-02 Thread Henrik Pauli
On Wednesday 02 December 2009 09:43:06 Mark Summerfield wrote:
 On 2009-12-01, Glenn Linderman wrote:
  On approximately 12/1/2009 6:15 AM, came the following characters from
 
  the keyboard of Mark Summerfield:
   Here's the direct link:
   http://ptgmedia.pearsoncmg.com/imprint_downloads/informit/promotions/..
  .
 
  Produces File not found. in a web page, when I click.
 
 The link seems to have been mangled. Here it is in full:
 http://ptgmedia.pearsoncmg.com/imprint_downloads/informit/promotions/python
 /python2python3.pdf
 

Thanks!  It’s a great compilation :)

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


RE: [PyQt] Drag Drop with QTreeWidget

2009-12-02 Thread NARCISO, Rui

 
 I have several question (tree = QTreeWidget())
  1) I have activated:
  tree.setSelectionMode(QAbstractView.ExtendedSelection)
 yet before I would just keep the mouse pressed and slide over 
 the selection I wanted but now that is not possible. Is there a way 
 to maintain such behaviour and force that the drag is only performed 
 on a second click over the selection ?

not sure i undertstand what you mean - but i would have thought the 
selection behaviour changed because you enabled drag and drop, not 
because you changed the selection mode.

I wasn't clear on my explanation.
Before trying any Drag'n'Drop I had QAbstractView.ExtendedSelection and now, 
with Drag'n'Drop I have a different behaviour.

I would like to keep the same behaviour as before ...


 and when doing so create the sub-node Folder1 if it does not exist within 
 campaign and put the dragged items under folder1 (and not 
 campaign where they were dropped). How to do this ? Do I do this 
 in a dropEvent? In a dropEventAction ?

you could monitor the tree using QTreeView.rowsInserted and then 
reparent dropped items as necessary.

I will take a look at this ...

The information in this e-mail is confidential. The contents may not be 
disclosed or used by anyone other than the addressee. Access to this e-mail by 
anyone else is unauthorised.
If you are not the intended recipient, please notify Airbus immediately and 
delete this e-mail.
Airbus cannot accept any responsibility for the accuracy or completeness of 
this e-mail as it has been sent over public networks. If you have any concerns 
over the content of this message or its Accuracy or Integrity, please contact 
Airbus immediately.
All outgoing e-mails from Airbus are checked using regularly updated virus 
scanning software but you should take whatever measures you deem to be 
appropriate to ensure that this message and any attachments are virus free.


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


RE: [PyQt] Drag Drop with QTreeWidget

2009-12-02 Thread NARCISO, Rui

 and when doing so create the sub-node Folder1 if it does not exist within 
 campaign and put the dragged items under folder1 (and not 
 campaign where they were dropped). How to do this ? Do I do this 
 in a dropEvent? In a dropEventAction ?

you could monitor the tree using QTreeView.rowsInserted and then 
reparent dropped items as necessary.

Hi again, 

I have tried but I am unable from redefining rowsInserted to reparent the items.
I am having problems combining the information QModelIndex used by rowsInserted 
and the QAbstractModel automatically set-up behind the scenes by QTreeWidget 


Help !

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

This mail has originated outside your organization, either from an external 
partner or the Global Internet.
Keep this in mind if you answer this message.



The information in this e-mail is confidential. The contents may not be 
disclosed or used by anyone other than the addressee. Access to this e-mail by 
anyone else is unauthorised.
If you are not the intended recipient, please notify Airbus immediately and 
delete this e-mail.
Airbus cannot accept any responsibility for the accuracy or completeness of 
this e-mail as it has been sent over public networks. If you have any concerns 
over the content of this message or its Accuracy or Integrity, please contact 
Airbus immediately.
All outgoing e-mails from Airbus are checked using regularly updated virus 
scanning software but you should take whatever measures you deem to be 
appropriate to ensure that this message and any attachments are virus free.


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


[PyQt] ANN: qimage2ndarray - converting between QImages and numpy.ndarrays

2009-12-02 Thread Hans Meine
Hi,

I have just uploaded a first release of qimage2ndarray, a tiny python 
extension for quickly converting between QImages and numpy.ndarrays
(in both directions).  These are very common tasks when programming e.g. 
scientific visualizations in Python using PyQt4 as the GUI library.

Similar code was found in Qwt and floating around on mailing lists,
but qimage2ndarray has the following unique feature set:

* Supports conversion of scalar and RGB data, with arbitrary dtypes
  and memory layout, with and without alpha channels, into QImages
  (e.g. for display or saving using Qt).

* Using a tiny C++ extension, qimage2ndarray makes it possible to
  create ndarrays that are *views* into a given QImage's memory.

  This allows for very efficient data handling and makes it possible
  to modify Qt image data in-place (e.g. for brightness/gamma or alpha
  mask modifications).

* qimage2ndarray is stable and unit-tested:

  * proper reference counting even with views (ndarray.base points to
the underlying QImage)

  * handles non-standard widths and respects QImage's 32-bit row
alignment

* Masked arrays are also supported and are converted into QImages
  with transparent pixels.

* Supports value scaling / normalization to 0..255 for convenient
  display of arbitrary NumPy arrays.

The extension is open source, BSD-licensed, and available via PyPI or here:

  http://kogs-www.informatik.uni-hamburg.de/~meine/software/qimage2ndarray/

I hope this is useful to many of you and look forward to your feedback,
  Hans

PS: Now that I am announcing this, I suddenly have the feeling that I should 
have talked with some lawyer (or Phil) about possible license issues because 
of PyQt.  I really hope there will not turn out to be problems with this.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] suggestion for installing 64-bit Qt-4.6.0 on Snow Leopard

2009-12-02 Thread Darren Dale
For anyone interested in installing 64-bit qt-4.6.0 on Snow Leopard,
it looks like the download at http://qt.nokia.com/downloads is 32-bit.
After a bit of digging, I found an alternative installer at
http://download.qt.nokia.com/qt/source/qt-mac-cocoa-opensource-4.6.0.dmg
which installs a 64-bit library that appears to be compatible with
PyQt4 and the 64-bit system python.

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


Re: [PyQt] Python bindings for Poppler-Qt4, pypoppler-qt4

2009-12-02 Thread David Boddie
On Tue Dec 1 10:22:24 GMT 2009, Wilbert Berendsen wrote:

 at http://websvn.pardus.org.tr/trunk/playground/pypoppler-qt4/?root=uludag
 there are Python bindings for Poppler-Qt4. I would really like to use them
 in my application, but I also need the links() method of the Page object
 working. This method (and the link classes) is not available. Any chance
 this nice package gets updated? Otherwise I'll try myself but then I need
 to learn SIP a lot better. :)

I made some private modifications to this package some time ago but never
got round to doing anything with them. I think Roberto Alsina has something
more up to date:

  http://code.google.com/p/rst2pdf/

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


Re: [PyQt] Drag Drop with QTreeWidget

2009-12-02 Thread Baz Walter

NARCISO, Rui wrote:
and when doing so create the sub-node Folder1 if it does not exist within 
campaign and put the dragged items under folder1 (and not 
campaign where they were dropped). How to do this ? Do I do this 
in a dropEvent? In a dropEventAction ?
you could monitor the tree using QTreeView.rowsInserted and then 
reparent dropped items as necessary.


Hi again, 


I have tried but I am unable from redefining rowsInserted to reparent the items.
I am having problems combining the information QModelIndex used by rowsInserted 
and the QAbstractModel automatically set-up behind the scenes by QTreeWidget 



don't know what you're trying to do, but i had in mind something like this:

import sys
from PyQt4 import QtGui, QtCore

CAMPAIGN_TYPE, FOLDER_TYPE, CALC_TYPE = range(1001, 1004)


class TreeWidget(QtGui.QTreeWidget):
def __init__(self, parent=None):
QtGui.QTreeWidget.__init__(self, parent)
self.header().setHidden(True)
self.setSelectionMode(self.ExtendedSelection)
self.setDragDropMode(self.InternalMove)
self.setDragEnabled(True)
self.setDropIndicatorShown(True)
self.invisibleRootItem().setFlags(QtCore.Qt.NoItemFlags)
parent = TreeWidgetItem(self, CAMPAIGN_TYPE)
for i in xrange(1, 4):
TreeWidgetItem(parent, CALC_TYPE)
TreeWidgetItem(self, CAMPAIGN_TYPE)
TreeWidgetItem(self, CAMPAIGN_TYPE)

def rowsInserted(self, parent, start, end):
QtGui.QTreeWidget.rowsInserted(self, parent, start, end)
item = self.itemFromIndex(parent)
if (item is not None and
item.type() == CAMPAIGN_TYPE and
item.child(start).type() == CALC_TYPE):
child = item.takeChild(start)
if item.folder is None:
item.folder = TreeWidgetItem(item, FOLDER_TYPE)
item.folder.addChild(child)


class TreeWidgetItem(QtGui.QTreeWidgetItem):
def __init__(self, parent, type):
QtGui.QTreeWidgetItem.__init__(self, parent, type)
if type == CALC_TYPE:
text, flags = 'Calc', ~QtCore.Qt.ItemIsDropEnabled
else:
self.setChildIndicatorPolicy(self.ShowIndicator)
self.setExpanded(True)
if type == CAMPAIGN_TYPE:
text, flags = 'Campaign', ~QtCore.Qt.ItemIsDragEnabled
elif type == FOLDER_TYPE:
text, flags = 'Folder', ~QtCore.Qt.ItemIsDragEnabled
self.setText(0, text)
self.setFlags(self.flags()  flags)
self.folder = None


if __name__ == __main__:
app = QtGui.QApplication(sys.argv)
tree = TreeWidget()
tree.resize(200, 300)
tree.move(300, 300)
tree.show()
sys.exit(app.exec_())
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] Taskbar daemon

2009-12-02 Thread lokev

Hi

I'm fairly new to PyQt

I was wondering if I could get some pointers, or directions to good
tutorials or examples for the following:

I want to make a daemon that runs with an icon in the system
tray/notification area, how to i do this?

I want to create a new filetype, which the daemon is set in the os to handle
by default, and opens it without having to open it from the daemon itself
(with a file dialog, etc), how do i code this? 

Also, are there any good pyqt tutorials or examples for SSL-sockets?

Thanks, 
loke
-- 
View this message in context: 
http://old.nabble.com/Taskbar-daemon-tp26618709p26618709.html
Sent from the PyQt mailing list archive at Nabble.com.

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


[PyQt] ActiveX Question

2009-12-02 Thread Hazen Babcock


Hello,

Does anyone know the right way to call a ActiveX function that expects 
to get a argument by reference? For example, if there is a function 
called getPosition(double *) how do I call this function? I thought 
that I was close with:


pos = -1.0
self.dynamicCall('getPosition(double )', pos)

This does not complain about the wrong parameter type, or generate any 
other warning/error messages, but it also does not change the value of 
pos to 1.0 as expected. Using pos = QtCore.QVariant(-1.0) also does not 
work. self is a QAxWidget object.


Any links or pointers would be appreciated.

Thank you,
-Hazen

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


Re: [PyQt] Python bindings for Poppler-Qt4, pypoppler-qt4

2009-12-02 Thread Rajeev J Sebastian
On Thu, Dec 3, 2009 at 4:10 AM, David Boddie da...@boddie.org.uk wrote:
 On Tue Dec 1 10:22:24 GMT 2009, Wilbert Berendsen wrote:

 at http://websvn.pardus.org.tr/trunk/playground/pypoppler-qt4/?root=uludag
 there are Python bindings for Poppler-Qt4. I would really like to use them
 in my application, but I also need the links() method of the Page object
 working. This method (and the link classes) is not available. Any chance
 this nice package gets updated? Otherwise I'll try myself but then I need
 to learn SIP a lot better. :)

 I made some private modifications to this package some time ago but never
 got round to doing anything with them. I think Roberto Alsina has something
 more up to date:

  http://code.google.com/p/rst2pdf/

Roberto had sent me his patches and they were integrated into the binding.

However, some other projects have made some mods, but not contributed
back. No idea why (or whether its ethical).

Regards
Rajeev J Sebastian

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


Re: [PyQt] Freezes and crashes with signal autoconnection

2009-12-02 Thread Christian Roche


Phil Thompson-5 wrote:
 
 Either way people need a small, self-contained example that demonstrates
 the problem.
 

Hi Phil,

I think I've been able to isolate a small piece of code that consistently
reproduces the problem.  http://old.nabble.com/file/p26619445/main.py This
piece of code  displays a gray rectangle on my system and systematically
crashes when I click on it.  My config is as follows:

qt-4.5.3-9.fc11.i586.rpm
PyQt4-4.5.4-1.fc11.i586.rpm
sip-4.8.2-1.fc11.i586.rpm

I'd be very interested in understanding what's wrong here because i've been
strugling for weeks with incomprehensible crashes that seem to come out of
nowhere and I've not the single clue what's going on.

Thanks for your support,
Chris
-- 
View this message in context: 
http://old.nabble.com/Freezes-and-crashes-with-signal-autoconnection-tp25716493p26619445.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] Python bindings for Poppler-Qt4, pypoppler-qt4

2009-12-02 Thread David Boddie
On Thu Dec 3 01:07:20 GMT 2009, Rajeev J Sebastian wrote:

 Roberto had sent me his patches and they were integrated into the binding.

 However, some other projects have made some mods, but not contributed
 back. No idea why (or whether its ethical).

Mine were quickly done for an article I was writing, though in the end, I
never used the bindings. The only possibly worthwhile change I made was
removing some hard-coded paths in the configure.py file.

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