Creating Standalone Data Processing Applications with Python and Tkinter

Sam Giebner

  1. Background

  2. Sharing scripts/tools

  3. Example Apps

  4. Tkinter

  5. Considerations

  6. Resources

Python Anyone?

Powerful

Easy to learn

Open-source

Cross-platform

Large user community

Background

Request

Client

Coworker

Goals:

  • Save time
  • Eliminate/reduce error
  • Fill gaps in existing tools
  • Amplify everyday and non-GIS users

Sharing Scripts/Tools

Traditional Options:

  • Standalone script
  • Script in an ArcGIS Toolbox
  • ArcGIS Python Add-in

Great, but...

Why would I create a standalone data processing application?

  • Lightweight
  • Efficient
  • Stable
  • "On the fly" data validation
  • Fully customizable user experience
  • "Reactive" error handling
  • Not reliant on ESRI products
  • *Cross-platform
  • *No Installation

Tkinter

Graphical

User

Interface?

  • Native Python!
  • Most commonly used GUI toolkit for Python 
  • Object-oriented layer on top of Tcl/Tk
    • Tcl: Tool Command Languege
    • Tk: standard Tcl GUI toolkit 

What is Tkinter?

Essentially, it's a collection of Python modules

Tkinter App: 3 Main Parts

1. Tk instance

2. Widgets

3. Tkinter event loop

Tk Instance


    from Tkinter import *

    root = Tk()
  • Button

  • Canvas

  • Checkbutton

  • Entry

  • Frame

  • Label

  • Listbox

  • Menu

  • Menubutton

  • Message

  • Radiobutton

  • Scale

  • Scrollbar

  • Text

  • Toplevel

  • LabelFrame

  • PanedWindow

  • Spinbox

18 Core Widget Classes

Widget Workflow

    # Create widget instance     
    new_button = Button(tk_instance)

    # Style widget
    new_button['text'] = 'Click Here'
    new_button['command'] = do_something()

    # Place widget
    new_button.grid(row=0, column=2)

Initiate Tkinter event loop


    root.mainloop()

Examples

Consider the Following:

Is it worth the time?

Create/use templates!

Modules


    import arcpy

Prerequisites

Classes


    class NewClass():

        def __init__.py(self):
            pass

        def method_one(self):
            print("I'm a method!")

Sam's Favorite Tkinter Resources

tutorialspoint.com

http://tutorialspoint.com/python/python_gui_programming

effbot.org

http://effbot.org/tkinterbook

Workshop Resources

Slides:

http://slides.com/northpointgis/fall2016_python_applications_ws

Questions?

Sam Giebner

samg@northpointgis.com

218.720.67.47 ext 4

Creating Standalone Data Processing Applications with Python and Tkinter: What You Need to Know (But Were Afraid to Ask).

By North Point Geographic Solutions

Creating Standalone Data Processing Applications with Python and Tkinter: What You Need to Know (But Were Afraid to Ask).

Creating standalone data processing applications with Python and Tkinter allows for the development of powerful apps that can utilize a wide variety of GIS software that can easily be shared cross-platform. In this presentation, we will cover several benefits to creating a standalone data processing application, we will take a look at a few recent examples, and we will discuss available resources for creating your own standalone data processing application!

  • 900