13,228
回編集
| 69行目: | 69行目: | ||
>>> import tkinter | >>> import tkinter | ||
>>> tkinter._test() | >>> tkinter._test() | ||
<br><br> | |||
== その他 == | |||
==== PyGObjectのインストール ==== | |||
PyGObjectが提供するPythonバインディングを使用して、GTKベースのGUIアプリケーションを実行することができる。<br> | |||
これには、PyGObject、GTK、それらの依存関係をインストールする必要がある。<br> | |||
<br> | |||
* パッケージ管理システムでのインストール | |||
*: 以下のコマンドを実行する。 | |||
** CentOS : <code>sudo dnf install python3-gobject gtk3</code> | |||
** SUSE : <code>sudo zypper install python3-gobject python3-gobject-Gdk typelib-1_0-Gtk-3_0 libgtk-3-0</code> | |||
*: <br> | |||
*: 以下のサンプルコードを実行する。 | |||
*: <code>python3 Sample.py</code> | |||
<br> | |||
* PIPコマンド(PyPI)でのインストール | |||
*: GTKと依存関係をビルドするため、以下のコマンドを実行する。 | |||
** CentOS : <code>sudo dnf install gcc gobject-introspection-devel cairo-devel pkg-config python3-devel gtk3</code> | |||
** SUSE : <code>sudo zypper install cairo-devel pkg-config python3-devel gcc gobject-introspection-devel</code> | |||
*: <br> | |||
*: PycairoとPyGObjectをビルド・インストールするため、以下のコマンドを実行する。 | |||
*: <code>pip3 install pycairo</code> | |||
*: <code>pip3 install PyGObject</code> | |||
*: <br> | |||
*: 以下のサンプルコードを実行する。 | |||
*: <code>python3 Sample.py</code> | |||
<br> | |||
<source lang="python"> | |||
import gi | |||
gi.require_version("Gtk", "3.0") | |||
from gi.repository import Gtk | |||
window = Gtk.Window(title="Hello World") | |||
window.show() | |||
window.connect("destroy", Gtk.main_quit) | |||
Gtk.main() | |||
</source> | |||
<br><br> | <br><br> | ||
__FORCETOC__ | __FORCETOC__ | ||
[[カテゴリ:Python]][[カテゴリ:CentOS]][[カテゴリ:SUSE]] | [[カテゴリ:Python]][[カテゴリ:CentOS]][[カテゴリ:SUSE]] | ||