Re: [PyQt] simpler 'connect' function

2008-01-17 Thread Ewald de Wit
On Wednesday 16 January 2008 09:21:40 Aaron Digulla wrote:
 As for making the API simpler, I'd opt for

      button.connectClicked(self.buttonWasClicked)

Wouldn't it be nicer if the signals where attributes of your object,
so that you could write

button.clicked.connect(self.onButtonClicked)

(and likewise for disconnect).

This is basically what C# uses, although there the += and -=
operators are used for connect and disconnect respectively.
To connect one would get:

button.clicked += self.onButtonClicked

I've adopted this notation in my Python programs because I think
it's the most visually appealing.

--
  -- Ewald


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


Re: [PyQt] simpler 'connect' function

2008-01-17 Thread Mark Summerfield
On 2008-01-17, Ewald de Wit wrote:
 On Wednesday 16 January 2008 09:21:40 Aaron Digulla wrote:
  As for making the API simpler, I'd opt for
 
       button.connectClicked(self.buttonWasClicked)

 Wouldn't it be nicer if the signals where attributes of your object,
 so that you could write

   button.clicked.connect(self.onButtonClicked)

 (and likewise for disconnect).

That seems like a nice syntax to me.

Qt Jambi (Qt bindings for Java) uses a similar (but not quite as nice)
syntax:

button.clicked.connect(this, buttonClicked());

 This is basically what C# uses, although there the += and -=
 operators are used for connect and disconnect respectively.
 To connect one would get:

   button.clicked += self.onButtonClicked

I'm not at all keen on this though.


 I've adopted this notation in my Python programs because I think
 it's the most visually appealing.

 --
   -- Ewald


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



-- 
Mark Summerfield, Qtrac Ltd., www.qtrac.eu


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


Re: [PyQt] simpler 'connect' function

2008-01-17 Thread Aaron Digulla

Quoting Ewald de Wit [EMAIL PROTECTED]:


On Wednesday 16 January 2008 09:21:40 Aaron Digulla wrote:

As for making the API simpler, I'd opt for

 button.connectClicked(self.buttonWasClicked)


Wouldn't it be nicer if the signals where attributes of your object,
so that you could write

button.clicked.connect(self.onButtonClicked)


That's one way to look at it. In C++, a signal is much more close to a  
method, though. Taking a step back, what happens behind the scenes is:


connect(sender, signal, receiver, slot)

i.e. connect is a global / static function. It just happens to work  
only with classes derived from QObject, so it has been implemented as  
a member method but actually, it just connects two QObjects. So the  
syntax most closely resembling what is actually going on would be:


connect(button.clicked, self.onButtonClicked)

For this to work, clicked must be implemented as a method of  
QPushButton, for example, so that connect() can pick the sender object  
from the call.


As a convenience (since clicked() is now a full-blown method), this  
would work, too:


button.clicked(self.onButtonClicked)

Since signals are actually declared in the C++ class headers, I think  
there is no possibility to have clashes between method and signal  
names. Unfortunately, this again introduces ambiguities because of  
argument overloading which must be solved by mapping argument types to  
the method name, probably manually.


Regards,

--
Aaron Optimizer Digulla a.k.a. Philmann Dark
It's not the universe that's limited, it's our imagination.
Follow me and I'll show you something beyond the limits.
http://www.pdark.de/

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


[PyQt] Changing systray icon while handling signal

2008-01-17 Thread Dog Walker
Using pyKde3

I have a KSytemTray application. I want to change the systray icon
(and tooltip)  when I begin handling a menuitem and change again
before returning. It appears that the icon/tooltip is only set after
returning to pyKde. Can I do what I want? How?

-- 
I have seen the future and I'm not in it!
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] Segfault with PyQt

2008-01-17 Thread Alexandre Badez
Hye every body,

I've got a problem with PyQt (4.1.1 (262401)) /Qt (v4.1.4 (262404)).
I'm coding for windows (W2K), and Unix (Solaris 5.8)

As you see in Error_Simple.py, the application crash if the view is a tree
but not a table nor a list view.

My question is, what am I doing wrong in my model, that make it appen ?
Is it a bug ?

Error.py, is a bit more complex script that test (kind of) every
possibilities of this bug.

-- 
Alex
#! /bin/env python
from PyQt4 import QtGui
from PyQt4 import QtCore
import sys
import os
import time

lProb = []

class myModel(QtCore.QAbstractItemModel):
def __init__(self, parent=None):
self._myDataStruct = None
super(myModel, self).__init__(parent)

def setDataStruct(self, myDataStruct):
self._myDataStruct = myDataStruct

def columnCount(self, parent=None):
return 1

def data(self, index, role):
if index.isValid() and role == QtCore.Qt.DisplayRole:
data = QtCore.QVariant(str(self.getMyObjectFromIndex(index)))
else:
data = QtCore.QVariant()
return data

def flags(self, index):
if not index.isValid():
flags = QtCore.Qt.ItemIsEnabled
else:
flags = QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable
return flags

def headerData(self, section, orientation, role):
if role == QtCore.Qt.DisplayRole:
v = QtCore.QVariant(header)
else:
v = QtCore.QVariant()
return v

def index(self, row, column, parent):
if (parent is None) or (not parent.isValid()):
parentNode = self._myDataStruct
else:
parentNode = self._myDataStruct.getMyObjectFromIndex(parent)
if parentNode is None:
parentNode = self._myDataStruct

try:
childNode = parentNode[row]
except IndexError:
childNode = None

if childNode is not None:
return self.createIndex(row, column, id(childNode))
else:
return QtCore.QModelIndex()

def parent(self, index):
parentIndex = None
if not index.isValid():
parentIndex = QtCore.QModelIndex()
else:
childNode = self.getMyObjectFromIndex(index)
if childNode is None:
parentIndex = QtCore.QModelIndex()
else:
parentIndex = self.getIndexFromMyObject(self._myDataStruct)
return parentIndex

def rowCount(self, parent):
if not parent.isValid():
node = self._myDataStruct
else:
node = self.getMyObjectFromIndex(parent)
return len(node)

def getIndexFromMyObject(self, myObject):
try:
dataIndex = self._myDataStruct.getIndex(myObject)
except ValueError:
index = QtCore.QModelIndex()
else:
index = self.createIndex(dataIndex, 0, id(myObject))
return index

def getMyObjectFromIndex(self, index):
return self._myDataStruct.getData(index.internalId())

def crashMethod11(self):
QtGui.QDialog().exec_()
self.beginRemoveRows(QtCore.QModelIndex(), 0, 0)
self.endRemoveRows()
return True

def crashMethod12(self):
self.beginRemoveRows(QtCore.QModelIndex(), 0, 0)
QtGui.QDialog().exec_()
self.endRemoveRows()
return True

def crashMethod13(self):
self.beginRemoveRows(QtCore.QModelIndex(), 0, 0)
self.endRemoveRows()
QtGui.QDialog().exec_()
return True

def crashMethod21(self):
QtGui.QDialog().exec_()
self.beginRemoveRows(QtCore.QModelIndex(), 0, 0)
QtGui.QDialog().exec_()
self.endRemoveRows()
return True

def crashMethod22(self):
QtGui.QDialog().exec_()
self.beginRemoveRows(QtCore.QModelIndex(), 0, 0)
self.endRemoveRows()
QtGui.QDialog().exec_()
return True

def crashMethod23(self):
self.beginRemoveRows(QtCore.QModelIndex(), 0, 0)
QtGui.QDialog().exec_()
self.endRemoveRows()
QtGui.QDialog().exec_()
return True

def crashMethod3(self):
QtGui.QDialog().exec_()
self.beginRemoveRows(QtCore.QModelIndex(), 0, 0)
QtGui.QDialog().exec_()
self.endRemoveRows()
QtGui.QDialog().exec_()
return True

class myDataStruct(object):
def __init__(self):
self._data = []
self._dico = {}

def __str__(self):
return str(self._dico)

