Download Gtk All In One Bundle
This is very straightforward. Download and install PyGTK, Py2Cairo and PyGObjects from Christoph Gohlke's website.Note, do not install pycairo, as Gohlke clearly states it is not compatible with PyGTK.; Create a folder called 'runtime' in `C: Python27 Lib site-packages gtk-2.0`. Download and install the GTK all in one bundle for 64-bit systems from Gnome. Eclipse is probably best known as a Java IDE, but it is more: it is an IDE framework, a tools framework, an open source project, a community, an eco-system, and a.
The architecture of Swing is designed so that you may change the 'look and feel' (L&F) of your application's GUI (see ). 'Look' refers to the appearance of GUI widgets (more formally, JComponents) and 'feel' refers to the way the widgets behave. Swing's architecture enables multiple L&Fs by separating every component into two distinct classes: a JComponent subclass and a corresponding ComponentUI subclass. For example, every JList instance has a concrete implementation of ListUI ( ListUI extends ComponentUI). The ComponentUI subclass is referred to by various names in Swing's documentation—'the UI,' 'component UI,' 'UI delegate,' and 'look and feel delegate' are all used to identify the ComponentUI subclass.
Most developers never need to interact with the UI delegate directly. For the most part, the UI delegate is used internally by the JComponent subclass for crucial functionality, with cover methods provided by the JComponent subclass for all access to the UI delegate. For example, all painting in JComponent subclasses is delegated to the UI delegate. By delegating painting, the 'look' can vary depending upon the L&F. It is the responsibility of each L&F to provide a concrete implementation for each of the ComponentUI subclasses defined by Swing.
For example, the Java Look and Feel creates an instance of MetalTabbedPaneUI to provide the L&F for JTabbedPane. The actual creation of the UI delegate is handled by Swing for you—for the most part you never need to interact directly with the UI delegate. The rest of this section discusses the following subjects:.
Sun's JRE provides the following L&Fs:. CrossPlatformLookAndFeel—this is the 'Java L&F' (also called 'Metal') that looks the same on all platforms. It is part of the Java API ( javax.swing.plaf.metal) and is the default that will be used if you do nothing in your code to set a different L&F.
SystemLookAndFeel—here, the application uses the L&F that is native to the system it is running on. The System L&F is determined at runtime, where the application asks the system to return the name of the appropriate L&F. Synth—the basis for creating your own look and feel with an XML file. Multiplexing— a way to have the UI methods delegate to a number of different look and feel implementations at the same time. For Linux and Solaris, the System L&Fs are 'GTK+' if GTK+ 2.2 or later is installed, 'Motif' otherwise. For Windows, the System L&F is 'Windows,' which mimics the L&F of the particular Windows OS that is running—classic Windows, XP, or Vista. The GTK+, Motif, and Windows L&Fs are provided by Sun and shipped with the Java SDK and JRE, although they are not part of the Java API.
Apple provides its own JVM which includes their proprietary L&F. In summary, when you use the SystemLookAndFeel, this is what you will see: Platform Look and Feel Solaris, Linux with GTK+ 2.2 or later GTK+ Other Solaris, Linux Motif IBM UNIX IBM. HP UX HP. Classic Windows Windows Windows XP Windows XP Windows Vista Windows Vista Macintosh Macintosh. Supplied by the system vendor.
You don't see the System L&F in the API. The GTK+, Motif, and Windows packages that it requires are shipped with the Java SDK as. Note: The GTK+ L&F will only run on UNIX or Linux systems with GTK+ 2.2 or later installed, while the Windows L&F runs only on Windows systems. Like the Java (Metal) L&F, the Motif L&F will run on any platform.
All of Sun's L&Fs have a great deal of commonality. This commonality is defined in the Basic look and feel in the API ( javax.swing.plaf.basic). The Motif and Windows L&Fs are each built by extending the UI delegate classes in javax.swing.plaf.basic (a custom L&F can be built by doing the same thing). The 'Basic' L&F is not used without being extended. In the API you will see four L&F packages:. javax.swing.plaf.basic—basic UI Delegates to be extended when creating a custom L&F. javax.swing.plaf.metal—the Java L&F, also known as the CrossPlatform L&F ('Metal' was the Sun project name for this L&F) The current default 'theme' (discussed below) for this L&F is 'Ocean, so this is often referred to as the Ocean L&F.
javax.swing.plaf.multi—a multiplexing look and feel that allows the UI methods to delegate to a number of look and feel implementations at the same time. It can be used to augment the behavior of a particular look and feel, for example with a L&F that provides audio cues on top of the Windows look and feel. This is a way of creating a handicapped-accessible look and feel. javax.swing.plaf.synth—an easily configured L&F using XML files (discussed in the next section of this lesson) You aren't limited to the L&Fs supplied with the Java platform. You can use any L&F that is in your program's class path.
External L&Fs are usually provided in one or more JAR files that you add to your program's class path at runtime. Note: If you are going to set the L&F, you should do it as the very first step in your application. Otherwise you run the risk of initializing the Java L&F regardless of what L&F you've requested. This can happen inadvertently when a static field references a Swing class, which causes the L&F to be loaded. If no L&F has yet been specified, the default L&F for the JRE is loaded. For Sun's JRE the default is the Java L&F, for Apple's JRE the Apple L&F, and so forth.
The L&F that Swing components use is specified by way of the UIManager class in the javax.swing package. Whenever a Swing component is created,the component asks the UI manager for the UI delegate that implements the component's L&F. For example, each JLabel constructor queries the UI manager for the UI delegate object appropriate for the label. It then uses that UI delegate object to implement all of its drawing and event handling. To programatically specify a L&F, use the UIManager.setLookAndFeel method with the fully qualified name of the appropriate subclass of LookAndFeel as its argument.
For example, the bold code in the following snippet makes the program use the cross-platform Java L&F. Java -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel MyApp java -Dswing.defaultlaf=com.sun.java.swing.plaf.windows.WindowsLookAndFeel MyApp Yet another way to specify the current L&F is to use the swing.properties file to set the swing.defaultlaf property. This file, which you may need to create, is located in the lib directory of Sun's Java release (other vendors of Java may use a different location). For example, if you're using the Java interpreter in javaHomeDirectory bin, then the swing.properties file (if it exists) is in javaHomeDirectory lib. Here is an example of the contents of a file. # Swing properties swing.defaultlaf=com.sun.java.swing.plaf.windows.WindowsLookAndFeel Here are the look-and-feel determination steps that occur when the UI manager needs to set a L&F:.
If the program sets the L&F before a look and feel is needed, the UI manager tries to create an instance of the specified look-and-feel class. If successful, all components use that L&F. If the program hasn't successfully specified a L&F, then the UI manager uses the L&F specified by the swing.defaultlaf property. If the property is specified in both the swing.properties file and on the command line, the command-line definition takes precedence. If none of these steps has resulted in a valid L&F, Sun's JRE uses the Java L&F. Other vendors, such as Apple, will use their default L&F.
You can change the L&F with setLookAndFeel even after the program's GUI is visible. To make existing components reflect the new L&F, invoke the SwingUtilities updateComponentTreeUI method once per top-level container. Then you might wish to resize each top-level container to reflect the new sizes of its contained components. // Specify the look and feel to use by defining the LOOKANDFEEL constant // Valid values are: null (use the default), 'Metal', 'System', 'Motif', // and 'GTK' final static String LOOKANDFEEL = 'Motif'; Here the constant is set to 'Motif', which is a L&F that will run on any platform (as will the default, 'Metal'). 'GTK+' will not run on Windows, and 'Windows' will run only on Windows. If you choose a L&F that will not run, you will get the Java, or Metal, L&F.
In the section of the code where the L&F is actually set, you will see several different ways to set it, as discussed above.
This is very straightforward. Download and install. Note, do not install pycairo, as Gohlke clearly states it is not compatible with PyGTK. Create a folder called 'runtime' in `C: Python27 Lib site-packages gtk-2.0`.
Download and install the systems from Gnome. Make sure that it is the same version as PyGTK that you installed from Christoph Gohlke's site, which was version 2.22 upon writing.
Download Gtk+ All In One Bundle
Extract the GTK files to the 'runtime' folder created in step 2. Add the runtime folder to your python path, and/or the path environment variable of any shells that you want to have access to GTK.