The Python GTK+ 3 Tutorial¶ Release 3.4 Date Nov 12, 2023 Copyright GNU Free Documentation License 1.3 with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts This tutorial gives an introduction to writing GTK+ 3 applications in Python. Prior to working through this tutorial, it is recommended that you have a reasonable grasp of the Python programming language. GUI programming in
# 最終更新日 2019.08.18 2019 年現在の仕様に追記と書き換え。 PyGtk 関連の削除、PDF の描写を追加、拡縮を Matrix 計算に変更、他書き直しと追記を沢山。 タイトルを [線や図形の描写] から [Draw(画像,PDF,SVG,図形)] に変更。 GTK3 では描写処理はすべて cairo を使うようになりました。 cairo 自体は GTK2 からも使えましたが GTK3 は以前の方法は使えません。 draw シグナルは GtkWidget が提供しています。 GtkDrawingArea を利用が鉄板ですが GtkWidget のサブクラスならどの Widget にでも描写できます。 GtkApplicationWindow に直接描写だとタイトルバー部分まで描写される困ったことになるので注意。 シグナルの引数に cairo_t が含まれていてそれを利用し
2.1. Simple Example¶ To start with our tutorial we create the simplest program possible. This program will create an empty 200 x 200 pixel window. import gi gi.require_version("Gtk", "3.0") from gi.repository import Gtk win = Gtk.Window() win.connect("destroy", Gtk.main_quit) win.show_all() Gtk.main()
Getting Started To get things started we will try to run a very simple GTK based GUI application using the PyGObject provided Python bindings. First create a small Python script called hello.py with the following content and save it somewhere: import sys import gi gi.require_version("Gtk", "4.0") from gi.repository import GLib, Gtk class MyApplication(Gtk.Application): def __init__(self): super()
やりたかったこと Windows環境のPython3でGTK+3を使いたかった。 ハマった時の環境 Windows 10 Python 3.5.2 何が起きたか PythonのインストールからPyGObjectの導入まで、何もかも上手く行っていた。 が、しかし。 >>> import gi Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named 'gi' 大事なものがimport出来ない… 結論 PyGObjectがPython3.5以上に対応してなかった。 一旦全部消してPython3.4をインストールして、PyGObjectを導入し直したら動いた。 ちなみにPython3.4.5のWindows版が見当たらなかったので3.4.4をインストールし
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く