1. PyQt を使って GUI アプリケーションを作る
Python でGUI アプリケーションを作る方法は幾つかあるが、ほとんどの場合は GUI のウインドウを作るのが面倒だ。
そこで今回はクロスプラットホーム(Linux/MacOS/Windows)で利用できる「Qt Creator」を利用した PyQt での作成方法について紹介しようと思う。
インストール
一般的な Linux では、パッケージャーからインストール可能だ。
まずはパッケージャーで「qt-creator」とウィジェットのデザインを行う「qt6-designer」をインストールする。


コマンドラインでのインストール
$ sudo dnf install qt-creator qt6-designer
Mac や Widnows でのインストール
こちらのサイトの末尾にある「Download the Qt Online Installer」から次のページに進み、ダウンロードとインストールを行う。

Qt Creator を実行してみる
以下の画面が表示されれば成功だ。

Qt Designer を実行してみる
以下の画面が表示されれば成功だ。

PySide6 をインストールする
PyQt でアプリケーションを作成する場合は、「PySide6」を呼ばれるモジュールを利用する。
しかし Fedora ではパッケージで提供されていないので、pip を用いてインストールを行う。
$ sudo pip install PySide6==6.6.1
※ PySide6 の 6.6.2 にはバグがあるようなので、6.6.1 をインストールしてある。
※ pip を root でインストールしてあるが、好みに応じて個人環境や仮想環境でも構わない。違いはこちらを熟読してください。
今回はここまで
今回はインストールまで説明したが、次回からは基本的な部分から説明していく。


