Python Forum
[SOLVED]PyQt5 tutorial - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: GUI (https://python-forum.io/forum-10.html)
+--- Thread: [SOLVED]PyQt5 tutorial (/thread-38183.html)



[SOLVED]PyQt5 tutorial - Barrowman - Sep-12-2022

I am trying to see if I want to use PyQt5 and am working my way through some tutorials. I haven't got very far yet.
This one does not show the tooltip when I hover over the button. All I did was copy and paste from
https://zetcode.com/gui/pyqt5/firstprograms/
#!/usr/bin/python

"""
ZetCode PyQt5 tutorial

This example
e shows a tooltip on
a window and a button.

Author: Jan Bodnar
Website: zetcode.com
"""

import sys
from PyQt5.QtWidgets import (QWidget, QToolTip,
    QPushButton, QApplication)
from PyQt5.QtGui import QFont


class Example(QWidget):

    def __init__(self):
        super().__init__()

        self.initUI()


    def initUI(self):

        QToolTip.setFont(QFont('SansSerif', 10))

        self.setToolTip('This is a <b>QWidget</b> widget')

        btn = QPushButton('Button', self)
        btn.setToolTip('This is a <b>QPushButton</b> widget')
        btn.resize(btn.sizeHint())
        btn.move(50, 50)

        self.setGeometry(300, 300, 300, 200)
        self.setWindowTitle('Tooltips')
        self.show()


def main():

    app = QApplication(sys.argv)
    ex = Example()
    sys.exit(app.exec_())


if __name__ == '__main__':
    main()
QT version is 5.12.8
PYQT version is 5.14.1
Running Linux Mint 20.3 Cinnamon
Python 3.8.10


RE: PyQt5 tutorial - deanhystad - Sep-12-2022

It works fine for me on windows.

What is your OS? Or I could just scroll down a little further and see it is Mint.


RE: PyQt5 tutorial - Barrowman - Sep-13-2022

(Sep-12-2022, 06:48 PM)deanhystad Wrote: It works fine for me on windows.

What is your OS? Or I could just scroll down a little further and see it is Mint.
So do you have any idea what I need to look at? Or can someone try from Linux to see if it's my setup or general in Linux please?


RE: PyQt5 tutorial - Axel_Erfurt - Sep-13-2022

I just did some tests in Mint 21 and LMDE5.

Tooltips are shown.

I've been using PyQt5 since Mint 17 and never had problems with tooltips.


RE: PyQt5 tutorial - deanhystad - Sep-13-2022

Also works fine with PySide6 on Windows 10 and Ubuntu 20.04.

How do you run the program?


RE: PyQt5 tutorial - Barrowman - Sep-13-2022

(Sep-13-2022, 05:35 PM)deanhystad Wrote: Also works fine with PySide6 on Windows 10 and Ubuntu 20.04.

How do you run the program?

python3 ./classes3.py
to start with and the made it executable
and got the same.
on running it from the command line I got
Output:
qt5ct: using qt5ct plugin



RE: PyQt5 tutorial - Barrowman - Sep-15-2022

Just been trying to see if there was something missing on my system and now when I run qt5ct I get the following:
Quote:qt5ct
qt5ct: using qt5ct plugin
Configuration path: "/home/norman/.config/qt5ct"
Shared QSS paths: ("/home/norman/.local/share/qt5ct/qss", "/usr/share/gnome/qt5ct/qss", "/usr/share/cinnamon/qt5ct/qss", "/home/norman/.local/share/flatpak/exports/share/qt5ct/qss", "/var/lib/flatpak/exports/share/qt5ct/qss", "/usr/local/share/qt5ct/qss", "/usr/share/qt5ct/qss", "/var/lib/snapd/desktop/qt5ct/qss")
Shared color scheme paths: ("/home/norman/.local/share/qt5ct/colors", "/usr/share/gnome/qt5ct/colors", "/usr/share/cinnamon/qt5ct/colors", "/home/norman/.local/share/flatpak/exports/share/qt5ct/colors", "/var/lib/flatpak/exports/share/qt5ct/colors", "/usr/local/share/qt5ct/colors", "/usr/share/qt5ct/colors", "/var/lib/snapd/desktop/qt5ct/colors")
Is this normal or have I some conflicts causing the problem?


RE: PyQt5 tutorial - Barrowman - Sep-15-2022

I decided to have a look at qt5ct.conf and found that one item was
Quote:gui_effects=@Invalid()
which seemed odd. S0 I deleted that line and tried running the code again. Well the tooltip worked so I thought I had sorted it out and tried another tutorial which had 2 buttons on it but that didn't work.
Guess what???!!! the original doesn't work again. It was a one time only thing. What on earth is happening?


RE: PyQt5 tutorial - Axel_Erfurt - Sep-15-2022

This my qt5ct.conf

It also has gui_effects=@Invalid(). Nevertheless it works.

Output:
[Appearance] color_scheme_path=/usr/share/qt5ct/colors/airy.conf custom_palette=false icon_theme=Mint-Y standard_dialogs=default style=gtk2 [Fonts] fixed=@Variant(\0\0\0@\0\0\0\x12\0M\0o\0n\0o\0s\0p\0\x61\0\x63\0\x65@$\0\0\0\0\0\0\xff\xff\xff\xff\x5\x1\0\x32\x10) general=@Variant(\0\0\0@\0\0\0\f\0R\0o\0\x62\0o\0t\0o@$\0\0\0\0\0\0\xff\xff\xff\xff\x5\x1\0\x32\x10) [Interface] activate_item_on_single_click=1 buttonbox_layout=0 cursor_flash_time=1000 dialog_buttons_have_icons=1 double_click_interval=400 gui_effects=@Invalid() keyboard_scheme=2 menus_have_icons=true show_shortcuts_in_context_menus=true stylesheets=@Invalid() toolbutton_style=4 underline_shortcut=1 wheel_scroll_lines=3 [SettingsWindow] geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x3\0\0\0\0\0\x32\0\0\0J\0\0\x3\x10\0\0\x2\xa8\0\0\0\x32\0\0\0\x66\0\0\x3\x10\0\0\x2\xa8\0\0\0\0\0\0\0\0\x5\xa0\0\0\0\x32\0\0\0\x66\0\0\x3\x10\0\0\x2\xa8)



