![](/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.