def __iter__(self):
return self._data.__iter__()

def __getitem__(self, index):
return self._data[index]

def __len__(self):
return len(self._data)

def addData(self, myObjectToStore):
self._data.append(myObjectToStore)
self._dico[id(myObjectToStore)] = myObjectToStore

def getData(self, id_):
return 

[PyQt] What do I import in pykde 3.16 to access PyKDE.versionString ()?

2008-01-17 Thread Dog Walker
The documentation says that both KDE.versionString and
PyKDE.versionString are available since 3.11. I find KDE.versionString
in kdecore on PyKDE 3.16 but cannot locate PyKDE.versionString. What
should I import to access this function?

-- 
I have seen the future and I'm not in it!
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] segfault!...and more

2008-01-17 Thread Alberto Berti

Hi all, 

i'm quite new to this list, but i'm working with PyQT4 with great
satisfaction to develop a framework, and an application, to build
database driven applications using the model/view/delegate approach
with SQLAlchemy (http://sqlalchemy.org) instead of the standard SQL
enabled tree of models in QT.  I've finished the low-level of
sqlalchemy related storages and i'm completing the AbstractTableModel
subclass that is usable as a QSQLRelationalTableModel replacement,
with semi-automatic wiring of the realtions thanks to SQLAlchemy
metadata introspection. Now it supports 1-1 relations, with 1-n
realtions to be completed for the end of the week:-).  I've
encountered a problem during the coding of a demo which i don't know
handle. I know it's related to the fact of a qt component that is
taking ownership of python objects, but nothing more.

Aside from this, does someone know the location of the repositories
for PyQt4 and PyKDE?

There is an updated QT 4.3 doxygen api available online?

Thanks in advance, especially to those that worked to make pyqt4:)

 Here is the relevant code (it's long, I hope that someone will find
te time to read it), commented to help your reading:

if __name__ == '__main__':

# A simple displaying combo boxes on 1-to-1 relations
from pypapi.db.interfaces import IIterProcedurale, IElementoAnagrafico, 
IDatabase
from pypapi.db.model import ElementoAnagrafico, IterProcedurale
from pypapi.db.storage import SAListStore
from zope.schema import getFieldsInOrder

# database initialization
db = getUtility(IDatabase)
db.open('sqlite:///procedimenti.sqlite')

# creation of the low-level stores that handle the join or the
# deletion of enitities instances from the persistence using
# standard list semantics. The 2nd and 3rd SAListStore are built
# using prconfigured lookup sources
iter_proc = SAListStore(db.session.query(IterProcedurale))
enti = SAListStore(IIterProcedurale.get('ente').source(IterProcedurale))
uffici = 
SAListStore(IIterProcedurale.get('ufficioattribuito').source(IterProcedurale))

# Now i create the three model classes, selecting proper subset of fields
# and generating QtModel oriented views of these field on the fly

class IterProcModel(TableModel):
# the last 3 fields are not rendered because they are 1-n
# relations, still unsupported
columns = [IColumn(field) for name, field in 
getFieldsInOrder(IIterProcedurale)][:-3]

class EnteModel(TableModel):
columns = [Column('getCaption', 'Enti')]

class UfficioModel(TableModel):
columns = [Column('getCaption', 'Uffici')]

from PyQt4.QtGui import QApplication, QTableView

# QT App init
app = QApplication([])

# Here the actual model instances are created, using the stores
ip_model = IterProcModel(iter_proc, app)
e_model = EnteModel(enti, app)
u_model = UfficioModel(uffici, app)
 
# wiring of the relations. This step and the latter over here will
# be automated inside form's code
col_ente = ip_model.getColumnByName('ente')
col_ente.setLookupModel(e_model, 'getCaption')
col_ufficio = ip_model.getColumnByName('ufficioattribuito')
col_ufficio.setLookupModel(u_model, 'getCaption')

from PyQt4.QtGui import QItemEditorCreatorBase, QComboBox, \
 QItemEditorFactory, QSpinBox, QLineEdit
 
