PyGtk is not difficult. It is similar to Tkinter. On the Internet, when the logic code and view code are combined, PyGtk performs the best job and should be able to learn it later. But there are still doubts about some things. PyGtk2.0 is a collection of Python modules and provides Python interfaces for GTK + 2. X. GTK (GIMPToolkit) is a library used to create a graphical user interface.
PyGtk is not difficult. It is similar to Tkinter. On the Internet, when the logic code and view code are combined, PyGtk performs the best job and should be able to learn it later. But there are still doubts about some things.
PyGtk2.0 is a collection of Python modules and provides Python interfaces for GTK + 2. X.
GTK (GIMP Toolkit) is a library for creating graphical user interfaces, which is fully written in C language.
Base. py
#! /Usr/bin/envpython
#Examplebase. py
ImportPygtk
Pygtk.Require(2.0)
ImportGtk
ClassBase:
Def _ Init __(Self ):
Self. window = gtk.Window(Gtk. WINDOW_TOPLEVEL)
Self. window.Show()
Def Main(Self ):
Gtk.Main()
Print_ Name __
If_ Name __= = "_ main __":
Base =Base()
Base.Main()
Why can I "import gtk? Is gtk a gtk. py file? No, I did not find it.
Comment out"ImportPygtk and pygtk.Require(2.0) "the program can run as usual, that is, pygtk is useless. You can see that the call in the Code only calls gtk. But gtk is written in C language. Why can I directly access gtk without using pygtk in python?
The relationship between pygtk and gtk and their respective organizational structures are unclear.
------------------------------------------------------
I suddenly remembered Eclipse when I went to the canteen to buy a meal. Why don't I use CTRL + CLICK to view the gtk file? So I don't know where it is? It turns out that this trick is not easy to use. It is finally found through the Debug method.
"Import gtk" is actually executing the "C: \ Python25 \ Lib \ site-packages \ gtk-2.0 \ gtk \ __init _. py" file.
In this file, "from gtk import _ gtk" is used to import the _ gtk. pyd file in the gtk folder. The following is an example of "from gtk. _ gtk import *" imported from this. pyd file. Including "Label", "Button", and so on.
"Window" and "WINDOW_TOPLEVEL" in "gtk. Window (gtk. WINDOW_TOPLEVEL)" are all from gdk in gtk. You can view them using "from gtk import gdk" and "dir (gdk.