Re: [PyQt] Creating widget drawing benchmark test

2009-04-24 Thread Andreas Pakulat
On 24.04.09 17:02:35, Brent Villalobos wrote:
> Has anyone written a widget draw-time benchmarking program?  I need to  
> write a test that will provide an idea of how PyQt performs with a large  
> number of widgets.  I'm thinking of writing an application that creates  
> a grid of QPushButton widgets.  The test then runs when someone pushes a  
> "Go" button which calls a function that hides and shows each button.  It  
> would look something like this:
>
>def refresh():
>startTime = time.time()
>for i, b in enumerate(buttons):
>b.hide()
>b.show()
>print "Hide/show buttons in %f seconds" % (time.time()-startTime)
>
> Is this a good test or am I not really testing what I think I'm testing?  

With that you're testing how fast a QWidget can set its internal state
variables from hidden to shown. You don't test any painting performance.
If you want to do that, you'll probably have to either

- patch Qt
- or write a subclass of QPushButton which overrides paintEvent() and
  then times how long a call to the base class implementation needs.

And then you should do just either a hide or a show, as doing both might
simply be discarded due to how the event queue works.

Andreas

-- 
In the stairway of life, you'd best take the elevator.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] Creating widget drawing benchmark test

2009-04-24 Thread Brent Villalobos
Has anyone written a widget draw-time benchmarking program?  I need to 
write a test that will provide an idea of how PyQt performs with a large 
number of widgets.  I'm thinking of writing an application that creates 
a grid of QPushButton widgets.  The test then runs when someone pushes a 
"Go" button which calls a function that hides and shows each button.  It 
would look something like this:


   def refresh():
   startTime = time.time()
   for i, b in enumerate(buttons):
   b.hide()
   b.show()
   print "Hide/show buttons in %f seconds" % (time.time()-startTime)

Is this a good test or am I not really testing what I think I'm 
testing?  If this isn't a good test, anyone have any suggestions for a 
simple draw-time benchmarking test?

-Brent

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


Re: [PyQt] uic and pyuic ? on windows

2009-04-24 Thread Hazen Babcock

mad city wrote:

Running tutorial with Qt Designer. When I try and 'view code' get error:

  Unable to launch c:/Python26/Lib/site-packages/PyQt4/.\uic

The path is messed up during the install?

So, I wanted to try the command line version, but I can't find the 
'pyuic.exe' executable, is this not included in the windows PyQt4 install?


It should be there (i.e. in c:/Python26/Lib/site-packages/PyQt4/uic/), 
it is a python script called "pyuic.py". I had the same problem but the 
command line version works fine so I haven't tried to figure out how to 
fix it.


-Hazen

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


[PyQt] uic and pyuic ? on windows

2009-04-24 Thread mad city
Running tutorial with Qt Designer. When I try and 'view code' get error:

  Unable to launch c:/Python26/Lib/site-packages/PyQt4/.\uic

The path is messed up during the install?

So, I wanted to try the command line version, but I can't find the
'pyuic.exe' executable, is this not included in the windows PyQt4 install?
Tim
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] sipdistutils.py - adding custom options to the sip build command

2009-04-24 Thread Stefano Brilli
Hi,

While using sipdistutils.py I noticed that it is not possible to add the
"-e" flag to the sip build command. So I did a little change in
sipdistutils.py

I would like to contribute with this patch.

(And this is a small using example)

- setup.py ---
from distutils.core import setup
from distutils.extension import Extension
import sipdistutils
import os
import sys

sipdistutils.additional_sip_options.append('-e')

undef_macros = [NDEBUG]

macros = [("USE_PYMALLOC", "0")]

libs = []

setup(
  name = 'foobar',
  ext_modules=[
Extension("foobar",
  [
"sip/_foobar.sip",
"foobar.cpp",
  ],

  depends =
  [
"sip/_foobar.sip",
"foobar.cpp",
  ],

  include_dirs=["."],
  define_macros=macros,

  library_dirs=[],
  libraries=libs,

  undef_macros=undef_macros,
),
],
  cmdclass = {'build_ext': sipdistutils.build_ext}
)
-


Thanks,
Stefano Brilli

--- /home/cyber/Desktop/sipdistutils.py	2009-04-21 04:30:37.0 +0200
+++ sipdistutils.py	2009-04-22 17:17:44.0 +0200
@@ -9,6 +9,8 @@
 import os
 import sys
 
+additional_sip_options = []
+
 def replace_suffix(path, new_suffix):
 return os.path.splitext(path)[0] + new_suffix
 
@@ -84,7 +86,7 @@
 return generated_sources + other_sources
 
 def _sip_compile(self, sip_bin, source, sbf):
-self.spawn([sip_bin,
-"-c", self.build_temp,
+self.spawn([sip_bin] + additional_sip_options +
+["-c", self.build_temp,
 "-b", sbf,
 source])
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Issue Building Latest Snapshot

2009-04-24 Thread Aron Bierbaum
If I change line 704 of PyQt's configure.py to be:

inc_path = [sipcfg.py_inc_dir, sipcfg.sip_inc_dir]

then PyQt builds without problems.

-Aron


On Thu, Apr 23, 2009 at 5:24 PM, Aron Bierbaum  wrote:
> If I configure PyQt with the following settings, keep in mind sip is
> not installed in default system Python location. I get the error shown
> below.
>
> C:\p5\p5_deps\pyqt\vendor_base\win32>python configure.py
> --bindir=C:\p5\p5_deps\pyqt\install_win32_vc90\bin
> --destdir=C:\p5\p5_deps\pyqt\install_win32_vc90\lib\python2.6\site-packages
> --sipdir=C:\p5\p5_deps\pyqt\install_win32_vc90\share --confirm-license
> --verbose --vendorid
> --vendorid-incdir=C:\p5\p5_deps\vendorid\install_win32_vc90\include
> --vendorid-libdir=C:\p5\p5_deps\vendorid\install_win32_vc90\Lib
>
>
>   cl -c -nologo -Zm200 -Zc:wchar_t- -O2 -MD -GL -GR -EHsc -W3 -w34100
> -w34189 -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG
> -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT
> -I"c:\Qt\4.5.0\include\QtCore" -I"c:\Qt\4.5.0\include\QtGui"
> -I"c:\Qt\4.5.0\include" -I"c:\Python26\include" -I"..\..\QtCore"
> -I"c:\Qt\4.5.0\include\ActiveQt" -I"release" -I"."
> -I"c:\Qt\4.5.0\mkspecs\default" -Forelease\
> @C:\DOCUME~1\ARONB~1.PRI\LOCALS~1\Temp\nm5C.tmp qpycore_chimera.cpp
> ..\..\QtCore\sipAPIQtCore.h(43) : fatal error C1083: Cannot open
> include file: 'sip.h': No such file or directory
> qpycore_chimera_signature.cpp
> ..\..\QtCore\sipAPIQtCore.h(43) : fatal error C1083: Cannot open
> include file: 'sip.h': No such file or directory
> qpycore_chimera_storage.cpp
>
> If I manually modify the qpy\QtCore\Makefile.Release file to list the
> sip include directory it compiles correctly.
>
> INCPATH       = -I"c:\Qt\4.5.0\include\QtCore"
> -I"c:\Qt\4.5.0\include\QtGui" -I"c:\Qt\4.5.0\include"
> -I"c:\Python26\include" -I"..\..\QtCore"
> -I"c:\Qt\4.5.0\include\ActiveQt" -I"release" -I"."
> -I"c:\Qt\4.5.0\mkspecs\default"
> -I"C:\p5\p5_deps\sip\install_win32_vc90\include\python2.6"
>
> Any ideas what could be going wrong? Is there something that I am
> configuring incorrectly? Maybe I built sip incorrectly?
>
> Thanks,
> Aron
>
> On Thu, Apr 23, 2009 at 4:32 PM, Phil Thompson
>  wrote:
>> On Thu, 23 Apr 2009 15:50:55 -0500, Aron Bierbaum 
>> wrote:
>>> While trying to build the latest snapshot I had to manually add the
>>> include directory for sip in the Makefile before I could compile
>>> qpycore. Am I missing a command line flag, or is there something that
>>> needs to be added/changed to the .pro file to know where sip is
>>> located?
>>
>> Nothing's changed in the build system for weeks, if not months.
>>
>> Phil
>>
>

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


Re: [PyQt] Crash in siplib.c:findSlot, with test case and fix

2009-04-24 Thread Phil Thompson
On Thu, 23 Apr 2009 15:21:51 -0700, Matt Newell  wrote:
> On Thursday 23 April 2009 10:32:59 Matt Newell wrote:
>> It seems if a wrapped class A has slots and a wrapped subclass B does
not
>> then an assert is triggered when calling a slot from A on an instance of
>> B.
>>
>> To build and run the test --
>>
>> ./build.sh
>> python test.py
>>
>>
>> findSlot function that fixes all problems for me
>>
>> static void *findSlot(PyObject *self, sipPySlotType st)
>> {
>> sipPySlotDef *psd;
>> PyTypeObject *py_type = Py_TYPE(self);
>>
>>  if( PySequence_Check( py_type->tp_bases ) ) {
>>  int i = 0, end = PySequence_Size( py_type->tp_mro );
>>  for( ; i < end; i++ ) {
>>  PyObject * type_o = PySequence_GetItem( 
>> py_type->tp_mro, i );
>>  if( PyType_Check(type_o) ) {
>>  PyTypeObject * py_type_to_check = 
>> (PyTypeObject*)type_o;
>>
>>  /* If it is not a wrapper then it must be an 
>> enum. */
>>  if (PyObject_TypeCheck((PyObject 
>> *)py_type_to_check,
>> &sipWrapperType_Type))
>>  psd = ((sipClassTypeDef 
>> *)((sipWrapperType *)
>> (py_type_to_check))->type)->ctd_pyslots;
>>  else
>>  {
>>  assert(PyObject_TypeCheck((PyObject 
>> *)py_type_to_check,
>> &sipEnumType_Type));
>>
>>  psd = ((sipEnumTypeDef 
>> *)((sipEnumTypeObject *)
>> (py_type_to_check))->type)->etd_pyslots;
>>  }
>>  while (psd && psd->psd_func != NULL)
>>  {
>>  if (psd->psd_type == st)
>>  return psd->psd_func;
>>
>>  ++psd;
>>  }
>>  } else
>>  printf( "mro member not a type object\n" );
>>  }
>>  }
>>
>> assert(NULL);
>>
>> /* This should never happen. */
>> return NULL;
>> }
> 
> 
> 
> My "fix" fixes the test case but causes a crash with
> QTreeWidgeItem() == None
> 
> so it's obviously not a solution.

It is the right solution - though I've implemented it differently.

> Calling QTreeWidgetItem() == None without my change it ends up returning
> NULL 
> from findSlot which the comment indicates should never happen.

The comment was wrong so later code needed to handle that case.

Hopefully it's all fixed in tonight's snapshot.

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


[PyQt] Populate Model data in a separate thread

2009-04-24 Thread Edwin Marshall




I've been reading on qtcentre that it is possible to populate a model from a separate qthread in order to prevent a program from freezing before it loads, however the example code I have seen is a bit too much involved (and in c++) for me to comprehend. I was wondering if anyone knew of a pyqt program that did, or could point me toward some code snippets doing this.The only thing that I can gather is that I need to create the qthread in the __init__ method of my model and call it's run command. However, I can't figure out what exactly need to go in the run method, or what signals to emit/catch.Thansk in advance for any help



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

Re: [PyQt] (PyQt-snapshot) + (SIP-snapshot) = plasma crash

2009-04-24 Thread Simon Edwards

Grissiom wrote:
After installed PyQt-snapshot-20090422 and sip-snapshot-20090420 my 
plasma crashed after re-login. KDE4.2.2, Qt-copy(equal to 4.5). Need I 
recompile KDE?... Any hints? Thanks in advance. ;)


You need to recompile PyKDE in kdebindings which actually won't work 
right now since PyKDE needs to be fixed up for SIP 4.8. I'm working on 
that at the moment.


cheers,

--
Simon Edwards | KDE-NL, Guidance tools, Guarddog Firewall
si...@simonzone.com   | 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] Re: Change subscription

