I am trying to run my program and when i get to this part of the program
I get the error that global name 'Primary_OH is not defined. Can someone look at my code and tell what i need to do to fix this.
Thanks
OK. It does not matter. The container of data is a Personal Geodatabase, is so similar to File Geodatabase
# Primary OH Path geodatabase = "C:\gismaps\LusData.mdb" dataset = "ElectricData" feature_class = "PriOHElectricLineSegment" Primary_OH_path = r"{0}\{1}\{2}".format(geodatabase, dataset, feature_class) Primary_OH = arcpy.MakeFeatureLayer_management(Primary_OH_path, "Primary_OH") <SPAN class="" style="color: #0077aa; border: 0px; font-weight: inherit;"></SPAN>
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
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.
Is there a way to not save the mxd file but refresh screen to see the changes.
<SPAN class="keyword token">from</SPAN> tkinter <SPAN class="keyword token">import</SPAN> <SPAN class="operator token">*</SPAN> <SPAN class="keyword token">from</SPAN> tkinter <SPAN class="keyword token">import</SPAN> messagebox <SPAN class="keyword token">import</SPAN> Tkinter<SPAN class="punctuation token">,</SPAN> arcpy <SPAN class="comment token">#mxd = arcpy.mapping.MapDocument("C:/GISMAPS/LUS Map.mxd")</SPAN> mxd <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>mapping<SPAN class="punctuation token">.</SPAN>MapDocument<SPAN class="punctuation token">(</SPAN>r<SPAN class="string token">"C:/GISMAPS/LUS Map.mxd"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#mxd = arcpy.mapping.MapDocument("CURRENT")</SPAN> <SPAN class="comment token">#reset (overwrite) MakeFeatureLayer_management. This is needed so you can run the program more than once.</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>overwriteOutput <SPAN class="operator token">=</SPAN> <SPAN class="token boolean">True</SPAN> <SPAN class="comment token">#delete the layer</SPAN> <SPAN class="comment token">#arcpy.Delete_managment </SPAN> <SPAN class="comment token">#set variables for when you run the section of program that set the layers that should be on</SPAN> geodatabase <SPAN class="operator token">=</SPAN> <SPAN class="string token">"C:\gismaps\LusData.mdb"</SPAN> dataset <SPAN class="operator token">=</SPAN> <SPAN class="string token">"ElectricData"</SPAN> feature_class <SPAN class="operator token">=</SPAN> <SPAN class="string token">"PriOHElectricLineSegment"</SPAN> <SPAN class="comment token">#Create main window</SPAN> window <SPAN class="operator token">=</SPAN> Tk<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> window<SPAN class="punctuation token">.</SPAN>title<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Feeders Selection"</SPAN><SPAN class="punctuation token">)</SPAN> window<SPAN class="punctuation token">.</SPAN>geometry<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"680x500"</SPAN><SPAN class="punctuation token">)</SPAN> window<SPAN class="punctuation token">.</SPAN>iconbitmap<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'C:/GISMAPS/lus.ico'</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#Define the frame for the feeders to be displayed</SPAN> frame <SPAN class="operator token">=</SPAN> Frame<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">)</SPAN> frame<SPAN class="punctuation token">.</SPAN>grid<SPAN class="punctuation token">(</SPAN>row<SPAN class="operator token">=</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> column<SPAN class="operator token">=</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> padx<SPAN class="operator token">=</SPAN><SPAN class="number token">15</SPAN><SPAN class="punctuation token">,</SPAN> pady<SPAN class="operator token">=</SPAN><SPAN class="number token">5</SPAN><SPAN class="punctuation token">)</SPAN> listNodes <SPAN class="operator token">=</SPAN> Listbox<SPAN class="punctuation token">(</SPAN>frame<SPAN class="punctuation token">,</SPAN> width<SPAN class="operator token">=</SPAN><SPAN class="number token">10</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">10</SPAN><SPAN class="punctuation token">,</SPAN> font<SPAN class="operator token">=</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Helvetica"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">10</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> listNodes<SPAN class="punctuation token">.</SPAN>pack<SPAN class="punctuation token">(</SPAN>side<SPAN class="operator token">=</SPAN><SPAN class="string token">"left"</SPAN><SPAN class="punctuation token">,</SPAN> fill<SPAN class="operator token">=</SPAN><SPAN class="string token">"y"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#Define the scrollbar in frame window</SPAN> scrollbar <SPAN class="operator token">=</SPAN> Scrollbar<SPAN class="punctuation token">(</SPAN>frame<SPAN class="punctuation token">,</SPAN> orient<SPAN class="operator token">=</SPAN><SPAN class="string token">"vertical"</SPAN><SPAN class="punctuation token">)</SPAN> scrollbar<SPAN class="punctuation token">.</SPAN>config<SPAN class="punctuation token">(</SPAN>command<SPAN class="operator token">=</SPAN>listNodes<SPAN class="punctuation token">.</SPAN>yview<SPAN class="punctuation token">)</SPAN> scrollbar<SPAN class="punctuation token">.</SPAN>pack<SPAN class="punctuation token">(</SPAN>side<SPAN class="operator token">=</SPAN><SPAN class="string token">"right"</SPAN><SPAN class="punctuation token">,</SPAN> fill<SPAN class="operator token">=</SPAN><SPAN class="string token">"y"</SPAN><SPAN class="punctuation token">)</SPAN> listNodes<SPAN class="punctuation token">.</SPAN>config<SPAN class="punctuation token">(</SPAN>yscrollcommand<SPAN class="operator token">=</SPAN>scrollbar<SPAN class="punctuation token">.</SPAN>set<SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#Add the selection of all feeders</SPAN> <SPAN class="keyword token">for</SPAN> item <SPAN class="keyword token">in</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="number token">2050</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">2051</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">2052</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">3050</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">3051</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">3052</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">3550</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">4050</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">4051</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">4052</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">5050</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">5051</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">5052</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">:</SPAN> listNodes<SPAN class="punctuation token">.</SPAN>insert<SPAN class="punctuation token">(</SPAN>END<SPAN class="punctuation token">,</SPAN> item<SPAN class="punctuation token">)</SPAN> feeder <SPAN class="operator token">=</SPAN> listNodes<SPAN class="punctuation token">.</SPAN>get<SPAN class="punctuation token">(</SPAN>ACTIVE<SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#Define all of the checkboxes</SPAN> prioh_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> priug_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> secoh_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> secug_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> fuse_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> switch_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> sp_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> cap_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> rec_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> pinhook_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> mall_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> peck_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> pri_oh <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Primary Overhead"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> prioh_var<SPAN class="punctuation token">,</SPAN>onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">175</SPAN><SPAN class="punctuation token">)</SPAN> pri_ug <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Primary Underground"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> priug_var<SPAN class="punctuation token">,</SPAN>onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">12</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">200</SPAN><SPAN class="punctuation token">)</SPAN> sec_oh <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Secondary Overhead"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> secoh_var<SPAN class="punctuation token">,</SPAN>onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">8</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">225</SPAN><SPAN class="punctuation token">)</SPAN> sec_ug <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Secondary Underground"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> secug_var<SPAN class="punctuation token">,</SPAN>onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">18</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">250</SPAN><SPAN class="punctuation token">)</SPAN> fuse <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Fuse"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> fuse_var<SPAN class="punctuation token">,</SPAN>onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">400</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">10</SPAN><SPAN class="punctuation token">)</SPAN> switch <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Switch"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> switch_var<SPAN class="punctuation token">,</SPAN>onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">405</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">35</SPAN><SPAN class="punctuation token">)</SPAN> servicepoint <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Service Point"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> sp_var<SPAN class="punctuation token">,</SPAN>onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">420</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">88</SPAN><SPAN class="punctuation token">)</SPAN> capacitor <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Capacitor"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> cap_var<SPAN class="punctuation token">,</SPAN>onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">412</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">60</SPAN><SPAN class="punctuation token">)</SPAN> recloser <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Recloser"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> rec_var<SPAN class="punctuation token">,</SPAN>onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">409</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">87</SPAN><SPAN class="punctuation token">)</SPAN> pinhook <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Pinhook"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> pinhook_var<SPAN class="punctuation token">,</SPAN> state <SPAN class="operator token">=</SPAN> DISABLED<SPAN class="punctuation token">,</SPAN> onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">175</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">15</SPAN><SPAN class="punctuation token">)</SPAN> mall <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Mall"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> mall_var<SPAN class="punctuation token">,</SPAN> state <SPAN class="operator token">=</SPAN> DISABLED<SPAN class="punctuation token">,</SPAN> onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">165</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">45</SPAN><SPAN class="punctuation token">)</SPAN> peck <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Peck"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> peck_var<SPAN class="punctuation token">,</SPAN> state <SPAN class="operator token">=</SPAN> DISABLED<SPAN class="punctuation token">,</SPAN> onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">165</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">75</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#Commit all of the options</SPAN> <SPAN class="keyword token">def</SPAN> <SPAN class="token function">commit</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> feeder <SPAN class="operator token">=</SPAN> listNodes<SPAN class="punctuation token">.</SPAN>get<SPAN class="punctuation token">(</SPAN>ACTIVE<SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#check to see which inputs have been selected</SPAN> <SPAN class="comment token">#Primary Overhead</SPAN> <SPAN class="keyword token">if</SPAN> prioh_var<SPAN class="punctuation token">.</SPAN>get<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"pri_oh = 1"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># show primary overhead feeder where feederid = feeder -ie: [FEEDERID] = "2050"</SPAN> <SPAN class="keyword token">print</SPAN> <SPAN class="string token">"Primary_OH"</SPAN> layer_name <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Primary OH"</SPAN> primary_oh <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>mapping<SPAN class="punctuation token">.</SPAN>ListLayers<SPAN class="punctuation token">(</SPAN>mxd<SPAN class="punctuation token">,</SPAN> layer_name<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN> primary_oh<SPAN class="punctuation token">.</SPAN>definitionQuery <SPAN class="operator token">=</SPAN> <SPAN class="string token">"[FEEDERID] = '2050'"</SPAN> <SPAN class="keyword token">print</SPAN> feeder <SPAN class="comment token">#Primary_OH_path = r"{0}\{1}\{2}".format(geodatabase, dataset, feature_class) </SPAN> <SPAN class="comment token">#Primary_OH = arcpy.MakeFeatureLayer_management(Primary_OH_path, "Primary_OH_layer2") </SPAN> <SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"pri_oh = 0"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># do not display primary overhead feeder for [FEEDERID] = "2050"</SPAN> <SPAN class="comment token">#Primary Underground </SPAN> <SPAN class="keyword token">if</SPAN> priug_var<SPAN class="punctuation token">.</SPAN>get<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"pri_ug = 1"</SPAN><SPAN class="punctuation token">)</SPAN> layer_name <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Primary UG"</SPAN> primary_ug <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>mapping<SPAN class="punctuation token">.</SPAN>ListLayers<SPAN class="punctuation token">(</SPAN>mxd<SPAN class="punctuation token">,</SPAN> layer_name<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN> primary_ug<SPAN class="punctuation token">.</SPAN>definitionQuery <SPAN class="operator token">=</SPAN> <SPAN class="string token">"[FEEDERID] = '2050'"</SPAN> <SPAN class="keyword token">print</SPAN> feeder <SPAN class="comment token">#else:</SPAN> <SPAN class="comment token">#print("pri_ug = 0")</SPAN> <SPAN class="comment token"># do not display primary underground feeder for [FEEDERID] = "2050"</SPAN> mxd<SPAN class="punctuation token">.</SPAN>save<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">return</SPAN> <SPAN class="comment token">#reset all variables </SPAN> <SPAN class="comment token">#def reset():</SPAN> <SPAN class="comment token">#Button to run the commit command </SPAN> Button<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text<SPAN class="operator token">=</SPAN><SPAN class="string token">"commit"</SPAN><SPAN class="punctuation token">,</SPAN> command<SPAN class="operator token">=</SPAN>commit<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">300</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">350</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#Button to run the reset command</SPAN> <SPAN class="comment token">#Button(window, text="reset", command=reset).place(x=400, y=350)</SPAN> <SPAN class="comment token">#Quit the program</SPAN> Button<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text<SPAN class="operator token">=</SPAN><SPAN class="string token">"Quit"</SPAN><SPAN class="punctuation token">,</SPAN> command<SPAN class="operator token">=</SPAN>window<SPAN class="punctuation token">.</SPAN>destroy<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">500</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">350</SPAN><SPAN class="punctuation token">)</SPAN> window<SPAN class="punctuation token">.</SPAN>mainloop<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Still getting the same error.
Adds the mxd.save() command before quit the full program , may be in line 115, inside commit function. Don't forget indentation.
<SPAN class="" style="color: slategray; border: 0px; font-weight: inherit;">#Commit all of the options</SPAN> <SPAN class="" style="color: #0077aa; border: 0px; font-weight: inherit;">def</SPAN> <SPAN class="" style="color: #d74444; border: 0px; font-weight: inherit;">commit</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">(</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">)</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">: </SPAN> # -------------------# # All your code here # # -------------------# mxd.save() return
ran as admin and still received the error. I am sorry for taking up so much of your time. I do appreciate it
Try executing the Python Script as administrator to test if is a permissions issue.
I added the new path and still got the same answer
According to Joe Borgione mentioned, Use "r" before a variable that include a path,
Use
mxd <SPAN class="" style="color: #a67f59; background: rgba(255, 255, 255, 0.5); border: 0px; font-weight: inherit;">=</SPAN> arcpy<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">.</SPAN>mapping<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">.</SPAN>MapDocument<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">(r</SPAN><SPAN class="" style="color: #669900; border: 0px; font-weight: inherit;">"C:/GISMAPS/LUS Map.mxd"</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">)</SPAN>
instead of
mxd <SPAN class="" style="color: #a67f59; background: rgba(255, 255, 255, 0.5); border: 0px; font-weight: inherit;">=</SPAN> arcpy<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">.</SPAN>mapping<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">.</SPAN>MapDocument<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">(</SPAN><SPAN class="" style="color: #669900; border: 0px; font-weight: inherit;">"C:/GISMAPS/LUS Map.mxd"</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">)</SPAN>
I will check on the permissions. By adding mxd.save() to the script does this make a permanent save to the file?
i added mxd.save() and got the following:
I pretty sure that i have access to the file.
Hi Rick
looks pretty good!
Adds the following command to end of the script to save changes to the map.
mxd.save()
Regards!
This is my partially completed python script:
<SPAN class="keyword token">from</SPAN> tkinter <SPAN class="keyword token">import</SPAN> <SPAN class="operator token">*</SPAN> <SPAN class="keyword token">from</SPAN> tkinter <SPAN class="keyword token">import</SPAN> messagebox <SPAN class="keyword token">import</SPAN> Tkinter<SPAN class="punctuation token">,</SPAN> arcpy mxd <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>mapping<SPAN class="punctuation token">.</SPAN>MapDocument<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"C:/GISMAPS/LUS Map.mxd"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#mxd = arcpy.mapping.MapDocument("CURRENT")</SPAN> <SPAN class="comment token">#reset (overwrite) MakeFeatureLayer_management. This is needed so you can run the program more than once.</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>overwriteOutput <SPAN class="operator token">=</SPAN> <SPAN class="token boolean">True</SPAN> <SPAN class="comment token">#delete the layer</SPAN> <SPAN class="comment token">#arcpy.Delete_managment </SPAN> <SPAN class="comment token">#set variables for when you run the section of program that set the layers that should be on</SPAN> geodatabase <SPAN class="operator token">=</SPAN> <SPAN class="string token">"C:\gismaps\LusData.mdb"</SPAN> dataset <SPAN class="operator token">=</SPAN> <SPAN class="string token">"ElectricData"</SPAN> feature_class <SPAN class="operator token">=</SPAN> <SPAN class="string token">"PriOHElectricLineSegment"</SPAN> <SPAN class="comment token">#Create main window</SPAN> window <SPAN class="operator token">=</SPAN> Tk<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> window<SPAN class="punctuation token">.</SPAN>title<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Feeders Selection"</SPAN><SPAN class="punctuation token">)</SPAN> window<SPAN class="punctuation token">.</SPAN>geometry<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"680x500"</SPAN><SPAN class="punctuation token">)</SPAN> window<SPAN class="punctuation token">.</SPAN>iconbitmap<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'C:/GISMAPS/lus.ico'</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#Define the frame for the feeders to be displayed</SPAN> frame <SPAN class="operator token">=</SPAN> Frame<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">)</SPAN> frame<SPAN class="punctuation token">.</SPAN>grid<SPAN class="punctuation token">(</SPAN>row<SPAN class="operator token">=</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> column<SPAN class="operator token">=</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> padx<SPAN class="operator token">=</SPAN><SPAN class="number token">15</SPAN><SPAN class="punctuation token">,</SPAN> pady<SPAN class="operator token">=</SPAN><SPAN class="number token">5</SPAN><SPAN class="punctuation token">)</SPAN> listNodes <SPAN class="operator token">=</SPAN> Listbox<SPAN class="punctuation token">(</SPAN>frame<SPAN class="punctuation token">,</SPAN> width<SPAN class="operator token">=</SPAN><SPAN class="number token">10</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">10</SPAN><SPAN class="punctuation token">,</SPAN> font<SPAN class="operator token">=</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Helvetica"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">10</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> listNodes<SPAN class="punctuation token">.</SPAN>pack<SPAN class="punctuation token">(</SPAN>side<SPAN class="operator token">=</SPAN><SPAN class="string token">"left"</SPAN><SPAN class="punctuation token">,</SPAN> fill<SPAN class="operator token">=</SPAN><SPAN class="string token">"y"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#Define the scrollbar in frame window</SPAN> scrollbar <SPAN class="operator token">=</SPAN> Scrollbar<SPAN class="punctuation token">(</SPAN>frame<SPAN class="punctuation token">,</SPAN> orient<SPAN class="operator token">=</SPAN><SPAN class="string token">"vertical"</SPAN><SPAN class="punctuation token">)</SPAN> scrollbar<SPAN class="punctuation token">.</SPAN>config<SPAN class="punctuation token">(</SPAN>command<SPAN class="operator token">=</SPAN>listNodes<SPAN class="punctuation token">.</SPAN>yview<SPAN class="punctuation token">)</SPAN> scrollbar<SPAN class="punctuation token">.</SPAN>pack<SPAN class="punctuation token">(</SPAN>side<SPAN class="operator token">=</SPAN><SPAN class="string token">"right"</SPAN><SPAN class="punctuation token">,</SPAN> fill<SPAN class="operator token">=</SPAN><SPAN class="string token">"y"</SPAN><SPAN class="punctuation token">)</SPAN> listNodes<SPAN class="punctuation token">.</SPAN>config<SPAN class="punctuation token">(</SPAN>yscrollcommand<SPAN class="operator token">=</SPAN>scrollbar<SPAN class="punctuation token">.</SPAN>set<SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#Add the selection of all feeders</SPAN> <SPAN class="keyword token">for</SPAN> item <SPAN class="keyword token">in</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="number token">2050</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">2051</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">2052</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">3050</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">3051</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">3052</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">3550</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">4050</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">4051</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">4052</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">5050</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">5051</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">5052</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">:</SPAN> listNodes<SPAN class="punctuation token">.</SPAN>insert<SPAN class="punctuation token">(</SPAN>END<SPAN class="punctuation token">,</SPAN> item<SPAN class="punctuation token">)</SPAN> feeder <SPAN class="operator token">=</SPAN> listNodes<SPAN class="punctuation token">.</SPAN>get<SPAN class="punctuation token">(</SPAN>ACTIVE<SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#Define all of the checkboxes</SPAN> prioh_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> priug_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> secoh_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> secug_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> fuse_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> switch_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> sp_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> cap_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> rec_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> pinhook_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> mall_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> peck_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> pri_oh <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Primary Overhead"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> prioh_var<SPAN class="punctuation token">,</SPAN>onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">175</SPAN><SPAN class="punctuation token">)</SPAN> pri_ug <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Primary Underground"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> priug_var<SPAN class="punctuation token">,</SPAN>onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">12</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">200</SPAN><SPAN class="punctuation token">)</SPAN> sec_oh <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Secondary Overhead"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> secoh_var<SPAN class="punctuation token">,</SPAN>onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">8</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">225</SPAN><SPAN class="punctuation token">)</SPAN> sec_ug <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Secondary Underground"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> secug_var<SPAN class="punctuation token">,</SPAN>onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">18</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">250</SPAN><SPAN class="punctuation token">)</SPAN> fuse <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Fuse"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> fuse_var<SPAN class="punctuation token">,</SPAN>onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">400</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">10</SPAN><SPAN class="punctuation token">)</SPAN> switch <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Switch"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> switch_var<SPAN class="punctuation token">,</SPAN>onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">405</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">35</SPAN><SPAN class="punctuation token">)</SPAN> servicepoint <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Service Point"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> sp_var<SPAN class="punctuation token">,</SPAN>onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">420</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">88</SPAN><SPAN class="punctuation token">)</SPAN> capacitor <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Capacitor"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> cap_var<SPAN class="punctuation token">,</SPAN>onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">412</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">60</SPAN><SPAN class="punctuation token">)</SPAN> recloser <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Recloser"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> rec_var<SPAN class="punctuation token">,</SPAN>onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">409</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">87</SPAN><SPAN class="punctuation token">)</SPAN> pinhook <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Pinhook"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> pinhook_var<SPAN class="punctuation token">,</SPAN> state <SPAN class="operator token">=</SPAN> DISABLED<SPAN class="punctuation token">,</SPAN> onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">175</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">15</SPAN><SPAN class="punctuation token">)</SPAN> mall <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Mall"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> mall_var<SPAN class="punctuation token">,</SPAN> state <SPAN class="operator token">=</SPAN> DISABLED<SPAN class="punctuation token">,</SPAN> onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">165</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">45</SPAN><SPAN class="punctuation token">)</SPAN> peck <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Peck"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> peck_var<SPAN class="punctuation token">,</SPAN> state <SPAN class="operator token">=</SPAN> DISABLED<SPAN class="punctuation token">,</SPAN> onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">165</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">75</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#Commit all of the options</SPAN> <SPAN class="keyword token">def</SPAN> <SPAN class="token function">commit</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> feeder <SPAN class="operator token">=</SPAN> listNodes<SPAN class="punctuation token">.</SPAN>get<SPAN class="punctuation token">(</SPAN>ACTIVE<SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#print feeder</SPAN> <SPAN class="comment token">#my_label = Label(window, text=prioh_var.get()).pack()</SPAN> <SPAN class="comment token">#check to see which inputs have been selected</SPAN> <SPAN class="comment token">#Primary Overhead</SPAN> <SPAN class="keyword token">if</SPAN> prioh_var<SPAN class="punctuation token">.</SPAN>get<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"pri_oh = 1"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># show primary overhead feeder where feederid = feeder -ie: [FEEDERID] = "2050"</SPAN> <SPAN class="keyword token">print</SPAN> <SPAN class="string token">"Primary_OH"</SPAN> <SPAN class="keyword token">print</SPAN> feeder layer_name <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Primary OH"</SPAN> primary_oh <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>mapping<SPAN class="punctuation token">.</SPAN>ListLayers<SPAN class="punctuation token">(</SPAN>mxd<SPAN class="punctuation token">,</SPAN> layer_name<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN> primary_oh<SPAN class="punctuation token">.</SPAN>definitionQuery <SPAN class="operator token">=</SPAN> <SPAN class="string token">"[FEEDERID] = '2050'"</SPAN> <SPAN class="comment token">#Primary_OH_path = r"{0}\{1}\{2}".format(geodatabase, dataset, feature_class) </SPAN> <SPAN class="comment token">#Primary_OH = arcpy.MakeFeatureLayer_management(Primary_OH_path, "Primary_OH_layer2") </SPAN> <SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"pri_oh = 0"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># do not display primary overhead feeder for [FEEDERID] = "2050"</SPAN> <SPAN class="comment token">#Primary Underground </SPAN> <SPAN class="keyword token">if</SPAN> priug_var<SPAN class="punctuation token">.</SPAN>get<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"pri_ug = 1"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">print</SPAN> feeder layer_name <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Primary UG"</SPAN> primary_ug <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>mapping<SPAN class="punctuation token">.</SPAN>ListLayers<SPAN class="punctuation token">(</SPAN>mxd<SPAN class="punctuation token">,</SPAN> layer_name<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN> primary_ug<SPAN class="punctuation token">.</SPAN>definitionQuery <SPAN class="operator token">=</SPAN> <SPAN class="string token">"[FEEDERID] = '2050'"</SPAN> <SPAN class="comment token">#else:</SPAN> <SPAN class="comment token">#print("pri_ug = 0")</SPAN> <SPAN class="comment token"># do not display primary underground feeder for [FEEDERID] = "2050"</SPAN> <SPAN class="comment token">#reset all variables </SPAN> <SPAN class="comment token">#def reset():</SPAN> <SPAN class="comment token">#Button to run the commit command </SPAN> Button<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text<SPAN class="operator token">=</SPAN><SPAN class="string token">"commit"</SPAN><SPAN class="punctuation token">,</SPAN> command<SPAN class="operator token">=</SPAN>commit<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">300</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">350</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#Button to run the reset command</SPAN> <SPAN class="comment token">#Button(window, text="reset", command=reset).place(x=400, y=350)</SPAN> <SPAN class="comment token">#Quit the program</SPAN> Button<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text<SPAN class="operator token">=</SPAN><SPAN class="string token">"Quit"</SPAN><SPAN class="punctuation token">,</SPAN> command<SPAN class="operator token">=</SPAN>window<SPAN class="punctuation token">.</SPAN>destroy<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">500</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">350</SPAN><SPAN class="punctuation token">)</SPAN> window<SPAN class="punctuation token">.</SPAN>mainloop<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
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
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.
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.
Rick
You can use this example in order to set a Definition Query on a map layer.
mxd = arcpy.mapping.MapDocument(r"C:/GISMAPS/LUS Map.mxd") layer_name = "Primary_OH" primary_oh = arcpy.mapping.ListLayers(mxd, layer_name)[0] primary_oh.definitionQuery = "[FEEDERID] = '2050'"
make feature layer and make table view both create the respective object in memory. If you run your tool more than once without exiting out of ArcMap, you'll get an error every time. (See this write up). If you need to get rid of the feature layer or table view you have a couple of choices. See this stack exchange post. You can use arcpy.Delete_managment or try arcpy.env.overwriteOutput = True at the top of the script. The former will delete it, while the the latter will overwrite it....
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.
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()<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
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?
i ran the program and it worked as it should. When i ran it again it said that the layer already exists:
<SPAN class="keyword token">from</SPAN> tkinter <SPAN class="keyword token">import</SPAN> <SPAN class="operator token">*</SPAN> <SPAN class="keyword token">from</SPAN> tkinter <SPAN class="keyword token">import</SPAN> messagebox <SPAN class="keyword token">import</SPAN> Tkinter<SPAN class="punctuation token">,</SPAN> arcpy myMap <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>mapping<SPAN class="punctuation token">.</SPAN>MapDocument<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"C:/GISMAPS/LUS Map.mxd"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#myMap = arcpy.mapping.MapDocument("CURRENT")</SPAN> geodatabase <SPAN class="operator token">=</SPAN> <SPAN class="string token">"C:\gismaps\LusData.mdb"</SPAN> dataset <SPAN class="operator token">=</SPAN> <SPAN class="string token">"ElectricData"</SPAN> feature_class <SPAN class="operator token">=</SPAN> <SPAN class="string token">"PriOHElectricLineSegment"</SPAN> window <SPAN class="operator token">=</SPAN> Tk<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> window<SPAN class="punctuation token">.</SPAN>title<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Feeders Selection"</SPAN><SPAN class="punctuation token">)</SPAN> window<SPAN class="punctuation token">.</SPAN>geometry<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"680x500"</SPAN><SPAN class="punctuation token">)</SPAN> window<SPAN class="punctuation token">.</SPAN>iconbitmap<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'C:/GISMAPS/lus.ico'</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#Define the frame for the feeders to be displayed</SPAN> frame <SPAN class="operator token">=</SPAN> Frame<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">)</SPAN> frame<SPAN class="punctuation token">.</SPAN>grid<SPAN class="punctuation token">(</SPAN>row<SPAN class="operator token">=</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> column<SPAN class="operator token">=</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> padx<SPAN class="operator token">=</SPAN><SPAN class="number token">15</SPAN><SPAN class="punctuation token">,</SPAN> pady<SPAN class="operator token">=</SPAN><SPAN class="number token">5</SPAN><SPAN class="punctuation token">)</SPAN> listNodes <SPAN class="operator token">=</SPAN> Listbox<SPAN class="punctuation token">(</SPAN>frame<SPAN class="punctuation token">,</SPAN> width<SPAN class="operator token">=</SPAN><SPAN class="number token">10</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">10</SPAN><SPAN class="punctuation token">,</SPAN> font<SPAN class="operator token">=</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Helvetica"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">10</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> listNodes<SPAN class="punctuation token">.</SPAN>pack<SPAN class="punctuation token">(</SPAN>side<SPAN class="operator token">=</SPAN><SPAN class="string token">"left"</SPAN><SPAN class="punctuation token">,</SPAN> fill<SPAN class="operator token">=</SPAN><SPAN class="string token">"y"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#Define the scrollbar in frame window</SPAN> scrollbar <SPAN class="operator token">=</SPAN> Scrollbar<SPAN class="punctuation token">(</SPAN>frame<SPAN class="punctuation token">,</SPAN> orient<SPAN class="operator token">=</SPAN><SPAN class="string token">"vertical"</SPAN><SPAN class="punctuation token">)</SPAN> scrollbar<SPAN class="punctuation token">.</SPAN>config<SPAN class="punctuation token">(</SPAN>command<SPAN class="operator token">=</SPAN>listNodes<SPAN class="punctuation token">.</SPAN>yview<SPAN class="punctuation token">)</SPAN> scrollbar<SPAN class="punctuation token">.</SPAN>pack<SPAN class="punctuation token">(</SPAN>side<SPAN class="operator token">=</SPAN><SPAN class="string token">"right"</SPAN><SPAN class="punctuation token">,</SPAN> fill<SPAN class="operator token">=</SPAN><SPAN class="string token">"y"</SPAN><SPAN class="punctuation token">)</SPAN> listNodes<SPAN class="punctuation token">.</SPAN>config<SPAN class="punctuation token">(</SPAN>yscrollcommand<SPAN class="operator token">=</SPAN>scrollbar<SPAN class="punctuation token">.</SPAN>set<SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#Add the selection of all feeders</SPAN> <SPAN class="keyword token">for</SPAN> item <SPAN class="keyword token">in</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="number token">2050</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">2051</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">2052</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">3050</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">3051</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">3052</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">3550</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">4050</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">4051</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">4052</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">5050</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">5051</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">5052</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">:</SPAN> listNodes<SPAN class="punctuation token">.</SPAN>insert<SPAN class="punctuation token">(</SPAN>END<SPAN class="punctuation token">,</SPAN> item<SPAN class="punctuation token">)</SPAN> feeder <SPAN class="operator token">=</SPAN> listNodes<SPAN class="punctuation token">.</SPAN>get<SPAN class="punctuation token">(</SPAN>ACTIVE<SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#Define all of the checkboxes</SPAN> prioh_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> priug_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> secoh_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> secug_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> fuse_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> switch_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> sp_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> cap_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> rec_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> pinhook_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> mall_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> peck_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> pri_oh <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Primary Overhead"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> prioh_var<SPAN class="punctuation token">,</SPAN>onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">175</SPAN><SPAN class="punctuation token">)</SPAN> pri_ug <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Primary Underground"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> priug_var<SPAN class="punctuation token">,</SPAN>onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">12</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">200</SPAN><SPAN class="punctuation token">)</SPAN> sec_oh <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Secondary Overhead"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> secoh_var<SPAN class="punctuation token">,</SPAN>onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">8</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">225</SPAN><SPAN class="punctuation token">)</SPAN> sec_ug <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Secondary Underground"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> secug_var<SPAN class="punctuation token">,</SPAN>onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">18</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">250</SPAN><SPAN class="punctuation token">)</SPAN> fuse <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Fuse"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> fuse_var<SPAN class="punctuation token">,</SPAN>onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">400</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">10</SPAN><SPAN class="punctuation token">)</SPAN> switch <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Switch"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> switch_var<SPAN class="punctuation token">,</SPAN>onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">405</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">35</SPAN><SPAN class="punctuation token">)</SPAN> servicepoint <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Service Point"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> sp_var<SPAN class="punctuation token">,</SPAN>onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">420</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">88</SPAN><SPAN class="punctuation token">)</SPAN> capacitor <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Capacitor"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> cap_var<SPAN class="punctuation token">,</SPAN>onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">412</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">60</SPAN><SPAN class="punctuation token">)</SPAN> recloser <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Recloser"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> rec_var<SPAN class="punctuation token">,</SPAN>onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">409</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">87</SPAN><SPAN class="punctuation token">)</SPAN> pinhook <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Pinhook"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> pinhook_var<SPAN class="punctuation token">,</SPAN> state <SPAN class="operator token">=</SPAN> DISABLED<SPAN class="punctuation token">,</SPAN> onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">175</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">15</SPAN><SPAN class="punctuation token">)</SPAN> mall <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Mall"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> mall_var<SPAN class="punctuation token">,</SPAN> state <SPAN class="operator token">=</SPAN> DISABLED<SPAN class="punctuation token">,</SPAN> onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">165</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">45</SPAN><SPAN class="punctuation token">)</SPAN> peck <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Peck"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> peck_var<SPAN class="punctuation token">,</SPAN> state <SPAN class="operator token">=</SPAN> DISABLED<SPAN class="punctuation token">,</SPAN> onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">165</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">75</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#Commit all of the options</SPAN> <SPAN class="keyword token">def</SPAN> <SPAN class="token function">commit</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="comment token">#my_label = IntVar() </SPAN> feeder <SPAN class="operator token">=</SPAN> listNodes<SPAN class="punctuation token">.</SPAN>get<SPAN class="punctuation token">(</SPAN>ACTIVE<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">print</SPAN> feeder <SPAN class="comment token">#my_label = Label(window, text=prioh_var.get()).pack()</SPAN> <SPAN class="comment token">#check to see which inputs have been selected</SPAN> <SPAN class="keyword token">if</SPAN> prioh_var<SPAN class="punctuation token">.</SPAN>get<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"pri_oh = 1"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># show primary overhead feeder where feederid = feeder -ie: [FEEDERID] = "2050"</SPAN> <SPAN class="keyword token">print</SPAN> <SPAN class="string token">"Primary_OH"</SPAN> Primary_OH_path <SPAN class="operator token">=</SPAN> r<SPAN class="string token">"{0}\{1}\{2}"</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>geodatabase<SPAN class="punctuation token">,</SPAN> dataset<SPAN class="punctuation token">,</SPAN> feature_class<SPAN class="punctuation token">)</SPAN> Primary_OH <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>MakeFeatureLayer_management<SPAN class="punctuation token">(</SPAN>Primary_OH_path<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"Primary_OH_layer2"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"pri_oh = 0"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># do not display primary overhead feeder for [FEEDERID] = "2050"</SPAN> <SPAN class="keyword token">if</SPAN> priug_var<SPAN class="punctuation token">.</SPAN>get<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"pri_ug = 1"</SPAN><SPAN class="punctuation token">)</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>SelectLayerByAttribute_management<SPAN class="punctuation token">(</SPAN>Primary_UG<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">""</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"[FEEDERID] = '2050'"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"pri_ug = 0"</SPAN><SPAN class="punctuation token">)</SPAN> Button<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text<SPAN class="operator token">=</SPAN><SPAN class="string token">"commit"</SPAN><SPAN class="punctuation token">,</SPAN> command<SPAN class="operator token">=</SPAN>commit<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">300</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">350</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#Quit the program</SPAN> Button<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text<SPAN class="operator token">=</SPAN><SPAN class="string token">"Quit"</SPAN><SPAN class="punctuation token">,</SPAN> command<SPAN class="operator token">=</SPAN>window<SPAN class="punctuation token">.</SPAN>destroy<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">400</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">350</SPAN><SPAN class="punctuation token">)</SPAN> window<SPAN class="punctuation token">.</SPAN>mainloop<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Can you share the whole code please?
Just as an experiment to get more familiar with the MakeFeatureLayer command, do you have a simpler feature class not in a feature dataset that you can try this command on just to see exactly how the syntax should be in a simpler working script?
A general question would also be if a complex edge type feature class as shown in screenshot above is supported with MakeFeatureLayer command?
I get the following
geodatabase = "C:\gismaps\LusData.mdb" dataset = "ElectricData" feature_class = "PriOHElectricLineSegment" ##### geodatabase = r"C:\gismaps\LusData.mdb"<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
You need to be careful when setting variables that include a path. I like to use the r (raw text): it takes care of any of the escaped slashes for you.
You might also consider using arcpy.env.workspace; it can help clean up logical paths as well...
Try to set another name to the layer object, like "Primary_OH_Layer1", or something like that.
Primary_OH = arcpy.MakeFeatureLayer_management(Primary_OH_path, "Primary_OH_layer1")
i did put this code at the beginning
geodatabase = "C:\gismaps\LusData.mdb"dataset = "ElectricData"feature_class = "PriOHElectricLineSegment"
i entered the code that you suggested:
When running it i get the following errors:
You can try testing your script using personal geodatabase for now.
But, as Michael recommends, you should evaluate to migrate your data to File Geodatabase to better support.
thanks everyone for you help. i will see what i need to do to copy the data to a .gdb file.
Will get back with you when this is completed.
Rick:
You should copy the data to a file gdb from the personal geodatabase that you are currently using as ESRI is migrating to Pro which does not support personal geodatabases that you are using. File geodatabases can be used in both ArcMap (32-bit) and Pro (64-bit).
When i do that i get the following:
There is no .gdb database.
Hi Rick,
The gdb file (File Geodatabase) is the most popular container of data in ArcGIS. However, mxd files can contain multiples types of files and containers (Data sources).
In order to get the Primary_OH_Path of yout layer follow these steps:
Joe,
I guess i will have to change the lines to some other command. What i am trying to do here is go to the properties of a layer and create a definition query (i.e. - [FEEDERID] = "2050") and turn off all of the feeders for that layer (Primary OH) that are not numbered 2050. Am i doing this wrong? Is there another way to do this?
I know about ..mxd files but do not know about .gdb files. Is that what you are telling me to put in the Primary_OH_path. Where would the .gdb be located? I do not see one when i search C: drive
Line 77 & 85 are going to give you problems every time:
# line 77: arcpy.SelectLayerByAttribute_management(Primary_OH, "", Expression) # line 85: arcpy.SelectLayerByAttribute_management(Primary_UG, "", "[FEEDERID] = '2050'") <SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Primary_OH and Primary_UG are never defined as variables in your script; when python reads a string that is not within quotes, it treats that string as a variable.
<SPAN class="keyword token">if</SPAN> x <SPAN class="operator token">==</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>x<SPAN class="punctuation token">)</SPAN> Traceback <SPAN class="punctuation token">(</SPAN>most recent call last<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> File <SPAN class="string token">"<ipython-input-1-ea8c3abaaaf7>"</SPAN><SPAN class="punctuation token">,</SPAN> line <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">in</SPAN> <SPAN class="operator token"><</SPAN>module<SPAN class="operator token">></SPAN> <SPAN class="keyword token">if</SPAN> x <SPAN class="operator token">==</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">:</SPAN> NameError<SPAN class="punctuation token">:</SPAN> name <SPAN class="string token">'x'</SPAN> <SPAN class="keyword token">is</SPAN> <SPAN class="operator token">not</SPAN> defined x <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN> <SPAN class="comment token"># value of x is now defined</SPAN> <SPAN class="keyword token">if</SPAN> x <SPAN class="operator token">==</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">'x equals zero'</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">'Nope; x does not equal zero...'</SPAN><SPAN class="punctuation token">)</SPAN> Nope<SPAN class="punctuation token">;</SPAN> x does <SPAN class="operator token">not</SPAN> equal zero<SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN> <SPAN class="comment token"># the result of the print() function...</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
I realized there is a variable called my Map that is not really being used in your script.Anyway, in the top of your script, try to define these variables as following:
# Referencing variables here ------------------------- Primary_OH_path = r"C:\<your_path>\<your_gdb.gdb>\Primary_OH" Primary_OH = arcpy.MakeFeatureLayer_management(Primary_OH_path, "Primary_OH") Primary_UG_path = r"C:\<your_path>\<your_gdb.gdb>\Primary_UG" Primary_UG = arcpy.MakeFeatureLayer_management(Primary_UG_path, "Primary_UG")<SPAN class="" style="color: slategray; border: 0px; font-weight: inherit;"></SPAN> <CODE><SPAN class="" style="color: #0077aa; border: 0px; font-weight: inherit;">from</SPAN> tkinter <SPAN class="" style="color: #0077aa; border: 0px; font-weight: inherit;">import</SPAN> <SPAN class="" style="color: #a67f59; background: rgba(255, 255, 255, 0.5); border: 0px; font-weight: inherit;">*</SPAN> <SPAN class="" style="color: #0077aa; border: 0px; font-weight: inherit;">from</SPAN> tkinter <SPAN class="" style="color: #0077aa; border: 0px; font-weight: inherit;">import</SPAN> messagebox <SPAN class="" style="color: #0077aa; border: 0px; font-weight: inherit;">import</SPAN> Tkinter<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">,</SPAN> arcpy myMap <SPAN class="" style="color: #a67f59; background: rgba(255, 255, 255, 0.5); border: 0px; font-weight: inherit;">=</SPAN> arcpy<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">.</SPAN>mapping<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">.</SPAN>MapDocument<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">(</SPAN><SPAN class="" style="color: #669900; border: 0px; font-weight: inherit;">"C:/GISMAPS/LUS Map.mxd"</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">)</SPAN> <SPAN class="" style="color: slategray; border: 0px; font-weight: inherit;">#myMap = arcpy.mapping.MapDocument("CURRENT") </SPAN>
<SPAN class="" style="color: slategray; border: 0px; font-weight: inherit;"></SPAN>
In your original post it said Primary_OH is not defined and now it says Primary_UG is not defined.
The print statement before the SelectLayerByAttribute call is just a troubleshooting technique to see what value is being passed if any.
Michael,
i can put a print statement but what do you want me to have printed out? I think that the error is due to line 77 but not sure.
This is the error that i get
Can you put a print statement in at line 73 and see what the result is?
Looks like line 74 is your problem. You are making a selection on what python thinks is a variable (since it's not quoted) but I don't see any other reference to Primary_OH. Typically, you make a selection against a table view or a feature layer, and I don't see either of those as well.
Thanks for the response. Line 77 is where the error is
<SPAN class="keyword token">from</SPAN> tkinter <SPAN class="keyword token">import</SPAN> <SPAN class="operator token">*</SPAN> <SPAN class="keyword token">from</SPAN> tkinter <SPAN class="keyword token">import</SPAN> messagebox <SPAN class="keyword token">import</SPAN> Tkinter<SPAN class="punctuation token">,</SPAN> arcpy myMap <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>mapping<SPAN class="punctuation token">.</SPAN>MapDocument<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"C:/GISMAPS/LUS Map.mxd"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#myMap = arcpy.mapping.MapDocument("CURRENT")</SPAN> window <SPAN class="operator token">=</SPAN> Tk<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> window<SPAN class="punctuation token">.</SPAN>title<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Feeders Selection"</SPAN><SPAN class="punctuation token">)</SPAN> window<SPAN class="punctuation token">.</SPAN>geometry<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"680x500"</SPAN><SPAN class="punctuation token">)</SPAN> window<SPAN class="punctuation token">.</SPAN>iconbitmap<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'C:/GISMAPS/lus.ico'</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#Define the frame for the feeders to be displayed</SPAN> frame <SPAN class="operator token">=</SPAN> Frame<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">)</SPAN> frame<SPAN class="punctuation token">.</SPAN>grid<SPAN class="punctuation token">(</SPAN>row<SPAN class="operator token">=</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> column<SPAN class="operator token">=</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> padx<SPAN class="operator token">=</SPAN><SPAN class="number token">15</SPAN><SPAN class="punctuation token">,</SPAN> pady<SPAN class="operator token">=</SPAN><SPAN class="number token">5</SPAN><SPAN class="punctuation token">)</SPAN> listNodes <SPAN class="operator token">=</SPAN> Listbox<SPAN class="punctuation token">(</SPAN>frame<SPAN class="punctuation token">,</SPAN> width<SPAN class="operator token">=</SPAN><SPAN class="number token">10</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">10</SPAN><SPAN class="punctuation token">,</SPAN> font<SPAN class="operator token">=</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Helvetica"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">10</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> listNodes<SPAN class="punctuation token">.</SPAN>pack<SPAN class="punctuation token">(</SPAN>side<SPAN class="operator token">=</SPAN><SPAN class="string token">"left"</SPAN><SPAN class="punctuation token">,</SPAN> fill<SPAN class="operator token">=</SPAN><SPAN class="string token">"y"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#Define the scrollbar in frame window</SPAN> scrollbar <SPAN class="operator token">=</SPAN> Scrollbar<SPAN class="punctuation token">(</SPAN>frame<SPAN class="punctuation token">,</SPAN> orient<SPAN class="operator token">=</SPAN><SPAN class="string token">"vertical"</SPAN><SPAN class="punctuation token">)</SPAN> scrollbar<SPAN class="punctuation token">.</SPAN>config<SPAN class="punctuation token">(</SPAN>command<SPAN class="operator token">=</SPAN>listNodes<SPAN class="punctuation token">.</SPAN>yview<SPAN class="punctuation token">)</SPAN> scrollbar<SPAN class="punctuation token">.</SPAN>pack<SPAN class="punctuation token">(</SPAN>side<SPAN class="operator token">=</SPAN><SPAN class="string token">"right"</SPAN><SPAN class="punctuation token">,</SPAN> fill<SPAN class="operator token">=</SPAN><SPAN class="string token">"y"</SPAN><SPAN class="punctuation token">)</SPAN> listNodes<SPAN class="punctuation token">.</SPAN>config<SPAN class="punctuation token">(</SPAN>yscrollcommand<SPAN class="operator token">=</SPAN>scrollbar<SPAN class="punctuation token">.</SPAN>set<SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#Add the selection of all feeders</SPAN> <SPAN class="keyword token">for</SPAN> item <SPAN class="keyword token">in</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="number token">2050</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">2051</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">2052</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">3050</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">3051</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">3052</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">3550</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">4050</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">4051</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">4052</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">5050</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">5051</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">5052</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">:</SPAN> listNodes<SPAN class="punctuation token">.</SPAN>insert<SPAN class="punctuation token">(</SPAN>END<SPAN class="punctuation token">,</SPAN> item<SPAN class="punctuation token">)</SPAN> feeder <SPAN class="operator token">=</SPAN> listNodes<SPAN class="punctuation token">.</SPAN>get<SPAN class="punctuation token">(</SPAN>ACTIVE<SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#Define all of the checkboxes</SPAN> prioh_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> priug_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> secoh_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> secug_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> fuse_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> switch_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> sp_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> cap_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> rec_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> pinhook_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> mall_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> peck_var <SPAN class="operator token">=</SPAN> IntVar<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> pri_oh <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Primary Overhead"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> prioh_var<SPAN class="punctuation token">,</SPAN>onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">175</SPAN><SPAN class="punctuation token">)</SPAN> pri_ug <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Primary Underground"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> priug_var<SPAN class="punctuation token">,</SPAN>onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">12</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">200</SPAN><SPAN class="punctuation token">)</SPAN> sec_oh <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Secondary Overhead"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> secoh_var<SPAN class="punctuation token">,</SPAN>onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">8</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">225</SPAN><SPAN class="punctuation token">)</SPAN> sec_ug <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Secondary Underground"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> secug_var<SPAN class="punctuation token">,</SPAN>onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">18</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">250</SPAN><SPAN class="punctuation token">)</SPAN> fuse <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Fuse"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> fuse_var<SPAN class="punctuation token">,</SPAN>onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">400</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">10</SPAN><SPAN class="punctuation token">)</SPAN> switch <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Switch"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> switch_var<SPAN class="punctuation token">,</SPAN>onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">405</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">35</SPAN><SPAN class="punctuation token">)</SPAN> servicepoint <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Service Point"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> sp_var<SPAN class="punctuation token">,</SPAN>onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">420</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">88</SPAN><SPAN class="punctuation token">)</SPAN> capacitor <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Capacitor"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> cap_var<SPAN class="punctuation token">,</SPAN>onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">412</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">60</SPAN><SPAN class="punctuation token">)</SPAN> recloser <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Recloser"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> rec_var<SPAN class="punctuation token">,</SPAN>onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">409</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">87</SPAN><SPAN class="punctuation token">)</SPAN> pinhook <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Pinhook"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> pinhook_var<SPAN class="punctuation token">,</SPAN> state <SPAN class="operator token">=</SPAN> DISABLED<SPAN class="punctuation token">,</SPAN> onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">175</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">15</SPAN><SPAN class="punctuation token">)</SPAN> mall <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Mall"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> mall_var<SPAN class="punctuation token">,</SPAN> state <SPAN class="operator token">=</SPAN> DISABLED<SPAN class="punctuation token">,</SPAN> onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">165</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">45</SPAN><SPAN class="punctuation token">)</SPAN> peck <SPAN class="operator token">=</SPAN> Checkbutton<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Peck"</SPAN><SPAN class="punctuation token">,</SPAN> variable <SPAN class="operator token">=</SPAN> peck_var<SPAN class="punctuation token">,</SPAN> state <SPAN class="operator token">=</SPAN> DISABLED<SPAN class="punctuation token">,</SPAN> onvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> offvalue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> height<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> width <SPAN class="operator token">=</SPAN> <SPAN class="number token">20</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">165</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">75</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#Commit all of the options</SPAN> <SPAN class="keyword token">def</SPAN> <SPAN class="token function">commit</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="comment token">#my_label = IntVar() </SPAN> feeder <SPAN class="operator token">=</SPAN> listNodes<SPAN class="punctuation token">.</SPAN>get<SPAN class="punctuation token">(</SPAN>ACTIVE<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">print</SPAN> feeder <SPAN class="comment token">#my_label = Label(window, text=prioh_var.get()).pack()</SPAN> <SPAN class="comment token">#check to see which inputs have been selected</SPAN> <SPAN class="keyword token">if</SPAN> prioh_var<SPAN class="punctuation token">.</SPAN>get<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"pri_oh = 1"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># show primary overhead feeder where feederid = feeder -ie: [FEEDERID] = "2050"</SPAN> Expression <SPAN class="operator token">=</SPAN> <SPAN class="string token">"[FEEDERID] = '2050'"</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>SelectLayerByAttribute_management<SPAN class="punctuation token">(</SPAN>Primary_OH<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">""</SPAN><SPAN class="punctuation token">,</SPAN> Expression<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"pri_oh = 0"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># do not display primary overhead feeder for [FEEDERID] = "2050"</SPAN> <SPAN class="keyword token">if</SPAN> priug_var<SPAN class="punctuation token">.</SPAN>get<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"pri_ug = 1"</SPAN><SPAN class="punctuation token">)</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>SelectLayerByAttribute_management<SPAN class="punctuation token">(</SPAN>Primary_UG<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">""</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"[FEEDERID] = '2050'"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"pri_ug = 0"</SPAN><SPAN class="punctuation token">)</SPAN> Button<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text<SPAN class="operator token">=</SPAN><SPAN class="string token">"commit"</SPAN><SPAN class="punctuation token">,</SPAN> command<SPAN class="operator token">=</SPAN>commit<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">300</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">350</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#Quit the program</SPAN> Button<SPAN class="punctuation token">(</SPAN>window<SPAN class="punctuation token">,</SPAN> text<SPAN class="operator token">=</SPAN><SPAN class="string token">"Quit"</SPAN><SPAN class="punctuation token">,</SPAN> command<SPAN class="operator token">=</SPAN>window<SPAN class="punctuation token">.</SPAN>destroy<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>place<SPAN class="punctuation token">(</SPAN>x<SPAN class="operator token">=</SPAN><SPAN class="number token">400</SPAN><SPAN class="punctuation token">,</SPAN> y<SPAN class="operator token">=</SPAN><SPAN class="number token">350</SPAN><SPAN class="punctuation token">)</SPAN> window<SPAN class="punctuation token">.</SPAN>mainloop<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Your code would be a lot easier to trouble shoot if you paste it into the syntax highlighter rather than providing it as an image. I don't see a reference to Primary_OH in the what you display, but I might be missing it. Somewhere in your code you call it and it should be in quotes is my guess...
Membros conectados podem postar, seguir atualizações e mais. Novo aqui? Registre uma conta gratuita.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.