[PyQt] QGraphicsScene/Item/View optimisation

2009-02-04 Thread Frédéric

Hello,

I draw some items (mainly rectangles or ellispes) on a scene, and it
seems to take a lot of resources, even with a few objects (say 10).

The main issue is on the maemo plateform, as Nokia N8x0 devices are not
that powerfull. Just drawing the initial scene takes a few seconds.

Are there some optimisation tips I should know? Or is there a big issue
in my design? The code is here:

http://trac.gbiloba.org/papywizard/browser/trunk/papywizard/view/shootingScene.py
http://trac.gbiloba.org/papywizard/browser/trunk/papywizard/view/pictureItem.py

Thanks,


--
   Frédéric

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


Re: [PyQt] import ui_rc

2009-02-04 Thread simozack
2009/2/4, Yusuf X ys1...@gmail.com:

 I have one question: when I run pyuic4 on a .ui file that has a QMainWindow,
 it adds import ui_rc at the end of the resultant .py file. Then when I use
 that .py file, I get ImportError: No module named ui_rc. If I delete that
 last line by hand, the .py works fine and I can display the window as
 needed.

Probably you are using a resources file (for example for icons). You
can resolve the issue by creating the resource file in this way:

pyrrc4 file_name.rc  ui_rc.py

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


Re: [PyQt] import ui_rc

2009-02-04 Thread Phil Thompson
On Tue, 3 Feb 2009 22:52:09 -0800, Yusuf X ys1...@gmail.com wrote:
 Hello, first of all thanks for making PyQT.
 
 I have one question: when I run pyuic4 on a .ui file that has a
 QMainWindow,
 it adds import ui_rc at the end of the resultant .py file. Then when I
 use
 that .py file, I get ImportError: No module named ui_rc. If I delete
that
 last line by hand, the .py works fine and I can display the window as
 needed.

See http://www.riverbankcomputing.com/support/help

 So what's with the extraneous ui_rc? I'm using Qt4.5, Python2.6 and PyQt4
 on
 Windows Vista. FWIW, I have no such issues with QDialog.

Qt 4.5 isn't yet supported.

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


[PyQt] Worker Thread

2009-02-04 Thread Matt Smith
It seems like your worker thread should start, I don't really like how
you've set it up, but I think it should start, so I am going to suggest
that pow is too much for it.  Ie it is taking all of the resources
your application gets.  Really what you should do in that case is use
multiprocessing.  Plus 'terminate()' is not going to do what you want.  

 So maybe you should use multiprocessing.  I don't have multiprocessing
installed, yet, but create a thread and then when you use .start() have
your thread start a process.  This will give you access to terminate,
which will be like hitting ctrl-c

http://docs.python.org/library/multiprocessing.html

And there is a version of multiprocessing for 2.5 if you are running
that.

mbs

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


Re: [PyQt] Newbie with a circular problem calling problem

2009-02-04 Thread Marc Nations
In order to prevent similar situations in the my code where I have a set of
dependent boxes I've used a couple of methods.

First method is to use a governor function. Send all of your signals to one
function which can evaluate each signal as it's called and decide to act on
or ignore subsequent signals. From here you can set status flags and call
your worker methods. When the signals are triggered again, because of your
status flags you know to ignore them.

Second method is to disconnect the widgets that you're currently working on
and them re-connect them when you're done. This way probably works better as
it decrease the amount of events flying around.

It becomes an issue not just when updating widgets, but clearing them as
well sometimes, depending on which signal you use. I have functions which I
can call that does mass connects and disconnects.

There may be better methods for handling this in Qt, but I've found these to
work.

Marc



On Tue, Feb 3, 2009 at 11:28 AM, Knapp magick.c...@gmail.com wrote:

 Hello, I am a bit new to all this, so I hope this question is not to
 dumb. I am writing a program that must have a form with just these
 inputs and one input effects the other. I have one spin box,
 ST(strength) that sets the base of the second, HP (hit points). So if
 you have 10 ST then you have 10 HP but you can buy more HP by rolling
 the roller for ST. This is where it gets really messed up! Changing ST
 must update ST and HP. Calling HP must update only HP. I know this
 explanation sucks but hopefully the code will help. I am using count
 to try and stop the run away look that is happening. Is there a much
 better way?!

 BTW, ST cost one price and HP a second so changes from both rollers
 must be kept separately be be shown added.

 Thanks all!
 Douglas E

 import sys
 from PyQt4 import * #QtCore, QtGui
 from Char1 import *

 class StartQT4(QtGui.QMainWindow):
