13,005
回編集
(ページの作成:「== 概要 == <br><br> == 画面の表示 == まず、PyQtで基本となるものは、画面を表示することである。<br> 以下のサンプルコードでは…」) |
編集の要約なし |
||
5行目: | 5行目: | ||
== 画面の表示 == | == 画面の表示 == | ||
まず、PyQtで基本となるものは、画面を表示することである。<br> | まず、PyQtで基本となるものは、画面を表示することである。<br> | ||
以下のサンプルコードでは、<code>QWidget</code>クラスを使用して画面のみを表示している。<br> | |||
<source lang="python"> | <source lang="python"> | ||
# - * - coding: utf8 - * - | # - * - coding: utf8 - * - | ||
43行目: | 43行目: | ||
ステータスバーには、現在の画面内の情報等を表示することが可能である。<br> | ステータスバーには、現在の画面内の情報等を表示することが可能である。<br> | ||
<br> | <br> | ||
上記のセクションでは、<code>QWidget</code>クラスを継承したMyWindowクラスを作成して画面を表示しているが、<br> | |||
ステータスバーを表示するには、<code>QMainWindow</code>クラスを継承して画面を作成する必要がある。<br> | |||
<br> | <br> | ||
<code>QWidget</code>クラスや<code>QDialog</code>クラスを使用して画面を作成することもできるが、<br> | |||
メイン画面においては<code>QMainWindow</code>クラスを使用することを推奨する。<br> | |||
それは、<u><code>QMainWindow</code>クラスは、以下に示すメイン画面を作成するための機能を提供しているからである。</u><br> | |||
* メニューバー | * メニューバー | ||
* ツールバー | * ツールバー | ||
53行目: | 54行目: | ||
* 中央ウィジェット | * 中央ウィジェット | ||
* ステータスバー | * ステータスバー | ||
<br> | |||
以下のサンプルコードでは、ステータスバーを表示している。<br> | 以下のサンプルコードでは、ステータスバーを表示している。<br> | ||
<source lang="python"> | <source lang="python"> | ||
62行目: | 63行目: | ||
from PyQt5.QtWidgets import * | from PyQt5.QtWidgets import * | ||
# | # QMainWindowクラスの使用 | ||
class MyWindow( | class MyWindow(QMainWindow): | ||
def __init__(self, parent=None): | def __init__(self, parent=None): | ||
97行目: | 98行目: | ||
from PyQt5.QtWidgets import * | from PyQt5.QtWidgets import * | ||
# | # QMainWindowクラスの使用 | ||
class MyWindow( | class MyWindow(QMainWindow): | ||
def __init__(self, parent=None): | def __init__(self, parent=None): | ||
154行目: | 155行目: | ||
from PyQt5.QtWidgets import * | from PyQt5.QtWidgets import * | ||
# | # QMainWindowクラスの使用 | ||
class MyWindow( | class MyWindow(QMainWindow): | ||
def __init__(self, parent=None): | def __init__(self, parent=None): |