Re: [PyQt] python cxfreeze package pyqt app lost icon and tray icon

2010-09-16 Thread Von
WOW,I resolved it finally.
I create a setup.py file scratch from cx_setup.py which from Armando.
The main purpose of the setup.py is to include plugins of PyQt4.Then build
with command:python setup.py build
That's all I have done,the icon shows.
Thank you Armando and Hans.

Bests,

On Thu, Sep 16, 2010 at 9:16 PM, "V. Armando Solé"  wrote:

>  Hi Von,
>
>
> On 16/09/2010 08:38, Von wrote:
>
>> Hi,
>> Here is my command:
>> cxfreeze --target-dir=AutoOrder gui.py
>> --base-name=D:\Python31\Lib\site-packages\cx_Freeze\bases\Win32GUI.exe
>> --include-path=. -z icon.jpg
>>
>> Both app icon and tray icon used icon.jpg
>>
>> Regards,
>>
>>
> I had similar problems in the past and they were due to the generated
> binary not finding the qt libraries. I do not know if those issues are
> automatically handled by cx_freeze now.
>
> I solved them adding a qtconffile saying where to find them in the frozen
> binary.
>
> You can take a look at the cx_setup.py and the qtconffile files found in
> the pymca svn repository (http://pymca.svn.sourceforge.net/viewvc/pymca/ )
>
> Best regards,
>
> Armando
>
>
> ___
> 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] Howto use the Qt documentation successfully.

2010-09-16 Thread Algis Kabaila
On Tuesday 14 September 2010 19:08:23 Hans-Peter Jansen wrote:
> Just a few words on methology:
> 
> Searching for some functionality of QTextEdit, e.g. how to get at a
> specific line via line number:
>  * Look up QTextEdit in assistant
>We read: The QTextEdit class provides a widget that is used to edit and
>display both plain and rich text.
>  * Click on more...
>We read: QTextEdit works on paragraphs and characters. A paragraph is a
>formatted string which is word-wrapped to fit into the width of the
>widget. By default when reading plain text, one newline signifies a
>paragraph.
>Sounds like we're looking for paragraphs in plain text mode
>  * Check class methods, that do what we want:
>Nothing obvious stands out
>  * Check base classes:
>QTextEdit inherits from QAbstractScrollArea only, that won't help us
>much here
>  * Check methods again:
>Nothing obvious with paragraphs, but QTextDocument * document() might be
>interesting
>  * Click on document() method:
>We read: Returns a pointer to the underlying document.
>  * Check it out: click on QTextDocument
>We read: The QTextDocument class holds formatted text that can be viewed
>and edited using a QTextEdit
>We're getting nearer, but still no ball: check out class methods
>  * It has a method: QTextBlock findBlockByLineNumber ( int lineNumber )
>Sounds like the best fit: click on method
>  * We read: Returns the text block that contains the specified lineNumber.
>What the hell is a QTextBlock? Click:
>It encapsulates text fragments, and provides access to them
>  * Check methods: QString text() sounds, like what we are looking for
>We read: Returns the block's contents as plain text.
> Target reached.
> Pete

Pete, your detailed outline is so good that I am going to save it to my 
private moin-moin wiki!

I saw a complaint in this thread (I can not find it now...) that all a newbie 
can do is to modify some existing example to adapt it to some problem at hand.  
IMHO that is about the best way to learn as long as one picks a suitable 
prototype, viz. a GUI in chapter 6 of Mark Summerfield's book!

Thank you again, Pete. 

IMO, more tutorial material could be useful.  Pete, would you encourage 
tutorials written by newbies for newbies?  

Al.

-- 
OldAl
akaba...@pcug.org.au
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] KConfigSkeleton and pyqt4 API version 2

2010-09-16 Thread Wolfgang Rohdewald
Hi, 

this code prints random output. How should I fix this?

import sip
sip.setapi('QString', 2)

from PyKDE4.kdeui import KConfigSkeleton

a = KConfigSkeleton()
name = 'tilesetName'
value = 'I am a value'
s = a.addItemString(name, value)
print s.value()

== output: ==
value is: 䱀Ɨ!䱠Ɨ彐Ɨ美繈
*** glibc detected *** python: corrupted double-linked list: 
0x01975f50 ***



ii  python-qt4 
4.7.3-1ubuntu2~lucid1~ppa3  Python bindings 
for Qt4

ii  python-kde4
4:4.5.1-0ubuntu1~lucid1~ppa1Python bindings 
for the KDE 4 libraries


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

[PyQt] QsciAPIs usage

2010-09-16 Thread dusan smitran
Has anyone got a good example on how to use the QsciApi module?
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Advice for thread/process output logging, Windows debugging

2010-09-16 Thread Erik Janssens

Hello Steve,

We've ran in more or less the same issues with the recent
refactoring of Camelot, here are some things I learned
(but I haven't found a decent solution yet) :

- those kind of bugs tend to appear more frequent on windows
  than on Linux, I don't know why.  But they happen on Linux
  as well.  The best way to discover them is build stress tests
  and run the garbage collector explicitly in your test

- try to reproduce them with stress tests on Linux, since
  debugging on Linux with gdb is much easier

- you can as well disable the garbage collector to see if it
  prevents the crashes, it usually does

- those crashes are related to ownership problems, see the in
  depth explanation of Phil :

http://www.riverbankcomputing.com/pipermail/pyqt/2010-September/027705.html

- there are issues when exceptions have been raised in python,
  since this keeps a stack trace alive with potential references
  to objects

- some typical pythonic constructions should be avoided inside
  methods of Qt objects, like closures involving other Qt objects
  or construction of inner classes, they create difficult to track
  references

If you learn more on this subject, I'd be very interested.

Regards,

Erik

On Thu, 2010-09-16 at 14:48 -0500, Steve Borho wrote:
> Before I get to my questions, I want to congratulate you folks for
> such a tremendous toolkit.   I can only imagine how much further along
> TortoiseHg would be today if we had selected PyQt from the start
> (which was my suggestion at the time).
> 
> Our port from PyGtk is progressing very well, but we've run into a few
> snags that I would like some advice about.  Both have to do with
> Mercurial commands running as Python code in a Qthread.  We're giving
> Mercurial a modified "user interface" object that captures output
> messages and progress reports and emits them as PyQt signals [1].
> 
> What we've found is that this is fairly inefficient; commands run an
> order of magnitude slower than they do on the console, and they get
> progressively slower the longer the application is alive.  I'm
> contemplating various buffering techniques to cut down on the number
> of signals, but I'm curious if people have other suggestions for
> making this more efficient.
> 
> The second problem is that on Windows this setup can cause hard
> crashes after spewing a number of messages to the console like
> 'QObject::KillTimers: timers cannot be stopped from another thread'.
> Disabling the output and progress signals does not prevent these
> crashes, they seemed to be triggered by garbage collection, but I've
> been unable to determine which objects are the problematic ones.  And
> I've been unable to reproduce the crash on Linux or Mac.   What's the
> best way to debug this?   I've downloaded the Python source and
> compiled a python_d.exe and dll, but even though I thought I built the
> same revision as the 2.6.5 release I have installed, it appears to
> reject all the compiled modules in my C:\Python26 folder.
> 
> Is there a way to make PyQt emit more verbose error messages?
> 


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


Re: [PyQt] Image type RAW destroyed by PyQt

2010-09-16 Thread Vincent Vande Vyvre




Le 16/09/10 12:59, Dan Halbert a écrit :
 On
9/16/2010 4:02 AM, Vincent Vande Vyvre wrote:
  
  If an image is type RAW, (.CR2, .RAF, .3FR,
.MRW etc) an image format .tiff is automatically created

and replace the RAW file. The original file is lost.

  
Could you give a short test program that reproduces the problem? Sounds
like it only needs to read the file and maybe generate a thumbnail. 
--Dan
  
  
___
  
PyQt mailing list    PyQt@riverbankcomputing.com
  
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
  
  

Hello,

Thanks for the respons.

Well, any trivial code may reproduce the problem :

folder = /folder/with/image/files
images = glob.glob(folder)
for image in images:
 img = QtGui.QImage(image)
 if not img.isNull():
  set_thumbnail(img)

If you have some RAW type of image in the folder, these files 
are converted in .tiff and the original files are lost.

(RAW images are downloadable here : http://www.rawsamples.ch)

I know, I can filter the list before process, but this isn't the
question.

After reading the doc, I believed that Qt did not support RAW type.

Actually, I'm implementing the support of RAW files in my application
Oqapy.
I use, for this, the librairy Dcraw for extract thumbnails, metadatas, 
convert images to .tiff, etc.

At this end and for testing, I have a folder with some images in RAW
type.

The probleme : if I open (accidentally) this folder with the last
version of Oqapy,
witch NOT yet support RAW type, all files is convert immediatelly in
.tiff format.

Bad surprise, no ?

I investigate in Qt doc, Faq and forum and, maybe, I'll post a bug.

Thanks again.

Cheers.

-- 
Vincent V.V.
Oqapy



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

[PyQt] Advice for thread/process output logging, Windows debugging

2010-09-16 Thread Steve Borho
Before I get to my questions, I want to congratulate you folks for
such a tremendous toolkit.   I can only imagine how much further along
TortoiseHg would be today if we had selected PyQt from the start
(which was my suggestion at the time).

Our port from PyGtk is progressing very well, but we've run into a few
snags that I would like some advice about.  Both have to do with
Mercurial commands running as Python code in a Qthread.  We're giving
Mercurial a modified "user interface" object that captures output
messages and progress reports and emits them as PyQt signals [1].

What we've found is that this is fairly inefficient; commands run an
order of magnitude slower than they do on the console, and they get
progressively slower the longer the application is alive.  I'm
contemplating various buffering techniques to cut down on the number
of signals, but I'm curious if people have other suggestions for
making this more efficient.

The second problem is that on Windows this setup can cause hard
crashes after spewing a number of messages to the console like
'QObject::KillTimers: timers cannot be stopped from another thread'.
Disabling the output and progress signals does not prevent these
crashes, they seemed to be triggered by garbage collection, but I've
been unable to determine which objects are the problematic ones.  And
I've been unable to reproduce the crash on Linux or Mac.   What's the
best way to debug this?   I've downloaded the Python source and
compiled a python_d.exe and dll, but even though I thought I built the
same revision as the 2.6.5 release I have installed, it appears to
reject all the compiled modules in my C:\Python26 folder.

Is there a way to make PyQt emit more verbose error messages?

-- 
Steve Borho

[1] http://bitbucket.org/tortoisehg/thg/src/tip/tortoisehg/hgqt/thread.py
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Newbie QMainWindow tips

2010-09-16 Thread fpp
On Thu, Sep 16, 2010 at 7:46 PM, Eric Frederich
 wrote:
>
> I think that seems to be my problem.
> Just way too many ways to skin this cat.
> I'd hate to say something good about Java (especially now that they're owned
> by Orable) but there were much less options for me to get overwhelmed with.
> Perhaps after I'm done being overwhelmed I'll welcome the multitude of
> options.
> Its just at this early stage I don't want to start going down the wrong
> path.

Choosing is always an effort, but better several choices than none IMHO...

A large part of my initial relationship with (Py)Qt has consisted of
spending an hour to write fifty lines of (working) code... then spend
another two bringing that line count to five or so, after discovering
the magic API I had been duplicating :-)

