|
POST
|
Thanks Chris, Would you mind taking a look at this post if you have a few moments? http://forums.arcgis.com/threads/78771-Use-Selection-of-one-Combobox-to-update-the-items-list-in-another-Combobox?referrerid=32780
... View more
02-28-2013
06:48 AM
|
0
|
0
|
773
|
|
POST
|
So I have a series of Comboboxes which I created to perform a "Quick-Jump" function in which a user can select AOIs at varying geography levels, and kind of quickly drill down into a very specific AOI without having to know where it is geographically. The Comboboxes are Major Geographic Level (MajorGeoLevel.cbx) and Minor Geographic Level (MinorGeoLevel.cbx). Major Geographic Level contains a static items list of containing the National Extent and 8 different regions around the US. When a user selects a region, the Combobox should: Perform a selection against the Regions Layer for the Region selected in the Combobox, zoom to the selected feature, turn the layer on, clear the selection and refresh the active view. Enable the MinorGeoLevel.cbx and update the items contained in the MinorGeoLevel.cbx with a predefined list of Minor Geographic Levels, which correspond to the selected item in the MajorGeoLevel.cbx, unless the item selected in MajorGeoLevel.cbx is 'National'. I am having two issues. 1. The selection from MajorGeoLevel.cbx does not seem to be doing anything. ie. When I select National...nothing happens. It doesn't even reflect in the Combobox. 2. MinorGeoLevel.cbx is not becoming enabled once a selection is made in MajorGeoLevel. Because it's not becoming enabled, I can't even tell if it's updating the item list for MinorGeoLevel.cbx either. Here is my code: class QuickJump_MajorGeoLevel(object): """Implementation for QuickJump_MajorGeoLevel.cbx (ComboBox)""" def __init__(self): self.items = ["National", "National-Direct", "Region I", "Region II", "Region III", "Region IV", "Region V", "Region VI", "Region VII", "Region VIII"] self.editable = False self.enabled = True self.dropdownWidth = 'XXXXXXXXXXXXXXXXXXXX' self.width = 'XXXXXXXXXXXXXXXXXXXX' def onSelChange(self, selection): #Instantiate the current MXD as a variable mxd = arcpy.mapping.MapDocument("Current") #Jump to the selected MajorGeoLevel and initialize the MinorGeoLevel combobox, populated with the MinorGeoList that corresponds to the current selection #If the current selection is 'National', jump to the NationalExtent. MinorGeoLevel.cbx and SubGeoLevel.cbx remain disabled from Initialization. if selection == "National": #Jump to the 'NationalExtent' df = arcpy.mapping.ListDataFrames(mxd, "Business Analyst Map")[0] NationalExtent = df.extent NationalExtent.XMin, NationalExtent.YMin = -13978263.2599, -1547990.11744 NationalExtent.XMax, NationalExtent.YMax = -7429812.66299, 7011646.87809 df.extent = NationalExtent arcpy.RefreshActiveView() #if the current selection is National-Direct , refresh the MinorGeoLevel.cbx in the UI elif selection == "National-Direct": #Refresh the 'QuickJump_MinorGeoLevel' combobox which enables the combobox and updates the item list QuickJump_MinorGeoLevel.refresh() #Jump to the Full Extent of the National-Direct Region and Turn the layer On for lyr in arcpy.mapping.ListLayers (mxd): if lyr.name == "Regions_All": #if the layer is not currently visible, make the layer visible and refresh the Map Display Window if lyr.visible == False: lyr.visible = True #Establish the DataFrame and the 'Regions_All' variables df = arcpy.mapping.ListDataFrames(mxd, "Business Analyst Map")[0] Regions_All = arcpy.mapping.ListLayers(mxd, "Regions_All", df) #Select 'Region 1' from the 'Regions_All' layer arcpy.SelectLayerByAttribute_management ("Regions_All", "NEW_SELECTION", ' "REGION" = ND') #Zoom to the selected feature df.zoomToSelectedFeatures() #Apply a 10% Buffer to the Extent of the Zoom df.scale = df.scale * 1.1 #Clear the Selection arcpy.SelectLayerByAttribute_management ("Regions_All", "CLEAR_SELECTION") #Refresh the Map Display Window arcpy.RefreshActiveView() #Report an with a MessageBox if the 'Regions_All' layer is not loaded in the MXD else: pythonaddins.MessageBox('The layer Regions_All is not loaded in the MXD. Unable to turn layer on or jump to extent.', 'Layer not Found', 5) class QuickJump_MinorGeoLevel(object): """Implementation for QuickJump_MinorGeoLevel.cbx (ComboBox)""" def __init__(self): #Create the Predefined Item Lists, which are initialized depending on the QuickJump_MajorGeoLevel Combobox's current selection self.items= [] self.editable = False self.enabled = False self.dropdownWidth = 'WWWWWW' self.width = 'WWWWWW' def SelChange(self, selection): pass def refresh(self): #Create the Predefined Minor Geography Item Lists, which are implemented in the QuickJump_MinorGeoLevel Combobox depending on the QuickJump_MajorGeoLevel Combobox's current selection ND_MinorGeoList = ["Boston", "Los Angeles", "San Francisco", "Honolulu", "Chicago", "Minneapolis/St. Paul", "New York", "Philadelphia", "Wilmington"] RegionI_MinorGeoList["New York-Northern New Jersey-Long Island, NY-NJ-PA"] RegionII_MinorGeoList["New York-Northern New Jersey-Long Island, NY-NJ-PA"] RegionIII_MinorGeoList["Bridgeport-Stamford-Norwalk, CT", "Hartford West-Hartford East, CT", "New Haven-Milford,CT", "New York-Northern New Jersey-Long Island, NY-NJ-PA", "Poughkeepsie-Newburgh-Middletown, NY", "Torrington, CT", "Trenton-Ewing, NJ", "Allentown-Bethlehem-Easton, PA-NJ", "Philadelphia-Camden-Wilmington, PA-NJ-DE-MD"] RegionIV_MinorGeoList["Baltimore-Townsend, MD", "Cambridge, MD", "Dover, DE", "Easton, MD", "Gettysburg, PA", "Lexington Park, MD", "Ocean Pines, MD", "Salisbury, MD", "Seaford, DE", "Washington-Arlington-Alexandria, DC-VA-MD-WV", "York-Hanover, PA"] RegionV_MinorGeoList["Baltimore-Townsend, MD", "Chambersburg, PA", "Charlottesville, VA", "Culpepper, VA", "Cumberland, MD-WV", "Gettysburg, PA", "Hagerstown-Martinsburg, MD-WV", "Harrisonburg, VA", "Richmond, VA", "Staunton-Waynesboro, VA", "Washington-Arlington-Alexandria, DC, VA-MD-WV", "Winchester,VA-WV"] RegionVI_MinorGeoList["Athens, TX", "Bonham, TX", "Dallas-Fort Worth-Arlington, TX", "Durant, OK", "Gainesville, TX", "Palestine, TX", "Paris, TX", "Sherman-Denison, TX", "Sulpher Springs, TX", "Alexandria, LA", "Baton Rouge, LA", "Crowley, LA", "DeRidder, LA", "Fort Polk South, LA", "Jennings, LA", "Lufkin, TX", "Natchez, MS-LA", "Opelousas-Eunice, LA", "Bastrop, LA", "El Dorado, AR", "Jacksonville, TX", "Longview, TX", "Magnolia, AR", "MArshall, TX", "Minden, LA", "Monroe, LA", "Mount Pleasant, TX", "Nacogdoches, TX", "Natchitoches, LA", "Ruston, LA", "Shreveport-Bossier City, LA", "Tallulah, LA", "Texarkana, TX", "Tyler, TX", "Vicksburg, MS"] RegionVII_MinorGeoList["Baton Rouge, LA", "Bogalusa, LA", "Crowley, LA", "Gulfport-Biloxi, MS", "Hammond, LA", "Houma-Bayou Cane-Thibodaux, LA", "Jennings, LA", "Lafayette, LA", "Lakes Charles, LA", "McComb, MS", "Morgan City, LA", "New Iberia, LA", "New Orleans-Metairie-Kenner, LA", "Opelousas-Eunice, LA", "Picayune, MS", "Pierre Part, LA"] RegionVIII_MinorGeoList["Alice, TX", "Austin-Round Rock-San Marcos, TX", "Bay City, TX", "Brenham, TX", "Brownsville-Harlingen", "College Station-Bryan, TX", "Corpus Christi, TX", "El Campo, TX", "Huntsville, TX", "Kileen-Temple-Fort Hood, TX", "Kingsville, TX", "Marble Falls, TX", "McAllen-Edinburg-Mission, TX", "Raymondville, TX", "Rio Grande City-Roma, TX", "San Antonio-New Braunfels, TX", "Victoria, TX", "Abbeville, LA", "Beaumont-Port Arthur, TX", "DeRidder, LA", "Houston-Sugar Land-Baytown, TX", "Jennings, LA", "Lake Charles, LA"] if QuickJump_MajorGeoLevel.selection == "National-Direct": self.enabled = True self.items = ND_MinorGeoList Any insight is greatly appreciated
... View more
02-28-2013
06:46 AM
|
0
|
3
|
1514
|
|
POST
|
Does anyone know of a way to reorder Python Addin elements built in the Addin Assistant without having to rebuild the entire thing? Situation: I built a couple of toolbars and toolpalettes, buttons, tools, ect. I've been asked to insert a "Combo Box" drop down to control the tool all of the elements enabled state based on the user's combo box selection ie. [INDENT][/INDENT]if combo box = "Selection1", tool1, tool2 and tool3, self.enabled=true and tool4, tool5, tool6 self.enabled=false. That's not the actual code, just a basic reference to give you an idea of what I mean. So when I added the combo box into the addin, the stupid thing is at the end of the toolpalette and toolbar because of course, I created it after everything else. There doesn't appear to be a way to just drag and drop elements into the order you want them to appear in. I thought about maybe editing the config.xml but first of all, I don't know if that will actually solve the problem and secondly, I'd prefer not to delve into that and open pandora's box if there is a more elegant solution available. I know I can hit customize in ArcMap and move it. But that customization won't reflect in the esriaddin file I distribute, so when others install it they will need to make that customization as well which...they shouldn't have to do. Any ideas?
... View more
01-28-2013
04:58 AM
|
0
|
2
|
2869
|