12.07.2015 Views

Is Python a

Is Python a

Is Python a

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Getting Tkinter (and IDLE) GUI Support on LinuxThe IDLE interface described in Chapter 2 is a <strong>Python</strong> Tkinter GUI program. Tkinteris a GUI toolkit, and it’s a complete, standard component of <strong>Python</strong> on Windows andsome other platforms. On some Linux systems, though, the underlying GUI librarymay not be a standard installed component. To add GUI support to your <strong>Python</strong> onLinux if needed, try running a command line of the form yum tkinter to automaticallyinstall Tkinter’s underlying libraries. This should work on Linux distributions (andsome other systems) on which the yum installation program is available.How to Set Configuration OptionsThe way to set <strong>Python</strong>-related environment variables, and what to set them to,depends on the type of computer you’re working on. And again, remember that youwon’t necessarily have to set these at all right away; especially if you’re working inIDLE (described in Chapter 3), configuration is not required up front.But suppose, for illustration, that you have generally useful module files in directoriescalled utilities and package1 somewhere on your machine, and you want to beable to import these modules from files located in other directories. That is, to load afile called spam.py from the utilities directory, you want to be able to say:import spamfrom another file located anywhere on your computer. To make this work, you’llhave to configure your module search path one way or another to include the directorycontaining spam.py. Here are a few tips on this process.Unix/Linux shell variablesOn Unix systems, the way to set environment variables depends on the shell you use.Under the csh shell, you might add a line like the following in your .cshrc or .login fileto set the <strong>Python</strong> module search path:setenv PYTHONPATH /usr/home/pycode/utilities:/usr/lib/pycode/package1This tells <strong>Python</strong> to look for imported modules in two user-defined directories. But,if you’re using the ksh shell, the setting might instead appear in your .kshrc file, andlook like this:export PYTHONPATH="/usr/home/pycode/utilities:/usr/lib/pycode/package1"Other shells may use different (but analogous) syntax.DOS variables (Windows)If you are using MS-DOS, or some older flavors of Windows, you may need to addan environment variable configuration command to your C:\autoexec.bat file, and644 | Appendix A: Installation and Configuration

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!