2009-04-24 Thread Edwin Marshall




NVM, I found my subscription page. I'm pretty new to using mailing lists, so please excuse the ignorance.




Get Free Smileys for Your IM & Email - Learn more at www.crawler.com/smileys
Works with AIM®, MSN® Messenger, Yahoo!® Messenger, ICQ®, Google Talk™ and most webmails


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

[PyQt] Change subscription

2009-04-24 Thread Edwin Marshall




How do I change my subscription to daily digest instead of individual emails? Thanks.



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

[PyQt] (PyQt-snapshot) + (SIP-snapshot) = plasma crash

2009-04-24 Thread Grissiom
Hi all,

After installed PyQt-snapshot-20090422 and sip-snapshot-20090420 my plasma
crashed after re-login. KDE4.2.2, Qt-copy(equal to 4.5). Need I recompile
KDE?... Any hints? Thanks in advance. ;)

-- 
Cheers,
Grissiom
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Exposing complex Qt objects as javascript objects

2009-04-24 Thread Ori Avtalion
On 04/23/2009 03:31 AM, Henning Schröder wrote:
> On Tue, Apr 21, 2009 at 2:15 AM, Ori Avtalion  wrote:
>> Hi,
>>
>> I'm trying to create a Qt object that will be exposed to javascript.
>> I want that javascript object to be complex: It has nested objects
>> inside it, and has arrays with other objects in them.
>>
>> I'm not sure how to define the properties for the top object that I
>> expose. pyqtProperty doesn't accept "QVariant". (It returns the error
>> "TypeError: type 'QVariant' is not supported as a property type")
> Dynamic properties via setProperty use variants but I think it does
> not work correctly for objects and widgets. It seems that the type is
> not set to QMetaType::QObjectStar or QMetaType::QWidgetStar in the
> constructor. At least QtScript does not recognize the variant as a
> object or widget (see app property in attached example - the C++
> equivalent would work this way).
> 

Thanks Henning!

setProperty() seems to work fine when I give it a QVariant("{'foo':'bar'}")

However, it means I have both a raw pythonic copy of it, and a QVariant
copy that I can't modify. If I have a large object, I want to avoid
copying it just for that. (I guess I won't use it for large objects)

Any idea why pyqtProperty doesn't accept "QVariant"?

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


Re: [PyQt] splitting windows

2009-04-24 Thread Mads
I found a solution for this, QSplitter works fine for me.

thanks





From: Mads 
To: pyqt@riverbankcomputing.com
Sent: Thursday, April 23, 2009 5:19:53 PM
Subject: [PyQt] splitting windows


Hi all

I have an application with a Graphicsscene with different objects. I want to be 
able to split the scene into several views so I can work in different zoom 
levels. If I change something in one splitwindow it should be changed in every 
window, so I need to render the same scene in different views and zoom levels. 
So my question is, is it possible to add such a feature to the scene, and which 
way is the best way to proceed?


hope anyone have some good ideas.

Thanks in advance

Mads


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

Re: Re: [PyQt] Link between a QWebViev and a JavaScript program

2009-04-24 Thread projetmbc

Marcell Mars a écrit :

from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtWebKit import *

myWebKit = QWebView()
myWebKit.show()

myWebKit.setUrl(QUrl("http://www.google.com";))

myWebKit.page().mainFrame().evaluateJavaScript(open('jquery.js').read())

myWebKit.page().mainFrame().evaluateJavaScript("""$(document).ready(function()
{ $("body").css("background", "#f00");});""")



Indeed the line

   
myWebKit.page().mainFrame().evaluateJavaScript("""$(document).ready(function()


{ $("body").css("background", "#f00");});""")


must be changed to

   
self.webView.page().mainFrame().evaluateJavaScript("""$("body").css("background", 
"#f00");""")


With this modification, everything is ok.

Thanks.
Christophe.

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


Re: [PyQt] implications of running PyQt 4.4.x with Qt 4.5?

2009-04-24 Thread Phil Thompson
On Thu, 23 Apr 2009 22:06:20 -0400, Devon Rueckner
 wrote:
> On Wed, Apr 22, 2009 at 4:08 PM, Phil Thompson
>  wrote:
>> On Wed, 22 Apr 2009 15:51:23 -0400, Devon Rueckner
>>  wrote:
>>> On Wed, Apr 22, 2009 at 12:50 PM, Phil Thompson
>>>  wrote:
 On Wed, 22 Apr 2009 12:40:49 -0400, Devon Rueckner
  wrote:
> Hi -
>
> We would like to upgrade to Qt 4.5 for its bug fixes, performance and
> license.
>
> After simply swapping out Qt and leaving PyQt alone, empirically
> everything works with the exception of a few graphics view rendering
> issues.
>
> Is running PyQt 4.4.4 with Qt 4.5 considered supported?  What are
the
> implications?

 Generally there is no problem with using a later version of Qt. The
 exception is when that new version introduces new implementations of
 existing virtuals - an older PyQt doesn't know to call them. There are
 some
 cases of that in Qt v4.5.

 Phil

>>>
>>> Just to clarify:
>>>
>>> Are you saying that there is no problem as long as we don't use
>>> certain known functions?
>>> Or, in the case of 4.5 there is a problem and we would not be safe
>>> using an older PyQt?
>>
>> The problem is limited to specific classes - QGraphicsProxyWidget is the
>> only one that springs to mind.
>>
>> Phil
>>
> 
> 
> That class is indeed causing problems.  Would it be possible to patch
> PyQt 4.4.4 to point to the new implementation?

Have a look at the GGraphicsProxyWidget changes in the current snapshot and
apply them to the 4.4.4 .sip file.

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


Re: [PyQt] Simple connect does not work

2009-04-24 Thread Mads Ipsen
> On Friday 24 April 2009, Mads Ipsen wrote:
>
>> OK, I need to use a signature (see below). Sorry for bothering you!
>>
>> class SpinBox(QtGui.QSpinBox):
>> def __init__(self, parent=None):
>> QtGui.QSpinBox.__init__(self, parent)
>>
>> @QtCore.pyqtSignature("int")
>> def foo(self, i):
>> print i
>
> Or perhaps:
>
> QtCore.QObject.connect(spin, QtCore.SIGNAL('valueChanged(int)'), spin.foo)
>
> --
> Jan Ekholm
> jan.ekh...@smultron.net
> ___
> PyQt mailing listPyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>

That's the way that I normally would approach it, sure. But I wanted to
know how the SIGNAL, SLOT approach works - and there a signature is
needed.

Best regards,

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


Re: [PyQt] Simple connect does not work

2009-04-24 Thread Jan Ekholm
On Friday 24 April 2009, Mads Ipsen wrote:

> OK, I need to use a signature (see below). Sorry for bothering you!
>
> class SpinBox(QtGui.QSpinBox):
> def __init__(self, parent=None):
> QtGui.QSpinBox.__init__(self, parent)
>
> @QtCore.pyqtSignature("int")
> def foo(self, i):
> print i

Or perhaps:

QtCore.QObject.connect(spin, QtCore.SIGNAL('valueChanged(int)'), spin.foo)

-- 
Jan Ekholm
jan.ekh...@smultron.net
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Simple connect does not work

2009-04-24 Thread Mads Ipsen
> Hi,
>
> I am puzzled why the connection used in the example below does not work. I
> get the error:
>
> Object::connect: No such slot SpinBox::foo(int)
>
> Example snippet:
>
> import sys
> from PyQt4 import QtCore, QtGui
>
> class SpinBox(QtGui.QSpinBox):
> def __init__(self, parent=None):
> QtGui.QSpinBox.__init__(self, parent)
>
> def foo(self, i):
> print i
>
> if __name__ == "__main__":
> app = QtGui.QApplication(sys.argv)
>
> spin = SpinBox()
> QtCore.QObject.connect(spin, QtCore.SIGNAL('valueChanged(int)'),
>spin, QtCore.SLOT('foo(int)'))
> spin.show()
>
> sys.exit(app.exec_())
> ___
> PyQt mailing listPyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>


OK, I need to use a signature (see below). Sorry for bothering you!

class SpinBox(QtGui.QSpinBox):
def __init__(self, parent=None):
QtGui.QSpinBox.__init__(self, parent)

@QtCore.pyqtSignature("int")
def foo(self, i):
print i
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] Simple connect does not work

2009-04-24 Thread Mads Ipsen
Hi,

I am puzzled why the connection used in the example below does not work. I
get the error:

Object::connect: No such slot SpinBox::foo(int)

Example snippet:

import sys
from PyQt4 import QtCore, QtGui

class SpinBox(QtGui.QSpinBox):
def __init__(self, parent=None):
QtGui.QSpinBox.__init__(self, parent)

def foo(self, i):
print i

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

spin = SpinBox()
QtCore.QObject.connect(spin, QtCore.SIGNAL('valueChanged(int)'),
   spin, QtCore.SLOT('foo(int)'))
spin.show()

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