Add a table from an Information Link using the Library Browser Dialog


import clr
import sys

from System.IO import Directory

clr.AddReferenceToFileAndPath(''.join([Directory.GetCurrentDirectory(),'\Spotfire.Dxp.Forms.dll']))
clr.AddReference('System.Windows.Forms')

from Spotfire.Dxp.Forms.Dialogs import LibraryBrowserDialog
from Spotfire.Dxp.Framework.Library import LibraryItemType
from Spotfire.Dxp.Data.Import import InformationLinkDataSource

from System.Windows.Forms import DialogResult

def openFromLibrary():
 libraryBrowser=LibraryBrowserDialog();
 libraryBrowser.Title="Open from Library";
 libraryBrowser.SetItemTypeFilter(LibraryItemType.InformationLink)

 if(libraryBrowser.ShowDialog()==DialogResult.OK):
  libraryItem=libraryBrowser.SelectedItem
  datasource=InformationLinkDataSource(libraryItem)
  Document.Data.Tables.Add(libraryItem.Title, datasource)


openFromLibrary()


Source: https://tibbr.tibcommunity.com/tibbr/#!/messages/75074

No comments: