![](/img/trans.png)
[英]How to process data before downloading using st.download_button with on_click callback?
[英]Using the on_click option for a REVIT RPW flexform button
我已经为此困扰了几个小时,有人可以指出我正确的方向吗?
我知道按钮单击的默认值为FlexForm.get_values,我正在尝试调用自己的函数。 我不知道我要去哪里。
我知道我的错误在于以下两行:
Button('Proceed', on_click=proceed_pressed()),\
Button('Cancel', on_click=cancel_clicked())\
预先感谢您.....下面的完整代码.....
# -*- coding: utf-8 -*-
import rpw
from rpw import revit, db, ui, DB, UI
import sys
from rpw.ui.forms import FlexForm, Label, ComboBox, TextBox, TextBox, Separator, Button, CheckBox
def proceed_pressed():
print "proceed clicked"
def cancel_clicked():
print "canceled clicked"
components = [\
Label('Before Labeling Outlets:'),\
CheckBox('checkbox0', 'Audit Outlets, Zones, and Floors BEFORE writing Outlet IDs',default=True),\
CheckBox('checkbox1', 'Send Audit results to Excel',default=False),\
Separator(),\
Label('Pick Outlet Labeling Options:'),\
ComboBox('combobox2', {'Label with ROOM NUMBERS': 1, 'Label with SEQUENTIAL NUMBERS': 2}),\
Separator(),\
CheckBox('checkbox3', 'Include Zone Information (IDF Room)', default=True),\
CheckBox('checkbox4', 'Include Floor Number', default=True),\
Separator(),\
Button('Proceed', on_click=proceed_pressed()),\
Button('Cancel', on_click=cancel_clicked())\
]
form = FlexForm('Label Outlet', components)
form.show()
下面的代码将根据您的需要工作,并通过一些易于遵循的步骤来构建您自己的自定义函数类。
您需要创建一个继承自System.Windows.Window的新类。
您需要在每个函数之前添加@staticmethod
装饰器
您需要指定参数sender
和e
抱歉,我无法提供适当的解决方案。
clr.AddReference("PresentationFramework")
from System.Windows import Window
class ButtonClass(Window):
@staticmethod
def proceed_pressed(sender, e):
print("proceed clicked")
@staticmethod
def cancel_clicked(sender, e):
print("canceled clicked")
from rpw.ui.forms import FlexForm, Label, ComboBox, TextBox, TextBox, Separator, Button, CheckBox
components = [
Label('Before Labeling Outlets:'),
CheckBox('checkbox0', 'Audit Outlets, Zones, and Floors BEFORE writing Outlet IDs',default=True),
CheckBox('checkbox1', 'Send Audit results to Excel',default=False),
Separator(),
Label('Pick Outlet Labeling Options:'),
ComboBox('combobox2', {'Label with ROOM NUMBERS': 1, 'Label with SEQUENTIAL NUMBERS': 2}),
Separator(),
CheckBox('checkbox3', 'Include Zone Information (IDF Room)', default=True),
CheckBox('checkbox4', 'Include Floor Number', default=True),
Separator(),\
Button('Proceed', on_click=ButtonClass.proceed_pressed),
Button('Cancel', on_click=ButtonClass.cancel_clicked)
]
form = FlexForm('Label Outlet', components)
form.show()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.