Re: [PyQt] Custom QSqlRelationalDelagate: how to change text?

2008-04-12 Thread Simone

Simone Zaccarin ha scritto:

My only problem is that I construct the UI via QtDesigner. Is there a way to 
overwrite the table added via Designer without being a PyQt4 expert?


Sorry, I misunderstood the message... :)

The QSqlRelationalTableModel is added by code... :)

Simone
Chiacchiera con i tuoi amici in tempo reale! 
http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com 


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


Re: [PyQt] Custom QSqlRelationalDelagate: how to change text?

2008-04-12 Thread Simone

Mark Summerfield ha scritto:

On 2008-04-11, Simone Zaccarin wrote:

I'm trying to create a custom QSqlRelationalDelegate.

In the database, the date field is in text form '-MM-dd'. I have to
show that string in a QSqlTable in the form 'dd-MM-'.


If that's the only change you want to make, you could try what might be
a simpler approach, such as subclassing QRelationalTableModel and
reimplementing the data() method. For every column except the date just
pass the work to the base class, and for your date column do something
like:

dateString = index.model().data(index).toString() return

return QDate.fromString(dateString, -MM-dd).toString(dd/MM/)


Thanks, Mark! :D

This is the final version:

def data(self, index, role):
if index.column() == 1 and role == Qt.DisplayRole:
try:
dateString = QSqlRelationalTableModel.\
 data(self, index, role).toString()
date = QDate.fromString(dateString,
(-MM-dd).toString(dd/MM/)
return QVariant(date)
except ValueError:
return QSqlRelationalTableModel.data(self, index, role)
else:
return QSqlRelationalTableModel.data(self, index, role)

I have to get the string value with the QSqlRelationalTableModel.data 
method because otherwise I obtain a recursion without end.


Thanks a lot,
Simone
Chiacchiera con i tuoi amici in tempo reale! 
http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com 


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


[PyQt] Python(x,y), Python/Qt for Scientists

2008-04-12 Thread Python(x,y)
Dear all,

The scientists among you may be interested in Python(x,y), a new
scientific-oriented Python distribution. This Python/Eclipse/PyQt
distribution
is freely available as a one-click Windows installer (a release for
GNU/Linux with similar features will follow soon):
http://www.pythonxy.com

Please do not hesitate to forward this announcement...
(I am very sorry if you have already received this e-mail through
python-list mailing list)

Thanks a lots,
PR

-- 
P. Raybaut
Python(x,y)
http://www.pythonxy.com

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


[PyQt] Small error in PyKDE4 tutorial for KAction (4th program)

2008-04-12 Thread Christoph Burgmer
The kactionui.rc file given in the fourth example KAction in the PyKDE4 
tutorial uses a ampersand for the text string of the file menu. As  is a 
special character in XML it needs to be encoded as amp; which the author 
maybe already did, but then forgot to encode the amp; again to amp;amp;

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


[PyQt] kdecore.KProcess.Communication enum not OR-able

2008-04-12 Thread Wilbert Berendsen
Hi,

The KDE docs say that you can OR the values of the 
kdecore.KProcess.Communication enum when start()ing a KProcess.[1]

However that seems not to be possible:
 from kdecore import *
 p=KProcess()
 p.setExecutable('cat')
True
 p.start(KProcess.NotifyOnExit, KProcess.Stdin | KProcess.Stdout)
Traceback (most recent call last):
  File stdin, line 1, in module
TypeError: argument 2 of KProcess.start() has an invalid type
 type(KProcess.Stdin | KProcess.Stdout)
type 'int'
 type(KProcess.Stdin)
class 'kdecore.Communication'


So I can only use the predefined values of the Communication enum (All, 
AllOuput etc.). Is this a bug and is there a workaround to start a KProcess() 
and only communicate with stdout and stdin and not stderr?

[1]http://api.kde.org/3.5-api/kdelibs-apidocs/kdecore/html/classKProcess.html#31e69eb366082bb93bbdc31e6e281019

TIA,
w best regards,
Wilbert Berendsen

-- 
http://www.wilbertberendsen.nl/
You must be the change you wish to see in the world.
-- Mahatma Gandhi
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] PyQt and image processing

