python - Python在类中传递值并使用.self定义
问题描述
我想将一些值传递给 def,但在正确添加它时遇到问题。
在
class MyAddin():
def __init__(self, imapinfopro, thisApplication): #also tried including _self.Table_Path in this.
try:
self._pro = imapinfopro
self._thisApplication = thisApplication
self._tab = None
#self._table_path =(r'D:\junk\28355.tab')
# Some standard variables to allow functions to be created for each action for easier use. r_ is for Ribbon actions
r_item_name="Infrastructure_Data" #Name of button on main ribbon (no spaces allowed)
r_button_name="Water" #same as operations in the ribbon_customization.py
r_subroup_name="Not Abandoned" #same as "Table" and "CallBack" in the ribbon_customization.py
r_subgroup_action="Open\nClose" #same as 'MB Handler\nNo Parameter'in the ribbon_customization.py
tab = self._pro.Ribbon.Tabs.Add(r_item_name)
self._tab = tab
if tab:
group = tab.Groups.Add(r_button_name, r_button_name)
if group:
button = group.Controls.Add("ButtonOpenTable", r_subroup_name, ControlType.Button)
button.IsLarge = True
button.LargeIcon = CommonUtil.path_to_uri("pack://application:,,,/MapInfo.StyleResources;component/Images/Mapping/infoTool_32x32.png")
button.SmallIcon = CommonUtil.path_to_uri("pack://application:,,,/MapInfo.StyleResources;component/Images/Mapping/infoTool_16x16.png")
button.Command = AddinUtil.create_command(self.open_table_click)
except Exception as e:
print("Failed to load: {}".format(e))
def open_table_click(self, sender):
#table_path=(r'D:\junk\28355.tab') #if left in this is used to open the table but I want to get this value from button.Command above.
table = self._pro.Catalog.OpenTable(table_path)
CommonUtil.do("map from {}".format(table.Alias))
CommonUtil.do("browse * from {}".format(table.Alias))
pass
我想将 in 的值发送table_path
到def open_table_click
from button.Command = AddinUtil.create_command(self.open_table_click)
。如果这不是一个自我调用,那将是......_command(self.open_table_click, tablepath)
和def open_table_click(self, sender, table_path):
解决方案
推荐阅读
- android - 如何使用 SHA256 算法签署 .apk
- docusignapi - DSA Web 应用程序和客户端应用程序上的 DocuSign 基本 URL 和资源路径位置
- keycloak - Keycloak 向客户端添加资源
- linux - IO 到固定内存
- imagemagick - 有没有办法使用 ImageMagick 在图像周围绘制边框?
- anylogic - 在任意逻辑参数变化实验中显示模拟进度百分比
- python - 如何在 ASGI 中使用 StreamingHttpResponse 运行 Django 频道
- .net - Azure AD MSAL 中范围、角色和组之间的区别
- rsa - 在 swift 中使用 rsa 创建公钥时出错
- laravel - 如何使用微风启动新的 Laravel 项目?