Re: [PyQt] vertical alignment of richtext in a table view

2010-09-06 Thread Mark Summerfield
On Tue, 7 Sep 2010 01:37:45 +0200
Wolfgang Rohdewald  wrote:
> On Montag 06 September 2010, Mark Summerfield wrote:
> > I'm tending to use a differnt approach for rich text delegates
> > nowadays. Instead of using a QTextDocument, I store a
> > class-level QLabel, something like this:
> 
> your solution certainly looks cleaner than my temporary fix
> (document.setDocumentMargin(7.0)), and it solves
> the problem of painting outside of the field.
> 
> but it does not quite work for me. Your untested example
> leaves the fields blank, it seems I have to give the
> renderer a position. Using view.pos() + option.rect.topLeft(), 
> labels are still too far up and left.
> The magical offset (3,25) puts them all in the right place.
> How can I compute the correct place instead?

I should have mentioned before that it is better to inherit from
QStyledItemDelegate rather than QItemDelegate. I'd try that first & see
if that improves things at all.

The offset you need _might_ be made up of the option.decorationSize's
width; not sure about the height offset.

Using QTextDocument is fine for computing the size hint, although for
efficiency you might create a class-level QTextDocument and reuse it.
(There are other possibilities too, that I cover in Advanced Qt
Programming, but can't recall off hand.)

> 
> class RichTextColumnDelegate(QtGui.QItemDelegate):
> 
> label = QtGui.QLabel()
> 
> def __init__(self, parent=None):
> super(RichTextColumnDelegate, self).__init__(parent)
> 
> def paint(self, painter, option, index):
> text = index.model().data(index, 
> QtCore.Qt.DisplayRole).toString()
> self.label.setText(text)
> self.label.setFixedSize(option.rect.size())
> view = self.parent().parent().view
> topLeft = view.pos() + option.rect.topLeft() + 
> QtCore.QPoint(3, 25)
> self.label.render(painter, topLeft)
> 
>   def sizeHint(self,option,index):
>   # still uses QTextDocument as in your book
> 
> 



-- 
Mark Summerfield, Qtrac Ltd, www.qtrac.eu
C++, Python, Qt, PyQt - training and consultancy
"Rapid GUI Programming with Python and Qt" - ISBN 0132354187
http://www.qtrac.eu/pyqtbook.html
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] vertical alignment of richtext in a table view

2010-09-06 Thread Wolfgang Rohdewald
On Montag 06 September 2010, Mark Summerfield wrote:
> I'm tending to use a differnt approach for rich text delegates
> nowadays. Instead of using a QTextDocument, I store a
> class-level QLabel, something like this:

your solution certainly looks cleaner than my temporary fix
(document.setDocumentMargin(7.0)), and it solves
the problem of painting outside of the field.

but it does not quite work for me. Your untested example
leaves the fields blank, it seems I have to give the
renderer a position. Using view.pos() + option.rect.topLeft(), 
labels are still too far up and left.
The magical offset (3,25) puts them all in the right place.
How can I compute the correct place instead?

class RichTextColumnDelegate(QtGui.QItemDelegate):

label = QtGui.QLabel()

def __init__(self, parent=None):
super(RichTextColumnDelegate, self).__init__(parent)

def paint(self, painter, option, index):
text = index.model().data(index, 
QtCore.Qt.DisplayRole).toString()
self.label.setText(text)
self.label.setFixedSize(option.rect.size())
view = self.parent().parent().view
topLeft = view.pos() + option.rect.topLeft() + 
QtCore.QPoint(3, 25)
self.label.render(painter, topLeft)

def sizeHint(self,option,index):
# still uses QTextDocument as in your book


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

Re: [PyQt] deadlock when using new style signal / slots

2010-09-06 Thread Hans-Peter Jansen
On Tuesday 07 September 2010, 00:01:55 Erik Janssens wrote:
> Hello Pete,
>
> it might indeed be that the deadlock is not directly
> related to the new style signal slot, since the deadlock
> might become visible due to a slight timing difference
> cause by eg switching to new style signal slots.
>
> however I wonder wether I'm doing anything wrong by
> connecting and emiting the same signal object at the
> same time (I did experiment with the connection type,
> but without result).

Hmm, that's a pity.

> For now I have put a mutexlock around 
> this particular instance, but I wonder if I should mutex
> all possible cases ??

Did you searched for well known Qt issues of this kind already? 

Anyway, I would start to create a test script. That way, Phil might take a 
deeper look inside, since this problem combines a _somewhat_ hairy area 
(threads in general) with a complex PyQt one (dynamic "mocing" with 
signals/slots). Therefore my usual advise to look into the sip/PyQt/Qt 
source is exceptionally hard to follow in this case.

> The camelot website (www.python-camelot.com) should be
> up and running, I was not aware of any downtime, it's
> hosted at weebly.com.

Hmm:
$ LANG=C wget www.python-camelot.com
--2010-09-07 00:21:40--  http://www.python-camelot.com/
Resolving www.python-camelot.com... 199.34.228.100
Connecting to www.python-camelot.com|199.34.228.100|:80... failed: 
Connection timed out.
Retrying.

--2010-09-07 00:24:50--  (try: 2)  http://www.python-camelot.com/
Connecting to www.python-camelot.com|199.34.228.100|:80... failed: 
Connection timed out.
Retrying.

--2010-09-07 00:28:01--  (try: 3)  http://www.python-camelot.com/
Connecting to www.python-camelot.com|199.34.228.100|:80... failed: 
Connection timed out.
Retrying.


> The project is going well, we've 
> put a lot of work in switching from MDI to tab based and
> are now converting to new style signal/slots because we
> noticed stability improvements by using them.  These
> deadlocks are of course bothering me.

Sounds nice. Is there any VCS I can pull from?

Best regards,
Pete

> Best regards,
>
> Erik
>
> On Mon, 2010-09-06 at 10:43 +0200, Hans-Peter Jansen wrote:
> > Dear Erik,
> >
> > On Friday 27 August 2010, 21:56:14 Erik Janssens wrote:
> > > Hi,
> > >
> > > Another issue popped up when porting our code to
> > > new style signal slots.
> > >
> > > it appears the deadlock occurs when one thread is
> > > emitting using a pyqtSignal object, while another
> > > thread is connecting the same pyqtSignal object to
> > > a slot,
> >
> > I don't believe, that this is _directly_ related to the new style
> > signal/slot idiom, but you might want to experiment with the connection
> > type argument of connect.
> >
> > > this is the pseudocode for the connection :
> > >
> > > class(...):
> > >
> > > def __init__(...):
> > >   self.rsh.entity_update_signal.connect(
> > > self.handle_entity_update )
> > >
> > > @QtCore.pyqtSlot( object, object )
> > > def handle_entity_update( self, sender, entity ):
> > > ...
> > >
> > > Are these operations supposed to be thread safe or am
> > > I missing something ?
> >
> > BTW, the camelot website http://www.python-camelot.com/ seems to be
> > down since some time.. What's the state of your project?
> >
> > Best regards,
> > 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] deadlock when using new style signal / slots

2010-09-06 Thread Erik Janssens
Hello Pete,

it might indeed be that the deadlock is not directly
related to the new style signal slot, since the deadlock
might become visible due to a slight timing difference
cause by eg switching to new style signal slots.

however I wonder wether I'm doing anything wrong by 
connecting and emiting the same signal object at the
same time (I did experiment with the connection type,
but without result).  For now I have put a mutexlock around
this particular instance, but I wonder if I should mutex
all possible cases ??

The camelot website (www.python-camelot.com) should be
up and running, I was not aware of any downtime, it's
hosted at weebly.com.  The project is going well, we've
put a lot of work in switching from MDI to tab based and
are now converting to new style signal/slots because we
noticed stability improvements by using them.  These
deadlocks are of course bothering me.

Best regards,

Erik

On Mon, 2010-09-06 at 10:43 +0200, Hans-Peter Jansen wrote:
> Dear Erik,
> 
> On Friday 27 August 2010, 21:56:14 Erik Janssens wrote:
> > Hi,
> >
> > Another issue popped up when porting our code to
> > new style signal slots.
> >
> > it appears the deadlock occurs when one thread is
> > emitting using a pyqtSignal object, while another
> > thread is connecting the same pyqtSignal object to
> > a slot,
> 
> I don't believe, that this is _directly_ related to the new style 
> signal/slot idiom, but you might want to experiment with the connection 
> type argument of connect. 
> 
> > this is the pseudocode for the connection : 
> >
> > class(...):
> >
> > def __init__(...):
> >   self.rsh.entity_update_signal.connect( self.handle_entity_update )
> >
> > @QtCore.pyqtSlot( object, object )
> > def handle_entity_update( self, sender, entity ):
> > ...
> >
> > Are these operations supposed to be thread safe or am
> > I missing something ?
> >
> 
> BTW, the camelot website http://www.python-camelot.com/ seems to be down 
> since some time.. What's the state of your project?
> 
> Best regards,
> Pete


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


[PyQt] List widgets in a widget

2010-09-06 Thread starglider develop
Hi,
I have a TabWidget dinamicly populated with widgtes(QLabel and QLineEdit),
and I need to know all the widgets by name in a way I can get their values.
This is for a database application, and I want to get the name of the
widgets that
are the name of the fields in the database.

the widget if populated like this:

field2Display = [[1, 'Titulo', 'pu_title'], [3, 'Autor', 'pu_author'],
[2,'Titulo Original', 'pu_title_original']]
for n in field2Display:
dumLayout = QHBoxLayout()
self.dum = QLineEdit()
self.dum.setObjectName(n[2])
label = QLabel( n[1])
dumLayout.addWidget(label)
dumLayout.addWidget(self.dum)


tab1Layout.addLayout(dumLayout)

the first element is a index, the second is the namoe of the label, the
third is the name os the widget and the name of the field.

Or

is there any other way o achieve this?

Thank you in advance for your help.

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

Re: [PyQt] Composite widgets?

2010-09-06 Thread fpp
On Mon, Sep 6, 2010 at 10:15 PM, Hans-Peter Jansen  wrote:
>
> Start browsing the Qt documentation. Yes, it's a bit arkward to ignore the
> C++ decoration, but after getting used to, you start to enjoy to be able to
> ignore all the C++ related complexities and regret all those poor C++
> hackers: hack, compile, link, crash, hack, compile, link, just for entering
> the event loop two or three hundred microseconds earlier then us (on an
> average system) when they finally fixed their self created headaches.

ROFL... if this were comp.lang.python, this would be my QOTW nominee :-)
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Composite widgets?

2010-09-06 Thread Hans-Peter Jansen
On Monday 06 September 2010, 03:13:29 Peter Milliken wrote:
> Prior to embarking on learning PyQt, I wrote my GUI applications using
> Tkinter and Pmw. The Pmw widget set is quite nice and provides a library
> of composite classes using the Tkinter widgets.
>
> My question is:
>
> Is there any (similar) composite widgets in PyQt? i.e. Pmw has the
> EntryField widget, which combines the (commonly used case) of a Label and
> a LineEdit into the one class - much more convenient than always having
> to specify the two entities separately, which seems to be the case with
> PyQt? The EntryField widget offers far more than just conveniently
> creating a Label and a LineEdit in the one class, it also allows
> definition of entry validation as well, so you can see that the composite
> classes provide quite a high level of functional behaviour to the user.

Well, the powers of Pmw are undoubted, as long as you keep on the well 
prepared route. The reason, why Qt and therefore PyQt doesn't follow this 
route is flexibility. E.g. a label/editfield composite: usually you want 
the labels and editfields align to some grid, where they all align 
vertically, otherwise the UI looks pretty crowded. Given, I need more 
editors, e.g. a date and a combo for a single item, I tend to combine them 
ad hoc by a hbox layout from within designer instead of creating some 
composite widgets.

> Pmw defines other composite widgets like: RadioSelect - which groups
> radio buttons (well, you have the choice of defining it to handle radio
> buttons, check buttons or "normal" buttons). Of course in PyQt I have
> found the QGroupBox class, but this only performs a (small) part of what
> the Pmw RadioSelect widget does.

All these exist as single items, just add them to your UI interactively in 
designer, but there's no such thing in Pmw. In a very old project, where I 
used Pmw until lately for historical reasons, I suffered from crashes in 
newer versions of tix, that where related to unicode issues of edit 
widgets. Such problems can drive you crazy, since looking into tix might 
damage one's brain. 

Try to create a table like window and different editors for all columns and 
say 10 rows with Pmw. Let it update hundreds of cells every second. 
Will it still be usable? 

I replaced that Pmw database frontend with a PyQt based one, where I halved 
the number of lines, but _added_ a bulk of functionality, that simply 
wouldn't been able with Pmw. Needless to say, it starts ten times quicker, 
it has a quick full text search facility in _huge_ tables at nearly zero 
cost, a table query tool, that creates persistent queries by dynamically 
creating the widgets (field, operation, argument, join) in a dummy prove 
way (this is an application where custom widgets make sense), print the 
tables nicely, the app looks good and the usability improved greatly.

> Do such composite widgets exist? am I missing something in the PyQt
> documentation?

Start browsing the Qt documentation. Yes, it's a bit arkward to ignore the 
C++ decoration, but after getting used to, you start to enjoy to be able to 
ignore all the C++ related complexities and regret all those poor C++ 
hackers: hack, compile, link, crash, hack, compile, link, just for entering 
the event loop two or three hundred microseconds earlier then us (on an 
average system) when they finally fixed their self created headaches. 

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


[PyQt] ANN: PyQt v4.7.6 and SIP v4.11.1 Released

2010-09-06 Thread Phil Thompson
PyQt v4.7.6 and SIP v4.11.1 have been released and can be downloaded from
the usual places.

Both are minor bug fix releases.

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


Re: [PyQt] QDockwidget advice needed

2010-09-06 Thread Hans-Peter Jansen
Dear Al,

On Saturday 21 August 2010, 03:42:22 Algis Kabaila wrote:
> > Not exactly, but who cares. AFAICS, all you need is the Signals and
> > Slots chapter. Unfortunately, it misses the new style signals (because
> > Phil invented them later), but you should get hold of them from the
> > beginning. Much less to type, better type checking, and no silly Qt
> > types anymore. IIRC, the later variants of Marks examples available on
> > his site do use them already.
>
> Mark Summerfield's "Rapid GUI Programming with Python an Qt" is one
> of my most valued possessions and most highly respected programming
> guides.  As I am a perennial noob, I would like to get hold of some
> examples of the new type SIGNALs, preferably examples from Mark's book. 
> When you say that "variants of Marks examples available on his site do
> use them already", would it be too much trouble to refer me to the
> chapter number?  (Chapter 4 deals with SIGNALS and SLOTS. SLOTS are dealt
> with in both new and old style, but SIGNALS are in the old style. Chapter
> 10 deals with the deeper level of *events*).

Yes, you're right. I thought, that Mark adjusted the 2.6 variant of book 
examples accordingly, but obviously, that was a mirage..

Luckily, Phil's concept is pretty sound, here is his description:

http://www.riverbankcomputing.com/static/Docs/PyQt4/pyqt4ref.html#new-style-signal-and-slot-support

Just play with it a bit and call back in case of trouble.

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


Re: [PyQt] vertical alignment of richtext in a table view

2010-09-06 Thread Mark Summerfield
Hi Wolfgang,

On Sun, 5 Sep 2010 10:55:04 +0200
Wolfgang Rohdewald  wrote:
> Hi,
> 
> in Mark Summerfields book "Rapid GUI programming with Python
> and QT", there is an example on page 485 with a table column
> having a delegate that displays richtext. In the book,
> the text in this column has a vertical alignment in the middle
> of the cells, just like the other columns.
> 
> but if I execute that example (from the downloadable source:
> chap16/carhirelog.pyw), the rich text is vertically not 
> in the middle but above. How can I make it align vertically
> just like a normal column?
> 
> His book has another such table chap14, page 436 /
> ships_delegate.pyw.
> Here, both the image in the book and the executable show
> the same wrong vertical alignment.
> 
> BTW interesting things happen if the column with richtext
> is resized to a minimum: the delegate draws outside of its
> available horizontal space, showing text to the right of
> the rightmost column.

I'm tending to use a differnt approach for rich text delegates nowadays.
Instead of using a QTextDocument, I store a class-level QLabel,
something like this:

# UNTESTED!
def paint(self, painter, option, index):
text = index.model().data(index, Qt.DisplayRole).toString()
self.label.setText(text) # self.label is a QLabel with alignment
 # etc. set up as one likes in the
 # delegate's constructor
# might want to change the label's palette here, depending on
# the selection state
self.label.setFixedSize(option.rect)
self.label.render(painter)

Hope this helps:-)
 
> (using pyqt 4.7.3 with qt4-4.7.0-rc1)
> 
> this is the paint of the delegate:
> 
> def paint(self, painter, option, index):
> text = index.model().data(index, Qt.DisplayRole).toString()
> palette = QApplication.palette()
> document = QTextDocument()
> document.setDefaultFont(option.font)
> if option.state & QStyle.State_Selected:
> document.setHtml(QString("%2") \
> .arg(palette.highlightedText().color().name()) \
> .arg(text))
> else:
> document.setHtml(text)
> painter.save()
> color = palette.highlight().color() \
> if option.state & QStyle.State_Selected \
> else QColor(index.model().data(index,
> Qt.BackgroundColorRole))
> painter.fillRect(option.rect, color)
> painter.translate(option.rect.x(), option.rect.y())
> document.drawContents(painter)
> painter.restore()
> 
> 



-- 
Mark Summerfield, Qtrac Ltd, www.qtrac.eu
C++, Python, Qt, PyQt - training and consultancy
"Rapid GUI Programming with Python and Qt" - ISBN 0132354187
http://www.qtrac.eu/pyqtbook.html
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] PyQt4 4.7.5 configure fails under Python7 and sip 4.11

2010-09-06 Thread Demetrius Cassidy


Ah yes spaces. The bane of all evil - I forgot about that, thanks.

On 9/5/2010 10:05 PM, Robin M Baur wrote:

On Sun, Sep 5, 2010 at 19:17, Demetrius Cassidy  wrote:

Using PyQt-win-gpl-4.7.5 with sip 4.11 under Python7, configure fails with a
syntax error executing sip:

C:\Documents and Settings\dcassidy\My
Documents\Downloads\PyQt-win-gpl-4.7.5\PyQ
t-win-gpl-4.7.5>python configure.py --confirm-license

[snip configure output]


Generating the C++ source for the QtCore module...
sip: Usage: sip [-h] [-V] [-a file] [-b file] [-c dir] [-d file] [-e] [-g]
[-I d
ir] [-j #] [-k] [-m file] [-o] [-p module] [-P] [-r] [-s suffix] [-t tag]
[-w] [
-x feature] [-z file] [file]
Error: Unable to create the C++ code.

In my (limited) experience, the usual cause of this error is that sip
doesn't understand paths with spaces in the file names.

HTH,
Robin



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


Re: [PyQt] Composite widgets?

2010-09-06 Thread Dan Kripac
On having a quick look at pmw, I can definitely say that a lot of that
functionality is available as PyQt native widgets (plus much much more) and
the few exceptions would be able to be made with code not much more complex
than the example I gave.

It may seem overwhelming at first, but it would be a good way to learn PyQt
and python as well I reckon ;-)

Cheers
Dan

On 6 September 2010 11:18, Peter Milliken  wrote:

> Thanks Dan, but I was really looking for something much more elaborate :-)
> The structure of the Pmw library/widgets is difficult to describe, but I
> found it an amazingly powerful library that allow some pretty nice (and
> easy) extensions once you understood how it worked. Whilst I have never
> delved into the inner workings, I might try some form of a basic port of the
> code to PyQt (assuming there is nothing else available) - I'll have to look
> into it, because I suspect it might be a pretty big job! It will certainly
> stretch my knowledge of Python! :-)
>
> Thanks anyway,
> Peter
>
>
> On Mon, Sep 6, 2010 at 5:16 PM, Dan Kripac  wrote:
>
>> Hi Peter,
>>
>> I find that a lot of my use with PyQt is composing compound widget
>> subclasses that combine other widgets in a particular arrangement and
>> behaviour that I need. You can easily design the way they behave in terms of
>> signals emitted, and you can capture mouse and keyboard events simply by
>> overriding particular methods from the base QWidget class.
>>
>> Not sure if there are many pre-existing libraries of these (that I know).
>> Perhaps because it's easy to do once you get the hang of it. For example, to
>> make a combined label and line edit:
>>
>> class myTextField(QWidget):
>> def __init__(self,label="My Text Field", parent=None):
>> super(myTextField,self).__init__(parent)
>> layout = QHBoxLayout()
>> self.label = QLabel(label)
>> layout.addWidget( self.label )
>> self.lineEdit = QLineEdit()
>> layout.addWidget( self.lineEdit )
>> self.setLayout( layout )
>>
>> You can get much more sophisticated than this, but just a quick example
>> really.
>>
>> Hope this helps.
>>
>> Dan
>>
>> On 6 September 2010 02:13, Peter Milliken wrote:
>>
>>> Prior to embarking on learning PyQt, I wrote my GUI applications using
>>> Tkinter and Pmw. The Pmw widget set is quite nice and provides a library of
>>> composite classes using the Tkinter widgets.
>>>
>>> My question is:
>>>
>>> Is there any (similar) composite widgets in PyQt? i.e. Pmw has the
>>> EntryField widget, which combines the (commonly used case) of a Label and a
>>> LineEdit into the one class - much more convenient than always having to
>>> specify the two entities separately, which seems to be the case with PyQt?
>>> The EntryField widget offers far more than just conveniently creating a
>>> Label and a LineEdit in the one class, it also allows definition of entry
>>> validation as well, so you can see that the composite classes provide quite
>>> a high level of functional behaviour to the user.
>>>
>>> Pmw defines other composite widgets like: RadioSelect - which groups
>>> radio buttons (well, you have the choice of defining it to handle radio
>>> buttons, check buttons or "normal" buttons). Of course in PyQt I have found
>>> the QGroupBox class, but this only performs a (small) part of what the Pmw
>>> RadioSelect widget does.
>>>
>>> Do such composite widgets exist? am I missing something in the PyQt
>>> documentation?
>>>
>>> Thanks
>>> Peter
>>>
>>>
>>> ___
>>> 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] Composite widgets?

2010-09-06 Thread Peter Milliken
Thanks Dan, but I was really looking for something much more elaborate :-)
The structure of the Pmw library/widgets is difficult to describe, but I
found it an amazingly powerful library that allow some pretty nice (and
easy) extensions once you understood how it worked. Whilst I have never
delved into the inner workings, I might try some form of a basic port of the
code to PyQt (assuming there is nothing else available) - I'll have to look
into it, because I suspect it might be a pretty big job! It will certainly
stretch my knowledge of Python! :-)

Thanks anyway,
Peter

On Mon, Sep 6, 2010 at 5:16 PM, Dan Kripac  wrote:

> Hi Peter,
>
> I find that a lot of my use with PyQt is composing compound widget
> subclasses that combine other widgets in a particular arrangement and
> behaviour that I need. You can easily design the way they behave in terms of
> signals emitted, and you can capture mouse and keyboard events simply by
> overriding particular methods from the base QWidget class.
>
> Not sure if there are many pre-existing libraries of these (that I know).
> Perhaps because it's easy to do once you get the hang of it. For example, to
> make a combined label and line edit:
>
> class myTextField(QWidget):
> def __init__(self,label="My Text Field", parent=None):
> super(myTextField,self).__init__(parent)
> layout = QHBoxLayout()
> self.label = QLabel(label)
> layout.addWidget( self.label )
> self.lineEdit = QLineEdit()
> layout.addWidget( self.lineEdit )
> self.setLayout( layout )
>
> You can get much more sophisticated than this, but just a quick example
> really.
>
> Hope this helps.
>
> Dan
>
> On 6 September 2010 02:13, Peter Milliken wrote:
>
>> Prior to embarking on learning PyQt, I wrote my GUI applications using
>> Tkinter and Pmw. The Pmw widget set is quite nice and provides a library of
>> composite classes using the Tkinter widgets.
>>
>> My question is:
>>
>> Is there any (similar) composite widgets in PyQt? i.e. Pmw has the
>> EntryField widget, which combines the (commonly used case) of a Label and a
>> LineEdit into the one class - much more convenient than always having to
>> specify the two entities separately, which seems to be the case with PyQt?
>> The EntryField widget offers far more than just conveniently creating a
>> Label and a LineEdit in the one class, it also allows definition of entry
>> validation as well, so you can see that the composite classes provide quite
>> a high level of functional behaviour to the user.
>>
>> Pmw defines other composite widgets like: RadioSelect - which groups radio
>> buttons (well, you have the choice of defining it to handle radio buttons,
>> check buttons or "normal" buttons). Of course in PyQt I have found the
>> QGroupBox class, but this only performs a (small) part of what the Pmw
>> RadioSelect widget does.
>>
>> Do such composite widgets exist? am I missing something in the PyQt
>> documentation?
>>
>> Thanks
>> Peter
>>
>>
>> ___
>> 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 signals

2010-09-06 Thread Phil Thompson
On Mon, 6 Sep 2010 10:44:21 +0200 (CEST), "lucabe...@libero.it"
 wrote:
> Hello i have write this but i'm not able to connect the emit of the
> class Socket to the Form class, can you help me?
> 
> class Socket(QtNetwork.QTcpSocket):
> def __init__(self, parent=None):
> super(Socket, self).__init__(parent)
> self.connect(self, QtCore.SIGNAL("readyRead()"),
> self.leggi_richiesta)
> 
> def leggi_richiesta(self):
> messaggio = self.readData(self.bytesAvailable())
> print 'dati_letti = ', messaggio
> self.emit(QtCore.SIGNAL("messaggio"), messaggio)
> print 'segnale emesso'
> 
> class Form(QWidget, Ui_Form):
> """
> Class documentation goes here.
> """
> def __init__(self, parent = None):
> """
> Constructor
> """
> 
> connesso_in_arr =False
> self.coda = False
> QWidget.__init__(self, parent)
> self.setupUi(self)
> self.dati = False
> self.lu = TcpServer()
> self.lu
> self.connect(Socket(self), QtCore.SIGNAL('messaggio'),
> self.leggo_risposta)
> 
> def leggo_risposta(self, messaggio):
> self.plainTextEdit_2.appendPlainText(messaggio)

You aren't keeping a reference to your Socket().

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


Re: [PyQt] QFileDialog crash with Gnome + "Desktop Settings (Default)" + QFileDialog.DontUseNativeDialog

2010-09-06 Thread Hans-Peter Jansen
On Sunday 29 August 2010, 15:40:48 PyCoder PyCoder wrote:
> Hi
>
> I have a lil problem with QFileDialog and i think its a bug but im not
> sure...
>
>
> The code is realy simple:
>
> contSave = QtGui.QFileDialog(self)
> contSave.setFileMode(QtGui.QFileDialog.AnyFile)
> contSave.setFilter('*')
> contSave.setViewMode(QtGui.QFileDialog.List)
> contSave.setOptions(QtGui.QFileDialog.DontUseNativeDialog)
> contSave.exec_()
>
> This works unter KDE with  "Desktop Settings (Default)" and under Gnome
> with  GTK+, Motif, CDE, Plastic, Windows and Clearlooks.
>
> But  if is use "Desktop Settings (Default)" under Gnome QFileDialog
> crashes without  a Traceback.
>
> Its the combination of  Gnome + "Desktop Settings (Default)" in
> qtconfig-qt4 and QFileDialog.DontUseNativeDialog.
>
> I have the same problem under Fedora and Ubuntu with Gnome.
>
> Is it a bug or what?

Install the debug packages of Qt4, sip and PyQt and run your app under gdb 
control. When it crashes, type bt, post the results (with line wrap 
switched _off_ for the backtrace).

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


[PyQt] pyqt signals

2010-09-06 Thread lucabe...@libero.it
Hello i have write this but i'm not able to connect the emit of the
class Socket to the Form class, can you help me?

class Socket(QtNetwork.QTcpSocket):
def __init__(self, parent=None):
super(Socket, self).__init__(parent)
self.connect(self, QtCore.SIGNAL("readyRead()"),
self.leggi_richiesta)

def leggi_richiesta(self):
messaggio = self.readData(self.bytesAvailable())
print 'dati_letti = ', messaggio
self.emit(QtCore.SIGNAL("messaggio"), messaggio)
print 'segnale emesso'

class Form(QWidget, Ui_Form):
"""
Class documentation goes here.
"""
def __init__(self, parent = None):
"""
Constructor
"""

connesso_in_arr =False
self.coda = False
QWidget.__init__(self, parent)
self.setupUi(self)
self.dati = False
self.lu = TcpServer()
self.lu
self.connect(Socket(self), QtCore.SIGNAL('messaggio'),
self.leggo_risposta)

def leggo_risposta(self, messaggio):
self.plainTextEdit_2.appendPlainText(messaggio)

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


Re: [PyQt] deadlock when using new style signal / slots

2010-09-06 Thread Hans-Peter Jansen
Dear Erik,

On Friday 27 August 2010, 21:56:14 Erik Janssens wrote:
> Hi,
>
> Another issue popped up when porting our code to
> new style signal slots.
>
> it appears the deadlock occurs when one thread is
> emitting using a pyqtSignal object, while another
> thread is connecting the same pyqtSignal object to
> a slot,

I don't believe, that this is _directly_ related to the new style 
signal/slot idiom, but you might want to experiment with the connection 
type argument of connect. 

> this is the pseudocode for the connection : 
>
> class(...):
>
> def __init__(...):
>   self.rsh.entity_update_signal.connect( self.handle_entity_update )
>
> @QtCore.pyqtSlot( object, object )
> def handle_entity_update( self, sender, entity ):
> ...
>
> Are these operations supposed to be thread safe or am
> I missing something ?
>

BTW, the camelot website http://www.python-camelot.com/ seems to be down 
since some time.. What's the state of your project?

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


Re: [PyQt] Composite widgets?

2010-09-06 Thread Dan Kripac
Hi Peter,

I find that a lot of my use with PyQt is composing compound widget
subclasses that combine other widgets in a particular arrangement and
behaviour that I need. You can easily design the way they behave in terms of
signals emitted, and you can capture mouse and keyboard events simply by
overriding particular methods from the base QWidget class.

Not sure if there are many pre-existing libraries of these (that I know).
Perhaps because it's easy to do once you get the hang of it. For example, to
make a combined label and line edit:

class myTextField(QWidget):
def __init__(self,label="My Text Field", parent=None):
super(myTextField,self).__init__(parent)
layout = QHBoxLayout()
self.label = QLabel(label)
layout.addWidget( self.label )
self.lineEdit = QLineEdit()
layout.addWidget( self.lineEdit )
self.setLayout( layout )

You can get much more sophisticated than this, but just a quick example
really.

Hope this helps.

Dan

On 6 September 2010 02:13, Peter Milliken  wrote:

> Prior to embarking on learning PyQt, I wrote my GUI applications using
> Tkinter and Pmw. The Pmw widget set is quite nice and provides a library of
> composite classes using the Tkinter widgets.
>
> My question is:
>
> Is there any (similar) composite widgets in PyQt? i.e. Pmw has the
> EntryField widget, which combines the (commonly used case) of a Label and a
> LineEdit into the one class - much more convenient than always having to
> specify the two entities separately, which seems to be the case with PyQt?
> The EntryField widget offers far more than just conveniently creating a
> Label and a LineEdit in the one class, it also allows definition of entry
> validation as well, so you can see that the composite classes provide quite
> a high level of functional behaviour to the user.
>
> Pmw defines other composite widgets like: RadioSelect - which groups radio
> buttons (well, you have the choice of defining it to handle radio buttons,
> check buttons or "normal" buttons). Of course in PyQt I have found the
> QGroupBox class, but this only performs a (small) part of what the Pmw
> RadioSelect widget does.
>
> Do such composite widgets exist? am I missing something in the PyQt
> documentation?
>
> Thanks
> Peter
>
>
> ___
> PyQt mailing listPyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt