Adding URL or Hyperlink in a forms.alert() TaskDialog

Is it possible to have a clickable URL/Hyperlink in the form?

Hello, Hi, What’s up? Welcome,

_ general bienséance rule _

from pyrevit import forms

forms.alert(msg='With the forms alert, the link is expressed in html in the sub_msg argument ', sub_msg="<a href=\"https://discourse.pyrevitlabs.io/ \">Click here for the pyRevit Forum</a>")
3 Likes

and another way directly from the TaskDialog class of the Revit API

MainContent => sub_msg argument in the forms module

The code below demonstrate also the usage of the CommandLink and the result upon clicking to opens a webpage.

import webbrowser
from Autodesk.Revit.UI import (TaskDialog, TaskDialogCommonButtons, TaskDialogCommandLinkId, TaskDialogResult)

title = 'Task Dialog Title'
dialog = TaskDialog(title)
dialog.MainContent = "<a href=\"https://discourse.pyrevitlabs.io/\">Click here for the pyRevit Forum</a>"
dialog.CommonButtons = TaskDialogCommonButtons.Ok
# Add Command Link
dialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink1,
                      'Click here for google.com',
                      'Command Button Sub Text')

result = dialog.Show()
if result == TaskDialogResult.Ok:
    webbrowser.open('https://bing.com')
if result == TaskDialogResult.CommandLink1:
    webbrowser.open('https://google.com')
3 Likes

Jean-Marc,
Thank you that is exactly what I was looking for… much appreciated

Regards
Eddie

1 Like