[PyQt] Re: PyQT lost reference (was: Re: PyKDE: KConfigSkeleton not writing configuration)

2009-03-13 Thread Till Gerken
Hi,

sorry for keeping replying to myself, but nobody else seems to show
interest and I am trying to find the root cause of the error:

The QString() that I am passing as reference to the C++ class
KCoreConfigSkeleton exists as local variable in my Python class
derived from KCoreConfigSkeleton. Now any code that interacts with
KCoreConfigSkeleton (C++ or Python) may change this QString instance.

Looking at the SIP file I see the following:

KCoreConfigSkeleton::ItemString*  addItemString (const QString name,
QString reference, const QString defaultValue = QLatin1String(),
const QString key = QString());

Could it be that this method declaration misses /In/ and /Out/ for
QString reference? The documentation on /In/ and /Out/ was not too
clear for me, could someone elaborate what happens exactly when these
statements are given?

Thanks,

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


Re: [PyQt] Re: PyQT lost reference (was: Re: PyKDE: KConfigSkeleton not writing configuration)

2009-03-13 Thread Phil Thompson
On Fri, 13 Mar 2009 11:15:41 +0100, Till Gerken till.ger...@gmail.com
wrote:
 Hi,
 
 sorry for keeping replying to myself, but nobody else seems to show
 interest and I am trying to find the root cause of the error:
 
 The QString() that I am passing as reference to the C++ class
 KCoreConfigSkeleton exists as local variable in my Python class
 derived from KCoreConfigSkeleton. Now any code that interacts with
 KCoreConfigSkeleton (C++ or Python) may change this QString instance.
 
 Looking at the SIP file I see the following:
 
 KCoreConfigSkeleton::ItemString*  addItemString (const QString name,
 QString reference, const QString defaultValue = QLatin1String(),
 const QString key = QString());
 
 Could it be that this method declaration misses /In/ and /Out/ for
 QString reference? The documentation on /In/ and /Out/ was not too
 clear for me, could someone elaborate what happens exactly when these
 statements are given?

By default SIP infers whether an argument is being passed into a function
or is only being used to return a value from the function according to the
type of the argument. /In/ and /Out/ allow you to be explicit about the
direction in case the default behaviour is wrong.

For a QString the default is that the argument is being passed into the
function. The fact that the string may be being updated doesn't qualify it
as being used to return a value in this context.

It looks like the omission of any /In/ or /Out/ is correct in this case.

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


[PyQt] Re: PyQT lost reference (was: Re: PyKDE: KConfigSkeleton not writing configuration)

2009-03-13 Thread Wolfgang Rohdewald
On Freitag, 13. März 2009, Till Gerken wrote:

 The QString() that I am passing as reference to the C++ class
 KCoreConfigSkeleton exists as local variable in my Python class
 derived from KCoreConfigSkeleton. Now any code that interacts with
 KCoreConfigSkeleton (C++ or Python) may change this QString instance.

this is because QString() is mutable while python strings are immutable.
When dealing with KCoreConfig, do not use QString as local variables,
always convert explicitly from/to python strings.

I wonder what happens with this when the QString will be eliminated
in PyQt4 as announced. That might break code which relies on 
QString being mutable.

See my message

http://www.mail-archive.com:80/pyqt@riverbankcomputing.com/msg16594.html

-- 
Wolfgang

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


Re: [PyQt] Re: PyQT lost reference (was: Re: PyKDE: KConfigSkeleton not writing configuration)

2009-03-13 Thread Phil Thompson
On Fri, 13 Mar 2009 11:44:57 +0100, Wolfgang Rohdewald
wolfg...@rohdewald.de wrote:
 On Freitag, 13. März 2009, Till Gerken wrote:
 
 The QString() that I am passing as reference to the C++ class
 KCoreConfigSkeleton exists as local variable in my Python class
 derived from KCoreConfigSkeleton. Now any code that interacts with
 KCoreConfigSkeleton (C++ or Python) may change this QString instance.
 
 this is because QString() is mutable while python strings are immutable.
 When dealing with KCoreConfig, do not use QString as local variables,
 always convert explicitly from/to python strings.

