Re: [PyQt] tooltips in menu: how?

2009-04-18 Thread projetmbc
V. Armando Solé is right. With this solution the tooltips come quickly 
in my computer. The corresponding PyQt code is :


#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
from PyQt4 import QtCore, QtGui, uic

class MainWindow(QtGui.QWidget):
   def __init__(self, parent=None):
   super(MainWindow, self).__init__(parent)
   self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
   self.setAttribute(QtCore.Qt.WA_GroupLeader)
   self.menuI = QtGui.QPushButton(Menu)
   self.menuI.setToolTip(Click here...)
   self.menuI.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)

   mainLayout = QtGui.QHBoxLayout()
   mainLayout.addWidget(self.menuI)
   self.setLayout(mainLayout)
   self.resize(49,40)
   self.setWindowTitle(Qt menu)

   self.clicAct0 = QtGui.QAction(0, self)
   self.clicAct0.setToolTip(tooltip 0)
   self.connect(self.clicAct0, QtCore.SIGNAL(triggered()), self.clic)

   self.clicAct1 = QtGui.QAction(1, self)
   self.clicAct1.setToolTip(tooltip 1)
   self.connect(self.clicAct1, QtCore.SIGNAL(triggered()), self.clic)

   self.clicAct2 = QtGui.QAction(2, self)
   self.clicAct2.setToolTip(tooltip 2)
   self.connect(self.clicAct2, QtCore.SIGNAL(triggered()), self.clic)

   menu0 = QtGui.QMenu(self)
   menu0.addAction(self.clicAct0)
   menu0.addAction(self.clicAct1)
   menu0.addAction(self.clicAct2)

   self.connect(menu0, QtCore.SIGNAL(hovered(QAction *)),
   self._actionHovered)
  
   menu1 = QtGui.QMenu(self)

   menu1.setTitle(submenu)
   menu1.setToolTip(tooltip submenu)

   menu1_0 = QtGui.QAction(subentry,self)
   menu1_0.setToolTip(tooltip subentry)

   self.connect(menu1_0, QtCore.SIGNAL(triggered()), self.clic)
   menu1.addAction(menu1_0)
   menu0.addMenu(menu1)
   self.menuI.setMenu(menu0)

   def clic(self):
   print clic

   def _actionHovered(self, action):
   tip = action.toolTip()
   QtGui.QToolTip.showText(QtGui.QCursor.pos(), tip)

def main():
   app = QtGui.QApplication(sys.argv)
   locale = QtCore.QLocale.system().name()
   appTranslator = QtCore.QTranslator()
   app.setApplicationName(app.translate(main, qtmenu))

   form = MainWindow()
   form.show()
   app.exec_()

if __name__ == __main__:
   main()






Andreas Pakulat wrote:

On 17.04.09 19:57:29, V. Armando Solé wrote:
 

Hi!

I encounter the same problem as the original poster. The tooltips 
of  QActions in a QMenu are not shown.


Is there a solution?



You can set the statustip on the actions, which makes the text show up
in the statusbar (at least in KDE apps, maybe pure Qt needs some
additional hookup there). But AFAIK Qt simply doesn't support Tooltips
on menus at this point, possibly something they could add to 4.6.

Andreas
I get satisfactory results (if one does not mind to show ALWAYS a 
tooltip) with:


   qt.QObject.connect(menu, qt.SIGNAL(hovered(QAction *)), 
self._actionHovered)


   def _actionHovered(self, action):
   tip = action.toolTip()
   qt.QToolTip.showText(qt.QCursor.pos(), tip)

Surely there are cleaner workarounds ...

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] tooltips in menu: how?

2009-04-17 Thread V. Armando Solé

Hi!

I encounter the same problem as the original poster. The tooltips of 
QActions in a QMenu are not shown.


Is there a solution?

My system is Windows XP, python 2.5, Qt 4.4.3 and PyQt 4.4.4

Thanks,

Armando

Paolo Milani wrote:

Hi! :)
I'm a newbie. I've searched in the docs, but I haven't found the solution.
I want to add tooltips to menu, but it doesn't work: tooltips are not 
displayed.  Suggestions?

my system: ubuntu linux 8.10 with kde 4..2 repository.

Many thanks. This is the code:



#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
from PyQt4 import QtCore, QtGui, uic

class MainWindow(QtGui.QWidget):
  def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
self.setAttribute(QtCore.Qt.WA_GroupLeader)
self.menuI = QtGui.QPushButton(Menu)
self.menuI.setToolTip(Click here...)
self.menuI.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)

mainLayout = QtGui.QHBoxLayout()
mainLayout.addWidget(self.menuI)
self.setLayout(mainLayout)
self.resize(49,40)
self.setWindowTitle(Qt menu)

self.clicAct0 = QtGui.QAction(0, self)
self.clicAct0.setToolTip(tooltip 0)
self.connect(self.clicAct0, QtCore.SIGNAL(triggered()), self.clic)

self.clicAct1 = QtGui.QAction(1, self)
self.clicAct1.setToolTip(tooltip 1)
self.connect(self.clicAct1, QtCore.SIGNAL(triggered()), self.clic)

self.clicAct2 = QtGui.QAction(2, self)
self.clicAct2.setToolTip(tooltip 2)
self.connect(self.clicAct2, QtCore.SIGNAL(triggered()), self.clic)

menu0 = QtGui.QMenu(self)
menu0.addAction(self.clicAct0)
menu0.addAction(self.clicAct1)
menu0.addAction(self.clicAct2)

menu1 = QtGui.QMenu(self)
menu1.setTitle(submenu)
menu1.setToolTip(tooltip submenu)

menu1_0 = QtGui.QAction(subentry,self)
menu1_0.setToolTip(tooltip subentry)

self.connect(menu1_0, QtCore.SIGNAL(triggered()), self.clic)
menu1.addAction(menu1_0)
menu0.addMenu(menu1)
self.menuI.setMenu(menu0)

  def clic(self):
print clic


def main():
  app = QtGui.QApplication(sys.argv)
  locale = QtCore.QLocale.system().name()
  appTranslator = QtCore.QTranslator()
  app.setApplicationName(app.translate(main, qtmenu))

  form = MainWindow()
  form.show()
  app.exec_()

if __name__ == __main__:
  main()


  



___
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] tooltips in menu: how?

2009-04-17 Thread Andreas Pakulat
On 17.04.09 19:57:29, V. Armando Solé wrote:
 Hi!

 I encounter the same problem as the original poster. The tooltips of  
 QActions in a QMenu are not shown.

 Is there a solution?

You can set the statustip on the actions, which makes the text show up
in the statusbar (at least in KDE apps, maybe pure Qt needs some
additional hookup there). But AFAIK Qt simply doesn't support Tooltips
on menus at this point, possibly something they could add to 4.6.

Andreas

-- 
You will obey or molten silver will be poured into your ears.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] tooltips in menu: how?

2009-04-17 Thread V. Armando Solé

Andreas Pakulat wrote:

On 17.04.09 19:57:29, V. Armando Solé wrote:
  

Hi!

I encounter the same problem as the original poster. The tooltips of  
QActions in a QMenu are not shown.


Is there a solution?



You can set the statustip on the actions, which makes the text show up
in the statusbar (at least in KDE apps, maybe pure Qt needs some
additional hookup there). But AFAIK Qt simply doesn't support Tooltips
on menus at this point, possibly something they could add to 4.6.

Andreas
I get satisfactory results (if one does not mind to show ALWAYS a 
tooltip) with:


   qt.QObject.connect(menu, qt.SIGNAL(hovered(QAction *)), 
self._actionHovered)


   def _actionHovered(self, action):
   tip = action.toolTip()
   qt.QToolTip.showText(qt.QCursor.pos(), tip)

Surely there are cleaner workarounds ...

Armando


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


Re: [PyQt] tooltips in menu: how?

2009-03-20 Thread paolomilani

--- Mer 18/3/09, massimo di stefano massimodisa...@yahoo.it wrote:
 i runned your code here on a mac osx, python2.5, qt-4.4.3,
 pyqt4.4.4
 seems it works properly,
 i can see tooltips :

do you see tooltips on menu entry 0, 1 and 2?

many thanks!

paolo



  


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


[PyQt] tooltips in menu: how?

2009-03-18 Thread Paolo Milani

Hi! :)
I'm a newbie. I've searched in the docs, but I haven't found the solution.
I want to add tooltips to menu, but it doesn't work: tooltips are not 
displayed.  Suggestions?

my system: ubuntu linux 8.10 with kde 4..2 repository.

Many thanks. This is the code:



#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
from PyQt4 import QtCore, QtGui, uic

class MainWindow(QtGui.QWidget):
  def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
self.setAttribute(QtCore.Qt.WA_GroupLeader)
self.menuI = QtGui.QPushButton(Menu)
self.menuI.setToolTip(Click here...)
self.menuI.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)

mainLayout = QtGui.QHBoxLayout()
mainLayout.addWidget(self.menuI)
self.setLayout(mainLayout)
self.resize(49,40)
self.setWindowTitle(Qt menu)

self.clicAct0 = QtGui.QAction(0, self)
self.clicAct0.setToolTip(tooltip 0)
self.connect(self.clicAct0, QtCore.SIGNAL(triggered()), self.clic)

self.clicAct1 = QtGui.QAction(1, self)
self.clicAct1.setToolTip(tooltip 1)
self.connect(self.clicAct1, QtCore.SIGNAL(triggered()), self.clic)

self.clicAct2 = QtGui.QAction(2, self)
self.clicAct2.setToolTip(tooltip 2)
self.connect(self.clicAct2, QtCore.SIGNAL(triggered()), self.clic)

menu0 = QtGui.QMenu(self)
menu0.addAction(self.clicAct0)
menu0.addAction(self.clicAct1)
menu0.addAction(self.clicAct2)

menu1 = QtGui.QMenu(self)
menu1.setTitle(submenu)
menu1.setToolTip(tooltip submenu)

menu1_0 = QtGui.QAction(subentry,self)
menu1_0.setToolTip(tooltip subentry)

self.connect(menu1_0, QtCore.SIGNAL(triggered()), self.clic)
menu1.addAction(menu1_0)
menu0.addMenu(menu1)
self.menuI.setMenu(menu0)

  def clic(self):
print clic


def main():
  app = QtGui.QApplication(sys.argv)
  locale = QtCore.QLocale.system().name()
  appTranslator = QtCore.QTranslator()
  app.setApplicationName(app.translate(main, qtmenu))

  form = MainWindow()
  form.show()
  app.exec_()

if __name__ == __main__:
  main()


  


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