[PyQt] Any possibility doing SIGNAL forward using pyuic4?

2009-03-10 Thread Grissiom
Hi,

When I try to do SIGNAL forwarding using the designer I found that pyuic4
always generate a short-circuit connections but not a customed new signal.
Is there anyway to do signal forwarding using pyuic4?

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

Re: [PyQt] Any possibility doing SIGNAL forward using pyuic4?

2009-03-10 Thread Phil Thompson
On Tue, 10 Mar 2009 16:07:54 +0800, Grissiom 
wrote:
> Hi,
> 
> When I try to do SIGNAL forwarding using the designer I found that pyuic4
> always generate a short-circuit connections but not a customed new
signal.
> Is there anyway to do signal forwarding using pyuic4?

Can you send me a .ui file and describe what you want to happen?

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


[PyQt] PyQt & SIP Release Plans

2009-03-10 Thread Phil Thompson
The current PyQt and SIP snapshots represent what will be in the next
releases. As well as full support for Qt v4.5 the following Roadmap items
have been implemented...

- Pythonic Connections

- Implicit copying of const&

- Extra Reference without Ownership

There has been a significant amount of internal refactoring (mainly to
support the future elimination of QString, QVariant etc). Although the new
code passes a couple of hundred unit tests I would strongly encourage
people to test it for themselves. I will not make a final release for at
least a couple of weeks.

In the meantime I will start porting to Python v3. Whether or not this
makes it to the next release depends on how it goes.

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


Re: [PyQt] Qfiledailoug multiple file selection

2009-03-10 Thread klia



Detlev Offenbach wrote:
> 
> On Samstag, 7. März 2009, klia wrote:
>> Detlev Offenbach wrote:
>> > On Freitag, 6. März 2009, klia wrote:
>> >> Hey folks;
>> >>
>> >> How can i be able to select multiple files whenever i browse my
>> >> directory using QfileDailoug?
>> >>
>> >> this is the code to call up the filedailoug
>> >>
>> >> files = QtGui.QFileDialog.getOpenFileName(self,  'Open file','/home/',
>> >> ("Images (*.png *.tiff *.jpg)"))
>> >
>> > Just use "getOpenFileNames(...)". See the docs for more details.
>> >
>> >> Thank you
>> >
>> > --
>> > Detlev Offenbach
>> > det...@die-offenbachs.de
>> >
>> > ___
>> > PyQt mailing listPyQt@riverbankcomputing.com
>> > http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>>
>> Thank you Detlev Offenbach it worked but python complaining that there's
>> no
>> buffer or string to hold the selected files in order to process
>> them...Any idea
> 
> Just call it like this:
> 
> fileNames = QFileDialog.getOpenFileNames(\
> self,
> self.trUtf8("Add Documentation"),
> QString("/home"),
> self.trUtf8("Qt Compressed Help Files (*.qch)"))
> 
> Detlev
> -- 
> Detlev Offenbach
> det...@die-offenbachs.de
> 
> ___
> PyQt mailing listPyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> 
> 
hey man;
it worked perfectly after commenting this line:
#data = file.read()

anyway, i still have one more question, in my interface i have few buttons
that should be linked with functions, my functions are in separate .py files
but some of the functions when i execute them from terminal they should be
in this syntax 
was...@home:~$python csv2sql.py -t my_table photos.csv | sqlite 3 photos.db
how can i be able to link such a function with this syntax in pyqt? 
-- 
View this message in context: 
http://www.nabble.com/Qfiledailoug-multiple-file-selection-tp22369488p22432064.html
Sent from the PyQt mailing list archive at Nabble.com.


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


[PyQt] QTreeWidget sorting problem

2009-03-10 Thread NARCISO, Rui

Hi all

I have a QTreeWIdget that works perfectly to which I can add items without any 
problems.

The problem happens when I sort the data after having dynamically removed an 
item. So, I remove an item by doing:
item.parent().removeChild(item)
which successfuly removes the item from the list.
However, afterwards when I sort using whatever column, data is missing on some 
columsn for the item just before (on the same levl, not parent)

Has anyone encountered this problem before?

If need be I can post my code.

Rui

The information in this e-mail is confidential. The contents may not be 
disclosed or used by anyone other then the addressee. Access to this e-mail by 
anyone else is unauthorised.
If you are not the intended recipient, please notify Airbus immediately and 
delete this e-mail.
Airbus cannot accept any responsibility for the accuracy or completeness of 
this e-mail as it has been sent over public networks. If you have any concerns 
over the content of this message or its Accuracy or Integrity, please contact 
Airbus immediately.
All outgoing e-mails from Airbus are checked using regularly updated virus 
scanning software but you should take whatever measures you deem to be 
appropriate to ensure that this message and any attachments are virus free.


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


[PyQt] QGraphicsView in a QGraphicsLayout/Plasmoid?

2009-03-10 Thread cfigura

I'm hoping someone can help me out here.  I've got a little applet that I had
originally written with the QCanvas but have just ported over to Qt4 using
the QGraphicsView.

I'd like to turn it into a plasmoid app, but have had very little luck
finding documentation on that.  I've successfully found a few examples (such
as http://techbase.kde.org/Development/Tutorials/Plasma/PythonPlasmoid), and
it appears that the base plasmoid applet is based on a QGraphicsLayout.  I
know it's probably just my poor understanding of the whole QGraphics
heirarchy, but I can't figure out how to use a QGraphicsView in a
QGraphicsLayout.  Can anyone help out?  Or point me to somewhere where I can
get some info?

Thanks!
-- 
View this message in context: 
http://www.nabble.com/QGraphicsView-in-a-QGraphicsLayout-Plasmoid--tp22433047p22433047.html
Sent from the PyQt mailing list archive at Nabble.com.

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


[PyQt] linking listwidget with Qgraphicsview

2009-03-10 Thread klia

hey guys;

in my application i have Listwidegt and Qgraphics view beside to each other
in the interface, my intension is after i list my photos in the listwidget,
i want that whenever i click on the photo on listwidget it will be displayed
on the graphics view...

Any idea on how to do that?

here's the code of inserting photos into Listwidegt

files = QFileDialog.getOpenFileNames(self, self.trUtf8("Add documentation"),
QString("/home"), self.trUtf8("Images (*.png *.tiff *.jpg)")) 
for file_ in files:
data = ""
f = open(file_)
#data = file.read()
self.listWidget.addItem(file_)

here's a screen shot of my inquiry 
http://www.nabble.com/file/p22433529/Screenshot-MainWindow-1.png 
-- 
View this message in context: 
http://www.nabble.com/linking-listwidget-with-Qgraphicsview-tp22433529p22433529.html
Sent from the PyQt mailing list archive at Nabble.com.

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


[PyQt] QPixmap().grabWidget()

2009-03-10 Thread Michael Wyss

Hi
I want to render my customwidget with fixed size into a Pixmap with 
QPixmap().grabWidget() but when doing so the width of the Widgets 
expands before the actual rendering, the height remains the same.
I looked into the sourcecode of QPixmap and found out that the widget is 
being resized before the rendering. Same result with widget.show().

I also tried that with a standardwidget QPushButton... same results.
How can I avoid the annoyng resizing?
Thanks for your consideration,
Michael
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] FocusEvent problem with QTabWidget

2009-03-10 Thread Philippe Fremy

Hi,

I am trying to catch focus events on my main widget, which happens to be
a QTabWidget. It does not work if the widget is a QTabWidget but works
for a regular QWidget. See the attached program, where you can choose
the base class.

I don't think I'm doing something wrong, so it's either a PyQt bug or Qt
bug.

Any confirmation ?

cheers,

Philippe

from PyQt4 import QtGui, QtCore

# parentClass = QtGui.QWidget 
# parentClass = QtGui.QTabWidget
parentClass = QtGui.QTextEdit

class MyWidget( parentClass ):
def __init__(self, *args ):
parentClass.__init__( self, *args )
print 'old focus policy: ', self.focusPolicy()
self.setFocusPolicy( QtCore.Qt.TabFocus )
print 'new focus policy: ', self.focusPolicy()

def focusInEvent( self, focusEvent ):
print 'focusInEvent'
parentClass.focusInEvent( self, focusEvent )

def focusOutEvent( self, focusEvent ):
print 'focusOutEvent'
parentClass.focusInEvent( self, focusEvent )



def main():
app = QtGui.QApplication([])
w = MyWidget()
w.setFocus()
w.show()
app.exec_()

if __name__ == '__main__':
main()

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

Re: [PyQt] QTextEdit.ExtraSelection not working anymore

2009-03-10 Thread Phil Thompson
On Tue, 10 Mar 2009 03:23:56 +0100, Henning Schröder
 wrote:
> Hi!
> In the attached example the first line should be highlighted.
> Unfortunately it does not work on my system[1]
> Normally I would think I have done something wrong but this code works
> on my laptop[2]
> 
> I haven't seen anything relevant in the changelogs. Did I miss anything?
> 
> Regards
> Henning
> 
> 
> [1] Ubuntu Jaunty, PyQt 4.4.4, sip 4.7.9, Qt 4.5 (but I think it
> already failed with the previous Qt version)
> [2] Ubuntu  Hardy, PyQt 4.3.3, sip 4.7.7, Qt 4.4.3
> 
> 
> PS: Anyone having problems  with QSyntaxHighlighter and Qt 4.5 should
> read http://labs.trolltech.com/blogs/2008/11/04/910/

This will be fixed in tonight's SIP snapshot.

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


[PyQt] QFIleDialog.getSaveFileName get the selectedFilter

2009-03-10 Thread Darryl Wallace
I prefer to use the static method for the getSaveFilename in the 
QFileDialog so that the user sees the Windows/Mac native dialog.


My problem is that if the user doesn't type the file extension the in 
the save file name (say when selecting an image type to save a file as), 
then I don't have a way of checking to see what type of file they wanted 
to save as.


Is there away to get the selectedFilter using this method?

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


[PyQt] Re: Embedding w/ multi-threaded Python

2009-03-10 Thread McKay Davis
After no response, maybe more specifics with our Multi-Threaded Python
w/ PyQt problem would help:

In the main thread, we do:

PyEval_InitThreads(); // acquires the lock
PyInitialize();
// other init stuff
PyThread_release_lock()

…and in each new Python thread we do:
Py_NewInterpreter()
…
PyThreads_release_lock()

We call release()/acquire() blocks whenever the python script does a
blocking operation.  A specific example of a lockup with PyQT is
running examples/tutorial/t8.pyw.  We basically:

PyThreads_acquire_lock()

PyThreads_release_lock()

When a slot is invoked as a result of the slider being moved we get a
deadlock.  This happens when sip_ProtectVirt_languageChange calls
PyThreads_release_lock() on an already released lock.  If we don’t
release the lock after the main thread PyQT script code runs, then the
script runs fine – but our other python script threads will be starved
out.

Anybody have any ideas on how to resolve this deadlock?

-McKay Davis

On Mon, Mar 9, 2009 at 2:12 PM, McKay Davis  wrote:
>
> All,
>
> We are encountering difficulties embedding PyQT into our application.  In our 
> situation, we provide the capability to run multiple python interpreters 
> simultaneously along with the main thread PyQT interpreter.
>
> We try to correctly manage the python global interpreter lock in such a way 
> so that we can run PyQT python code in conjunction with non-PyQt python code 
> running in other threads.  What we have found however, is that under some 
> circumstances (ie , our application will deadlock since there appears to be 
> an implicit assumption that the global interpreter lock is already held the 
> moment that slot code is invoked by PyQT.
>
> We can assure this to be the case, but only at the expense of locking other 
> python code threads out of the global interpreter lock.  Are there any 
> provisions to accommodate what we are trying to do that we are not making use 
> of?  Or is this perhaps a known issue?  Are there any workarounds?  We would 
> appreciate any help or tips on this.
>
> Thanks,
>
> McKay Davis

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


Re: [PyQt] Re: Embedding w/ multi-threaded Python

2009-03-10 Thread Marc Nations
Are you putting a small sleep (100 msec)  in all your continuous thread
loops to ensure that control gets passed back to the main thread?

Sounds like a minor issue, but it can be a silent killer. Even with locks
Python doesn't automatically handle the handoffs well. I don't think that
changed with the multiprocessing features introduced in 2.6 either, but I
haven't read much about it.



On Tue, Mar 10, 2009 at 2:30 PM, McKay Davis  wrote:

> After no response, maybe more specifics with our Multi-Threaded Python
> w/ PyQt problem would help:
>
> In the main thread, we do:
>
> PyEval_InitThreads(); // acquires the lock
> PyInitialize();
> // other init stuff
> PyThread_release_lock()
>
> …and in each new Python thread we do:
> Py_NewInterpreter()
> …
> PyThreads_release_lock()
>
> We call release()/acquire() blocks whenever the python script does a
> blocking operation.  A specific example of a lockup with PyQT is
> running examples/tutorial/t8.pyw.  We basically:
>
> PyThreads_acquire_lock()
> 
> PyThreads_release_lock()
>
> When a slot is invoked as a result of the slider being moved we get a
> deadlock.  This happens when sip_ProtectVirt_languageChange calls
> PyThreads_release_lock() on an already released lock.  If we don’t
> release the lock after the main thread PyQT script code runs, then the
> script runs fine – but our other python script threads will be starved
> out.
>
> Anybody have any ideas on how to resolve this deadlock?
>
> -McKay Davis
> - Show quoted text -
>
> On Mon, Mar 9, 2009 at 2:12 PM, McKay Davis  wrote:
> >
> > All,
> >
> > We are encountering difficulties embedding PyQT into our application.  In
> our situation, we provide the capability to run multiple python interpreters
> simultaneously along with the main thread PyQT interpreter.
> >
> > We try to correctly manage the python global interpreter lock in such a
> way so that we can run PyQT python code in conjunction with non-PyQt python
> code running in other threads.  What we have found however, is that under
> some circumstances (ie , our application will deadlock since there appears
> to be an implicit assumption that the global interpreter lock is already
> held the moment that slot code is invoked by PyQT.
> >
> > We can assure this to be the case, but only at the expense of locking
> other python code threads out of the global interpreter lock.  Are there any
> provisions to accommodate what we are trying to do that we are not making
> use of?  Or is this perhaps a known issue?  Are there any workarounds?  We
> would appreciate any help or tips on this.
> >
> > Thanks,
> >
> > McKay Davis
>
> ___
> 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] QFIleDialog.getSaveFileName get the selectedFilter

2009-03-10 Thread Phil Thompson
On Tue, 10 Mar 2009 15:39:41 -0400, Darryl Wallace
 wrote:
> I prefer to use the static method for the getSaveFilename in the 
> QFileDialog so that the user sees the Windows/Mac native dialog.
> 
> My problem is that if the user doesn't type the file extension the in 
> the save file name (say when selecting an image type to save a file as), 
> then I don't have a way of checking to see what type of file they wanted 
> to save as.
> 
> Is there away to get the selectedFilter using this method?

If you pass a QString as the selectedFilter argument it will be updated on
return - not very Pythonic I know.

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


Re: [PyQt] Re: Embedding w/ multi-threaded Python

2009-03-10 Thread Phil Thompson
On Tue, 10 Mar 2009 10:30:04 -1000, McKay Davis 
wrote:
> After no response, maybe more specifics with our Multi-Threaded Python
> w/ PyQt problem would help:
> 
> In the main thread, we do:
> 
> PyEval_InitThreads(); // acquires the lock
> PyInitialize();
> // other init stuff
> PyThread_release_lock()
> 
> …and in each new Python thread we do:
> Py_NewInterpreter()
> …
> PyThreads_release_lock()
> 
> We call release()/acquire() blocks whenever the python script does a
> blocking operation.  A specific example of a lockup with PyQT is
> running examples/tutorial/t8.pyw.  We basically:
> 
> PyThreads_acquire_lock()
> 
> PyThreads_release_lock()
> 
> When a slot is invoked as a result of the slider being moved we get a
> deadlock.  This happens when sip_ProtectVirt_languageChange calls
> PyThreads_release_lock() on an already released lock.  If we don’t
> release the lock after the main thread PyQT script code runs, then the
> script runs fine – but our other python script threads will be starved
> out.
> 
> Anybody have any ideas on how to resolve this deadlock?

PyQt uses the PyGILState_* functions. These aren't supported with multiple
interpreters - see the docs for Py_NewInterpreter().

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


[PyQt] Pydee v0.3.0

2009-03-10 Thread Pierre Raybaut

Hi all,

Two months ago, I made an announcement regarding a little open-source 
project of mine, PyQtShell -- that is a module providing embeddable 
console widgets for your PyQt applications (interactive Python shell, 
workspace, working directory browser, editor, ...) as well as "Pydee", a 
PYthon Development EnvironmEnt based on these widgets (which could 
become an interesting alternative to IDLE for example).


Pydee features have been greatly enhanced these last weeks, and a lot of 
bugs were fixed thanks to Christopher Brown (thank you again Christopher 
for your bug reports/feature requests which are always very detailed and 
constructive).


I recently (a few minutes ago actually..) added an interesting feature 
in Pydee v0.3.0: matplotlib integration (i.e. matplotlib figures can be 
docked inside Pydee which is quite convenient).

See this screenshot for example:
http://source.pythonxy.com/PyQtShell/screenshots/ss3.png

Other screenshots and informations:
http://pypi.python.org/pypi/PyQtShell/
http://code.google.com/p/pyqtshell/

As some of you may have noticed, Pydee is intended to be a mini-MATLAB 
environment -- that being said, it still at an early stage of development.


Cheers,
Pierre

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


[PyQt] seeking advice on why this script segfaults

2009-03-10 Thread Darren Dale
Hello,

I am trying to create a simple model and view for a simple nested dictionary
like d:

c1 = {'id':1, 'description':'child 1'}
c2 = {'id':2, 'description':'child 2'}
d = {'id':0, 'description':'whatever', 'children':[c1, c2]}

I have a self-contained, relatively simple script attached. When I run it
and try to open the top-level entry by clicking on the +, I get errors like:

Traceback (most recent call last):
  File "tree_test.py", line 111, in parent
parent = index.internalPointer().parent
AttributeError: 'ItemDataRole' object has no attribute 'parent'
Traceback (most recent call last):
  File "tree_test.py", line 111, in parent
parent = index.internalPointer().parent
AttributeError: parent

Traceback (most recent call last):
  File "tree_test.py", line 111, in parent
parent = index.internalPointer().parent
AttributeError: 'exceptions.AttributeError' object has no attribute 'parent'
Bus error

sometimes I get a different error:

Traceback (most recent call last):
  File "tree_test.py", line 111, in parent
parent = index.internalPointer().parent
AttributeError: 'ItemDataRole' object has no attribute 'parent'
Segmentation fault


Could anyone please help me understand what is happening? I dont understand
why index.internalPointer() is returning an ItemDataRole object or an
exceptions.AttributeError object.

Im running Qt-4.5.0, sip-4.7.9 and PyQt-4.4.4.

Thank you,
Darren
"""
"""

from PyQt4 import QtCore, QtGui


class TreeItem:

def __init__(self, data, parent=None):
self._parent = parent
self._data = data

@property
def children(self):
return []

@property
def columns(self):
return [self.data['id'], self.data['description']]

@property
def parent(self):
return self._parent

@property
def data(self):
return self._data

@property
def row(self):
if self.parent:
return self.parent.children.index(self)
return 0

def __len__(self):
return len(self.columns)


class RootItem(TreeItem):

def __init__(self):
self._parent = None
self._children = []

@property
def children(self):
return self._children

@property
def columns(self):
return ['ID', 'Description']

def appendChild(self, child):
self._children.append(child)


class DictItem(TreeItem):

@property
def children(self):
return [TreeItem(child, self) for child in self.data['children']]


class FileModel(QtCore.QAbstractItemModel):

"""
"""

def __init__(self, parent=None):
super(FileModel, self).__init__(parent)
self._rootItem = RootItem()

@property
def rootItem(self):
return self._rootItem

def columnCount(self, parent):
if parent.isValid():
return len(parent.internalPointer().columns)
else:
return len(self.rootItem.columns)

def data(self, index, role):
if not index.isValid() or role != QtCore.Qt.DisplayRole:
return QtCore.QVariant()

item = index.internalPointer()
return QtCore.QVariant(item.columns[index.column()])

def headerData(self, section, orientation, role):
if orientation == QtCore.Qt.Horizontal and \
role == QtCore.Qt.DisplayRole:
return QtCore.QVariant(self.rootItem.columns[section])

return QtCore.QVariant()

def index(self, row, column, parent):
if not self.hasIndex(row, column, parent):
return QtCore.QModelIndex()

if parent.isValid():
parentItem = parent.internalPointer()
else:
parentItem = self.rootItem
child = parentItem.children[row]
return self.createIndex(row, column, child)

def parent(self, index):
if not index.isValid():
return QtCore.QModelIndex()
parent = index.internalPointer().parent
if parent == self.rootItem or parent is None:
return QtCore.QModelIndex()
return self.createIndex(parent.row, 0, parent)

def rowCount(self, parent):
if parent.isValid():
parentItem = parent.internalPointer()
else:
parentItem = self.rootItem
return len(parentItem.children)

def appendDict(self, d):
assert 'id' in d
assert 'description' in d
self.rootItem.appendChild(DictItem(d))


class FileView(QtGui.QTreeView):

def __init__(self, model=None, parent=None):
super(FileView, self).__init__(parent)
self.setModel(model)


if __name__ == '__main__':
import sys
app = QtGui.QApplication(sys.argv)
model = FileModel()
form = FileView(model)
c1 = {'id':1, 'description':'child 1'}
c2 = {'id':2, 'description':'child 2'}
d = {'id':0, 'description':'whatever', 'children':[c1, c2]}
model.appendDict(d)
form.show()
sys.exit(app.exec_())
_

Re: [PyQt] Re: Embedding w/ multi-threaded Python

2009-03-10 Thread McKay Davis
On Tue, Mar 10, 2009 at 11:08 AM, Phil Thompson
 wrote:
> On Tue, 10 Mar 2009 10:30:04 -1000, McKay Davis 
> wrote:
>> After no response, maybe more specifics with our Multi-Threaded Python
>> w/ PyQt problem would help:
>>
>> In the main thread, we do:
>>
>> PyEval_InitThreads(); // acquires the lock
>> PyInitialize();
>> // other init stuff
>> PyThread_release_lock()
>>
>> …and in each new Python thread we do:
>> Py_NewInterpreter()
>> …
>> PyThreads_release_lock()
>>
>> We call release()/acquire() blocks whenever the python script does a
>> blocking operation.  A specific example of a lockup with PyQT is
>> running examples/tutorial/t8.pyw.  We basically:
>>
>> PyThreads_acquire_lock()
>> 
>> PyThreads_release_lock()
>>
>> When a slot is invoked as a result of the slider being moved we get a
>> deadlock.  This happens when sip_ProtectVirt_languageChange calls
>> PyThreads_release_lock() on an already released lock.  If we don’t
>> release the lock after the main thread PyQT script code runs, then the
>> script runs fine – but our other python script threads will be starved
>> out.
>>
>> Anybody have any ideas on how to resolve this deadlock?
>
> PyQt uses the PyGILState_* functions. These aren't supported with multiple
> interpreters - see the docs for Py_NewInterpreter().

So its not possible to run PyQt with multiple python interpreters?

This is too bad, because we require the ability to allow users to
script our application using Python.  But, we would also like to
internally use PyQt for GUI development.  If we only have one
interpreter then we cannot use PyQt because we cannot allow end-users
the ability to potentially develop PyQt under the commercial license.

Is there a way to allow only our program to access PyQt and end-users
access to the python interpreter too?

-McKay

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


Re: [PyQt] Re: Embedding w/ multi-threaded Python

2009-03-10 Thread Phil Thompson
On Tue, 10 Mar 2009 11:40:48 -1000, McKay Davis 
wrote:
> On Tue, Mar 10, 2009 at 11:08 AM, Phil Thompson
>  wrote:
>> On Tue, 10 Mar 2009 10:30:04 -1000, McKay Davis 
>> wrote:
>>> After no response, maybe more specifics with our Multi-Threaded Python
>>> w/ PyQt problem would help:
>>>
>>> In the main thread, we do:
>>>
>>> PyEval_InitThreads(); // acquires the lock
>>> PyInitialize();
>>> // other init stuff
>>> PyThread_release_lock()
>>>
>>> …and in each new Python thread we do:
>>> Py_NewInterpreter()
>>> …
>>> PyThreads_release_lock()
>>>
>>> We call release()/acquire() blocks whenever the python script does a
>>> blocking operation.  A specific example of a lockup with PyQT is
>>> running examples/tutorial/t8.pyw.  We basically:
>>>
>>> PyThreads_acquire_lock()
>>> 
>>> PyThreads_release_lock()
>>>
>>> When a slot is invoked as a result of the slider being moved we get a
>>> deadlock.  This happens when sip_ProtectVirt_languageChange calls
>>> PyThreads_release_lock() on an already released lock.  If we don’t
>>> release the lock after the main thread PyQT script code runs, then the
>>> script runs fine – but our other python script threads will be
starved
>>> out.
>>>
>>> Anybody have any ideas on how to resolve this deadlock?
>>
>> PyQt uses the PyGILState_* functions. These aren't supported with
>> multiple
>> interpreters - see the docs for Py_NewInterpreter().
> 
> So its not possible to run PyQt with multiple python interpreters?
> 
> This is too bad, because we require the ability to allow users to
> script our application using Python.  But, we would also like to
> internally use PyQt for GUI development.  If we only have one
> interpreter then we cannot use PyQt because we cannot allow end-users
> the ability to potentially develop PyQt under the commercial license.

I'm not sure how using multiple interpreters would help anyway.

> Is there a way to allow only our program to access PyQt and end-users
> access to the python interpreter too?

Obviously you need some decoupling - but what (separate processes or just
filtering the Python the user is typing) depends on your application and
the scripting the user wants to do. Or let them script with JavaScript
instead.

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


Re: [PyQt] Re: Embedding w/ multi-threaded Python

2009-03-10 Thread Roberto Alsina
On Tuesday 10 March 2009 19:40:48 McKay Davis wrote:
> On Tue, Mar 10, 2009 at 11:08 AM, Phil Thompson
>
>  wrote:
> > On Tue, 10 Mar 2009 10:30:04 -1000, McKay Davis 
> >
> > wrote:
> >> After no response, maybe more specifics with our Multi-Threaded Python
> >> w/ PyQt problem would help:
> >>
> >> In the main thread, we do:
> >>
> >> PyEval_InitThreads(); // acquires the lock
> >> PyInitialize();
> >> // other init stuff
> >> PyThread_release_lock()
> >>
> >> …and in each new Python thread we do:
> >> Py_NewInterpreter()
> >> …
> >> PyThreads_release_lock()
> >>
> >> We call release()/acquire() blocks whenever the python script does a
> >> blocking operation.  A specific example of a lockup with PyQT is
> >> running examples/tutorial/t8.pyw.  We basically:
> >>
> >> PyThreads_acquire_lock()
> >> 
> >> PyThreads_release_lock()
> >>
> >> When a slot is invoked as a result of the slider being moved we get a
> >> deadlock.  This happens when sip_ProtectVirt_languageChange calls
> >> PyThreads_release_lock() on an already released lock.  If we don’t
> >> release the lock after the main thread PyQT script code runs, then the
> >> script runs fine – but our other python script threads will be starved
> >> out.
> >>
> >> Anybody have any ideas on how to resolve this deadlock?
> >
> > PyQt uses the PyGILState_* functions. These aren't supported with
> > multiple interpreters - see the docs for Py_NewInterpreter().
>
> So its not possible to run PyQt with multiple python interpreters?
>
> This is too bad, because we require the ability to allow users to
> script our application using Python.  But, we would also like to
> internally use PyQt for GUI development.  If we only have one
> interpreter then we cannot use PyQt because we cannot allow end-users
> the ability to potentially develop PyQt under the commercial license.

Why not use multiprocessing and some sort of message passing via queues? Of 
course maybe I am not understanding what you are trying to do :-)

> Is there a way to allow only our program to access PyQt and end-users
> access to the python interpreter too?
>
> -McKay
>
> ___
> 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] PyQt & SIP Release Plans

2009-03-10 Thread Damien Elmes
I'm finding that executing the following code in an abstracttablemodel
results in a crash:

self.emit(SIGNAL("dataChanged(QModelIndex,
QModelIndex)"), index, index)

.. where index is taken from tableView.currentIndex()

This code ran fine in PyQt4.4. Is it a bug in Qt/PyQt, or am I doing
something wrong?

On Tue, Mar 10, 2009 at 5:39 PM, Phil Thompson
 wrote:
> The current PyQt and SIP snapshots represent what will be in the next
> releases. As well as full support for Qt v4.5 the following Roadmap items
> have been implemented...
>
> - Pythonic Connections
>
> - Implicit copying of const&
>
> - Extra Reference without Ownership
>
> There has been a significant amount of internal refactoring (mainly to
> support the future elimination of QString, QVariant etc). Although the new
> code passes a couple of hundred unit tests I would strongly encourage
> people to test it for themselves. I will not make a final release for at
> least a couple of weeks.
>
> In the meantime I will start porting to Python v3. Whether or not this
> makes it to the next release depends on how it goes.
>
> Phil
> ___
> PyQt mailing list    p...@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>

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


[PyQt] PyKDE: KConfigSkeleton not writing configuration

2009-03-10 Thread Till Gerken
Hello,

I have a problem with KConfigSkeleton not writing its configuration to
disk when calling KCoreConfigSkeleton::writeConfig(). The odd thing
about this is that it works when being used together with
KConfigDialog and KConfigDialogManager, in which case the
configuration file is written correctly.

I have attached a small sample illustrating this behavior. When run,
the value that is entered in the configuration widget will be written
to disk. However, the value that is specified in
MyConfigMain.queryClose() is not written.

Is this a bug in PyKDE or am I missing something?

Thanks,

Till
import sys

from PyKDE4.kdecore import *
from PyKDE4.kdeui import *

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

from PyQt4 import uic

#
# Configuration storage
#
class MyConfig(KConfigSkeleton):
	_simpleThing = QString()
	_simpleThingDlg = QString()
	__instance = None

	def __init__(self):
		if self.__instance:
			raise self.__instance
		self.__instance = self
		KConfigSkeleton.__init__(self, "configtestrc")
		self.createConfig()
		self.readConfig()

	def createConfig(self):
		# Create entries for the main window
		self.addItemString ("simpleThing",  self._simpleThing,  QString("foo"))
		self.addItemString ("simpleThingDlg",  self._simpleThingDlg,  QString("bar"))

	def simpleThing(self):
		return self._simpleThing
		
	def setSimpleThing(self,  simpleThing):
		self._simpleThing = simpleThing

	def simpleThingDlg(self):
		return self._simpleThingDlg
		
	def setSimpleThingDlg(self,  simpleThingDlg):
		self._simpleThingDlg = simpleThingDlg

#
# Configuration dialog
#
class MyConfigDialog(KConfigDialog):
	def __init__(self, parentWidget, configuration):
		KConfigDialog.__init__(self, parentWidget, "MainSettings", configuration )
		self.setFaceType ( KPageDialog.Plain )
		self.configWidget = QWidget()
		uic.loadUi ( "mycfg.ui", self.configWidget )
		self.addPage ( self.configWidget, "Configuration" )

#
# Main application class
#
class MyConfigMain(KMainWindow):
	def __init__(self):
		KMainWindow.__init__(self)

		# Create configuration
		self.config = MyConfig()

		#
		# BUG?: A value that is accessed from the dialog below is written to the file when changed (desired behavior)
		#
		self.cfgDialog = MyConfigDialog(self, self.config)
		self.cfgDialogManager = KConfigDialogManager(self.cfgDialog, self.config)
		self.cfgDialog.show()
		
		# not necessary, nothing here - but do something
		self.show()

	def queryClose(self):
		#
		# BUG?: This should cause the text to be written to the configuration file, but it does not appear (not desired)
		#
		self.config.setSimpleThingDlg("foobar!")
		self.config.writeConfig()
		return True

#
# Startup Code
#
# Create main window and application info,
# then instantiate main class and jump there
#

appName = "configtest"
catalog = ""
programName = ki18n("Configuration Test")
version = "0.1"
description = ki18n("Configuration Test")
license = KAboutData.License_GPL
copyright = ki18n("(c) 2009 Till Gerken, ")
text = ki18n("none")
homePage = ""
bugEmail = "till.ger...@gmail.com"

aboutData = KAboutData ( appName, catalog, programName, version, description, license, copyright, text, homePage, bugEmail )

KCmdLineArgs.init ( sys.argv, aboutData )
app = KApplication()

docmgr = MyConfigMain()

sys.exit(app.exec_())


mycfg.ui
Description: application/designer
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] PyQt & SIP Release Plans

2009-03-10 Thread Phil Thompson
On Wed, 11 Mar 2009 07:06:21 +0900, Damien Elmes  wrote:
> I'm finding that executing the following code in an abstracttablemodel
> results in a crash:
> 
> self.emit(SIGNAL("dataChanged(QModelIndex,
> QModelIndex)"), index, index)
> 
> .. where index is taken from tableView.currentIndex()
> 
> This code ran fine in PyQt4.4. Is it a bug in Qt/PyQt, or am I doing
> something wrong?

I think it's a regression...

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


[PyQt] Phonon example

2009-03-10 Thread Roberto Alsina
Just in case before I spend another two hours trying:

Anyone has a simple working audio player widget done using phonon?

My goal is just a widget that takes a URL and lets the user play a sound file,
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Programmatically changing the input method, and a missing qinputcontextfactory

2009-03-10 Thread Damien Elmes
Testing this out, QInputContextFactory.keys() returns 6 instances of
"win", and there doesn't seem to be an obvious way to access the
Japanese IME. I'm starting to think this might not be possible without
writing a custom plugin that uses raw win32 calls to do its magic,
unfortunately.

On Wed, Jan 28, 2009 at 2:48 AM, Phil Thompson
 wrote:
> On Sat, 24 Jan 2009 17:25:18 +0900, Damien Elmes  wrote:
>> Hi folks,
>>
>> In my application (http://ichi2.net/anki/) I'd like text input fields
>> to remember the last input method, so that if a user is inputting
>> Japanese into one field and English in another, they don't have to
>> switch between input methods every time. This works out of the box for
>> me on Linux, as apparently Qt uses a separate XIM context for each
>> widget. But on Windows and OSX, the input context seems to be
>> application-wide.
>>
>> I was looking at the docs to QInputContextFactory. The keys() and
>> languages() methods look like they might be useful here, but I see
>> that this class is not available in PyQt. Am I barking up the wrong
>> tree? If inclusion of this class in unlikely in the future, is there
>> an easy way to add it to a binary install of PyQt (such as dropping an
>> extra sip into a directory)?
>
> QInputContextFactory will be in tonight's PyQt4 snapshot - I'm not sure why
> I didn't wrap it originally.
>
> Phil
>
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] linking listwidget with Qgraphicsview

2009-03-10 Thread Matt Smith
>From the looks of it your list widget has the name of the file you want
to open and display so what you can do is connect the signal being
emitted, itemClicked(QListWidgetItem *), and then get the text from the
item passed with say my_list_item.text().  

>From that you should be able to make a QPixmap with the file name and
put that in your graphicscene as a QGraphicsPixmapItem.

mbs

there are a couple signals you could use:
http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qlistwidget.html

> Message: 2
> Date: Tue, 10 Mar 2009 05:49:35 -0700 (PDT)
> From: klia 
> Subject: [PyQt] linking listwidget with Qgraphicsview
> To: pyqt@riverbankcomputing.com
> Message-ID: <22433529.p...@talk.nabble.com>
> Content-Type: text/plain; charset=us-ascii
> 
> 
> hey guys;
> 
> in my application i have Listwidegt and Qgraphics view beside to each other
> in the interface, my intension is after i list my photos in the listwidget,
> i want that whenever i click on the photo on listwidget it will be displayed
> on the graphics view...
> 
> Any idea on how to do that?
> 
> here's the code of inserting photos into Listwidegt
> 
> files = QFileDialog.getOpenFileNames(self, self.trUtf8("Add documentation"),
> QString("/home"), self.trUtf8("Images (*.png *.tiff *.jpg)")) 
>   for file_ in files:
>   data = ""
>   f = open(file_)
>   #data = file.read()
>   self.listWidget.addItem(file_)
> 
> here's a screen shot of my inquiry 
> http://www.nabble.com/file/p22433529/Screenshot-MainWindow-1.png 
> -- 


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


Re: [PyQt] PyQt & SIP Release Plans

2009-03-10 Thread Matt Smith
I wonder what you mean by "crash" I had a similar problem passing a
QMouseEvent, when I upgraded I needed to use &QMouseEvent with the
ampersand.  When it didn't work I would get the last event, so sometimes
I would get a QTimer instead of a mouse event, but once I put the '&' in
it worked ok.

mbs
>I'm finding that executing the following code in an abstracttablemodel
>results in a crash:

>self.emit(SIGNAL("dataChanged(QModelIndex,
>QModelIndex)"), index, index)

>.. where index is taken from tableView.currentIndex()

>This code ran fine in PyQt4.4. Is it a bug in Qt/PyQt, or am I doing
>something wrong?


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


Re: [PyQt] PyQt & SIP Release Plans

2009-03-10 Thread Matt Smith
Okay, I've got the latest PyQt, and I built it using the latest Qt4.5 so
now I wanna know, how do I put plugins into a webview?  is that
supported yet?

thanks
mbs

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


[PyQt] Re: seeking advice on why this script segfaults

2009-03-10 Thread Darren Dale
On Tue, Mar 10, 2009 at 5:28 PM, Darren Dale  wrote:

> Hello,
>
> I am trying to create a simple model and view for a simple nested
> dictionary like d:
>
> c1 = {'id':1, 'description':'child 1'}
> c2 = {'id':2, 'description':'child 2'}
> d = {'id':0, 'description':'whatever', 'children':[c1, c2]}
>
> I have a self-contained, relatively simple script attached. When I run it
> and try to open the top-level entry by clicking on the +, I get errors like:
>
> Traceback (most recent call last):
>   File "tree_test.py", line 111, in parent
> parent = index.internalPointer().parent
> AttributeError: 'ItemDataRole' object has no attribute 'parent'
> Traceback (most recent call last):
>   File "tree_test.py", line 111, in parent
> parent = index.internalPointer().parent
> AttributeError: parent
>
> Traceback (most recent call last):
>   File "tree_test.py", line 111, in parent
> parent = index.internalPointer().parent
> AttributeError: 'exceptions.AttributeError' object has no attribute
> 'parent'
> Bus error
>
> sometimes I get a different error:
>
> Traceback (most recent call last):
>   File "tree_test.py", line 111, in parent
> parent = index.internalPointer().parent
> AttributeError: 'ItemDataRole' object has no attribute 'parent'
> Segmentation fault
>
>
> Could anyone please help me understand what is happening? I dont understand
> why index.internalPointer() is returning an ItemDataRole object or an
> exceptions.AttributeError object.
>
> Im running Qt-4.5.0, sip-4.7.9 and PyQt-4.4.4.


I just checked this script on a 64-bit kubuntu intrepid system with qt-4.4.3
and PyQt4-4.4.4, sip-4.7.9 and python-2.5.2 and I get segfaults here too. I
guess that rules out some issue specific to qt-4.5.

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

Re: [PyQt] Phonon example

2009-03-10 Thread Christoph Burgmer
> Anyone has a simple working audio player widget done using phonon?

http://techbase.kde.org/Development/Tutorials/Phonon/Introduction/Python

Dunno if this is what you're looking for.
Christoph

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