## page was renamed from zhArticleTemplate ##language:zh #pragma section-numbers on ''' 含有章节索引的中文 文章模板 ''' ::-- ehu4ever [<>] <> = Using libGlade with Python = Libglade is a library that reads in an XML file and makes the corresponding calls to GTK to create a GUI. Glade (actually Glade-2. exe or glade2) will present you with a GUI for creating these XML files. There are many advantages for doing your GUI in this way: * You can change your GUI quickly and easily. * You can have multiple GUIs that drive the same underlying application. * You spend your time designing the GUI, and not debugging the GUI creation code. As Immunity developed CANVAS, we also strove as much as possible to isolate the code from the GUI altogether. Although we liked the pyGTK model, there was a distinct possibility that someday we would want to port to a platform that GTK did not support, such as the Sharp Zaurus. Good application design specifies that you actually build another layer in between your GUI and your application code, such that you have three layers: * The XML file that describes your GUI. * An application file (called something like mygui . py), which loads the GUI and application, and other application files as needed for major GUI components to allow for testing them independently of the rest of the application. These are the only files that use GTK functionality directly. * The application logic itself, which should never import GTK or any GUI toolkit library. All calls to the GUI should be through the code in mygui . py. Using this design will save you years of time later trying to debug some small threading error. All of Immunity CANVAS (not a trivial application) was ported from GTK version 1 (and pyGTK version 1) to GTK version 2 (and corresponding pyGTK) within one day. Because GTK development is proceeding quite quickly, this sort of capability is going to be key to maintaining compatibility with the library itself.