No, do exactly the opposite. If you pass a Python string then it will be
converted to a QString under the covers. Any changes to that QString will
then be discarded.

 I wonder what happens with this when the QString will be eliminated
 in PyQt4 as announced. That might break code which relies on 
 QString being mutable.

Which is why eliminating QStrings is an incompatible change and will
require changes to your code.

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


Re: [PyQt] Re: PyQT lost reference (was: Re: PyKDE: KConfigSkeleton not writing configuration)

2009-03-13 Thread Wolfgang Rohdewald
On Freitag, 13. März 2009, Phil Thompson wrote:

 Which is why eliminating QStrings is an incompatible change and will
 require changes to your code.

Sorry, it seems I misread your roadmap - I thought this would be a
compatible change.

-- 
Wolfgang

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


[PyQt] Executing function with argument under a button in pyqt

2009-03-13 Thread klia

hey guys;

I have this function that is suppose to extract Exif(exchangeable image
formate) from photos and direct the output to an .CSV file (comma seperated
values)

well the function syntax is like the following:

was...@home:~/Desktop/Project2/GUI$ python myexif.py -q waseem1.JPG 
test.csv

in the program now my photos are listed in ListWidget...
How can i select photo or multiple photos from the listwidget and execute
the above syntax after clicking a button which is already there in order to
create a CSV file??

Thanks in advance  
 
-- 
View this message in context: 
http://www.nabble.com/Executing-function-with-argument-under-a-button-in-pyqt-tp22496319p22496319.html
Sent from the PyQt mailing list archive at Nabble.com.

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


[PyQt] Reducing Ram Usage Tips?

2009-03-13 Thread Darryl Wallace

Hello,

I've recently developed a data analysis program using PyQt.  It's not a 
huge program but it's not small either.  I've noticed that, in Windows, 
the memory usage at startup is ~80MB.  I've removed all of the 'import 
*'s that I previously had and do not load the Qt module at any location.


I am packaging the entire library in the exe using py2exe.

Just wondering if anyone else has had any success bringing down the 
memory consumption.


Thanks,
Darryl

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


Re: [PyQt] Executing function with argument under a button in pyqt

2009-03-13 Thread klia



Till Gerken-2 wrote:
 
 On Fri, Mar 13, 2009 at 2:23 PM, klia alwaseem307s...@yahoo.com wrote:
 I have this function that is suppose to extract Exif(exchangeable image
 formate) from photos and direct the output to an .CSV file (comma
 seperated
 values)

 well the function syntax is like the following:

 was...@home:~/Desktop/Project2/GUI$ python myexif.py -q waseem1.JPG 
 test.csv

 in the program now my photos are listed in ListWidget...
 How can i select photo or multiple photos from the listwidget and execute
 the above syntax after clicking a button which is already there in order
 to
 create a CSV file??
 
 Just create a new method that you connect to your button's clicked()
 signal and include the Exif extraction code there. Since your Exif
 extraction already seems to be in Python, you do not have to execute
 any external programs.
 
 connect(yourButton, SIGNAL(clicked(bool)), yourExifMethod)
 
 The signal is documented here:
 http://doc.trolltech.com/4.4/qpushbutton.html#details
 http://doc.trolltech.com/4.4/qabstractbutton.html#clicked
 
 Till
 ___
 PyQt mailing listPyQt@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt
 
 
Thank you for replaying,

creating a connect method ain't a problem for me but how to select photo in
the ListWidget and then executing myexif functiion with -q argument?
-- 
View this message in context: 
http://www.nabble.com/Executing-function-with-argument-under-a-button-in-pyqt-tp22496319p22496972.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] derive from a designer widget

2009-03-13 Thread Mario Daniel Carugno
2009/3/13, Andreas Pakulat ap...@gmx.de:
   I want that it could be as simple as derivating the 'data' class
   from the 'main window' class. I've read that derivating a widget
   from another one, makes that widget to appear inside it's parent,
   right ?

 No thats wrong. Deriving one class from another is something different than
  adding a widget to a parent widget.

What about this ?

#!/bin/env python
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *

class Frame(QDialog):
   def __init__(self):
  QDialog.__init__(self)
  pass

class GUI(Frame):
   def __init__(self):
  Frame.__init__(self)
  b = QLabel(HOLA)
  l = QVBoxLayout()
  l.addWidget(b)
  self.setLayout(l)

if __name__ == __main__:
   app = QApplication(sys.argv)
   ui = GUI()
   ui.show()
   app.exec_()

This snippet creates a Frame and a widget as a subclass of it.
This is enough to make the widget appear into the Frame
I want to achieve that, but with Frame being a compound widget with its
central area, and that area being the default 'container' to hold
derived widgets.
I note that one problem with this using designer, is that designer creates
widgets subclassing 'object' instead of 'QWidget' or 'QDialog'. With the
main form derived from 'object' i can't make the above subclassing example.

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


Re: [PyQt] Reducing Ram Usage Tips?

2009-03-13 Thread Darryl Wallace

Hello Stan

stan wrote:

On Fri, 2009-03-13 at 09:37 -0400, Darryl Wallace wrote:
  

Hello,

I've recently developed a data analysis program using PyQt.  It's not a 
huge program but it's not small either.  I've noticed that, in Windows, 
the memory usage at startup is ~80MB.  I've removed all of the 'import 
*'s that I previously had and do not load the Qt module at any location.


I am packaging the entire library in the exe using py2exe.

Just wondering if anyone else has had any success bringing down the 
memory consumption.


Thanks,
Darryl



While there are a great number advantages to having a nice single
huge .exe, memory consumption is driven up as that entire .exe has to
be loaded in memory at one time, of course.  With the one directory
option in PyInstaller or py2exe, the .exe's themselves are quite small
by comparison, so that loading and speed generally are much faster out
of the gate as they make system calls as needed; of course memory
usage will then increase as needed, but in general, memory use seems
to remain much smaller.  Of course, the initial distribution directory
is often bigger (a one timer, usually), but later I have found that
simple updates, bug fixes, etc. don't require many additional dirctory
items (of course this depends on what you later add!), but total
subsequent distribution time is greatly simplified and is limited to the
new .exe and the simple occasional additions.
  
Ok that's one of the things that  I thought regarding the single 'exe' 
file. 

Did you happen to avoid using the QTCore4.dll and QtGui4.dll? (you
mentioned not having loaded the Qt modules) Can these be avoided in
favor of the PyQt dll's??  Those are very large, but I think they must
be always and unavoidably pulled in by PyQt??
  
From what I've read and my experience you cannot avoid including the Qt 
dll's.  While they're very large relatively speaking, my entire 
program approaches a 21 MB zipped download; acceptable as far as I'm 
concerned.


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


Re: [PyQt] Executing function with argument under a button in pyqt

2009-03-13 Thread Till Gerken
On Fri, Mar 13, 2009 at 2:59 PM, klia alwaseem307s...@yahoo.com wrote:
 Till Gerken-2 wrote:
 On Fri, Mar 13, 2009 at 2:23 PM, klia alwaseem307s...@yahoo.com wrote:
 I have this function that is suppose to extract Exif(exchangeable image
 formate) from photos and direct the output to an .CSV file (comma
 seperated
 values)

 well the function syntax is like the following:

 was...@home:~/Desktop/Project2/GUI$ python myexif.py -q waseem1.JPG 
 test.csv

 in the program now my photos are listed in ListWidget...
 How can i select photo or multiple photos from the listwidget and execute
 the above syntax after clicking a button which is already there in order
 to
 create a CSV file??

 Just create a new method that you connect to your button's clicked()
 signal and include the Exif extraction code there. Since your Exif
 extraction already seems to be in Python, you do not have to execute
 any external programs.

 connect(yourButton, SIGNAL(clicked(bool)), yourExifMethod)

 The signal is documented here:
 http://doc.trolltech.com/4.4/qpushbutton.html#details
 http://doc.trolltech.com/4.4/qabstractbutton.html#clicked

 creating a connect method ain't a problem for me but how to select photo in
 the ListWidget and then executing myexif functiion with -q argument?

For selecting an item in the list widget and retrieving an item see
QListWidget::setCurrentItem() and QListWidget::currentItem():

http://doc.trolltech.com/4.4/qlistwidget.html#currentItem
http://doc.trolltech.com/4.4/qlistwidget.html#setCurrentItem

If the list item is changed, currentItemChanged() is emitted:

http://doc.trolltech.com/4.4/qlistwidget.html#currentItemChanged

And for executing, why do you want to run a Python script as external
application rather than just embedding it into your own script? But if
you really want to run it as external application, see os.exec*():

http://docs.python.org/library/os.html#process-management

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


Re: [PyQt] Reducing Ram Usage Tips?

2009-03-13 Thread stan
OK, Darryl, thanks for that time saving response! I was pretty sure
that was the case.  Hope the other solution helps you some... will post
again if I find anything relevant as I continue on...!

On Fri, 2009-03-13 at 10:44 -0400, Darryl Wallace wrote:
 Hello Stan
 
 stan wrote:
  On Fri, 2009-03-13 at 09:37 -0400, Darryl Wallace wrote:

  Hello,
 
  I've recently developed a data analysis program using PyQt.  It's not a 
  huge program but it's not small either.  I've noticed that, in Windows, 
  the memory usage at startup is ~80MB.  I've removed all of the 'import 
  *'s that I previously had and do not load the Qt module at any location.
 
  I am packaging the entire library in the exe using py2exe.
 
  Just wondering if anyone else has had any success bringing down the 
  memory consumption.
 
  Thanks,
  Darryl
 
  
  While there are a great number advantages to having a nice single
  huge .exe, memory consumption is driven up as that entire .exe has to
  be loaded in memory at one time, of course.  With the one directory
  option in PyInstaller or py2exe, the .exe's themselves are quite small
  by comparison, so that loading and speed generally are much faster out
  of the gate as they make system calls as needed; of course memory
  usage will then increase as needed, but in general, memory use seems
  to remain much smaller.  Of course, the initial distribution directory
  is often bigger (a one timer, usually), but later I have found that
  simple updates, bug fixes, etc. don't require many additional dirctory
  items (of course this depends on what you later add!), but total
  subsequent distribution time is greatly simplified and is limited to the
  new .exe and the simple occasional additions.

 Ok that's one of the things that  I thought regarding the single 'exe' 
 file. 
  Did you happen to avoid using the QTCore4.dll and QtGui4.dll? (you
  mentioned not having loaded the Qt modules) Can these be avoided in
  favor of the PyQt dll's??  Those are very large, but I think they must
  be always and unavoidably pulled in by PyQt??

  From what I've read and my experience you cannot avoid including the Qt 
 dll's.  While they're very large relatively speaking, my entire 
 program approaches a 21 MB zipped download; acceptable as far as I'm 
 concerned.
 
 Darryl
 

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


Re: [PyQt] derive from a designer widget

2009-03-13 Thread Andreas Pakulat
On 13.03.09 12:18:24, Mario Daniel Carugno wrote:
 2009/3/13, Andreas Pakulat ap...@gmx.de:
I want that it could be as simple as derivating the 'data' class
from the 'main window' class. I've read that derivating a widget
from another one, makes that widget to appear inside it's parent,
right ?
 
  No thats wrong. Deriving one class from another is something different than
   adding a widget to a parent widget.
 
 What about this ?
 
 #!/bin/env python
 import sys
 from PyQt4.QtCore import *
 from PyQt4.QtGui import *
 
 class Frame(QDialog):
def __init__(self):
   QDialog.__init__(self)
   pass
 
 class GUI(Frame):
def __init__(self):
   Frame.__init__(self)
   b = QLabel(HOLA)
   l = QVBoxLayout()
   l.addWidget(b)
   self.setLayout(l)
 
 if __name__ == __main__:
app = QApplication(sys.argv)
ui = GUI()
ui.show()
app.exec_()
 
 This snippet creates a Frame and a widget as a subclass of it.

No its not, you're mixing different terms here. A subclass (aka derived
class) in python is created by this statement:

class Foo(Bar):
...

In this case Foo is a subclass of Bar.

However in the above example (with the magic re-parenting of
QLayoutQWidget) b is just a child widget inside your Frame.

 This is enough to make the widget appear into the Frame
 I want to achieve that, but with Frame being a compound widget with its
 central area, and that area being the default 'container' to hold
 derived widgets.

