|
POST
|
Dan, I read through the documentation and have my popup screen showing my values. I need to work on another project and i do not want the popup window to appear. I looked in the documentation but did not find anything. Do you know how to do this? Thanks
... View more
01-03-2020
05:59 AM
|
0
|
0
|
2194
|
|
POST
|
Javier, It looks like the code you sent me is working. I had to quit the script for the changes to show up. Thank you for all of your help
... View more
01-02-2020
10:06 AM
|
1
|
0
|
738
|
|
POST
|
Javier, for this query in arcGIS Do these lines in the python script do the same thing? When i apply the query from ArcGIS all of the primaryOH that is not part of 2050 turns off.
... View more
01-02-2020
04:39 AM
|
0
|
0
|
738
|
|
POST
|
Is there a way to not save the mxd file but refresh screen to see the changes.
... View more
12-31-2019
11:06 AM
|
0
|
0
|
738
|
|
POST
|
from tkinter import *
from tkinter import messagebox
import Tkinter, arcpy
#mxd = arcpy.mapping.MapDocument("C:/GISMAPS/LUS Map.mxd")
mxd = arcpy.mapping.MapDocument(r"C:/GISMAPS/LUS Map.mxd")
#mxd = arcpy.mapping.MapDocument("CURRENT")
#reset (overwrite) MakeFeatureLayer_management. This is needed so you can run the program more than once.
arcpy.env.overwriteOutput = True
#delete the layer
#arcpy.Delete_managment
#set variables for when you run the section of program that set the layers that should be on
geodatabase = "C:\gismaps\LusData.mdb"
dataset = "ElectricData"
feature_class = "PriOHElectricLineSegment"
#Create main window
window = Tk()
window.title("Feeders Selection")
window.geometry("680x500")
window.iconbitmap('C:/GISMAPS/lus.ico')
#Define the frame for the feeders to be displayed
frame = Frame(window)
frame.grid(row=1, column=1, padx=15, pady=5)
listNodes = Listbox(frame, width=10, height=10, font=("Helvetica", 10))
listNodes.pack(side="left", fill="y")
#Define the scrollbar in frame window
scrollbar = Scrollbar(frame, orient="vertical")
scrollbar.config(command=listNodes.yview)
scrollbar.pack(side="right", fill="y")
listNodes.config(yscrollcommand=scrollbar.set)
#Add the selection of all feeders
for item in [2050, 2051, 2052,
3050, 3051, 3052, 3550,
4050, 4051, 4052,
5050, 5051, 5052]:
listNodes.insert(END, item)
feeder = listNodes.get(ACTIVE)
#Define all of the checkboxes
prioh_var = IntVar()
priug_var = IntVar()
secoh_var = IntVar()
secug_var = IntVar()
fuse_var = IntVar()
switch_var = IntVar()
sp_var = IntVar()
cap_var = IntVar()
rec_var = IntVar()
pinhook_var = IntVar()
mall_var = IntVar()
peck_var = IntVar()
pri_oh = Checkbutton(window, text = "Primary Overhead", variable = prioh_var,onvalue = 1, offvalue = 0, height=2, width = 20).place(x=2, y=175)
pri_ug = Checkbutton(window, text = "Primary Underground", variable = priug_var,onvalue = 1, offvalue = 0, height=2, width = 20).place(x=12, y=200)
sec_oh = Checkbutton(window, text = "Secondary Overhead", variable = secoh_var,onvalue = 1, offvalue = 0, height=2, width = 20).place(x=8, y=225)
sec_ug = Checkbutton(window, text = "Secondary Underground", variable = secug_var,onvalue = 1, offvalue = 0, height=2, width = 20).place(x=18, y=250)
fuse = Checkbutton(window, text = "Fuse", variable = fuse_var,onvalue = 1, offvalue = 0, height=2, width = 20).place(x=400, y=10)
switch = Checkbutton(window, text = "Switch", variable = switch_var,onvalue = 1, offvalue = 0, height=2, width = 20).place(x=405, y=35)
servicepoint = Checkbutton(window, text = "Service Point", variable = sp_var,onvalue = 1, offvalue = 0, height=2, width = 20).place(x=420, y=88)
capacitor = Checkbutton(window, text = "Capacitor", variable = cap_var,onvalue = 1, offvalue = 0, height=2, width = 20).place(x=412, y=60)
recloser = Checkbutton(window, text = "Recloser", variable = rec_var,onvalue = 1, offvalue = 0, height=2, width = 20).place(x=409, y=87)
pinhook = Checkbutton(window, text = "Pinhook", variable = pinhook_var, state = DISABLED, onvalue = 1, offvalue = 0, height=2, width = 20).place(x=175, y=15)
mall = Checkbutton(window, text = "Mall", variable = mall_var, state = DISABLED, onvalue = 1, offvalue = 0, height=2, width = 20).place(x=165, y=45)
peck = Checkbutton(window, text = "Peck", variable = peck_var, state = DISABLED, onvalue = 1, offvalue = 0, height=2, width = 20).place(x=165, y=75)
#Commit all of the options
def commit():
feeder = listNodes.get(ACTIVE)
#check to see which inputs have been selected
#Primary Overhead
if prioh_var.get() == 1:
print("pri_oh = 1")
# show primary overhead feeder where feederid = feeder -ie: [FEEDERID] = "2050"
print "Primary_OH"
layer_name = "Primary OH"
primary_oh = arcpy.mapping.ListLayers(mxd, layer_name)[0]
primary_oh.definitionQuery = "[FEEDERID] = '2050'"
print feeder
#Primary_OH_path = r"{0}\{1}\{2}".format(geodatabase, dataset, feature_class)
#Primary_OH = arcpy.MakeFeatureLayer_management(Primary_OH_path, "Primary_OH_layer2")
else:
print("pri_oh = 0")
# do not display primary overhead feeder for [FEEDERID] = "2050"
#Primary Underground
if priug_var.get() == 1:
print("pri_ug = 1")
layer_name = "Primary UG"
primary_ug = arcpy.mapping.ListLayers(mxd, layer_name)[0]
primary_ug.definitionQuery = "[FEEDERID] = '2050'"
print feeder
#else:
#print("pri_ug = 0")
# do not display primary underground feeder for [FEEDERID] = "2050"
mxd.save()
return
#reset all variables
#def reset():
#Button to run the commit command
Button(window, text="commit", command=commit).place(x=300, y=350)
#Button to run the reset command
#Button(window, text="reset", command=reset).place(x=400, y=350)
#Quit the program
Button(window, text="Quit", command=window.destroy).place(x=500, y=350)
window.mainloop() Still getting the same error.
... View more
12-31-2019
10:39 AM
|
0
|
0
|
738
|
|
POST
|
ran as admin and still received the error. I am sorry for taking up so much of your time. I do appreciate it
... View more
12-31-2019
08:20 AM
|
0
|
1
|
1357
|
|
POST
|
I will check on the permissions. By adding mxd.save() to the script does this make a permanent save to the file?
... View more
12-31-2019
07:57 AM
|
0
|
0
|
1357
|
|
POST
|
i added mxd.save() and got the following: I pretty sure that i have access to the file.
... View more
12-31-2019
07:46 AM
|
0
|
1
|
1357
|
|
POST
|
Javier, This is my partially completed python script: from tkinter import *
from tkinter import messagebox
import Tkinter, arcpy
mxd = arcpy.mapping.MapDocument("C:/GISMAPS/LUS Map.mxd")
#mxd = arcpy.mapping.MapDocument("CURRENT")
#reset (overwrite) MakeFeatureLayer_management. This is needed so you can run the program more than once.
arcpy.env.overwriteOutput = True
#delete the layer
#arcpy.Delete_managment
#set variables for when you run the section of program that set the layers that should be on
geodatabase = "C:\gismaps\LusData.mdb"
dataset = "ElectricData"
feature_class = "PriOHElectricLineSegment"
#Create main window
window = Tk()
window.title("Feeders Selection")
window.geometry("680x500")
window.iconbitmap('C:/GISMAPS/lus.ico')
#Define the frame for the feeders to be displayed
frame = Frame(window)
frame.grid(row=1, column=1, padx=15, pady=5)
listNodes = Listbox(frame, width=10, height=10, font=("Helvetica", 10))
listNodes.pack(side="left", fill="y")
#Define the scrollbar in frame window
scrollbar = Scrollbar(frame, orient="vertical")
scrollbar.config(command=listNodes.yview)
scrollbar.pack(side="right", fill="y")
listNodes.config(yscrollcommand=scrollbar.set)
#Add the selection of all feeders
for item in [2050, 2051, 2052,
3050, 3051, 3052, 3550,
4050, 4051, 4052,
5050, 5051, 5052]:
listNodes.insert(END, item)
feeder = listNodes.get(ACTIVE)
#Define all of the checkboxes
prioh_var = IntVar()
priug_var = IntVar()
secoh_var = IntVar()
secug_var = IntVar()
fuse_var = IntVar()
switch_var = IntVar()
sp_var = IntVar()
cap_var = IntVar()
rec_var = IntVar()
pinhook_var = IntVar()
mall_var = IntVar()
peck_var = IntVar()
pri_oh = Checkbutton(window, text = "Primary Overhead", variable = prioh_var,onvalue = 1, offvalue = 0, height=2, width = 20).place(x=2, y=175)
pri_ug = Checkbutton(window, text = "Primary Underground", variable = priug_var,onvalue = 1, offvalue = 0, height=2, width = 20).place(x=12, y=200)
sec_oh = Checkbutton(window, text = "Secondary Overhead", variable = secoh_var,onvalue = 1, offvalue = 0, height=2, width = 20).place(x=8, y=225)
sec_ug = Checkbutton(window, text = "Secondary Underground", variable = secug_var,onvalue = 1, offvalue = 0, height=2, width = 20).place(x=18, y=250)
fuse = Checkbutton(window, text = "Fuse", variable = fuse_var,onvalue = 1, offvalue = 0, height=2, width = 20).place(x=400, y=10)
switch = Checkbutton(window, text = "Switch", variable = switch_var,onvalue = 1, offvalue = 0, height=2, width = 20).place(x=405, y=35)
servicepoint = Checkbutton(window, text = "Service Point", variable = sp_var,onvalue = 1, offvalue = 0, height=2, width = 20).place(x=420, y=88)
capacitor = Checkbutton(window, text = "Capacitor", variable = cap_var,onvalue = 1, offvalue = 0, height=2, width = 20).place(x=412, y=60)
recloser = Checkbutton(window, text = "Recloser", variable = rec_var,onvalue = 1, offvalue = 0, height=2, width = 20).place(x=409, y=87)
pinhook = Checkbutton(window, text = "Pinhook", variable = pinhook_var, state = DISABLED, onvalue = 1, offvalue = 0, height=2, width = 20).place(x=175, y=15)
mall = Checkbutton(window, text = "Mall", variable = mall_var, state = DISABLED, onvalue = 1, offvalue = 0, height=2, width = 20).place(x=165, y=45)
peck = Checkbutton(window, text = "Peck", variable = peck_var, state = DISABLED, onvalue = 1, offvalue = 0, height=2, width = 20).place(x=165, y=75)
#Commit all of the options
def commit():
feeder = listNodes.get(ACTIVE)
#print feeder
#my_label = Label(window, text=prioh_var.get()).pack()
#check to see which inputs have been selected
#Primary Overhead
if prioh_var.get() == 1:
print("pri_oh = 1")
# show primary overhead feeder where feederid = feeder -ie: [FEEDERID] = "2050"
print "Primary_OH"
print feeder
layer_name = "Primary OH"
primary_oh = arcpy.mapping.ListLayers(mxd, layer_name)[0]
primary_oh.definitionQuery = "[FEEDERID] = '2050'"
#Primary_OH_path = r"{0}\{1}\{2}".format(geodatabase, dataset, feature_class)
#Primary_OH = arcpy.MakeFeatureLayer_management(Primary_OH_path, "Primary_OH_layer2")
else:
print("pri_oh = 0")
# do not display primary overhead feeder for [FEEDERID] = "2050"
#Primary Underground
if priug_var.get() == 1:
print("pri_ug = 1")
print feeder
layer_name = "Primary UG"
primary_ug = arcpy.mapping.ListLayers(mxd, layer_name)[0]
primary_ug.definitionQuery = "[FEEDERID] = '2050'"
#else:
#print("pri_ug = 0")
# do not display primary underground feeder for [FEEDERID] = "2050"
#reset all variables
#def reset():
#Button to run the commit command
Button(window, text="commit", command=commit).place(x=300, y=350)
#Button to run the reset command
#Button(window, text="reset", command=reset).place(x=400, y=350)
#Quit the program
Button(window, text="Quit", command=window.destroy).place(x=500, y=350)
window.mainloop() The program ran fine but all of the feeders were still showing on the map. What do i have to do to alter the script so that when the program runs lines 90-92 the feeders that are not the one selected (such as 2050) are not shown?. This field will be a variable that the user selects from a list so i need to allow this to be a variable Thanks for your help
... View more
12-31-2019
07:27 AM
|
0
|
1
|
1357
|
|
POST
|
also, after i removed line 88 the program ran fine but all of the feeders were still showing on the map. What do i have to do after the program runs lines 86-89 to not show feeders that are not the one selected such as 2050. This will be a variable that the user selects from a list.
... View more
12-30-2019
12:19 PM
|
0
|
0
|
1357
|
|
POST
|
Javier, I think i am pretty close to finishing this section. When i enter the code above i had to change the Primary_OH to Primary OH since that is how it is labeled in the properties for label name. I get an invalid syntax for line 88. 2 questions and i hope i won't have to bother you anymore. What do i need to fix line 88 and also how to i make 2050 in line 89 a variable. The variable would be "feeder". I really appreciate your help fixing all of my errors.
... View more
12-30-2019
12:12 PM
|
0
|
0
|
1509
|
|
POST
|
Javier, I think i have confused myself looking at the code between lines 77 and 83. What i am trying to do is change the properties for the layer "Primary OH". When line 77 is a one I want the definition query to be set to [FEEDERID] = '2050' in the layer properties.This way only the primary overhead lines with a feeder id on 2050 will show on the screen. i will need to do this for approx 8 layers (primary ug, switches, fuses, etc....). I probably am missing something but i not sure how this code will do what i want.
... View more
12-30-2019
10:43 AM
|
0
|
1
|
1509
|
|
POST
|
Javier, when i run the program i put in some write statements: from tkinter import *
from tkinter import messagebox
import Tkinter, arcpy
myMap = arcpy.mapping.MapDocument("C:/GISMAPS/LUS Map.mxd")
#myMap = arcpy.mapping.MapDocument("CURRENT")
geodatabase = "C:\gismaps\LusData.mdb"
dataset = "ElectricData"
feature_class = "PriOHElectricLineSegment"
window = Tk()
window.title("Feeders Selection")
window.geometry("680x500")
window.iconbitmap('C:/GISMAPS/lus.ico')
#Define the frame for the feeders to be displayed
frame = Frame(window)
frame.grid(row=1, column=1, padx=15, pady=5)
listNodes = Listbox(frame, width=10, height=10, font=("Helvetica", 10))
listNodes.pack(side="left", fill="y")
#Define the scrollbar in frame window
scrollbar = Scrollbar(frame, orient="vertical")
scrollbar.config(command=listNodes.yview)
scrollbar.pack(side="right", fill="y")
listNodes.config(yscrollcommand=scrollbar.set)
#Add the selection of all feeders
for item in [2050, 2051, 2052,
3050, 3051, 3052, 3550,
4050, 4051, 4052,
5050, 5051, 5052]:
listNodes.insert(END, item)
feeder = listNodes.get(ACTIVE)
#Define all of the checkboxes
prioh_var = IntVar()
priug_var = IntVar()
secoh_var = IntVar()
secug_var = IntVar()
fuse_var = IntVar()
switch_var = IntVar()
sp_var = IntVar()
cap_var = IntVar()
rec_var = IntVar()
pinhook_var = IntVar()
mall_var = IntVar()
peck_var = IntVar()
pri_oh = Checkbutton(window, text = "Primary Overhead", variable = prioh_var,onvalue = 1, offvalue = 0, height=2, width = 20).place(x=2, y=175)
pri_ug = Checkbutton(window, text = "Primary Underground", variable = priug_var,onvalue = 1, offvalue = 0, height=2, width = 20).place(x=12, y=200)
sec_oh = Checkbutton(window, text = "Secondary Overhead", variable = secoh_var,onvalue = 1, offvalue = 0, height=2, width = 20).place(x=8, y=225)
sec_ug = Checkbutton(window, text = "Secondary Underground", variable = secug_var,onvalue = 1, offvalue = 0, height=2, width = 20).place(x=18, y=250)
fuse = Checkbutton(window, text = "Fuse", variable = fuse_var,onvalue = 1, offvalue = 0, height=2, width = 20).place(x=400, y=10)
switch = Checkbutton(window, text = "Switch", variable = switch_var,onvalue = 1, offvalue = 0, height=2, width = 20).place(x=405, y=35)
servicepoint = Checkbutton(window, text = "Service Point", variable = sp_var,onvalue = 1, offvalue = 0, height=2, width = 20).place(x=420, y=88)
capacitor = Checkbutton(window, text = "Capacitor", variable = cap_var,onvalue = 1, offvalue = 0, height=2, width = 20).place(x=412, y=60)
recloser = Checkbutton(window, text = "Recloser", variable = rec_var,onvalue = 1, offvalue = 0, height=2, width = 20).place(x=409, y=87)
pinhook = Checkbutton(window, text = "Pinhook", variable = pinhook_var, state = DISABLED, onvalue = 1, offvalue = 0, height=2, width = 20).place(x=175, y=15)
mall = Checkbutton(window, text = "Mall", variable = mall_var, state = DISABLED, onvalue = 1, offvalue = 0, height=2, width = 20).place(x=165, y=45)
peck = Checkbutton(window, text = "Peck", variable = peck_var, state = DISABLED, onvalue = 1, offvalue = 0, height=2, width = 20).place(x=165, y=75)
#Commit all of the options
def commit():
#my_label = IntVar()
feeder = listNodes.get(ACTIVE)
print feeder
#my_label = Label(window, text=prioh_var.get()).pack()
#check to see which inputs have been selected
if prioh_var.get() == 1:
print("pri_oh = 1")
# show primary overhead feeder where feederid = feeder -ie: [FEEDERID] = "2050"
print "Primary_OH"
Primary_OH_path = r"{0}\{1}\{2}".format(geodatabase, dataset, feature_class)
Primary_OH = arcpy.MakeFeatureLayer_management(Primary_OH_path, "Primary_OH_layer2")
print Primary_OH
else:
print("pri_oh = 0")
# do not display primary overhead feeder for [FEEDERID] = "2050"
if priug_var.get() == 1:
print("pri_ug = 1")
arcpy.SelectLayerByAttribute_management(Primary_UG, "", "[FEEDERID] = '2050'")
else:
print("pri_ug = 0")
Button(window, text="commit", command=commit).place(x=300, y=350)
#Quit the program
Button(window, text="Quit", command=window.destroy).place(x=400, y=350)
window.mainloop() for the print statement on line 83 the output is: Primary_OH_layer2. Should it show the feeder number which is 2050? Line 73 does print the correct number Since the program gives an error when i run it a second time because the layer has been created, how do i modify the code so that this will not happen. Do i need to change the MakeFeatureLayer_management?
... View more
12-30-2019
10:21 AM
|
0
|
1
|
1509
|
|
POST
|
i ran the program and it worked as it should. When i ran it again it said that the layer already exists: from tkinter import *
from tkinter import messagebox
import Tkinter, arcpy
myMap = arcpy.mapping.MapDocument("C:/GISMAPS/LUS Map.mxd")
#myMap = arcpy.mapping.MapDocument("CURRENT")
geodatabase = "C:\gismaps\LusData.mdb"
dataset = "ElectricData"
feature_class = "PriOHElectricLineSegment"
window = Tk()
window.title("Feeders Selection")
window.geometry("680x500")
window.iconbitmap('C:/GISMAPS/lus.ico')
#Define the frame for the feeders to be displayed
frame = Frame(window)
frame.grid(row=1, column=1, padx=15, pady=5)
listNodes = Listbox(frame, width=10, height=10, font=("Helvetica", 10))
listNodes.pack(side="left", fill="y")
#Define the scrollbar in frame window
scrollbar = Scrollbar(frame, orient="vertical")
scrollbar.config(command=listNodes.yview)
scrollbar.pack(side="right", fill="y")
listNodes.config(yscrollcommand=scrollbar.set)
#Add the selection of all feeders
for item in [2050, 2051, 2052,
3050, 3051, 3052, 3550,
4050, 4051, 4052,
5050, 5051, 5052]:
listNodes.insert(END, item)
feeder = listNodes.get(ACTIVE)
#Define all of the checkboxes
prioh_var = IntVar()
priug_var = IntVar()
secoh_var = IntVar()
secug_var = IntVar()
fuse_var = IntVar()
switch_var = IntVar()
sp_var = IntVar()
cap_var = IntVar()
rec_var = IntVar()
pinhook_var = IntVar()
mall_var = IntVar()
peck_var = IntVar()
pri_oh = Checkbutton(window, text = "Primary Overhead", variable = prioh_var,onvalue = 1, offvalue = 0, height=2, width = 20).place(x=2, y=175)
pri_ug = Checkbutton(window, text = "Primary Underground", variable = priug_var,onvalue = 1, offvalue = 0, height=2, width = 20).place(x=12, y=200)
sec_oh = Checkbutton(window, text = "Secondary Overhead", variable = secoh_var,onvalue = 1, offvalue = 0, height=2, width = 20).place(x=8, y=225)
sec_ug = Checkbutton(window, text = "Secondary Underground", variable = secug_var,onvalue = 1, offvalue = 0, height=2, width = 20).place(x=18, y=250)
fuse = Checkbutton(window, text = "Fuse", variable = fuse_var,onvalue = 1, offvalue = 0, height=2, width = 20).place(x=400, y=10)
switch = Checkbutton(window, text = "Switch", variable = switch_var,onvalue = 1, offvalue = 0, height=2, width = 20).place(x=405, y=35)
servicepoint = Checkbutton(window, text = "Service Point", variable = sp_var,onvalue = 1, offvalue = 0, height=2, width = 20).place(x=420, y=88)
capacitor = Checkbutton(window, text = "Capacitor", variable = cap_var,onvalue = 1, offvalue = 0, height=2, width = 20).place(x=412, y=60)
recloser = Checkbutton(window, text = "Recloser", variable = rec_var,onvalue = 1, offvalue = 0, height=2, width = 20).place(x=409, y=87)
pinhook = Checkbutton(window, text = "Pinhook", variable = pinhook_var, state = DISABLED, onvalue = 1, offvalue = 0, height=2, width = 20).place(x=175, y=15)
mall = Checkbutton(window, text = "Mall", variable = mall_var, state = DISABLED, onvalue = 1, offvalue = 0, height=2, width = 20).place(x=165, y=45)
peck = Checkbutton(window, text = "Peck", variable = peck_var, state = DISABLED, onvalue = 1, offvalue = 0, height=2, width = 20).place(x=165, y=75)
#Commit all of the options
def commit():
#my_label = IntVar()
feeder = listNodes.get(ACTIVE)
print feeder
#my_label = Label(window, text=prioh_var.get()).pack()
#check to see which inputs have been selected
if prioh_var.get() == 1:
print("pri_oh = 1")
# show primary overhead feeder where feederid = feeder -ie: [FEEDERID] = "2050"
print "Primary_OH"
Primary_OH_path = r"{0}\{1}\{2}".format(geodatabase, dataset, feature_class)
Primary_OH = arcpy.MakeFeatureLayer_management(Primary_OH_path, "Primary_OH_layer2")
else:
print("pri_oh = 0")
# do not display primary overhead feeder for [FEEDERID] = "2050"
if priug_var.get() == 1:
print("pri_ug = 1")
arcpy.SelectLayerByAttribute_management(Primary_UG, "", "[FEEDERID] = '2050'")
else:
print("pri_ug = 0")
Button(window, text="commit", command=commit).place(x=300, y=350)
#Quit the program
Button(window, text="Quit", command=window.destroy).place(x=400, y=350)
window.mainloop()
... View more
12-30-2019
10:02 AM
|
0
|
0
|
1509
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 01-02-2020 10:06 AM |
| Online Status |
Offline
|
| Date Last Visited |
11-11-2020
02:23 AM
|