- Programming ArcGIS 10.1 with Python Cookbook
- Eric Pimpler
- 531字
- 2021-07-30 17:29:53
Using the ArcGIS Python window
In this recipe, you'll learn how to use the ArcGIS Python window. In Chapter 1, Fundamentals of the Python Language for ArcGIS, you learned how to use the IDLE development environment for Python, so this chapter will give you an alternative for writing your geoprocessing scripts. Either development environment can be used but it is common for people to start writing scripts with the ArcGIS Desktop Python window and then move on to IDLE when scripts become more complex. I should also mention that there are many other development environments that you may want to consider, including PythonWin, Wingware, Komodo, and others. The development environment you choose is really a matter of preference.
Getting ready
The new Python window is an embedded, interactive Python window in ArcGIS Desktop 10, that is ideal for testing small blocks of code, learning Python basics, building quick and easy workflows, and executing geoprocessing tools. However, as your scripts become more complex, you'll quickly find the need for a more robust development environment. By default, IDLE is installed with ArcGIS Desktop, so this is a logical next choice for many. For new programmers, though, the ArcGIS Python window is a great place to start!
The ArcGIS Python window has a number of capabilities in addition to being the location for writing your code. You can save the content of the window to a Python script file on a disk or load an existing Python script into the window. The window can be either pinned or floating. While floating, the window can be expanded or contracted as you wish. The window can also be pinned to various parts of the ArcGIS display. You can also format the font and text colors displayed in the window by right-clicking on the window and selecting Format.
How to do it…
The Python window can be opened by clicking on the Python window button on the main ArcGIS Desktop toolbar.
- Open
c:\ArcpyBook\Ch2\Crime_Ch2.mxd
with ArcMap. - Click on the Python window button from the main ArcMap toolbar. The Python window will be displayed as shown in the following screenshot. This is a floating window, so you can resize as needed and also dock it at various places on the ArcMap interface:
The Python window is essentially a shell window that allows you to type in statements one line at a time, just after the line input characters
>>>
. On the right-hand side of the divider, you will find a help window. - Load an existing script by right-clicking inside the Python window and selecting Load from the menu. Navigate to the
c:\ArcpyBook\Ch2
directory and selectListFields.py
to load a sample script.You can also format the font and text colors displayed in the window by right-clicking on the window and selecting Format. You will be provided with White and Black themes; you can select fonts and colors individually:
Click on the Set Black Theme button to see an example. If you spend a lot of time writing code, you may find that darker themes are easier on your eyes:

- 零基礎學Visual C++第3版
- PaaS程序設計
- 程序員面試筆試寶典
- x86匯編語言:從實模式到保護模式(第2版)
- Visual C++串口通信技術詳解(第2版)
- Python數據結構與算法(視頻教學版)
- INSTANT Adobe Edge Inspect Starter
- Android應用開發深入學習實錄
- Extending Unity with Editor Scripting
- IoT Projects with Bluetooth Low Energy
- 奔跑吧 Linux內核
- Python機器學習與量化投資
- The Statistics and Calculus with Python Workshop
- 用Python動手學統計學
- 少年小魚的魔法之旅:神奇的Python