Version 13 of optcl

Updated 2002-05-09 14:27:24

"Open Tcl is a Tcl extension to provide connectivity to the resident host's component model." http://www.sys.uea.ac.uk/~fuzz/optcl/default.html Farzad Pezeshkpour wrote and maintains it.


[Recommend Leslie Brooks' nice example [L1 ] and commentary ...]


An example:

    #
    # Open Word and read the template for the report.  (The template
    # contains Header and Footer macros that we will use.)
    #
    set word [optcl::new word.application]
    set filename [file join [pwd] "Chapter 5 template.doc"]
    set doc [$word -with documents open $filename]
    #
    # Set the header by running a Word Macro recorded in the
    # template file and passing it the parameters it needs 
    # (System Release, RTP version, and Test Step).
    #
    $word run header "$test_step" "$SR" "$RTP_Version"
    $word run footer "$Operator"    

The template for the header macro is

    Sub Header(TestStep As String, SR As String, RTP As String)
    '
    ' Header Macro
    ' Macro recorded 7/24/01 by Leslie Brooks
    ' Set the Test Step number, the System Release number, and the
    ' RTP version number in the report header.

    .


    .

    . 
    End Sub  

MPJ Here is some code to display a Microsoft's Internet Explorer ActiveX component in a Tk frame with the IE's scroll bar.

MPJ (5/02) Changed to use ProgId from the registry instead of the CLSID. The CLSID is a string representation of a COM Globally Unique IDentifer (GUID for short). This should make it a little easier to understand instead of the ProgId numbers.

 package require optcl
 wm title . {MSIE in Tk with scroll}
 set htm [optcl::new -window .htm Shell.Explorer.2] ;# for MSIE ActiveX Control
 # set htm [optcl::new -window .htm Mozilla.Browser.1] ;# for Mozilla ActiveX Control
 .htm config -width 800 -height 600
 pack .htm -fill both -expand 1
 $htm navigate www.scriptics.com
 # to view the type information for the control
 pack [button .b  -text "View TypeLibrary for IE container" -command {
                        tlview::viewtype [ optcl::class $htm ]
        } ] -side bottom

Here is the code to do it without the IE's scroll bar. Notice the difference???

 package require optcl
 wm title . {MSIE in Tk without scroll}
 set htm [optcl::new -window .htm {http://www.scriptics.com}]
 .htm config -width 800 -height 600
 pack .htm -fill both -expand 1
 # to view the type information for the control
 pack [button .b  -text "View TypeLibrary for IE container" -command {
                        tlview::viewtype [ optcl::class $htm ]
        } ] -side bottom

MPJ A little bigger example is how to play a VCD with Microsoft's MediaPlayer using optcl.

 package require optcl
 wm title . {VCD Document in Tk}
 set vcd [optcl::new -start -window .vcd MediaPlayer.MediaPlayer.1]
 .vcd config -width 640 -height 480
 pack .vcd -fill both -expand 1
 # put location of VCD file here ... need to make much smarter
 $vcd : filename "E:/mpegav/music01.dat"
 $vcd Play
 # view the loaded activex component
 ## tlview::loadedlibs .tmp2
 #how long the file is
 ## clock format [expr int([clock scan 0]+ [$vcd : duration])] -format %T
 # current position in time
 ## clock format [expr int([clock scan 0]+ [$vcd : CurrentPosition])] -format %T

MPJ Display of the Wiki in a Tk frame is yet another example Michael provides:

 package require optcl
 optcl::new -window .htm {http://wiki.tcl.tk}
 .htm config -width 800 -height 600
 pack .htm

MPJ Display the Calendar control being integrated within a Tk widget. Also see the examples files that come with OpTcl to bind events.

 package require optcl
 optcl::new -window .cal MSCAL.Calendar.7
 .cal config -width 300 -height 300
 pack .cal