使用REVIT RPW flexform按钮的“单击”选项

2024-04-18 19:20:00 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经被这个问题困扰了好几个小时了,有人能给我指出正确的方向吗?你知道吗

我知道按钮点击的默认值是FlexForm.get\u值,我正在尝试调用我自己的函数。我不知道我哪里出错了。你知道吗

我知道我的错误在这两行:

 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() 

Tags: importdefaultonbuttoncancellabelclickcheckbox
1条回答
网友
1楼 · 发布于 2024-04-18 19:20:00

下面的代码将适用于您所要查找的内容,并提供一些易于遵循的步骤来构建您自己的自定义函数类。你知道吗

  1. 您需要创建一个继承自的新类系统.Windows.Window你知道吗

    • 为什么?我不知道
  2. 您需要在每个函数之前添加@staticmethod修饰符

    • 为什么?我不知道
  3. 您需要指定参数sendere

    • 为什么?我不知道

对不起,我不能给出正确的解决办法。你知道吗

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()

相关问题 更多 >