RE: PyQt5 tutorial - Barrowman - Sep-16-2022

(Sep-15-2022, 11:31 AM)Axel_Erfurt Wrote: This my qt5ct.conf

It also has gui_effects=@Invalid(). Nevertheless it works.

Output:
[Appearance] color_scheme_path=/usr/share/qt5ct/colors/airy.conf custom_palette=false icon_theme=Mint-Y standard_dialogs=default style=gtk2 [Fonts] fixed=@Variant(\0\0\0@\0\0\0\x12\0M\0o\0n\0o\0s\0p\0\x61\0\x63\0\x65@$\0\0\0\0\0\0\xff\xff\xff\xff\x5\x1\0\x32\x10) general=@Variant(\0\0\0@\0\0\0\f\0R\0o\0\x62\0o\0t\0o@$\0\0\0\0\0\0\xff\xff\xff\xff\x5\x1\0\x32\x10) [Interface] activate_item_on_single_click=1 buttonbox_layout=0 cursor_flash_time=1000 dialog_buttons_have_icons=1 double_click_interval=400 gui_effects=@Invalid() keyboard_scheme=2 menus_have_icons=true show_shortcuts_in_context_menus=true stylesheets=@Invalid() toolbutton_style=4 underline_shortcut=1 wheel_scroll_lines=3 [SettingsWindow] geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x3\0\0\0\0\0\x32\0\0\0J\0\0\x3\x10\0\0\x2\xa8\0\0\0\x32\0\0\0\x66\0\0\x3\x10\0\0\x2\xa8\0\0\0\0\0\0\0\0\x5\xa0\0\0\0\x32\0\0\0\x66\0\0\x3\x10\0\0\x2\xa8)
Thanks Axel,
Yesterday I ran another program I normally run from the menu but had trouble with it. I ran it from the command line and got the message about qt5ct so i removed a few qt5 related items via software manager. Then when I ran the original program I have had trouble with it reported that PyQt5 was missing. I installed Python3-qt5 and now it's all working fine. So I guess Python3-qt5 had been corrupted at some point or it may have been a bad version.