# here i define a couple of editor creators. The first and most
# important redefines the standard editing of Int cells to render
# a QComboBox when the cell looks up its value on another table.
# The second is there just to handle the editing o string cells,
# Using the standard behavior. It's there just to allow editing
# because installing just LookupEditorCreator in the default
# factory doesn't work. So i create my own factory and install it.
class LookupEditorCreator(QItemEditorCreatorBase):

def createWidget(self, parent):

   # qui parent è in delegato, perciò parent.parent() è la
   # tabella
view = parent.parent()
index = view.currentIndex()
item = index.internalPointer()
if isinstance(item, LookupItem):
widget = QComboBox(parent)
widget.setModel(item.column.lookup_model)
else:
widget = QSpinBox(parent)
# piccola fix per permettere valori  99
widget.setMaximum(1)
return widget

def valuePropertyName(self):

return 'currentIndex'

class StringEditorCreator(QItemEditorCreatorBase):

def createWidget(self, parent):

return QLineEdit(parent)

#!!! This code works as expected, but a Segmentation Fault is
# raised on application termination, why?
edit_fac = QItemEditorFactory()
creator = LookupEditorCreator()
s_creator = StringEditorCreator()

Re: [PyQt] Segfault with PyQt

2008-01-17 Thread Phil Thompson
On Thursday 17 January 2008, Alexandre Badez wrote:
 Hye every body,

 I've got a problem with PyQt (4.1.1 (262401)) /Qt (v4.1.4 (262404)).
 I'm coding for windows (W2K), and Unix (Solaris 5.8)

Those are very old versions.

 As you see in Error_Simple.py, the application crash if the view is a tree
 but not a table nor a list view.

 My question is, what am I doing wrong in my model, that make it appen ?
 Is it a bug ?

 Error.py, is a bit more complex script that test (kind of) every
 possibilities of this bug.

I couldn't get Error_Simple.py to crash - but it has other problems. I guess 
you didn't get as far as finding them.

I suggest you upgrade Qt and PyQt.

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


RE: [PyQt] simpler 'connect' function

2008-01-17 Thread Peter Shinners
Ewald de Wit
 Wouldn't it be nicer if the signals where attributes of your object,
 so that you could write
 
   button.clicked.connect(self.onButtonClicked)

Is there a clean way to handle signals with the same name that take
different arguments? Here's an idea I can think of for QComboBox.

combo.activated[int].connect(callback1)
combo.activated[QString].connect(callback2)

This sort of matches the syntax the clr library is using to bind to
dotnet generic functions. This could still lead to ambiguities where a
signal argument used variations on the same type (reference vs pointer
vs const). 


Another thing to keep in mind is defining new slots on custom classes.
Declaring them statically on the class would be a closer match to what
C++ Qt does, but a departure from existing Pyqt code.


class MyObject(QObject):
forgotten = QtCore.SLOT()
remembered = QtCore.SLOT([QString])
perhaps = QtCore.SLOT_shortCircuit()



Interesting ideas. But I don't really have problems with the existing
connect function. If we could just get rid of the SIGNAL requirement and
pass a string argument it would get a whole lot nicer.

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


RE: [PyQt] simpler 'connect' function

2008-01-17 Thread Peter Shinners
Aaron Digulla:
 I've wasted several hours searching for typos so far, so
 I can't live with the current state and making this area
 even more volatile will only increase the chance that I'll
 give up on PyQt and create a fork.

At minimum I'm talking about the simplification of a single argument to
an existing function. You are talking about entirely new attributes that
leave no room for expansion and bring new ambiguities.

I've been using Pyqt for several years the way it is. I don't feel it's
broken and fork-worthy as you do. I do see room for improvements, and
don't need drastic changes.


 Remember: If everyone in the world would develop software
 the way you do, you'd be unemployed.

I'm not sure how to interpret this. I hope to keep using Pyqt for a long
time.

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


[PyQt] SIP problem -- multiple /Out/ args?

2008-01-17 Thread Jim Crowell

I'm using SIP 4.7.3.

The following method specification in my .sip file:

  int receiveMessage(string* userName /Out/, string* messageType /Out/,
  string* messageBody /Out/, string* context /Out/)
  /ReleaseGIL/ ;

Yields the following in the generated code:

if
(sipParseArgs(sipArgsParsed,sipArgs,B,sipSelf,sipClass_arSZGClient,sipCpp))
{
int sipRes;
PyObject *sipResult;
a0 = new string();
PyObject *sipResult;
a1 = new string();
PyObject *sipResult;
a2 = new string();
PyObject *sipResult;
a3 = new string();


i.e. sipResult is multiply defined, so of course it doesn't compile.
Bug?

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


[PyQt] mousePressEvent not getting called

2008-01-17 Thread Quoc Tran


I’m having a weird problem with using my custom Qt widget in
PyQt.

 

I created a custom QFrame in C++ and overrided:

virtual void mousePressEvent( QMouseEvent * );

 

When I use my widget in python the mousePressEvent is never
called but if I derive off of my custom class in PyQt and override
the mousePressEvent it will get called.

i.e.

class
MyPythonFrame(MyCPlusPlusFrame):

def
mousePressEvent(self, e):

   
print mouse event

 

Any ideas what I’m doing wrong?

 

Thanks!


_

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

Re: [PyQt] simpler 'connect' function

2008-01-17 Thread Aaron Digulla
Peter Shinners schrieb:

 But I don't really have problems with the existing
 connect function. If we could just get rid of the SIGNAL requirement and
 pass a string argument it would get a whole lot nicer.

I've wasted several hours searching for typos so far, so I can't live
with the current state and making this area even more volatile will only
increase the chance that I'll give up on PyQt and create a fork.

Remember: If everyone in the world would develop software the way you
do, you'd be unemployed.

Regards,

-- 
Aaron Optimizer Digulla a.k.a. Philmann Dark
It's not the universe that's limited, it's our imagination.
Follow me and I'll show you something beyond the limits.
http://darkviews.blogspot.com/  http://www.pdark.de/
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] QLabel.setTextInteractionFlags raises AttributeError

2008-01-17 Thread Dog Walker
QT: 3.3.7 SuSE 10.2

Docs  (/PyQt-x11-gpl-4.1.1/doc/html/qlabel.html) show
QLabel.setTextInteractionFlags (self, Qt.TextInteractionFlags flags)
but

from qt import *
...
self.aboutTextLabel = QLabel(self.itsWindow,aboutVersions)
...

Traceback (most recent call last):
  File kgmailnotifier.py, line 195, in module
main()
  File kgmailnotifier.py, line 188, in main
kgmailnotifier = KGmailNotifier()
  File kgmailnotifier.py, line 74, in __init__
self.itsAboutWindow = aboutdialog.AboutDialog()
  File /home/thudfoo/KGmailNotifier2/aboutdialog.py, line 56, in __init__
self.aboutTextLabel.setTextInteractionFlags(QLabel.TextSelectableByMouse)
# Can be selected by the mouse for copying to clipboard
AttributeError: setTextInteractionFlags

What did I do wrong?

-- 
I have seen the future and I'm not in it!
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] simpler 'connect' function

2008-01-17 Thread Aaron Digulla
Peter Shinners schrieb:

 Remember: If everyone in the world would develop software
 the way you do, you'd be unemployed.
 
 I'm not sure how to interpret this. I hope to keep using Pyqt for a long
 time.

I'm trying to make you understand that your way of developing software
works for *you* but not for *me*. I'm a very fast developer but that
means I quickly get frustrated when I can't track down bugs fast.

I wrote a little app with around 8000 lines of code in the past two
weeks, say 40h all in all, in my spare time. Of that, I spent 4 hours
hunting a connect() bug and 8 hours because of the setModel() bug I
reported in another thread. With tiny, compatible changes in the API, I
could have used that time on real work and I'd have, say, 3000
additional lines of code instead of a weekend wasted.

So that means, usually, I can code a huge amount of functionality in a
very short time but for these two weak spots (connect and GC), I'm
losing a lot of time and I see that a lot of other beginners have the
same problem. In the past two weeks, many people have complained about
the connect API and most don't like the current string literals.

