Skip to content

Commit

Permalink
Merge pull request #1801 from jmcouffin/show-balloon
Browse files Browse the repository at this point in the history
first prototype 
[forms module]
forms.show_balloon("my header", "Lorem ipsum", tooltip='tooltip')
  • Loading branch information
jmcouffin authored Apr 20, 2023
2 parents 327e3dd + 6d2479b commit 9ff5072
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,18 @@ def test_forms(forms_func, test_title, filterfuncstr='', *args, **kwargs):
print(selection)
else:
print('No selection...')


print(
forms.show_balloon(
"header",
"text",
tooltip='tooltip',
group='my group',
is_favourite=True,
is_new=True,
timestamp = None,
click_result = result_item_result_clicked(debug=True)
))

print(
forms.ask_for_string(
Expand Down
43 changes: 43 additions & 0 deletions pyrevitlib/pyrevit/forms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@

import pyevent #pylint: disable=import-error

import Autodesk.Windows.ComponentManager #pylint: disable=import-error
import Autodesk.Internal.InfoCenter #pylint: disable=import-error

#pylint: disable=W0703,C0302,C0103
mlogger = get_logger(__name__)
Expand Down Expand Up @@ -2823,6 +2825,47 @@ def pick_folder(title=None, owner=None):
return fb_dlg.SelectedPath


def result_item_result_clicked(sender, e, debug=False):
if debug:
print("Result clicked") # using print_md here will break the script
pass


def show_balloon(header, text, tooltip='', group='', is_favourite=False, is_new=False, timestamp = None, click_result = result_item_result_clicked):
r"""Show ballon in the info center section
Args:
header (str): Category section (Bold)
text (str): Title section (Regular)
tooltip (str): Tooltip
is_favourite (bool): Add a blue star before header
is_new (bool): Flag to new
timestamp (str): Set timestamp
click_result (def): Executed after a click event
Returns:
sync_balloon: None
Example:
>>> from pyrevit import forms
>>> forms.show_balloon("my header", "Lorem ipsum", tooltip='tooltip', group='group', is_favourite=True, is_new=True, timestamp = '2019-01-01 00:00:00', click_result = forms.result_item_result_clicked)
...
"""
result_item = Autodesk.Internal.InfoCenter.ResultItem()
result_item.Category = header
result_item.Title = text
result_item.TooltipText = tooltip
result_item.Group = group
result_item.IsFavorite = is_favourite
result_item.IsNew = is_new
if timestamp:
result_item.Timestamp = timestamp
result_item.ResultClicked += click_result
sync_balloon = Autodesk.Windows.ComponentManager.InfoCenterPaletteManager.ShowBalloon(
result_item)
return sync_balloon


def pick_file(file_ext='*', files_filter='', init_dir='',
restore_dir=True, multi_file=False, unc_paths=False, title=None):
r"""Pick file dialog to select a destination file.
Expand Down

0 comments on commit 9ff5072

Please sign in to comment.