【功能实现】实现wx界面的下拉框,可以动态变化的下拉框(arcpy中读取shp的字段,以及选择可以使用)

实现wx界面的下拉框,可以动态变化的下拉框(arcpy中读取shp的字段,以及选择可以使用)

#encoding: utf-8
import arcpy
import os
import wx

def get_field_names(self, input_feature_class):
    # 检查路径是否存在
    if not os.path.exists(input_feature_class):
        print("Error: File does not exist.")
        return []

    # 设置工作空间
    arcpy.env.workspace = os.path.dirname(input_feature_class)

    # 列出要素类的字段
    fields = arcpy.ListFields(input_feature_class)

    # 创建一个空列表来存储字段名
    field_names1 = []

    # 将字段名追加到列表中
    for field in fields:
        field_names1.append(field.name)

    # 返回字段名列表
    return field_names1


self.combo1 = wx.ComboBox(parent=panel1, id=-1, size=(100, 180), pos=(340, 200), value="")
def OnCombo1Select(self, event):
    field_names = self.get_field_names(self.editname5.GetValue())
    self.combo1.SetItems(field_names)
def OnClick5(self, event):
    wildcard = 'Raster (*.shp)|*.shp'
    dialog = wx.FileDialog(None, 'Browse for File', os.getcwd(), '', wildcard, wx.FD_OPEN)
    if dialog.ShowModal() == wx.ID_OK:
        self.editname5.SetValue(dialog.GetPath())
        dialog.Destroy
    self.OnCombo1Select(wx.CommandEvent(wx.EVT_COMBOBOX.typeId, self.combo1.GetId()))
    

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值