- 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:

- Dynamics 365 for Finance and Operations Development Cookbook(Fourth Edition)
- Practical Data Analysis Cookbook
- Developing Middleware in Java EE 8
- Go并發編程實戰
- SQL Server從入門到精通(第3版)
- Java Web從入門到精通(第3版)
- HTML5+CSS3+JavaScript 從入門到項目實踐(超值版)
- Magento 2 Beginners Guide
- 大學計算機基礎實訓教程
- Advanced Python Programming
- Visual Basic程序設計實驗指導及考試指南
- Scratch編程從入門到精通
- 移動智能系統測試原理與實踐
- Web前端開發實戰教程(HTML5+CSS3+JavaScript)(微課版)
- Learning Java by Building Android Games