2008-04-12 Thread Gerard Vermeulen
On Sat, 12 Apr 2008 02:16:58 -0300
Laura X [EMAIL PROTECTED] wrote:

 Dear PyQt experts,
 
 I am choosing a GUI toolkit for developing an application
 (cross-platform) and PyQt seems to be simpler/more-intuitive for
 programming than others. My application will have some basic image
 processing (transformations, filtering, pattern recognition (e.g.,
 with convolution), etc., but nothing complex) and some
 drawing/painting on image stuff (I am also interested in playing an
 AVI movie and transform each frame in single image inside my
 application).
 
 Pardon my ignorance but searching on the internet I was unable to find
 examples of applications or descriptions of these functionalities in
 PyQt.
 
 I saw that PyQt has some nice built in functions for more basic image
 processing but nothing on filtering and pattern recognition (e.g.,
 with convolution).
 It would be OK if I could use PIL or OpenCV for these stuff but it
 seems the PIL integration in PyQt is somewhat limited or at least the
 image conversion is too slow and there is nothing on OpenCV.
 
 So, are there PyQt applications/examples on image processing? Using
 PIL or OpenCV? Is it possible to load an AVI file and process the data
 in PyQt?
 Of course I understand that if there aren't good app's this does not
 mean it is not possible to develop, but I want to learn with the
 experience from others.
 
http://effbot.python-hosting.com/file/pil/PIL/ImageQt.py shows how to
convert a PIL image to a QImage using a Python string to exchange the
data.
It is also very easy to convert the data in a QImage to a Python string.
For instance
 image = QImage(256, 256, QImage.Format_ARGB32)
 bytes = image.bits().asstring(image.numBytes())
 len(bytes)
262144 # == 4*256*256
I suppose that it is easy to convert from a Python string to a PIL
image.  The penalty of using a Python string instead of copying
directly by means of a Python extension written in C or C++ is that
the data is copied twice instead of once.  It depends on the resources
required by your image processing if that is significant or not.

It looks that OpenCV has much more image processing capabilities than
PIL.  A bit of googling (search for numpy and OpenCV) shows that OpenCV
contains a file adaptors.py which allows to convert between OpenCV/IPL
images, PIL images and numpy arrays.  All those conversions use Python
strings as an intermediate format.
( 
http://opencvlibrary.cvs.sourceforge.net/opencvlibrary/opencv/interfaces/swig/python/adaptors.py?view=markup
 )

Anyhow, if you need PIL or OpenCV with another GUI toolkit, you have
to convert to and from the image format of the other toolkit.

I think that http://pymedia.org/ lets you convert AVI (and other) movie
frames to strings.

Regards -- Gerard

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


Re: [PyQt] kdecore.KProcess.Communication enum not OR-able

2008-04-12 Thread Wilbert Berendsen
I forgot to mention the version of PyKDE:
PyKDE 3.16.0
PyQT 3.17.4
KDE 3.5.8

thx,
Wilbert Berendsen

-- 
http://www.wilbertberendsen.nl/
You must be the change you wish to see in the world.
-- Mahatma Gandhi
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Goods news about the menu text missing in PyKDE apps with Oxygen bug

2008-04-12 Thread Detlev Offenbach
On Donnerstag, 10. April 2008, Simon Edwards wrote:
 Hello all,

 Some people here might have crossed paths with the menu text missing in
 PyKDE apps with Oxygen bug. Basically menu labels are not rendered when
 a PyKDE4 application is used with the Oxygen widget style. After quite a
 lot of hair-pulling work over the last few days I've figured out what
 the problem is.

 First, a solution. Put the following lines in your PyKDE4/__init__.py
 file in your Python installation's site-packages directory. (typically
 /lib/python2.5/site-packages/PyKDE4/__init__.py).

import sys, dl
sys.setdlopenflags(dl.RTLD_NOW|dl.RTLD_GLOBAL)

Python seems to be broken on openSUSE 10.3 64-bit. It doesn't contain the 
dl.so library. Any help is appreciated.


Regards,
Detlev
-- 
Detlev Offenbach
[EMAIL PROTECTED]
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] kdecore.KProcess.Communication enum not OR-able

2008-04-12 Thread Jim Bublitz
On Saturday 12 April 2008 06:04, Wilbert Berendsen wrote:
 Hi,

 The KDE docs say that you can OR the values of the
 kdecore.KProcess.Communication enum when start()ing a KProcess.[1]

 However that seems not to be possible:
  from kdecore import *
  p=KProcess()
  p.setExecutable('cat')

 True

  p.start(KProcess.NotifyOnExit, KProcess.Stdin | KProcess.Stdout)

 Traceback (most recent call last):
   File stdin, line 1, in module
 TypeError: argument 2 of KProcess.start() has an invalid type

  type(KProcess.Stdin | KProcess.Stdout)

 type 'int'

  type(KProcess.Stdin)

 class 'kdecore.Communication'


 So I can only use the predefined values of the Communication enum (All,
 AllOuput etc.). Is this a bug and is there a workaround to start a
 KProcess() and only communicate with stdout and stdin and not stderr?

It appears that sip is doing strict checking for the KProcess.Communication 
type, and KProcess.Stdin | KProcess.Stdout is not defined in that enum type.

Jim

 [1]http://api.kde.org/3.5-api/kdelibs-apidocs/kdecore/html/classKProcess.ht
ml#31e69eb366082bb93bbdc31e6e281019

 TIA,
 w best regards,
 Wilbert Berendsen
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] kdecore.KProcess.Communication enum not OR-able

2008-04-12 Thread Jim Bublitz
On Saturday 12 April 2008 06:04, Wilbert Berendsen wrote:
 Hi,

 The KDE docs say that you can OR the values of the
 kdecore.KProcess.Communication enum when start()ing a KProcess.[1]

 However that seems not to be possible:
  from kdecore import *
  p=KProcess()
  p.setExecutable('cat')

 True

  p.start(KProcess.NotifyOnExit, KProcess.Stdin | KProcess.Stdout)

Phil suggests that this:

p.start(KProcess.NotifyOnExit, KProcess.Communication (KProcess.Stdin | 
KProcess.Stdout))

should work - I haven't tried it.

A couple of other notes: 1. This enum isn't available in KDE4 and 2. A lot of 
the enums in KDE4/PyKDE4 (and Qt4) will require similar strict type-checking 
(everything using QFlags).

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


Re: [PyQt] kdecore.KProcess.Communication enum not OR-able

2008-04-12 Thread Wilbert Berendsen
Op zaterdag 12 april 2008, schreef Jim Bublitz:

 Phil suggests that this:

 p.start(KProcess.NotifyOnExit, KProcess.Communication (KProcess.Stdin |
 KProcess.Stdout))

Thanks, it works! I tried to do that, but tried kdecore.Communication instead 
of KProcess.Communication 

 should work - I haven't tried it.

 A couple of other notes: 1. This enum isn't available in KDE4 and 2. A lot
 of the enums in KDE4/PyKDE4 (and Qt4) will require similar strict
 type-checking (everything using QFlags).

Thanks for the information and explanation.
w best regards,
Wilbert Berendsen

-- 
http://www.wilbertberendsen.nl/
You must be the change you wish to see in the world.
-- Mahatma Gandhi
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[partially solved] Re: [PyQt] KProcess setUsePty not there...

2008-04-12 Thread Wilbert Berendsen
Op donderdag 3 april 2008, schreef Jim Bublitz:
 On Wednesday 02 April 2008 08:00, Wilbert Berendsen wrote:
  Hi,
 
  I want to run a program that insists on reading from a terminal using
  KProcess (from within PyKDE), but it seems KProcess::setUsePty() does not
  exist:
 
  Python 2.5.1 (r251:54863, Mar 26 2008, 22:37:08)
  [GCC 4.1.2 (Gentoo 4.1.2 p1.0.2)] on linux2
  Type help, copyright, credits or license for more information.
 
   from kdecore import *
   p=KProcess()
   p.setUsePty(3,False)

 It's an error in not providing a #define for a conditional in the h file
 when generating PyKDE.

Is this a bug in KDE, in PyKDE or in Gentoo's compile setup?

 You can fix it in sip/kdecore/kprocess.sip by changing this (near line
 193):

 %If ( KDE_3_2_0 - KDE_3_4_0 )
 void setUsePty (KProcess::Communication, bool);
 KPty*pty () const;
 %End

 to this:

 %If ( KDE_3_2_0 -   )
 void setUsePty (KProcess::Communication, bool);
 KPty*pty () const;
 %End

 and then rebuild with

 python configure.py -lkdecore  make  su -cmake install

I did that and yes, now setUsePty works. Thanks!

A remaining question, as I can't ask the users of my LilyKDE module to 
recompile PyKDE: does setUsePty work in mainstream distributions like Ubuntu?

Thanks,
Wilbert Berendsen

-- 
http://www.wilbertberendsen.nl/
You must be the change you wish to see in the world.
-- Mahatma Gandhi
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Goods news about the menu text missing in PyKDE apps with Oxygen bug

2008-04-12 Thread Simon Edwards

Detlev Offenbach wrote:

On Donnerstag, 10. April 2008, Simon Edwards wrote:

Hello all,

Some people here might have crossed paths with the menu text missing in
PyKDE apps with Oxygen bug. Basically menu labels are not rendered when
a PyKDE4 application is used with the Oxygen widget style. After quite a
lot of hair-pulling work over the last few days I've figured out what
the problem is.

First, a solution. Put the following lines in your PyKDE4/__init__.py
file in your Python installation's site-packages directory. (typically
/lib/python2.5/site-packages/PyKDE4/__init__.py).

   import sys, dl
   sys.setdlopenflags(dl.RTLD_NOW|dl.RTLD_GLOBAL)


Python seems to be broken on openSUSE 10.3 64-bit. It doesn't contain the 
dl.so library. Any help is appreciated.


Looking at the dl docs I see:


Note: This module will not work unless sizeof(int) == sizeof(long) == 
sizeof(char *) If this is not the case, SystemError will be raised on 
import.



That explains why it is not there for 64bit.

Docs for sys.setdlopenflags():


setdlopenflags(  n)
 Set the flags used by the interpreter for dlopen() calls, such as when 
the interpreter loads extension modules. Among other things, this will 
enable a lazy resolving of symbols when importing a module, if called as 
sys.setdlopenflags(0). To share symbols across extension modules, call 
as sys.setdlopenflags(dl.RTLD_NOW | dl.RTLD_GLOBAL). Symbolic names for 
the flag modules can be either found in the dl module, or in the DLFCN 
module. If DLFCN is not available, it can be generated from 
/usr/include/dlfcn.h using the h2py script. Availability: Unix. New in 
version 2.2.



Try this:

import sys,DLFCN
sys.setdlopenflags(DLFCN.RTLD_NOW|DLFCN.RTLD_GLOBAL)

cheers,

--
Simon Edwards | KDE-NL, Guidance tools, Guarddog Firewall
[EMAIL PROTECTED]   | http://www.simonzone.com/software/
Nijmegen, The Netherlands | ZooTV? You made the right choice.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] Error when compiling pyqt on mac

2008-04-12 Thread Felipe Ferreri Tonello

Hey guys, I don't know why is not compiling my PyQT for mac..

I have the Qt4, SIP, etc..

the configure is everything ok.. I specify the qmake and it works fine..
I'm using the configure like this:
python configure.py --confirm-license --qmake=/opt/qt4/bin/qmake

then I do the make.. but then after compile a lot of stuff.. it  
returns an error:
 QGLFramebufferObject::QGLFramebufferObject(QSize const, unsigned  
int), referenced from:
 sipQGLFramebufferObject::sipQGLFramebufferObject(QSize const,  
unsigned int)in sipQtOpenGLQGLFramebufferObject.o

ld: symbol(s) not found
collect2: ld returned 1 exit status
make[1]: *** [QtOpenGL.so] Error 1
make: *** [all] Error 2

Anyone can help me?? I really need this for today..

Thanks

Felipe Ferreri Tonello
[EMAIL PROTECTED]
http://felipetonello.com



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


Re: [PyQt] Error when compiling pyqt on mac

2008-04-12 Thread Phil Thompson
On Saturday 12 April 2008, Felipe Ferreri Tonello wrote:
 Hey guys, I don't know why is not compiling my PyQT for mac..

 I have the Qt4, SIP, etc..

What versions?

 the configure is everything ok.. I specify the qmake and it works fine..
 I'm using the configure like this:
 python configure.py --confirm-license --qmake=/opt/qt4/bin/qmake

 then I do the make.. but then after compile a lot of stuff.. it
 returns an error:
   QGLFramebufferObject::QGLFramebufferObject(QSize const, unsigned
 int), referenced from:
   sipQGLFramebufferObject::sipQGLFramebufferObject(QSize const,
 unsigned int)in sipQtOpenGLQGLFramebufferObject.o
 ld: symbol(s) not found
 collect2: ld returned 1 exit status
 make[1]: *** [QtOpenGL.so] Error 1
 make: *** [all] Error 2

 Anyone can help me?? I really need this for today..

Then perhaps you should check the mailing list archives.

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


[PyQt] Selection of MDI Child and Properties

2008-04-12 Thread B Clowers
So I've been trying to alter the mdi.py example packaged with PyQt and allow 
the contents of the child windows to be altered using the python interpreter.  
I've been successful in adding a python shell to the main user interface in a 
way similar to OpenAlea but really have no clue how to access the current 
window as a variable.

For example is it possible to type a command in the python interpreter that 
would allow text to be added directly to the window that has the current focus? 
 Something like:

child1.setText(foo bar)

As I did not write the python interpreter add-on I wonder if the threading is 
such that this is not possible.  Does anyone have a solution or an idea how to 
make this happen?  Do I need to create some global variables that get reset 
each time I change the focus or can they exist for each child window 
individual--the latter would be ideal.  I can post some the code but it is 
U-G-L-Y upon request.  Any help would be greatly appreciated.  

Cheers,

Brian
 __
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com ___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt