Re: [PyQt] spreadsheet example

2012-02-21 Thread Hans-Peter Jansen
Am Monday 20 February 2012 19:30:06 schrieb Phil Thompson:
 On Mon, 20 Feb 2012 18:20:32 +0100, Hans-Peter Jansen h...@urpla.net

 wrote:
  Am Sunday 19 February 2012 12:47:28 schrieb Phil Thompson:
  On Sat, 11 Feb 2012 01:36:14 +0100, Hans-Peter Jansen
  h...@urpla.net
 
  wrote:
   Hi Phil,
  
   while I'm seriously overloaded at the moment (a bunch of people are
   much
  
   harder to organize then code), I did some relaxations by converting
   another fine Qt example. As usual, I couldn't resist in pimping it
   up in some minor ways. Most prominently, I added a way to change
   the date format globally. Also, a workaround to fetch the correct
   cell background color is applied.
 
  I removed the workaround as (for me) it doesn't seem to be needed and
  also it breaks the background of the first and last rows.
 
  Not here. Does the background color dialog show the correct color for
  you in all fields? Here, it's showing black by default, while I use
  some very different background color.

 It shows black for white fields, and the correct colour for others. This
 is the same as the C++ version - this is on a Mac. I was more concerned
 about the incorrect first and last rows.

Yes, the C++ version suffers from the same problem. The idea was: only the 
initial background color was wrong (all zero), but after setting some valid 
color, the cell background color behaved well. Since it fails for you, and 
this is just an example, keeping it bug compatible is preferable. A real 
application would initialize such properties explicitely via proper 
interfaces. 

Have a nice day,
Pete
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] TableView - activated signal

2012-02-21 Thread Mads Ipsen

Hi,

Sorry for bugging you with the same issue again.

Last week I posted a problem regarding QTableView and the triggering of 
its activated signal. I didn't get any response - maybe I was too vague 
in the statement of the problem?


Anyway, this time I attach a snippet that reproduces the issue. So run 
the example and try to tell me why the activated signal is NOT triggered 
when a cell is clicked, double-clicked, entered etc.


Best regards,

Mads

--
+-+
| Mads Ipsen  |
+--+--+
| Gåsebæksvej 7, 4. tv |  |
| DK-2500 Valby| phone:  +45-29716388 |
| Denmark  | email:  mads.ip...@gmail.com |
+--+--+


import sys
from PyQt4 import QtGui, QtCore

class Table(QtGui.QTableView):
def __init__(self):
QtGui.QTableView.__init__(self)

# Hook up model
self._model = QtGui.QStandardItemModel(3,3)
self.setModel(self._model)

# Add dummy data
for i in range(3):
for j in range(3):
item = QtGui.QStandardItem('(%d,%d)' % (i,j))
self._model.setItem(i,j,item)

# Connect
self.connect(self, QtCore.SIGNAL('doubleClicked(const QModelIndex )'), self.doubleClicked)
self.connect(self, QtCore.SIGNAL('activated(const QModelIndex )'), self.activated)

def doubleClicked(self, index):
print 'doubleClick on cell[%d,%d]' % (index.row(), index.column())

def activated(self, index):
print 'activate on cell[%d,%d]' % (index.row(), index.column())

if __name__ == __main__:
app = QtGui.QApplication(sys.argv)

table = Table()
table.show()

sys.exit(app.exec_())
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] TableView - activated signal

2012-02-21 Thread Mads Ipsen

On 21/02/2012 15:32, Mateusz Korniak wrote:

On Tuesday 21 of February 2012, Mads Ipsen wrote:

(...) I attach a snippet that reproduces the issue. So run
the example and try to tell me why the activated signal is NOT triggered
when a cell is clicked, double-clicked, entered etc.


I get handlers called for click, dbl-click, and hitting enter.
python-PyQt4-4.8.5
QtGui-4.7.4

Regards,


This works for me also - except for single-click which triggers nothing.

   * But if you navigate around in the cell using arrow keys and then
 press space, the cell is opened, but no signal is triggered.
   * If you then write something in the cell and press TAB to leave the
 cell - no signal is triggered.
   * Also, I would expect a double-click to also trigger the activated
 signal, since the cell is activated by the double-click.


In short: What does it mean that a cell is activated? What actions will 
trigger this signal?


Best regards,

Mads

--
+-+
| Mads Ipsen  |
+--+--+
| Ga*seb?ksvej 7, 4. tv |  |
| DK-2500 Valby| phone:  +45-29716388 |
| Denmark  | email:  mads.ip...@gmail.com |
+--+--+


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

Re: [PyQt] TableView - activated signal

2012-02-21 Thread Mateusz Korniak
On Tuesday 21 of February 2012, Mads Ipsen wrote:
 On 21/02/2012 15:32, Mateusz Korniak wrote:
  On Tuesday 21 of February 2012, Mads Ipsen wrote:
  (...) I attach a snippet that reproduces the issue. So run
  the example and try to tell me why the activated signal is NOT triggered
  when a cell is clicked, double-clicked, entered etc.
  
  I get handlers called for click, dbl-click, and hitting enter.
  python-PyQt4-4.8.5
  QtGui-4.7.4
  
 * But if you navigate around in the cell using arrow keys and then
   press space, the cell is opened, but no signal is triggered.
 * If you then write something in the cell and press TAB to leave the
   cell - no signal is triggered.
Perhaps above are cell contents edits, without activation.

 * Also, I would expect a double-click to also trigger the activated
   signal, since the cell is activated by the double-click.
That works for me:
activate on cell[1,1]
doubleClick on cell[1,1]

 In short: What does it mean that a cell is activated? What actions will
 trigger this signal?

This signal is emitted when the item specified by index is activated by the 
user. How to activate items depends on the platform; e.g., by single- or 
double-clicking the item, or by pressing the Return or Enter key when the item 
is current ?

Regards,

-- 
Mateusz Korniak
(...) mam brata - poważny, domator, liczykrupa, hipokryta, pobożniś,
krótko mówiąc - podpora społeczeństwa.
Nikos Kazantzakis - Grek Zorba
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] TableView - activated signal

2012-02-21 Thread Mads Ipsen

On 21/02/2012 16:47, Mateusz Korniak wrote:

On Tuesday 21 of February 2012, Mads Ipsen wrote:

On 21/02/2012 15:32, Mateusz Korniak wrote:

On Tuesday 21 of February 2012, Mads Ipsen wrote:

(...) I attach a snippet that reproduces the issue. So run
the example and try to tell me why the activated signal is NOT triggered
when a cell is clicked, double-clicked, entered etc.

I get handlers called for click, dbl-click, and hitting enter.
python-PyQt4-4.8.5
QtGui-4.7.4


 * But if you navigate around in the cell using arrow keys and then
   press space, the cell is opened, but no signal is triggered.
 * If you then write something in the cell and press TAB to leave the
   cell - no signal is triggered.

Perhaps above are cell contents edits, without activation.


 * Also, I would expect a double-click to also trigger the activated
   signal, since the cell is activated by the double-click.

That works for me:
activate on cell[1,1]
doubleClick on cell[1,1]

Any idea why this fails for me? Because I use Gnome? Bug?

In short: What does it mean that a cell is activated? What actions will
trigger this signal?

This signal is emitted when the item specified by index is activated by the
user. How to activate items depends on the platform; e.g., by single- or
double-clicking the item, or by pressing the Return or Enter key when the item
is current ?

Regards,




--
+-+
| Mads Ipsen  |
+--+--+
| Gåsebæksvej 7, 4. tv |  |
| DK-2500 Valby| phone:  +45-29716388 |
| Denmark  | email:  mads.ip...@gmail.com |
+--+--+


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

Re: [PyQt] Mouse Hover Event small issue

2012-02-21 Thread uahmed
any help !


On Tue, Feb 21, 2012 at 7:27 AM, uahmed gleam.uah...@gmail.com wrote:

 hi ,

 I want to do hover i saw an example and then write a script which will be
 use as i made program i am facing one problem that hover only occur if u
 putt mouse on the left corner of button i want that it will happen for all
 the button that if i move cursor on button then it should change. here is
 my code

 from PyQt4 import QtGui, QtCore
 from PyQt4.QtCore import pyqtSignal
 import os,sys

 class HoverButton(QtGui.QToolButton):
 def enterEvent(self,event):
 print(Enter)
 button.setStyleSheet(background-color:#45b545;)

 def leaveEvent(self,event):
 button.setStyleSheet(background-color:yellow;)
 print(Leave)
 app = QtGui.QApplication(sys.argv)
 widget = QtGui.QWidget()
 button = QtGui.QToolButton(widget)
 button.setMouseTracking(True)
 buttonss =  HoverButton(button)
 button.setIconSize(QtCore.QSize(200,200))
 widget.show()
 sys.exit(app.exec_())



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

Re: [PyQt] TableView - activated signal

2012-02-21 Thread David Cortesi

  * But if you navigate around in the cell using arrow keys and then press
 space, the cell is opened, but no signal is triggered.
* If you then write something in the cell and press TAB to leave the
 cell - no signal is triggered.


These actions relate to editing the cell contents. Suggest you read the
Assistant page on QAbstractItemDelegate, with its examples. The Item
Delegate is what gets invoked when Qt thinks the user wants to modify the
contents of a cell.

Here are the notes I wrote to myself after figuring out how to create an
Abstract Item Delegate:

# a custom delegate is: an object that represents a
# type of data when an instance of that type needs to be displayed or
edited.
# The delegate must implement 3 methods:
# createEditor() returns a widget that the table view will position over the
#table cell to act as an editor, e.g. a combo-box or line-edit;
# setEditorData() initializes the editor widget with data to display;
# setModelData() is called when editing is complete, to store possibly
#changed data back to the model.

This is how you get control whenever the user indicates BY ANY MEANS that
she is ready to input or modify data, or has finished modifying the data.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt