这个问题困扰了我好几个小时,有人能指出我正确的方向吗?
我知道按钮单击的默认值为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()
答案 0 :(得分:0)
下面的代码将满足您的需求,并通过一些易于遵循的步骤来构建您自己的自定义函数类。
您需要创建一个从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()