Therefore, I'm trying to argue to make some changes to make PyQt more
bullet proof for beginners. If I get the feeling that no one listens to
my arguments, then I'll do what I have to do to scratch my itch: I'll
fork the project.

Regards,

-- 
Aaron Optimizer Digulla a.k.a. Philmann Dark
It's not the universe that's limited, it's our imagination.
Follow me and I'll show you something beyond the limits.
http://darkviews.blogspot.com/  http://www.pdark.de/
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] Re: Changing systray icon while handling signal

2008-01-17 Thread thudfoo
Dog Walker wrote:

 Using pyKde3
 
 I have a KSytemTray application. I want to change the systray icon
 (and tooltip)  when I begin handling a menuitem and change again
 before returning. It appears that the icon/tooltip is only set after
 returning to pyKde. Can I do what I want? How?
 

Should have added:
 KDE: 3.5.5
 QT: 3.3.7
 PyKDE: 3.16.0

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


Re: [PyQt] What do I import in pykde 3.16 to access PyKDE.versionString ()?

2008-01-17 Thread Jim Bublitz
On Thursday 17 January 2008 10:42, Dog Walker wrote:
 The documentation says that both KDE.versionString and
 PyKDE.versionString are available since 3.11. I find KDE.versionString
 in kdecore on PyKDE 3.16 but cannot locate PyKDE.versionString. What
 should I import to access this function?

It apparently got left out - it should be in kdeversion.sip.. However, you 
should have a copy of pykdeconfig in /site-packages, or wherever PyKDE has 
been installed (you will have for sure if you compiled - can't say if 
packagers install it).

You can find the version there:

 import pykdeconfig
 cfg = pykdeconfig.Configuration ()
 cfg.pykde_version
200450
 cfg.pykde_version_str
'3.15.2'

pykde_version is the hex representation - would be 0x030f02 in this case 
(which should equal decimal 200450).

I'm apparently running an older version of PyKDE on this box.

Jim

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


Re: [PyQt] simpler 'connect' function

2008-01-17 Thread Ewald de Wit
On Thursday 17 January 2008 18:27:19 Peter Shinners wrote:
  button.clicked.connect(self.onButtonClicked)

 Is there a clean way to handle signals with the same name that take
 different arguments? Here's an idea I can think of for QComboBox.

 combo.activated[int].connect(callback1)
 combo.activated[QString].connect(callback2)

A simpler way would be to just give the signal objects a different name,
like activatedInt and activatedString. It's the easiest way to uniquely
specify which signal you mean.

Btw, it would also be convenient to have an emit method on the signal
object, like for example

combo.activatedInt.emit(1)
combo.activatedString.emit('Pizza')
canvas.mouseMoved.emit(dx, dy)

If __call__ is used instead of emit, then the syntax becomes even shorter:

canvas.mouseMoved(dx, dy)

And once there is a signal object, other methods become possible as well.
For example a slots() method that returns a list of all connected
slots. One could then do lazy evaluation like

if self.heavyJobFinished.slots():
result = self.doHeavyJob()
self.heavyJobFinished.emit(result)

This example skips doing the heavy job if there is no one listening for
the result. Just some ideas.

--
  -- Ewald


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


Re: [PyQt] mousePressEvent not getting called

2008-01-17 Thread Phil Thompson
On Thursday 17 January 2008, Quoc Tran wrote:
 I’m having a weird problem with using my custom Qt widget in
 PyQt.



 I created a custom QFrame in C++ and overrided:

 virtual void mousePressEvent( QMouseEvent * );



 When I use my widget in python the mousePressEvent is never
 called but if I derive off of my custom class in PyQt and override
 the mousePressEvent it will get called.

 i.e.

 class
 MyPythonFrame(MyCPlusPlusFrame):

 def
 mousePressEvent(self, e):


 print mouse event



 Any ideas what I’m doing wrong?

The SIP file for your C++ class is probably incomplete.

Phil

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


Re: [PyQt] QLabel.setTextInteractionFlags raises AttributeError

2008-01-17 Thread Phil Thompson
On Thursday 17 January 2008, Dog Walker wrote:
 QT: 3.3.7 SuSE 10.2

 Docs  (/PyQt-x11-gpl-4.1.1/doc/html/qlabel.html) show
 QLabel.setTextInteractionFlags (self, Qt.TextInteractionFlags flags)

This is PyQt4.

 but

 from qt import *
 ...

This is PyQt3.

 self.aboutTextLabel = QLabel(self.itsWindow,aboutVersions)
 ...

 Traceback (most recent call last):
   File kgmailnotifier.py, line 195, in module
 main()
   File kgmailnotifier.py, line 188, in main
 kgmailnotifier = KGmailNotifier()
   File kgmailnotifier.py, line 74, in __init__
 self.itsAboutWindow = aboutdialog.AboutDialog()
   File /home/thudfoo/KGmailNotifier2/aboutdialog.py, line 56, in __init__

 self.aboutTextLabel.setTextInteractionFlags(QLabel.TextSelectableByMouse) #
 Can be selected by the mouse for copying to clipboard
 AttributeError: setTextInteractionFlags

 What did I do wrong?

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


Re: [PyQt] simpler 'connect' function

2008-01-17 Thread Phil Thompson
On Thursday 17 January 2008, Ewald de Wit wrote:
 On Thursday 17 January 2008 18:27:19 Peter Shinners wrote:
 button.clicked.connect(self.onButtonClicked)
 
  Is there a clean way to handle signals with the same name that take
  different arguments? Here's an idea I can think of for QComboBox.
 
  combo.activated[int].connect(callback1)
  combo.activated[QString].connect(callback2)

The problem with this approach is that you can't represent all C++ argument 
types with Python types.

 A simpler way would be to just give the signal objects a different name,
 like activatedInt and activatedString. It's the easiest way to uniquely
 specify which signal you mean.

The problem with this is that things can get clunky - 
focusChangedQWidgetPtrQWidgetPtr for example.

Those that don't like strings because they can't be type checked are wrong. 
They can be type checked against Qt signals (see 
QMetaObject::indexOfSignal()). The problem is that they can't be 
distinguished from Python signals which are not pre-defined.

My prefered option at the moment is just not to support Python signals in any 
new approach - short-circuit signals would have to be used instead (which 
don't have parentheses and are therefore easy to distinguish from Qt 
signals).

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


Re: [PyQt] QLabel.setTextInteractionFlags raises AttributeError

2008-01-17 Thread Dog Walker
On Jan 17, 2008 3:05 PM, Phil Thompson [EMAIL PROTECTED] wrote:
 On Thursday 17 January 2008, Dog Walker wrote:
  QT: 3.3.7 SuSE 10.2
 
  Docs  (/PyQt-x11-gpl-4.1.1/doc/html/qlabel.html) show
  QLabel.setTextInteractionFlags (self, Qt.TextInteractionFlags flags)

 This is PyQt4.


I guess that is what the 4.1.1 implies. Thanks.

[...]

What I wanted to do was make the various version information displayed
on an About dialog selectable. I tried rich text but that isn't
selectable either. Do I have to use some other widget in pyqt3 to get
that effect? And which one, please?

-- 
I have seen the future and I'm not in it!
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Changing systray icon while handling signal

2008-01-17 Thread Jim Bublitz
On Thursday 17 January 2008 08:27, Dog Walker wrote:
 Using pyKde3

 I have a KSytemTray application. I want to change the systray icon
 (and tooltip)  when I begin handling a menuitem and change again
 before returning. It appears that the icon/tooltip is only set after
 returning to pyKde. Can I do what I want? How?

Assuming you're using KSystemTray, KSystemTray.setPixmap (pix) sets the icon 
to pix, whatever it's value is when called.

See PyKDE/examples/systray.py

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


Re: [PyQt] Changing systray icon while handling signal