Now I spend more time upfront in the Qt docs, and looking for prior
art on the Web (of which there is a lot), and things are much
smoother.

One particular thing that tripped me badly in the early days, being
not well versed in object-oriented practice, was working from the PyQt
docs on the Riverbank website.

They're useful and indispensable in that they alone explain the
differences between the C++ Qt APIs and their Python equivalents.
Their drawback is that they *only* present the APIs (slots, signals
etc.) that are specific to the current object. I often puzzled why a
given object didn't offer a way to do this and that, only to realize
afterwards that it did have that method, but inherited from parent
classes several levels above, sometimes all the way back to QWidget...
The Qt version offers to list everything an object has to offer,
inherited or not, which is easier on newbies (if sometimes
overwhelming :-).

Learning to walk, then to ride a bike, is difficult too. But you get a
lot of mileage after that (bad pun intended).
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Newbie QMainWindow tips

2010-09-16 Thread Eric Frederich
On Thu, Sep 16, 2010 at 1:27 PM, fpp  wrote:

> On Thu, Sep 16, 2010 at 7:24 PM, Eric Frederich
>  wrote:
> >
> > So if I connect the tab bar's currentChanged(int) signal to a dock
> widget's
> > method, where does the dock widget get the data from?
> > Would the dock widget instance need to have a pointer to the the tab
> widget
> > or to something else?
> > This is what I'm confused about.
>
> There is always a way :-)
>
> Easiest here is for the dockwidget to query the tabwidget for its
> current index (active tab), there is a method for that.
>

I think that seems to be my problem.
Just way too many ways to skin this cat.
I'd hate to say something good about Java (especially now that they're owned
by Orable) but there were much less options for me to get overwhelmed with.
Perhaps after I'm done being overwhelmed I'll welcome the multitude of
options.
Its just at this early stage I don't want to start going down the wrong
path.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] Fwd: Newbie QMainWindow tips

2010-09-16 Thread fpp
Sorry, did it again ! :-)


-- Forwarded message --
From: fpp 
Date: Thu, Sep 16, 2010 at 7:27 PM
Subject: Re: [PyQt] Newbie QMainWindow tips
To: Eric Frederich 


On Thu, Sep 16, 2010 at 7:24 PM, Eric Frederich
 wrote:
>
> So if I connect the tab bar's currentChanged(int) signal to a dock widget's
> method, where does the dock widget get the data from?
> Would the dock widget instance need to have a pointer to the the tab widget
> or to something else?
> This is what I'm confused about.

There is always a way :-)

Easiest here is for the dockwidget to query the tabwidget for its
current index (active tab), there is a method for that.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Newbie QMainWindow tips

2010-09-16 Thread Eric Frederich
On Thu, Sep 16, 2010 at 11:55 AM, fpp  wrote:

> On Thu, Sep 16, 2010 at 5:02 PM, Eric Frederich
>  wrote:
> > Trying to get my first PyQt MainWindow application going.
> > Its going to be to edit multiple [we'll just call them] documents in
> tabs.
> > I will have several dockwidgets that need to correspond to the currently
> > selected tab.
> > So when the tab changes, or the data within the document changes, several
> > dockwidgets need to be kept in sync.
> > Some questions.
> > 1) How do I create static members for these dockwidgets on my subclass of
> > QMainWindow?
> > I'd like to do this so I don't have to pass around the actual reference
> to
> > an instance of the subclass (just import MyMainWindow at the top and get
> it
> > using MyMainWindow.dockWidgetX).
> > Right now I'm creating them during __init__ of my QMainWindow subclass
> and
> > they actually take references to other instance objects but I can
> re-factor
> > it to get those things later on.
> > Is having static members an advisable thing to do?  If not, please tell
> me a
> > better way to do it.  Passing around instances of the main window seems
> like
> > its wrong to me, but again, I'm a newbie.
>
> I'm not sure I understand this one correctly, but if you create your
> project with eric4 (and thus design your UI with Qt Designer), that is
> exactly the result you will get, so it's probably good practice...
>
> > 2) What is a good strategy for keeping the dock widgets in sync?
>
> The standard Qt way is to connect the signal emitted by the tab bar
> when you change tabs, to a slot (method) in your dock widgets so they
> will update their contents accordingly.
>

fpp, you didn't 'reply to all'
Since I'm replying to you I'm bringing the discussion back to the mailing
list.

In regard to question 2)
So if I connect the tab bar's currentChanged(int) signal to a dock widget's
method, where does the dock widget get the data from?
Would the dock widget instance need to have a pointer to the the tab widget
or to something else?
This is what I'm confused about.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Basic SIP

2010-09-16 Thread zhang jian
Hi,

I am a beginner as well. May be helpful to check my step-by-step note about
the hello SIP tst:

http://cid-a6597afda81373ba.spaces.live.com/blog/cns!A6597AFDA81373BA!1260.entry

It is on Mac though, but I think it should work on Windows, just need to set
the VC projects.

zhang

On Thu, Sep 16, 2010 at 4:50 PM, Mico Siahaan wrote:

> Dear all,
>
> I am learning SIP and I made simple source like this:
>
> //spam.cpp
>
> #include "spam.h"
>
> int spam_system(const char *command);
>
> int main(int argc, char **argv )
> {
> spam_system(argv[1]);
> return 0;
> }
>
> int spam_system(const char *command)
> {
> int sts;
> sts = system(command);
> return sts;
> }
>
>
> spam.h is in the same folder of spam.cpp and containing:
>
> // spam.h
> #include 
>
> int spam_system(const char *command);
>
>
> Then I made simple setup.py:
>
> from distutils.core import setup, Extension
> import sipdistutils
>
> setup(
>   name = 'spam',
>   version ='0.1',
>   ext_modules = [
> Extension("spam", ["spam.sip", "spam.cpp"])
> ],
>   cmdclass = {'build_ext': sipdistutils.build_ext}
>  )
>
> with spam.sip:
>
> /* Define the SIP wrapper to the spam library. */
>
> %Module spam 0
>
> %ModuleHeaderCode
> #include "spam.h"
> %End
>
> int spam_system(const char *command);
>
>
> Then run 'python.exe setup.py build'. But then I got error messages
>
> spam.sip(6) : fatal error C1083: Cannot open include file: 'spam.h': No
> such file or directory
> error: command '"C:\Program Files\Microsoft Visual Studio
> 9.0\VC\BIN\cl.exe"' failed with exit status 2
>
> My question: where shall I put spam.h then so sip can compile it
> successfully? How is the best structure of building python binding with sip?
> And sorry for the long email.
>
> --
> Mico | mico.siah...@gmail.com | @bangmico
>
>
> ___
> PyQt mailing listPyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] Newbie QMainWindow tips

2010-09-16 Thread Eric Frederich
Trying to get my first PyQt MainWindow application going.
Its going to be to edit multiple [we'll just call them] documents in tabs.
I will have several dockwidgets that need to correspond to the currently
selected tab.

So when the tab changes, or the data within the document changes, several
dockwidgets need to be kept in sync.

Some questions.

1) How do I create static members for these dockwidgets on my subclass of
QMainWindow?
I'd like to do this so I don't have to pass around the actual reference to
an instance of the subclass (just import MyMainWindow at the top and get it
using MyMainWindow.dockWidgetX).
Right now I'm creating them during __init__ of my QMainWindow subclass and
they actually take references to other instance objects but I can re-factor
it to get those things later on.
Is having static members an advisable thing to do?  If not, please tell me a
better way to do it.  Passing around instances of the main window seems like
its wrong to me, but again, I'm a newbie.

2) What is a good strategy for keeping the dock widgets in sync?

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

Re: [PyQt] python cxfreeze package pyqt app lost icon and tray icon

2010-09-16 Thread Hans-Peter Jansen
On Thursday 16 September 2010, 15:57:07 Von wrote:
> Hi,Armando thanks for your advice,it seems more complicated.
> I wonder is there a simple way to resolve it?

You might want to try PyInstaller, that has a better dependency resolution.

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


Re: [PyQt] python cxfreeze package pyqt app lost icon and tray icon

2010-09-16 Thread Von
Hi,Armando thanks for your advice,it seems more complicated.
I wonder is there a simple way to resolve it?

On Thu, Sep 16, 2010 at 9:16 PM, "V. Armando Solé"  wrote:

>  Hi Von,
>
>
> On 16/09/2010 08:38, Von wrote:
>
>> Hi,
>> Here is my command:
>> cxfreeze --target-dir=AutoOrder gui.py
>> --base-name=D:\Python31\Lib\site-packages\cx_Freeze\bases\Win32GUI.exe
>> --include-path=. -z icon.jpg
>>
>> Both app icon and tray icon used icon.jpg
>>
>> Regards,
>>
>>
> I had similar problems in the past and they were due to the generated
> binary not finding the qt libraries. I do not know if those issues are
> automatically handled by cx_freeze now.
>
> I solved them adding a qtconffile saying where to find them in the frozen
> binary.
>
> You can take a look at the cx_setup.py and the qtconffile files found in
> the pymca svn repository (http://pymca.svn.sourceforge.net/viewvc/pymca/ )
>
> Best regards,
>
> Armando
>
>
> ___
> 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] python cxfreeze package pyqt app lost icon and tray icon

2010-09-16 Thread Von
I did import the rc file in the Main.py and use cxfreeze --include-module
option to include the rc module
I made a gui bundle,so there wasn't any dos output.

On Thu, Sep 16, 2010 at 8:32 PM, Hans-Peter Jansen  wrote:

> On Thursday 16 September 2010, 13:30:28 Von wrote:
> > Hi Hans,strange thing happens
> > I put my icon.jpg file into the qrc file and compile it to py file.when I
> > run my Main.py directly I can see the icon show up correctly,but while I
> > use cxfreeze to package it,then it can't find the resource at all.Here is
> > my simple code:
> > pixmap = QtGui.QPixmap(":/icon.jpg") #:/icon.jpg is my resource name.
> > assert(pixmap.isNull() == False)  --> #this line raise AssertionError
>
> You need to include the module, you created beforehand.
>
> It might be, that cx_freeze misses other modules/libs as well. Did
> something
> appear on the DOS shell, if running from there?
>
> Pete
>
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] python cxfreeze package pyqt app lost icon and tray icon

2010-09-16 Thread V. Armando Solé

 Hi Von,

On 16/09/2010 08:38, Von wrote:

Hi,
Here is my command:
cxfreeze --target-dir=AutoOrder gui.py 
--base-name=D:\Python31\Lib\site-packages\cx_Freeze\bases\Win32GUI.exe 
--include-path=. -z icon.jpg


Both app icon and tray icon used icon.jpg

Regards,



I had similar problems in the past and they were due to the generated 
binary not finding the qt libraries. I do not know if those issues are 
automatically handled by cx_freeze now.


I solved them adding a qtconffile saying where to find them in the 
frozen binary.


You can take a look at the cx_setup.py and the qtconffile files found in 
the pymca svn repository (http://pymca.svn.sourceforge.net/viewvc/pymca/ )


Best regards,

Armando

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


Re: [PyQt] python cxfreeze package pyqt app lost icon and tray icon

2010-09-16 Thread Hans-Peter Jansen
On Thursday 16 September 2010, 13:30:28 Von wrote:
> Hi Hans,strange thing happens
> I put my icon.jpg file into the qrc file and compile it to py file.when I
> run my Main.py directly I can see the icon show up correctly,but while I
> use cxfreeze to package it,then it can't find the resource at all.Here is
> my simple code:
> pixmap = QtGui.QPixmap(":/icon.jpg") #:/icon.jpg is my resource name.
> assert(pixmap.isNull() == False)  --> #this line raise AssertionError

You need to include the module, you created beforehand.

It might be, that cx_freeze misses other modules/libs as well. Did something 
appear on the DOS shell, if running from there?

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


Re: [PyQt] python cxfreeze package pyqt app lost icon and tray icon

2010-09-16 Thread Von
Hi Hans,strange thing happens
I put my icon.jpg file into the qrc file and compile it to py file.when I
run my Main.py directly I can see the icon show up correctly,but while I use
cxfreeze to package it,then it can't find the resource at all.Here is my
simple code:
pixmap = QtGui.QPixmap(":/icon.jpg") #:/icon.jpg is my resource name.
assert(pixmap.isNull() == False)  --> #this line raise AssertionError

On Thu, Sep 16, 2010 at 6:23 PM, Hans-Peter Jansen  wrote:

> On Thursday 16 September 2010, 08:38:00 Von wrote:
> > Hi,
> > Here is my command:
> > cxfreeze --target-dir=AutoOrder gui.py
> > --base-name=D:\Python31\Lib\site-packages\cx_Freeze\bases\Win32GUI.exe
> > --include-path=. -z icon.jpg
>
> I haven't used cx_freeze, but why don't you wrap them into a python module
> with pyrcc4. The deleayedencoding example, I've send to the list lately,
> includes an Makefile for that task. BTW, pyrcc4 is able to wrap any data
> files, translation files, etc..
>
> > Both app icon and tray icon used icon.jpg
>
> Pete
> ___
> 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] Image type RAW destroyed by PyQt

2010-09-16 Thread Dan Halbert

 On 9/16/2010 4:02 AM, Vincent Vande Vyvre wrote:
If an image is type RAW, (.CR2, .RAF, .3FR, .MRW etc) an image format 
.tiff is automatically created

and replace the RAW file. The original file is lost.
Could you give a short test program that reproduces the problem? Sounds 
like it only needs to read the file and maybe generate a thumbnail.  --Dan


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


Re: [PyQt] Why am I missing a mouseRelease event in QWidget and QGLWidget?

2010-09-16 Thread Hans-Peter Jansen
On Thursday 16 September 2010, 10:52:10 HundredsAnd100s wrote:
> I'm new to both PyQt and Qt, so apologies if this is obvious. I'm trying
> to track mouse events with a QGLWidget but it's not working quite like
> expected. I switched to a QWidget to avoid any possible complications but
> the problem remains.
>
> I want to recognize that one or more mouse buttons are being pressed
> simultaneously. This works except for combinations of left and right
> buttons. If, at any time, both those buttons end up pressed, the button I
> release first won't generate a mouseRelease event. The other button will,
> but Qt seems to think the one I released first is still depressed and
> grabs the mouse until I press and release that button again, at which
> point I get a single mouseRelease event.
>
> For instance:
> Press left button --> mousePress: event.button()=left, event.buttons() =
> left
> Press right button --> mousePress: event.button()=right, event.buttons()
> = left | right
> Release right button --> nothing
> Release left button --> mouseRelease: event.button()=left,
> event.buttons()=right
> ...try to click other things but the mouse is locked...
> Press right button --> nothing
> Release right button --> mouseRelease: event.button()=right,
> event.buttons()=0
> ...Now I can use the mouse again...
>
> The code works for all three buttons on their own and for any combination
> of left and middle or right and middle buttons. Just not left and right.
> This is under Linux, for what that's worth, and I'm confident I'm not
> simulating a three-button mouse.
>
> I suspect this has something to do with context menus but can't find
> anything in QWidget that has any effect. I overrode event() and noticed
> that left and middle button presses were reported as
> QEvent.MouseButtonPress while right button presses were reported as
> QEvent.ContextMenu, even with the widget's context menu policy set to
> NoContextMenu or PreventContextMenu.
>
> I know I'm missing something, so if someone could point out what it is
> I'd be grateful. Here's the code:
>
> import sys
> import PyQt4.QtCore as core
> import PyQt4.QtGui as gui
>
> class MyWidget(gui.QWidget):
>   def __init__(self, *args, **kwargs):
>   gui.QWidget.__init__(self, *args, **kwargs)
>   self.setAttribute(core.Qt.WA_NoMousePropagation, False)
>
> self.setContextMenuPolicy(core.Qt.ContextMenuPolicy(core.Qt.PreventContex
>tMenu))
>
>   def mousePressEvent(self, event):
>   print "Mouse press:",  event.button(), int(event.buttons())
>
>   def mouseReleaseEvent(self, event):
>   print "Mouse release:",  event.button(), int(event.buttons())
>
>
> class MainWindow(gui.QMainWindow):
>   def __init__(self, parent=None):
>   gui.QWidget.__init__(self, parent)
>   self.setCentralWidget(MyWidget())
>
>
> app = gui.QApplication(sys.argv)
> main_window = MainWindow()
> main_window.show()
> app.exec_()

Hmm, not here, neither with self.setContextMenuPolicy (indented on 
self.setAttribute level), nor without:

With:
Mouse press: 1 1
Mouse release: 1 0
Mouse press: 4 4
Mouse release: 4 0
Mouse press: 2 2
Mouse release: 2 0
Mouse press: 4 4
Mouse press: 1 5
Mouse release: 4 1
Mouse release: 1 0
Mouse press: 2 2
Mouse release: 2 0
Mouse press: 1 1
Mouse press: 2 3
Mouse release: 1 2
Mouse release: 2 0
Mouse press: 1 1
Mouse release: 1 0
Mouse press: 2 2
Mouse release: 2 0
Mouse press: 1 1
Mouse press: 2 3
Mouse release: 1 2
Mouse release: 2 0
Mouse press: 4 4
Mouse release: 4 0
Mouse press: 1 1
Mouse release: 1 0
Mouse press: 1 1
Mouse press: 4 5
Mouse release: 4 1
Mouse release: 1 0
Mouse press: 2 2
Mouse release: 2 0
Mouse press: 4 4
Mouse press: 2 6
Mouse release: 4 2
Mouse release: 2 0
Mouse press: 1 1
Mouse press: 2 3
Mouse release: 1 2
Mouse release: 2 0

Without:
Mouse press: 2 2
Mouse release: 2 0
Mouse press: 1 1
Mouse release: 1 0
Mouse press: 4 4
Mouse release: 4 0
Mouse press: 1 1
Mouse press: 2 3
Mouse release: 2 1
Mouse release: 1 0
Mouse press: 1 1
Mouse press: 4 5
Mouse release: 4 1
Mouse release: 1 0
Mouse press: 2 2
Mouse press: 4 6
Mouse release: 4 2
Mouse release: 2 0
Mouse press: 2 2
Mouse release: 2 0
Mouse press: 2 2
Mouse press: 4 6
Mouse release: 4 2
Mouse release: 2 0
Mouse press: 2 2
Mouse release: 2 0
Mouse press: 4 4
Mouse press: 2 6
Mouse release: 4 2
Mouse release: 2 0
Mouse press: 1 1
Mouse release: 1 0
Mouse press: 4 4
Mouse press: 1 5
Mouse release: 4 1
Mouse release: 1 0
Mouse press: 1 1
Mouse press: 2 3
Mouse release: 1 2
Mouse release: 2 0

Python version: 2.6
sip version: 4.10.5
Qt4 version: 4.6.3
PyQt4 version: 4.7.4

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


Re: [PyQt] python cxfreeze package pyqt app lost icon and tray icon

2010-09-16 Thread Von
Hi,Hans I join this group today,could you send your example mail to me?

On Thu, Sep 16, 2010 at 6:23 PM, Hans-Peter Jansen  wrote:

> On Thursday 16 September 2010, 08:38:00 Von wrote:
> > Hi,
> > Here is my command:
> > cxfreeze --target-dir=AutoOrder gui.py
> > --base-name=D:\Python31\Lib\site-packages\cx_Freeze\bases\Win32GUI.exe
> > --include-path=. -z icon.jpg
>
> I haven't used cx_freeze, but why don't you wrap them into a python module
> with pyrcc4. The deleayedencoding example, I've send to the list lately,
> includes an Makefile for that task. BTW, pyrcc4 is able to wrap any data
> files, translation files, etc..
>
> > Both app icon and tray icon used icon.jpg
>
> Pete
> ___
> 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] python cxfreeze package pyqt app lost icon and tray icon

2010-09-16 Thread Hans-Peter Jansen
On Thursday 16 September 2010, 08:38:00 Von wrote:
> Hi,
> Here is my command:
> cxfreeze --target-dir=AutoOrder gui.py
> --base-name=D:\Python31\Lib\site-packages\cx_Freeze\bases\Win32GUI.exe
> --include-path=. -z icon.jpg

I haven't used cx_freeze, but why don't you wrap them into a python module 
with pyrcc4. The deleayedencoding example, I've send to the list lately, 
includes an Makefile for that task. BTW, pyrcc4 is able to wrap any data 
files, translation files, etc..

> Both app icon and tray icon used icon.jpg

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


[PyQt] Why am I missing a mouseRelease event in QWidget and QGLWidget?

2010-09-16 Thread HundredsAnd100s

I'm new to both PyQt and Qt, so apologies if this is obvious. I'm trying to
track mouse events with a QGLWidget but it's not working quite like
expected. I switched to a QWidget to avoid any possible complications but
the problem remains.

I want to recognize that one or more mouse buttons are being pressed
simultaneously. This works except for combinations of left and right
buttons. If, at any time, both those buttons end up pressed, the button I
release first won't generate a mouseRelease event. The other button will,
but Qt seems to think the one I released first is still depressed and grabs
the mouse until I press and release that button again, at which point I get
a single mouseRelease event.

For instance:
Press left button --> mousePress: event.button()=left, event.buttons() =
left
Press right button --> mousePress: event.button()=right, event.buttons() =
left | right
Release right button --> nothing
Release left button --> mouseRelease: event.button()=left,
event.buttons()=right
...try to click other things but the mouse is locked...
Press right button --> nothing
Release right button --> mouseRelease: event.button()=right,
event.buttons()=0
...Now I can use the mouse again...

The code works for all three buttons on their own and for any combination of
left and middle or right and middle buttons. Just not left and right. This
is under Linux, for what that's worth, and I'm confident I'm not simulating
a three-button mouse.

I suspect this has something to do with context menus but can't find
anything in QWidget that has any effect. I overrode event() and noticed that
left and middle button presses were reported as QEvent.MouseButtonPress
while right button presses were reported as QEvent.ContextMenu, even with
the widget's context menu policy set to NoContextMenu or PreventContextMenu.

I know I'm missing something, so if someone could point out what it is I'd
be grateful. Here's the code:

import sys
import PyQt4.QtCore as core
import PyQt4.QtGui as gui

class MyWidget(gui.QWidget):
def __init__(self, *args, **kwargs):
gui.QWidget.__init__(self, *args, **kwargs)
self.setAttribute(core.Qt.WA_NoMousePropagation, False)

self.setContextMenuPolicy(core.Qt.ContextMenuPolicy(core.Qt.PreventContextMenu))

def mousePressEvent(self, event):
print "Mouse press:",  event.button(), int(event.buttons())

def mouseReleaseEvent(self, event):
print "Mouse release:",  event.button(), int(event.buttons())


class MainWindow(gui.QMainWindow):
def __init__(self, parent=None):
gui.QWidget.__init__(self, parent)
self.setCentralWidget(MyWidget())


app = gui.QApplication(sys.argv)
main_window = MainWindow()
main_window.show()
app.exec_()
-- 
View this message in context: 
http://old.nabble.com/Why-am-I-missing-a-mouseRelease-event-in-QWidget-and-QGLWidget--tp29725398p29725398.html
Sent from the PyQt mailing list archive at Nabble.com.

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


[PyQt] Basic SIP

2010-09-16 Thread Mico Siahaan
Dear all,

I am learning SIP and I made simple source like this:

//spam.cpp

#include "spam.h"

int spam_system(const char *command);

int main(int argc, char **argv )
{
spam_system(argv[1]);
return 0;
}

int spam_system(const char *command)
{
int sts;
sts = system(command);
return sts;
}


spam.h is in the same folder of spam.cpp and containing:

// spam.h
#include 

int spam_system(const char *command);


Then I made simple setup.py:

from distutils.core import setup, Extension
import sipdistutils

setup(
  name = 'spam',
  version ='0.1',
  ext_modules = [
Extension("spam", ["spam.sip", "spam.cpp"])
],
  cmdclass = {'build_ext': sipdistutils.build_ext}
 )

with spam.sip:

/* Define the SIP wrapper to the spam library. */

%Module spam 0

%ModuleHeaderCode
#include "spam.h"
%End

int spam_system(const char *command);


Then run 'python.exe setup.py build'. But then I got error messages

spam.sip(6) : fatal error C1083: Cannot open include file: 'spam.h': No such
file or directory
error: command '"C:\Program Files\Microsoft Visual Studio
9.0\VC\BIN\cl.exe"' failed with exit status 2

My question: where shall I put spam.h then so sip can compile it
successfully? How is the best structure of building python binding with sip?
And sorry for the long email.

-- 
Mico | mico.siah...@gmail.com | @bangmico
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] QSortFilterProxyModel with 'fixed' item

2010-09-16 Thread Saúl Ibarra Corretgé
Hi all,

I'm currently using a subclass of QSortFilterProxyModel to populate a
QComboBox. This is working fine, but I'd like to have a 'fixed' entry
in this combo box. This entry is not present on the proxy model nor on
the source model, it guess it has to be 'invented' by the proxy model
so it's delivered to the view.

I've been playing around with rowCount and data functions (so it'll
return the real value + 1) and I suspect the key here are
mapFromSource and mapToSource but I'm unable to get this working :-S

Any hint on this would be appreciated.


Regards,

-- 
/Saúl
http://saghul.net | http://sipdoc.net
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] Image type RAW destroyed by PyQt

2010-09-16 Thread Vincent Vande Vyvre




Hi,

In an application, i have a function which create a thumbnail for each
image found in a folder.

If an image is type RAW, (.CR2, .RAF, .3FR, .MRW etc) an image format
.tiff is automatically created
and replace the RAW file. The original file is lost.

However, if I check the supported formats with
QImageReader.supportedImageFormats()
the RAW files do not seem not included.

This problem is it known?
-- 
Vincent V.V.
Oqapy



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