count=0
dHP = 0
oldHP = 10
dST = 0
oldST = 10
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
QtCore.QObject.connect(self.ui.spinBox_DX,
 QtCore.SIGNAL(valueChanged(int)), self.label_DX_Cost_Set)
QtCore.QObject.connect(self.ui.spinBox_ST,
 QtCore.SIGNAL(valueChanged(int)), self.label_ST_Cost_Set)
QtCore.QObject.connect(self.ui.spinBox_HP,
 QtCore.SIGNAL(valueChanged(int)), self.adjust_HP)
  #
  QtCore.QObject.connect(self.ui.spinBox_ST,QtCore.SIGNAL(valueChanged(int)),
 self.lineEdit_Basic_Lift_s)

def label_DX_Cost_Set(self, Num):
Num1= Num - self.dx
self.dx = Num
self.ui.label_DX_Cost.setNum(Num1)

def label_ST_Cost_Set(self, Num):
self.dST = Num - self.oldST
self.oldST = Num
self.ui.label_ST_Cost.setNum((Num-10)*20)
self.ui.lineEdit_Basic_Lift.setText(str(Num*Num/5))
#val = self.ui.spinBox_HP.value()
#self.ui.spinBox_HP.setValue(0)
self.adjust_HP(-99)

def adjust_HP(self, Num):
print Num, Count, Num, self.count
if Num==-99 :
self.ui.spinBox_HP.setValue(self.oldHP+self.dST)
print 99 ds, oldHP, self.dST, self.oldHP
self.oldHP += self.dST
elif self.count == 0 :
self.count += 1
self.dHP = Num - self.oldHP
print  ds, oldHP, self.dST, self.oldHP
self.oldHP = Num
self.ui.label_HP_Cost.setNum(Num+self.oldHP)
self.ui.spinBox_HP.setValue(self.oldHP+self.dHP)
else :
self.count = 0
print end

 if __name__ == __main__:
app = QtGui.QApplication(sys.argv)
myapp = StartQT4()
myapp.show()
sys.exit(app.exec_())
 --
 Douglas E Knapp

 Amazon Gift Cards; let them choose!!

 http://www.amazon.com/gp/product/B001078FFE?ie=UTF8tag=seattlebujinkandlinkCode=as2camp=1789creative=9325creativeASIN=B001078FFE
 ___
 PyQt mailing listPyQt@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt

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

Re: [PyQt] Linking Qt statically into a project using embedded Python and Sip/PyQt

2009-02-04 Thread Ulrich Berning

George Goussard wrote:


Hello.

My project that I am currently working on is a cross-platform C++ 
project. On Linux 32-bit/64-bit I have the constraint that I MUST link 
Qt (4.3.3) in statically with the project. This is a given and cannot 
be compromised. I have successfully embedded Python into our 
application and with this facility I can run external Python *.py 
files. With the help of Sip/PyQt used in these *.py files I can route 
the output to a nice window inside my Qt application etc. etc. 
But,the problem is that it only works if I link Qt in dynamically 
to my application.


The reason(I think – when I link dynamically to Qt) is because my 
application loads the Qt *.so file dynamically when I startup the 
application. Then when the application runs an external *.py file and 
it has the line “from PyQt import QtCore” then I suppose that it sees 
the *.so is already loaded and uses it. Now my question: How can I 
either get the Python mechanism or Sip/PyQt to rather use the 
statically linked in Qt with my project?


Currently, if I link Qt statically into my application and run the 
*.py files I get some strange Qt message on the command line and then 
it crashes.


George.


The only way to do this, is to have everything statically linked:
- Build a static Python library
- Build a static SIP library
- Build static PyQt libraries

Use PyImport_ExtendInittab() to declare the module initialization 
functions for SIP and all PyQt modules you need in your application. 
This must be done before you initialize the python interpreter with 
Py_Initialize().


Ulli



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


[PyQt] Newbie with a circular problem calling problem

2009-02-04 Thread Matt Smith
 Have you noticed that QLineEdit emits a signal textEdited which is not
emitted when the text is changed with setText.

http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qlineedit.html#textEdited

and spin boxes emit the following

http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qabstractspinbox.html#editingFinished

so that might not happen if you set the value programmaticaly.

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


Re: [PyQt] Linking Qt statically into a project using embedded Python and Sip/PyQt

2009-02-04 Thread Giovanni Bajo

On 2/4/2009 4:42 PM, Ulrich Berning wrote:

George Goussard wrote:


Hello.

My project that I am currently working on is a cross-platform C++ 
project. On Linux 32-bit/64-bit I have the constraint that I MUST link 
Qt (4.3.3) in statically with the project. This is a given and cannot 
be compromised. I have successfully embedded Python into our 
application and with this facility I can run external Python *.py 
files. With the help of Sip/PyQt used in these *.py files I can route 
the output to a nice window inside my Qt application etc. etc. 
But,the problem is that it only works if I link Qt in dynamically 
to my application.


The reason(I think – when I link dynamically to Qt) is because my 
application loads the Qt *.so file dynamically when I startup the 
application. Then when the application runs an external *.py file and 
it has the line “from PyQt import QtCore” then I suppose that it sees 
the *.so is already loaded and uses it. Now my question: How can I 
either get the Python mechanism or Sip/PyQt to rather use the 
statically linked in Qt with my project?


Currently, if I link Qt statically into my application and run the 
*.py files I get some strange Qt message on the command line and then 
it crashes.


George.


The only way to do this, is to have everything statically linked:
- Build a static Python library
- Build a static SIP library
- Build static PyQt libraries

Use PyImport_ExtendInittab() to declare the module initialization 
functions for SIP and all PyQt modules you need in your application. 
This must be done before you initialize the python interpreter with 
Py_Initialize().


It should also work if you recompile a single dynamic library 
(python.so) with PyQt and SIP included within as builting modules.

--
Giovanni Bajo
Develer S.r.l.
http://www.develer.com


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


[PyQt] Slow loading times of PyQt .exe with Pyinstaller

2009-02-04 Thread eliben

Hello,

I've compiled a relatively simple GUI application with PyQt into an .exe
with Pyinstaller. The loading time of this .exe is very long (7-8 seconds).

When I compile it with py2exe instead (which seems to work great except that
one has to remember adding 'sip' as an explicit depenency), the loading time
is only 1-2 seconds. The executable is a bit larger (10 MB instead of 9 MB
with Pyinstaller).

Has anyone had similar experiences? Am I configuring Pyinstaller wrong?

Eli

-- 
View this message in context: 
http://www.nabble.com/Slow-loading-times-of-PyQt-.exe-with-Pyinstaller-tp21836942p21836942.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] Newbie with a circular problem calling problem

2009-02-04 Thread Matt Smith
Here is what is meant by programatically change.  And this is what I
mean by using the signals.  I don't know what widgets your actually
using, but if you can't find signals that are only emitted when you
want, then you'll have have to hand the signals differently.

(I beleive there has been some other suggestions.)

As a final option you could change the event handlers.

mbs


On Wed, 2009-02-04 at 21:11 +0100, Knapp wrote:
 On Wed, Feb 4, 2009 at 5:40 PM, Matt Smith mel...@orangepalantir.org wrote:
   Have you noticed that QLineEdit emits a signal textEdited which is not
  emitted when the text is changed with setText.
 
  http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qlineedit.html#textEdited
 
  and spin boxes emit the following
 
  http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qabstractspinbox.html#editingFinished
 
  so that might not happen if you set the value programmaticaly.
 
 Thanks very much for the help. I don't fully understand though. What
 do you mean by programmatically and which value do you mean? I am very
 new to all this.
 
 
 
#!/usr/bin/env python


test program



from PyQt4 import QtGui,QtCore

class TestWidget(QtGui.QWidget):
def __init__(self,parent=None):
QtGui.QWidget.__init__(self,parent)
layout = QtGui.QVBoxLayout()
self.labelA = QtGui.QLineEdit(self)
self.labelB = QtGui.QSpinBox(self)
self.connect(self.labelB,QtCore.SIGNAL(editingFinished()),self.programaticallyChangeA)
self.connect(self.labelA,QtCore.SIGNAL(textChanged( QString )),self.programaticallyChangeB)
layout.addWidget(self.labelA)
layout.addWidget(self.labelB)
self.setLayout(layout)
def programaticallyChangeB(self,text):
try:
self.labelB.setValue(int(text))
except:
pass
def programaticallyChangeA(self):
try:
self.labelA.setText(str(self.labelB.value()))
except:
pass
app = QtGui.QApplication([])
widge = TestWidget()
widge.show()
app.exec_()
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] defining QlistViewitem in python

2009-02-04 Thread klia

hello folks

i have this problems in my codes. i am try to link qfiledailoug with
qlistviewitem so that whenever i chose a file it would be loaded in
qlistview item using this function
self.item.append(QlistViewitem(self.tree, 'filename'))
but whenever i try that it gives me an attribute error so, how can i define
qlistviewitem in the following codes.

import sys
import shutil
from test import Ui_MainWindow as UIMW
from PyQt4 import QtCore, QtGui
import urllib2 as ulib
#import  QFileDialog.py
#from PyQt4 import QtGui
#from PyQt4 import QtCore

class MyWindow(QtGui.QMainWindow, UIMW):

def __init__(self):
QtGui.QMainWindow.__init__(self)
self.setupUi(self)
self.__setupConnections()


def __setupConnections(self):
self.connect(self.addphoto, QtCore.SIGNAL(clicked())
,self._addphotoClicked)
self.connect(self.addphotoandtag, QtCore.SIGNAL(clicked())
,self._addphotoandtagClicked)
self.connect(self.removephoto, QtCore.SIGNAL(clicked())
,self._removephotoClicked)
self.connect(self.searchphoto, QtCore.SIGNAL(clicked() )
,self._searchphotoClicked)
self.connect(self.cancel, QtCore.SIGNAL(clicked()), 
self._cancelClicked)
self.connect(self.actionImport_Photos, 
QtCore.SIGNAL(triggered())
self._actionImport_Photos)
self.connect(self.actionExit, QtCore.SIGNAL(triggered()),
self._actionExit)
self.connect(self.listView, QtCore.SIGNAL(triggered()), 
self._listView)


def _addphotoClicked(self):
shutil.copytree('/home/waseem/My Pictures/yemen 2008/2008/1', 
'/home/waseem/test')

def _addphotoandtagClicked(self):
pass

def _searchphotoClicked(self):
pass

def _removephotoClicked(self):
pass

def _FinishClicked(self):
pass

def _cancelClicked(self):
pass

def _actionImport_Photos(self):
filename = QtGui.QFileDialog.getOpenFileName(self, 'Import Photo',
'/home/')#, tr('Images (*.png *.xpm *.jpg)'));
#self.items=[]
self.item.append(QlistViewitem(self.tree, 'filename'))
   # file=open(filename)
#data = file.read()
#print data
#self.photosdisplay.read(data)

def _actionExit(self):
pass

def _listView(self):
pass
#class Import_Photos(QtGui.QMainWindow, UIMW):

if __name__==__main__:
  app=QtGui.QApplication(sys.argv)
  w=MyWindow()
  w.show()
  sys.exit(app.exec_())
-- 
View this message in context: 
http://www.nabble.com/defining-QlistViewitem-in-python-tp21846265p21846265.html
Sent from the PyQt mailing list archive at Nabble.com.

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


[PyQt] item delegates

2009-02-04 Thread Mads Ipsen
Hi,

Suppose I have a TableView. Then I can set itemdelegates for a column, a row
or the entire view using the respective methods

void setItemDelegateForColumn ( int column, QAbstractItemDelegate * delegate
)
void setItemDelegateForRow ( int row, QAbstractItemDelegate * delegate )
void setItemDelegate ( QAbstractItemDelegate * delegate )

All this is fine. But how do I specify a delegate for a single cell in the
table?

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