2008-01-17 Thread Dog Walker
On Jan 17, 2008 2:23 PM, Jim Bublitz [EMAIL PROTECTED] wrote:
 On Thursday 17 January 2008 08:27, Dog Walker wrote:
  Using pyKde3
 
  I have a KSytemTray application. I want to change the systray icon
  (and tooltip)  when I begin handling a menuitem and change again
  before returning. It appears that the icon/tooltip is only set after
  returning to pyKde. Can I do what I want? How?

 Assuming you're using KSystemTray, KSystemTray.setPixmap (pix) sets the icon
 to pix, whatever it's value is when called.

 See PyKDE/examples/systray.py

 Jim

[...]

I have failed to make myself clear.

I have an icon in the systray with a menu.
One of the the menuitems is do_time_consuming_task.
When that menu item is selected by the user, function
do_time_consuming_task() runs.
That function tries to set the systray icon to busybusy.png and set
the tooltip to TCB'ing.
Immediatley after doing the icon change and tooltip code, the function
begins a long task.
After the long task end, the function changes the systray icon and
tooltip text back to what it was.
The function returns.

The icon/tooltip does not change during the running of the function.
Neither is the icon in the systray repainted if covered or when switching
desktops.
-
Anyway I solved the icon change part. The long running function could
be invoked from the menu or by a timer interrupt. So the first time
the long running function is entered, the icon is changed and a short
timer is set to invoke the function. The function returns, is
reentered, it does its long running thing, sets another icon and
restores the normal timer interval. Setting a tooltip to show during
the long running function is worthless because the app loop must be
running to show it. For the same reason, the icon disappears in the
systray if the user switches desktops (all the systray icons are
erased and must be repainted).

-- 
I have seen the future and I'm not in it!
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] Help with QTableView

2008-01-17 Thread Catriona Johnson
Hello

How do I implement a checkbox in a QTableView column that
retreives/stores values in a database?

Also, I have one model with columns say abc and I have two QTableViews
of this model that show the columns in different orders - bca and cab.
How do I change the column order in the QTableView?

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


Re: [PyQt] Changing systray icon while handling signal

2008-01-17 Thread Jim Bublitz
On Thursday 17 January 2008 21:26, Dog Walker wrote:
 On Jan 17, 2008 2:23 PM, Jim Bublitz [EMAIL PROTECTED] wrote:
  On Thursday 17 January 2008 08:27, Dog Walker wrote:
   Using pyKde3
  
   I have a KSytemTray application. I want to change the systray icon
   (and tooltip)  when I begin handling a menuitem and change again
   before returning. It appears that the icon/tooltip is only set after
   returning to pyKde. Can I do what I want? How?
 
  Assuming you're using KSystemTray, KSystemTray.setPixmap (pix) sets the
  icon to pix, whatever it's value is when called.
 
  See PyKDE/examples/systray.py
 
  Jim

 [...]

 I have failed to make myself clear.

 I have an icon in the systray with a menu.
 One of the the menuitems is do_time_consuming_task.
 When that menu item is selected by the user, function
 do_time_consuming_task() runs.
 That function tries to set the systray icon to busybusy.png and set
 the tooltip to TCB'ing.
 Immediatley after doing the icon change and tooltip code, the function
 begins a long task.
 After the long task end, the function changes the systray icon and
 tooltip text back to what it was.
 The function returns.

 The icon/tooltip does not change during the running of the function.
 Neither is the icon in the systray repainted if covered or when switching
 desktops.
 -
 Anyway I solved the icon change part. The long running function could
 be invoked from the menu or by a timer interrupt. So the first time
 the long running function is entered, the icon is changed and a short
 timer is set to invoke the function. The function returns, is
 reentered, it does its long running thing, sets another icon and
 restores the normal timer interval. Setting a tooltip to show during
 the long running function is worthless because the app loop must be
 running to show it. For the same reason, the icon disappears in the
 systray if the user switches desktops (all the systray icons are
 erased and must be repainted).

You can call your application object's processEvents() method (see 
QApplication docs)  or maybe set other timers to do redraws.

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