Then you should do similar to what QMainWindow does, provide a
setCentralWidget() method which takes a complete widget and uses for the
central area of the window.

 I note that one problem with this using designer, is that designer creates
 widgets subclassing 'object' instead of 'QWidget' or 'QDialog'. With the
 main form derived from 'object' i can't make the above subclassing example.

Thats because Qt designer doesn't design any widgets. You design a template
of how your gui should look like and then you can apply that template to a
given QWidget. That will create the designed gui inside the given QWidget.
Afterwards you can add that QWidget into any layout and the GUI will show
up inside that layout.

Maybe you should have a closer look at the PyQt examples and maybe check
out Mark Summerfields book on PyQt. It seems your missing some of the
basics of Qt GUI's.

Andreas

-- 
You will pioneer the first Martian colony.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Re: PyQT lost reference (was: Re: PyKDE: KConfigSkeleton not writing configuration)

2009-03-13 Thread Till Gerken
On 3/13/09, Phil Thompson p...@riverbankcomputing.com wrote:
 On Fri, 13 Mar 2009 11:44:57 +0100, Wolfgang Rohdewald
 wolfg...@rohdewald.de wrote:
 On Freitag, 13. März 2009, Till Gerken wrote:

 The QString() that I am passing as reference to the C++ class
 KCoreConfigSkeleton exists as local variable in my Python class
 derived from KCoreConfigSkeleton. Now any code that interacts with
 KCoreConfigSkeleton (C++ or Python) may change this QString instance.

 this is because QString() is mutable while python strings are immutable.
 When dealing with KCoreConfig, do not use QString as local variables,
 always convert explicitly from/to python strings.

 No, do exactly the opposite. If you pass a Python string then it will be
 converted to a QString under the covers. Any changes to that QString will
 then be discarded.

The weird thing in this case is that the changes made by
KCoreConfigSkeleton are discarded. Even if I call
KCoreConfigSkeleton::ItemString::setValue(), the referenced QString is
not updated (although it will then be written to disk correctly). This
suggests that two instances of the same QString exist.

I can live with the workaround calling
KCoreConfigSkeleton::ItemString::setValue() and getValue(), but I
wonder where the bug is.

Any pointers would be appreciated.

Till

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


[PyQt] QDataStream and arbitrary Python objects

2009-03-13 Thread Scott Ballard




I'm a bit of a PyQt newbie but have
plenty of Python experience.

Does anyone know if arbitrary Python objects will be supported by
QDataStream in PyQt 4.5?

I'm looking for a method of using PyQts model/view programming and its
drag and drop functionality with Python's base object class which
doesn't seem to be supported. Surprisingly, it seems that QDataStream
doesn't even support QObject (unless I'm missing something)

Many thanks!
-Scott





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

Re: [PyQt] Executing function with argument under a button in pyqt

2009-03-13 Thread Scott Ballard




I came across this link while I was
trying to do the same thing. It explained everything and might help you
with passing arguments.

http://blog.qgis.org/node/102

Cheers,
-Scott



klia wrote:

  

Till Gerken-2 wrote:
  
  
On Fri, Mar 13, 2009 at 2:23 PM, klia alwaseem307s...@yahoo.com wrote:


  I have this function that is suppose to extract Exif(exchangeable image
formate) from photos and direct the output to an .CSV file (comma
seperated
values)

well the function syntax is like the following:

was...@home:~/Desktop/Project2/GUI$ python myexif.py -q waseem1.JPG 
test.csv

in the program now my photos are listed in ListWidget...
How can i select photo or multiple photos from the listwidget and execute
the above syntax after clicking a button which is already there in order
to
create a CSV file??
  

Just create a new method that you connect to your button's clicked()
signal and include the Exif extraction code there. Since your Exif
extraction already seems to be in Python, you do not have to execute
any external programs.

connect(yourButton, SIGNAL("clicked(bool)"), yourExifMethod)

The signal is documented here:
http://doc.trolltech.com/4.4/qpushbutton.html#details
http://doc.trolltech.com/4.4/qabstractbutton.html#clicked

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



  
  Thank you for replaying,

creating a connect method ain't a problem for me but how to select photo in
the ListWidget and then executing myexif functiion with -q argument?
  



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