TitlePages

Friday, 12 December 2014

How to create Graphical User Interface in Arcpy

To Show GUI in your Script tool of your ArcMap



Python consist of  huge number of GUI frameworks (or toolkits) available for it, from TkInter to a number of other cross-platform solutions.

In your case we going to use the default TkInter Module to access the windows form from the python script tool.
TkInter is being proposed as the most interactive and easy to program module in Python GUI framework

1. Create a new Script tool in the Arcmap's ArcCatalog window in your desired location
2. Copy the below codes in to a notepad file and save it as python .py extension
3.Go to the script tool and Right Click > Properties > Parameter
4.Browse to your newly created python code as the source file to execute
5.All is well.Start GUI python from TkInter. Happy Programming




from Tkinter import *
import datetime
from array import *



root = Tk()
logo = PhotoImage(file="Image.Gif")
w2 = Label(root,
           image=logo).grid(row=0,column=1)
explanation = """Team Geo Zoner"""
w2 = Label(root, 
          compound = CENTER,
           fg="Red",
           bg="black",
           font="Times 55 bold",
          text=explanation)
w2.grid(row=0,column=0)

p=str(datetime.datetime.now().isoformat())
texter="Your Heading Goes Here"+str(p);
w3 = Label(root, 
          compound = CENTER,
           fg="Green",
           font="Times 20 bold",
          text=texter)
w3.grid(row=1,column=0)

Parameters = ['Number of Inputs','Number of Ouputs','Number of Processing Parameters','Number of Intermediate data']

r = 2
i=1
for c in Parameters:
    Label(text=c, relief=RIDGE,width=25).grid(row=r,column=0)
    Entry(text="Value", relief=SUNKEN,width=10).grid(row=r,column=1)
    r = r + 1
    i = i + 1

root.title("GISSTUDY")
root.mainloop()

No comments: