Python3 (3.5.2) と Pyqt5 (5.8.2) をインストールしました。このチュートリアルに従って、GUI を学び、作成しています: http://zetcode.com/gui/pyqt5/firstprograms/
私は2番目の例を実行しようとしていますが、プログラムは次のようなエラーを返しています(これは1番目の例でも発生しましたが、画像がなかったので気付かなかった):
QApplication: invalid style override passed, ignoring it.
No XVisualInfo for format QSurfaceFormat(version 2.0, options QFlags<QSurfaceFormat::FormatOption>(), depthBufferSize -1, redBufferSize 1, greenBufferSize 1, blueBufferSize 1, alphaBufferSize -1, stencilBufferSize -1, samples -1, swapBehavior QSurfaceFormat::SwapBehavior(SingleBuffer), swapInterval 1, profile QSurfaceFormat::OpenGLContextProfile(NoProfile))
Falling back to using screens root_visual.
これはどういう意味ですか?いくつかのパッケージがありませんか?
最初に次のコマンドで pyqt をインストールしました。
sudo -H pip3 install PyQt5
しかし、Python3はその存在を認識していなかったので、apt ubuntuリポジトリを検索してインストールしました:
sudo apt install python3-PyQt5
また、フルパス /foo/bar/image.png で画像を参照しようとしましたが、何もしませんでした
何が問題ですか?
編集#1
私が使用しているコードは、例 2 からのものです。
#!/usr/bin/python3
# -*- coding: utf-8 -*-
"""
ZetCode PyQt5 tutorial
This example shows an icon
in the titlebar of the window.
author: Jan Bodnar
website: zetcode.com
last edited: January 2015
"""
import sys
import os
from PyQt5.QtWidgets import QApplication, QWidget
from PyQt5.QtGui import QIcon
base_dir = os.path.dirname(os.path.abspath(__file__))
os.chdir(base_dir)
class Example(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.setGeometry(300, 300, 300, 220)
self.setWindowTitle('Icon')
self.setWindowIcon(QIcon('image.png'))
self.show()
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())
あなたの投稿の後、私はすべてのパッケージを再インストールしました。エラーは少し異なりますが、結果は同じです。
python3 example_02.py
QApplication: invalid style override passed, ignoring it.