📜 ⬆️ ⬇️

C / C ++ application development using Tcl / Tk

image The powerful functionality of the Tcl scripting language in combination with Tk / TTK widgets allows you to create serious applications in this environment. This also contributes to its cross-platform and excellent integration with the programming languages ​​C / C ++.
And as an example, we immediately give an example of a program in the C language. This program builds a graphical interface that has a field for entering a string, a button that, when clicked, calculates the length of the string, and fields for displaying the result:

image

The text of the program in C is as follows:

#include <stdlib.h> #include <stdio.h> #include <tcl.h> #include <tk.h> #include <string.h> Tcl_Interp * tcl_interp ; int lenStr(){ int code; int len; char slen[256]; char *res; /*  widget-     tcl   a*/ code = Tcl_Eval(tcl_interp, "set a [.ent1 get];"); /*  tcl- a  res   :*/ res = (char *)Tcl_GetVar(tcl_interp, "a", TCL_APPEND_VALUE); /*   C   :*/ len = strlen(res); /*   */ slen[0] = '\0'; sprintf(slen, "%i", len); /*   slen  Tcl- lens:*/ Tcl_SetVar(tcl_interp, "lens", slen, TCL_GLOBAL_ONLY); /* ,       */ code = Tcl_Eval(tcl_interp, ".ent4 delete 0 end;"); /*      */ code = Tcl_Eval(tcl_interp, ".ent4 insert 0 $lens;"); /* */ return TCL_OK; } int main (int argc, char *argv[]) { /*Tcl/Tk -    */ char strtcl[] ="\ wm title . \"   C  Tcl/Tk\";\ label .lab0 -text {strlen(};\ pack .lab0 -anchor {center} -side {left};\ entry .ent1 ;\ pack .ent1 -anchor {center} -side {left};\ label .lab2 -text {)};\ pack .lab2 -anchor {center} -side {left};\ button .but3 -text {=} -command {lenstr};\ pack .but3 -anchor {center} -side {left};\ entry .ent4 -width {5};\ pack .ent4 -pady {4} -side {top};\ pack .lab0 .ent1 .lab2 .but3 .ent4 -in {.};\ .ent4 delete 0 end;\ "; int code; Tcl_FindExecutable(argv[0]); /* tcl-*/ tcl_interp = Tcl_CreateInterp(); /*  tcl-*/ Tcl_Init(tcl_interp); /* Tk-    tcl-*/ Tk_Init(tcl_interp); /*  Tcl/Tk   */ code = Tcl_Eval(tcl_interp, strtcl); /* Tcl/Tk      : code = Tcl_EvalFile(tcl_interp, filetcl); */ /*      lenstr   */ code = Tcl_Eval(tcl_interp, ".but3 configure -command lenstr;"); /*   "lenstr"   lenStr   C-*/ Tcl_CreateCommand(tcl_interp, "lenstr", (Tcl_CmdProc *)lenStr, NULL, NULL); /*     */ Tk_MainLoop(); return 0; } 

I think the code does not need additional comments. You can get the executable code as follows:
')
 $gcc -o test_c test_c.c -ltcl8.6 -ltk8.6 $ 

If you are going to write an application with a complex GUI, then it is advisable to use designers to design it. It can be Vtcl , and TKproE-2.20 and others. I would recommend using TKproE. From the saved project, it is enough to take the body of the TKopenWindow procedure and load it using the Tcl_Eval or Tcl_EvalFile functions. In the first case, the code is inserted into the body of the program, for example, assigned to the variable strtcl, as in our example. In the second case it is saved in the file and loaded from it.

The natural question is how to handle events, for example, pressing a button. In this case, a match is made between the function name in the tcl code (for example, in the –command option of the button widget) that was loaded and the function in the program code. In our example, this is the following line:

 /*   "lenstr"   lenStr   C-*/ Tcl_CreateCommand(tcl_interp, "lenstr", (Tcl_CmdProc *)lenStr, NULL, NULL); 

For data exchange between the tcl-interpreter and the main C program, the functions Tcl_GetVar and Tcl_SetVar (see example), Tcl_LinkVar, etc. can be used.

To develop GUI applications using Tk widgets in C ++, a beautiful library called CPPTK has been developed . Its last update was released in May of this year. But we will keep in mind the penultimate version, namely CPPTK-1.0.2.

Using this library for development, I emphasize, for the development of graphical applications, allows you to forget about the interfaces of the libtcl and libtk libraries (see above). Agree, this is quite a lot, considering that the CPPTK library interface is as close as possible to the Tcl / Tk interface, and the most important thing is perfectly documented:

image

And so, the CPPTK library allows you to develop GUI applications on classic tk widgets. But it is so well designed that to go, and even better, add support for thematic widgets ttk does not do any work, which we did, adding first of all support for the widgets ttk :: notebook and ttk :: combobox.

The patch for the CPPTK-1.0.2 library is here.
 diff -ruN cpptk-1.0.2/base/cpptkbase.cc cpptk-1.0.2_with_ttk/base/cpptkbase.cc --- cpptk-1.0.2/base/cpptkbase.cc 2017-12-12 09:58:00.269337115 +0300 +++ cpptk-1.0.2_with_ttk/base/cpptkbase.cc 2017-12-08 14:41:51.589205618 +0300 @@ -209,11 +209,16 @@ // refresh Tcl variables linkCpptoTcl(); } - catch (exception const &e) + +/*LISSI*/ +// catch (exception const &e) + catch (std::exception const &e) + { Tcl_SetResult(interp, const_cast<char*>(e.what()), TCL_VOLATILE); return TCL_ERROR; } + return TCL_OK; } diff -ruN cpptk-1.0.2/cpptk.cc cpptk-1.0.2_with_ttk/cpptk.cc --- cpptk-1.0.2/cpptk.cc 2017-12-12 09:58:00.268337115 +0300 +++ cpptk-1.0.2_with_ttk/cpptk.cc 2017-12-11 20:10:09.699863718 +0300 @@ -226,6 +226,28 @@ return Expr(str); } +/*LISSI*/ +Expr Tk::addtab(string const &w1, + string const &w2) +{ + string str(""); + str += w1; + str += " add "; + str += w2; + str += " "; + return Expr(str); +} +Expr Tk::tab(string const &w1, + string const &w2) +{ + string str(""); + str += w1; + str += " tab "; + str += w2; + str += " "; + return Expr(str); +} + Expr Tk::panedwindow(string const &name) { @@ -254,6 +276,20 @@ str += name; return Expr(str); } + +/*LISSI*/ +Expr Tk::combobox(string const &name) +{ + string str("ttk::combobox "); + str += name; + return Expr(str); +} +Expr Tk::notebook(string const &name) +{ + string str("ttk::notebook "); + str += name; + return Expr(str); +} Expr Tk::textw(string const &name) { diff -ruN cpptk-1.0.2/cpptkconstants.x cpptk-1.0.2_with_ttk/cpptkconstants.x --- cpptk-1.0.2/cpptkconstants.x 2017-12-12 09:58:00.269337115 +0300 +++ cpptk-1.0.2_with_ttk/cpptkconstants.x 2017-12-08 17:51:55.772314308 +0300 @@ -81,6 +81,9 @@ CPPTK_CONSTANT(hourglass) CPPTK_CONSTANT(horizontal) CPPTK_CONSTANT(iconbitmap) +//LISSI +CPPTK_CONSTANT(iconphoto) + CPPTK_CONSTANT(iconic) CPPTK_CONSTANT(iconify) CPPTK_CONSTANT(iconmask) diff -ruN cpptk-1.0.2/cpptk.h cpptk-1.0.2_with_ttk/cpptk.h --- cpptk-1.0.2/cpptk.h 2017-12-12 09:58:00.268337115 +0300 +++ cpptk-1.0.2_with_ttk/cpptk.h 2017-12-08 14:43:29.004206546 +0300 @@ -74,6 +74,12 @@ std::string const &w8 = std::string(), std::string const &w9 = std::string(), std::string const &w10 = std::string()); +/*LISSI*/ +details::Expr addtab(std::string const &w1, + std::string const &w2 = std::string()); +details::Expr tab(std::string const &w1, + std::string const &w2 = std::string()); + template <typename T\> details::Expr pack(std::string const &option, @@ -85,6 +91,27 @@ str += details::toString(t); return details::Expr(str); } +/*LISSI*/ +template <typename T\> +details::Expr addtab(std::string const &option, + std::string const &w, T const &t) +{ + std::string str("addtab "); + str += option; str += " "; + str += w; str += " "; + str += details::toString(t); + return details::Expr(str); +} +template <typename T\> +details::Expr tab(std::string const &option, + std::string const &w, T const &t) +{ + std::string str("tab "); + str += option; str += " "; + str += w; str += " "; + str += details::toString(t); + return details::Expr(str); +} details::Expr panedwindow(std::string const &name); @@ -93,6 +120,9 @@ details::Expr scrollbar(std::string const &name); details::Expr spinbox(std::string const &name); +/*LISSI*/ +details::Expr combobox(std::string const &name); +details::Expr notebook(std::string const &name); details::Expr textw(std::string const &name); diff -ruN cpptk-1.0.2/cpptkoptions.x cpptk-1.0.2_with_ttk/cpptkoptions.x --- cpptk-1.0.2/cpptkoptions.x 2017-12-12 09:58:00.269337115 +0300 +++ cpptk-1.0.2_with_ttk/cpptkoptions.x 2017-12-08 18:05:51.108322269 +0300 @@ -49,6 +49,9 @@ CPPTK_OPTION(columnspan, false) CPPTK_OPTION(compositingrule, false) CPPTK_OPTION(compound, false) +//LISSI +CPPTK_OPTION(padding, false) + CPPTK_OPTION(confine, false) CPPTK_OPTION(container, false) CPPTK_OPTION(cursor, false) @@ -76,6 +79,9 @@ CPPTK_OPTION(fg, false) CPPTK_OPTION(fgstipple, false) CPPTK_OPTION(file, true) +//LISSI +CPPTK_OPTION(data, true) + CPPTK_OPTION(fill, false) CPPTK_OPTION(font, false) // TODO: fontmap option of the canvas postscript command 


This patch adds not only support for new widgets, but also support for –data mode when working with images (images (create, photo, '' myimage '' –date ('' PEM / base64-data '));) Unfortunately, when laying the spoiler, the + template line had to be replaced with + template <typename T \> (otherwise the spoiler displayed the text incorrectly). It is necessary to take this into account and carry out a reverse replacement.

You can apply the patch as follows. Create a directory. Place the CPPTK project directory in it. In it, save, say, in the patchForCPPTK-1.0.2.patch file the patch from the spoiler (taking into account the note) and, being in this directory, apply the patch:

 $patch –p0 < patchForCPPTK-1.0.2.patch $ 

That's it, now you have a CPPTK library with support for new widgets. And yet writing the GUI manually is a thankless job. For designing the GUI itself is still convenient to use the designer TKproE . A simple convertFromTclToCPPTK.tcl tcl script has been developed to obtain a C ++ program with the CPPTK library from a ready-made tcl script.

convertFromTclToCPPTK.tcl tcl script
 #!/usr/bin/tclsh # 1 -- source file from tkproe #LISSI-Soft ## Procedure: parseConfig proc ::parseConfig {w data cfile} { set ldata $data set len [llength $ldata] #puts $len set two "" set tree "" set first [lindex $ldata 0] if { $len \> 1 } { set two [lindex $ldata 1] } if { $len \> 2 } { set tree [lindex $ldata 2] } if {$first == "wm"} { set wmstr "wm($two" for {set i 2} {$i < $len} {incr i} { set par [lindex $ldata $i] set a ", \"$par\"" set wmstr "$wmstr$a" } set a ");" set wmstr "$wmstr$a" puts "\t$wmstr" return } # widget tk set tkWid "frame canvas button entry label message listbox text menubutton menu scrollbar scale checkbutton radiobutton toplevel labelframe spinbox panedwindow" set ttkWid "ttk::notebook ttk::combobox" set beg [string first $first $tkWid] if { $beg != -1 } { set initI 2 set wmstr "\t$first (\"$two\"" # set wmstr "$first(\"$two\"" if { [string range $tree 0 0 ] != "-" } { set wmstr "$wmstr, \"$tree\"" incr initI } set wmstr "$wmstr) " set lenstr [string length $wmstr] for {set i $initI} {$i < $len} {incr i} { set par [lindex $ldata $i] incr i set parVal [lindex $ldata $i] if { $par == "-variable" || $par == "-textvariable"} { set wmstr "$wmstr $par ($parVal)" } else { set wmstr "$wmstr $par (\"$parVal\")" } incr lenstr [string length $par] incr lenstr [string length $parVal] if {$lenstr \> 70} { set wmstr "$wmstr\n\t\t" set lenstr 10 } } set wmstr "$wmstr;" puts $wmstr return } #addTab to notebook set beg [string first " add ." $data] if { $beg != -1 } { set initI 2 set wmstr "\taddtab (\"$first\"" # set wmstr "$first(\"$two\"" if { [string range $tree 0 0 ] != "-" } { set wmstr "$wmstr, \"$tree\"" incr initI } set wmstr "$wmstr) " for {set i $initI} {$i < $len} {incr i} { set par [lindex $ldata $i] incr i if { $par == "-image" } {continue} set parVal [lindex $ldata $i] if { $par == "-variable" || $par == "-textvariable"} { set wmstr "$wmstr $par ($parVal)" } else { set wmstr "$wmstr $par (\"$parVal\")" } } set wmstr "$wmstr;" puts $wmstr return } #ttk::notebook set beg [string first "ttk::notebook" $data] if { $beg != -1 } { set initI 2 set wmstr "\tnotebook (\"$two\"" # set wmstr "$first(\"$two\"" if { [string range $tree 0 0 ] != "-" } { set wmstr "$wmstr, \"$tree\"" incr initI } set wmstr "$wmstr) " for {set i $initI} {$i < $len} {incr i} { set par [lindex $ldata $i] incr i # if { $par == "-image" } {continue} if { $par == "-variable" } {continue} if { $par == "-textvariable" } {continue} if { $par == "-takefocus" } {continue} set parVal [lindex $ldata $i] set wmstr "$wmstr $par (\"$parVal\")" } set wmstr "$wmstr;" puts $wmstr return } #ttk::combobox set beg [string first "ttk::combobox" $data] if { $beg != -1 } { set initI 2 set wmstr "\tcombobox (\"$two\"" # set wmstr "$first(\"$two\"" if { [string range $tree 0 0 ] != "-" } { set wmstr "$wmstr, \"$tree\"" incr initI } set wmstr "$wmstr) " for {set i $initI} {$i < $len} {incr i} { set par [lindex $ldata $i] incr i # if { $par == "-variable" } {continue} # if { $par == "-textvariable" } {continue} if { $par == "-takefocus" } {continue} # if { $par == "-relwidth" } {continue} set parVal [lindex $ldata $i] if { $par == "-variable" || $par == "-textvariable"} { set wmstr "$wmstr $par ($parVal)" } else { set wmstr "$wmstr $par (\"$parVal\")" } } set wmstr "$wmstr;" puts $wmstr return } #tkPlace set tkPlace "tkPlace: pack place grid" set beg [string first $first $tkPlace] if { $beg != -1 } { set tire 0 set initI 2 set wmstr "\t$first (\"$two\"" set lenstr [string length $wmstr] for {set i $initI} {$i < $len} {incr i} { set par [lindex $ldata $i] if { [string range $par 0 0 ] != "-" } { set wmstr "$wmstr, \"$par\"" continue } else { if { $tire == 0} { incr tire set wmstr "$wmstr) " } } if {$tire == 1} { incr i } if { $par == "-variable" } {continue} if { $par == "-textvariable" } {continue} if { $par == "-relwidth" } {continue} if { $par == "-fill" && $first == "pack" } {continue} set parVal [lindex $ldata $i] if {$parVal == ".\}"} { set parVal "." } set wmstr "$wmstr $par (\"$parVal\")" incr lenstr [string length $par] incr lenstr [string length $parVal] if {$lenstr \> 70} { set wmstr "$wmstr\n\t\t" set lenstr 10 } } set wmstr "$wmstr;" puts $wmstr return } if {$two == "configure"} { set wmstr "\t\"$first\" << configure() " for {set i 2} {$i < $len} {incr i} { set par [lindex $ldata $i] incr i set parVal [lindex $ldata $i] set wmstr "$wmstr $par (\"$parVal\")" } set wmstr "$wmstr;" puts $wmstr return } return } set largv [llength $argv] if {$largv != 1} { puts "Usage: [info script] <file tcl from TKproE\>\n" puts "Copyrait LISSI-Soft Ltd\n" exit } set fconf [file exists "$argv"] if { $fconf == "0" } { puts "File=\"$argv\" don't exist\n" puts "Usage: [info script] <file tcl from Page\>\n" puts "Copyrait LISSI-Soft Ltd\n" exit } set file $argv proc findFile {} { set types { {"GUI " {*.tcl} } {" " *} } set file "" set homeDir $env(HOME) set file [tk_getOpenFile -filetypes $types -parent . -initialdir $homeDir] puts "You selected file \"$file\"" if {[string compare $file ""] == 0} { return "" } } # read the file one line at a time set fp [open $file r] fconfigure $fp -buffering line puts "//Get file tcl from=$file" #"proc TPopenWindow" #"proc TPcloseWindow" set parseStr 0 puts "//Code for CPP generate LISSI-Soft" puts "#include \"cpptk.h\"" puts "#include <iostream\>\n" puts "using namespace Tk;" puts "using namespace std;\n" puts "int main(int, char *argv\[\])\n\{\n try\n {\n\tinit(argv\[0\]);" while 1 { gets $fp data if [eof $fp] break if {$data == ""} continue set com [string range $data 0 0] if {$com == "\n" || $com == "#"} continue set data [string trim $data] set len [string first "proc TPopenWindow" $data 0] if {$len != -1 } { set parseStr 1 puts "/*$data\}*/" continue } set len [string first "proc TPcloseWindow" $data 0] if {$len != -1 } { set parseStr 0 puts "/*$data\}*/\n" continue } if { $parseStr == 0 } {continue} parseConfig . $data $file } puts "\trunEventLoop();\n }\n catch (exception const &e)\n {\n\tcerr << \"Error: \" << e.what() << '\\n';\n \}\n\}" close $fp exit 


To get a program in C ++, just run this script:

 $ convertFromTclToCPPTK.tcl <tcl-  TKproE> > <    C++ - > $ 

As an example, let us consider the development of an advanced electronic signature generation program with the SSF library (“Secure Store and Forward”) used in SAP AG products to provide cryptographic protection of electronic documents by using electronic signature and encryption mechanisms using Russian cryptoalgorithms (GOST 28147- 89, GOST R 34.11-94, GOST R 34.11-2012, GOST R 34.10-2001, GOST R 34.10-2012). The GUI project in the TKproE designer is as follows:

image

The script for this project is here.
 # Generated by TKproE 2.20 - Tue Dec 12 12:50:32 MSK 2017 #Add from LISSI-Soft encoding system utf-8 global myHOME set myHOME $env(HOME) # Load all images # Define named fonts # Global variable initialization proc TPinitVars {} { # Initialize global variables namespace eval :: {;#Creating namespace ::;} set {::selectedButton} {} array set {::vTcl} {} set ::TPexclusions(user_namespace) {} set ::TPprojType TCL_TK } # Toplevel window procedures proc TPopenWindow. {} { # CLONEPATH = . # Cloned Tue Dec 12 12:50:32 MSK 2017 . configure -background {#00F5FF} bindtags . {. Tkproe.tcl all} wm aspect . wm focusmodel . passive wm grid . wm geometry . 723x618+383+57 wm iconmask . wm iconposition . wm maxsize . 1585 870 wm minsize . 1 1 wm overrideredirect . 0 wm positionfrom . user wm resizable . 1 1 wm sizefrom . wm state . normal wm transient . labelframe .lfSSF -borderwidth {4} -foreground {#141312} -relief {ridge} -text {  SSF} -background {#FFDEAD} -height {100} -padx {4} -width {100} entry .lfSSF.entSSF -background {#FFFAFA} -foreground {#141312} -highlightbackground {#ffffff} -highlightcolor {#141312} -selectbackground {#418bd4} -selectforeground {#ffffff} -width {40} pack .lfSSF.entSSF -anchor center -expand 0 -fill none -ipadx 0 -ipady 0 -padx 0 -pady 0 -side left button .lfSSF.butSSF -activebackground {#e0dfde} -activeforeground {#141312} -background {#e0dfde} -foreground {#141312} -highlightbackground {#e0dfde} -highlightcolor {#141312} -text { } pack .lfSSF.butSSF -anchor center -expand 0 -fill none -ipadx 0 -ipady 0 -padx 9 -pady 0 -side right pack .lfSSF -anchor center -expand 0 -fill none -ipadx 0 -ipady 0 -padx 0 -pady 10 -side top pack .lfSSF.entSSF .lfSSF.butSSF -in .lfSSF ttk::notebook .nbSSF -width {700} -height {400} -padding {7} .nbSSF state {} frame .nbSSF.frameNB1 -borderwidth {4} -relief {sunken} -background {#FF7256} -height {30} -highlightbackground {#e0dfde} -highlightcolor {#141312} -width {30} label .nbSSF.frameNB1.labLogo -activebackground {#e0dfde} -activeforeground {#141312} -background {#e0dfde} -foreground {#141312} -height {329} -highlightbackground {#e0dfde} -highlightcolor {#141312} -relief {raised} -text {labLogo} -width {509} pack .nbSSF.frameNB1.labLogo -anchor center -expand 0 -fill none -ipadx 0 -ipady 0 -padx 0 -pady 28 -side top pack .nbSSF.frameNB1.labLogo -in .nbSSF.frameNB1 frame .nbSSF.frameNB2 -borderwidth {2} -relief {raised} -background {#FF4500} -height {30} -highlightbackground {#e0dfde} -highlightcolor {#141312} -pady {19} -width {30} labelframe .nbSSF.frameNB2.lfSignDoc -borderwidth {4} -foreground {#141312} -relief {ridge} -text { } -background {#e0dfde} -height {100} -width {100} entry .nbSSF.frameNB2.lfSignDoc.entSignDoc -background {#FFFAFA} -foreground {#141312} -highlightbackground {#ffffff} -highlightcolor {#141312} -selectbackground {#418bd4} -selectforeground {#ffffff} -width {40} pack .nbSSF.frameNB2.lfSignDoc.entSignDoc -anchor center -expand 0 -fill none -ipadx 0 -ipady 0 -padx 5 -pady 0 -side left button .nbSSF.frameNB2.lfSignDoc.butSignDoc -activebackground {#e0dfde} -activeforeground {#141312} -background {#e0dfde} -foreground {#141312} -highlightbackground {#e0dfde} -highlightcolor {#141312} -text {} pack .nbSSF.frameNB2.lfSignDoc.butSignDoc -anchor center -expand 0 -fill none -ipadx 0 -ipady 0 -padx 6 -pady 0 -side top pack .nbSSF.frameNB2.lfSignDoc -anchor center -expand 0 -fill none -ipadx 0 -ipady 0 -padx 0 -pady 6 -side top pack .nbSSF.frameNB2.lfSignDoc.entSignDoc .nbSSF.frameNB2.lfSignDoc.butSignDoc -in .nbSSF.frameNB2.lfSignDoc labelframe .nbSSF.frameNB2.lfForType -borderwidth {4} -foreground {#141312} -relief {ridge} -text {   } -background {#e0dfde} -height {100} -padx {1} -pady {5} -width {100} ttk::combobox .nbSSF.frameNB2.lfForType.comboFor -values {PKCS7 CADES_BES CADES_XLT1} -cursor {xterm} .nbSSF.frameNB2.lfForType.comboFor state {} pack .nbSSF.frameNB2.lfForType.comboFor -anchor center -expand 0 -fill none -ipadx 0 -ipady 0 -padx 4 -pady 0 -side left radiobutton .nbSSF.frameNB2.lfForType.radAtt -activebackground {#e0dfde} -activeforeground {#141312} -background {#e0dfde} -foreground {#141312} -highlightbackground {#e0dfde} -highlightcolor {#141312} -text {} -value {1} pack .nbSSF.frameNB2.lfForType.radAtt -anchor center -expand 0 -fill none -ipadx 0 -ipady 0 -padx 26 -pady 0 -side left radiobutton .nbSSF.frameNB2.lfForType.radDet -activebackground {#e0dfde} -activeforeground {#141312} -background {#e0dfde} -foreground {#141312} -highlightbackground {#e0dfde} -highlightcolor {#141312} -text {} -value {0} pack .nbSSF.frameNB2.lfForType.radDet -anchor center -expand 0 -fill none -ipadx 0 -ipady 0 -padx 13 -pady 0 -side top pack .nbSSF.frameNB2.lfForType -anchor center -expand 0 -fill none -ipadx 0 -ipady 0 -padx 0 -pady 16 -side top pack .nbSSF.frameNB2.lfForType.comboFor .nbSSF.frameNB2.lfForType.radAtt .nbSSF.frameNB2.lfForType.radDet -in .nbSSF.frameNB2.lfForType labelframe .nbSSF.frameNB2.lfCert -borderwidth {4} -foreground {#141312} -relief {ridge} -text {  } -background {#e0dfde} -height {100} -width {100} entry .nbSSF.frameNB2.lfCert.entCert -background {#FFFAFA} -foreground {#141312} -highlightbackground {#ffffff} -highlightcolor {#141312} -selectbackground {#418bd4} -selectforeground {#ffffff} -width {40} pack .nbSSF.frameNB2.lfCert.entCert -anchor center -expand 0 -fill none -ipadx 0 -ipady 0 -padx 9 -pady 0 -side left button .nbSSF.frameNB2.lfCert.butCert -activebackground {#e0dfde} -activeforeground {#141312} -background {#e0dfde} -foreground {#141312} -highlightbackground {#e0dfde} -highlightcolor {#141312} -text { } pack .nbSSF.frameNB2.lfCert.butCert -anchor center -expand 0 -fill none -ipadx 0 -ipady 0 -padx 0 -pady 0 -side left pack .nbSSF.frameNB2.lfCert -anchor center -expand 0 -fill none -ipadx 0 -ipady 0 -padx 0 -pady 8 -side top pack .nbSSF.frameNB2.lfCert.entCert .nbSSF.frameNB2.lfCert.butCert -in .nbSSF.frameNB2.lfCert labelframe .nbSSF.frameNB2.lfAtCert -borderwidth {4} -foreground {#141312} -relief {ridge} -text {   } -background {#00FF00} -height {100} -width {100} radiobutton .nbSSF.frameNB2.lfAtCert.radAtCert -activebackground {#e0dfde} -activeforeground {#141312} -background {#e0dfde} -foreground {#141312} -highlightbackground {#e0dfde} -highlightcolor {#141312} -text {  } -value {1} pack .nbSSF.frameNB2.lfAtCert.radAtCert -anchor center -expand 0 -fill none -ipadx 0 -ipady 0 -padx 0 -pady 0 -side left radiobutton .nbSSF.frameNB2.lfAtCert.radDetCert -activebackground {#e0dfde} -activeforeground {#141312} -background {#e0dfde} -foreground {#141312} -highlightbackground {#e0dfde} -highlightcolor {#141312} -text { } -value {0} pack .nbSSF.frameNB2.lfAtCert.radDetCert -anchor center -expand 0 -fill none -ipadx 0 -ipady 0 -padx 10 -pady 0 -side top pack .nbSSF.frameNB2.lfAtCert -anchor center -expand 0 -fill none -ipadx 0 -ipady 0 -padx 0 -pady 0 -side top pack .nbSSF.frameNB2.lfAtCert.radAtCert .nbSSF.frameNB2.lfAtCert.radDetCert -in .nbSSF.frameNB2.lfAtCert button .nbSSF.frameNB2.butSign -activebackground {#e0dfde} -activeforeground {#141312} -background {#20B2AA} -borderwidth {7} -foreground {#141312} -highlightbackground {#e0dfde} -highlightcolor {#141312} -relief {ridge} -text { } pack .nbSSF.frameNB2.butSign -anchor center -expand 0 -fill none -ipadx 0 -ipady 0 -padx 0 -pady 14 -side top pack .nbSSF.frameNB2.lfSignDoc .nbSSF.frameNB2.lfForType .nbSSF.frameNB2.lfCert .nbSSF.frameNB2.lfAtCert .nbSSF.frameNB2.butSign -in .nbSSF.frameNB2 frame .nbSSF.frameNB3 -borderwidth {2} -relief {raised} -background {#e0dfde} -height {30} -highlightbackground {#e0dfde} -highlightcolor {#141312} -width {30} pack .nbSSF -anchor center -expand 0 -fill none -ipadx 0 -ipady 0 -padx 0 -pady 0 -side top labelframe .lfP11 -borderwidth {4} -foreground {#141312} -relief {ridge} -text {   } -background {#FFE4B5} -height {100} -width {100} entry .lfP11.entP11 -background {#FFFAFA} -foreground {#141312} -highlightbackground {#ffffff} -highlightcolor {#141312} -selectbackground {#418bd4} -selectforeground {#ffffff} -width {40} pack .lfP11.entP11 -anchor center -expand 0 -fill none -ipadx 0 -ipady 0 -padx 8 -pady 0 -side left button .lfP11.butP11 -activebackground {#e0dfde} -activeforeground {#141312} -background {#e0dfde} -borderwidth {4} -foreground {#141312} -highlightbackground {#e0dfde} -highlightcolor {#141312} -relief {ridge} -text {  } pack .lfP11.butP11 -anchor center -expand 0 -fill none -ipadx 0 -ipady 0 -padx 9 -pady 1 -side top pack .lfP11 -anchor center -expand 0 -fill none -ipadx 0 -ipady 0 -padx 0 -pady 14 -side top pack .lfP11.entP11 .lfP11.butP11 -in .lfP11 .nbSSF add .nbSSF.frameNB1 -padding 0 -sticky nsew -state normal -text  -image {} -compound none -underline -1 .nbSSF add .nbSSF.frameNB2 -padding 0 -sticky nsew -state normal -text  -image {} -compound none -underline -1 .nbSSF add .nbSSF.frameNB3 -padding 0 -sticky nsew -state normal -text  -image {} -compound none -underline -1 pack .lfSSF .nbSSF .lfP11 -in .} proc TPcloseWindow. {} { wm state . withdrawn} # User created procedures namespace eval :: { #Creating namespace :: } # Display and start the application if {[info proc TPstartupSrc] != {}} { TPstartupSrc } TPinitVars TPopenWindow. if {[info proc TPendSrc] != {}} { TPendSrc } # End of TKproE generated code #PS        >    \> #     . </spoiler>    , , forBook.tcl,       TKproE      (. ). ,    C++   convertFromTclToCPPTK.tcl: <source lang="bash">$ convertFromTclToCPPTK.tcl forBook.tcl >forBook.cc $ 

The resulting forBook.cc code can be seen here.
 //Get file tcl from=forBook.tcl //Code for CPP generate LISSI-Soft #include "cpptk.h" /*           >  \>   */ #include <iostream\> using namespace Tk; using namespace std; int main(int, char *argv[]) { try { init(argv[0]); /*proc TPopenWindow. {} {}*/ "." << configure() -background ("#00F5FF"); wm(aspect, "."); wm(focusmodel, ".", "passive"); wm(grid, "."); wm(geometry, ".", "723x618+383+57"); wm(iconmask, "."); wm(iconposition, "."); wm(maxsize, ".", "1585", "870"); wm(minsize, ".", "1", "1"); wm(overrideredirect, ".", "0"); wm(positionfrom, ".", "user"); wm(resizable, ".", "1", "1"); wm(sizefrom, "."); wm(state, ".", "normal"); wm(transient, "."); labelframe (".lfSSF") -borderwidth ("4") -foreground ("#141312") -relief ("ridge") -text ("  SSF") -background ("#FFDEAD") -height ("100") -padx ("4") -width ("100"); entry (".lfSSF.entSSF") -background ("#FFFAFA") -foreground ("#141312") -highlightbackground ("#ffffff") -highlightcolor ("#141312") -selectbackground ("#418bd4") -selectforeground ("#ffffff") -width ("40"); pack (".lfSSF.entSSF") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("0") -pady ("0") -side ("left") ; button (".lfSSF.butSSF") -activebackground ("#e0dfde") -activeforeground ("#141312") -background ("#e0dfde") -foreground ("#141312") -highlightbackground ("#e0dfde") -highlightcolor ("#141312") -text (" "); pack (".lfSSF.butSSF") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("9") -pady ("0") -side ("right") ; pack (".lfSSF") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("0") -pady ("10") -side ("top") ; pack (".lfSSF.entSSF", ".lfSSF.butSSF") -in (".lfSSF"); notebook (".nbSSF") -width ("700") -height ("400") -padding ("7"); frame (".nbSSF.frameNB1") -borderwidth ("4") -relief ("sunken") -background ("#FF7256") -height ("30") -highlightbackground ("#e0dfde") -highlightcolor ("#141312") -width ("30") ; label (".nbSSF.frameNB1.labLogo") -activebackground ("#e0dfde") -activeforeground ("#141312") -background ("#e0dfde") -foreground ("#141312") -height ("329") -highlightbackground ("#e0dfde") -highlightcolor ("#141312") -relief ("raised") -text ("labLogo") -width ("509"); pack (".nbSSF.frameNB1.labLogo") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("0") -pady ("28") -side ("top"); pack (".nbSSF.frameNB1.labLogo") -in (".nbSSF.frameNB1"); frame (".nbSSF.frameNB2") -borderwidth ("2") -relief ("raised") -background ("#FF4500") -height ("30") -highlightbackground ("#e0dfde") -highlightcolor ("#141312") -pady ("19") -width ("30"); labelframe (".nbSSF.frameNB2.lfSignDoc") -borderwidth ("4") -foreground ("#141312") -relief ("ridge") -text (" ") -background ("#e0dfde") -height ("100") -width ("100"); entry (".nbSSF.frameNB2.lfSignDoc.entSignDoc") -background ("#FFFAFA") -foreground ("#141312") -highlightbackground ("#ffffff") -highlightcolor ("#141312") -selectbackground ("#418bd4") -selectforeground ("#ffffff") -width ("40"); pack (".nbSSF.frameNB2.lfSignDoc.entSignDoc") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("5") -pady ("0") -side ("left"); button (".nbSSF.frameNB2.lfSignDoc.butSignDoc") -activebackground ("#e0dfde") -activeforeground ("#141312") -background ("#e0dfde") -foreground ("#141312") -highlightbackground ("#e0dfde") -highlightcolor ("#141312") -text (""); pack (".nbSSF.frameNB2.lfSignDoc.butSignDoc") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("6") -pady ("0") -side ("top"); pack (".nbSSF.frameNB2.lfSignDoc") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("0") -pady ("6") -side ("top"); pack (".nbSSF.frameNB2.lfSignDoc.entSignDoc", ".nbSSF.frameNB2.lfSignDoc.butSignDoc") -in (".nbSSF.frameNB2.lfSignDoc") ; labelframe (".nbSSF.frameNB2.lfForType") -borderwidth ("4") -foreground ("#141312") -relief ("ridge") -text ("   ") -background ("#e0dfde") -height ("100") -padx ("1") -pady ("5") -width ("100"); combobox (".nbSSF.frameNB2.lfForType.comboFor") -values ("PKCS7 CADES_BES CADES_XLT1") -cursor ("xterm"); pack (".nbSSF.frameNB2.lfForType.comboFor") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("4") -pady ("0") -side ("left"); radiobutton (".nbSSF.frameNB2.lfForType.radAtt") -activebackground ("#e0dfde") -activeforeground ("#141312") -background ("#e0dfde") -foreground ("#141312") -highlightbackground ("#e0dfde") -highlightcolor ("#141312") -text ("") -value ("1"); pack (".nbSSF.frameNB2.lfForType.radAtt") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("26") -pady ("0") -side ("left"); radiobutton (".nbSSF.frameNB2.lfForType.radDet") -activebackground ("#e0dfde") -activeforeground ("#141312") -background ("#e0dfde") -foreground ("#141312") -highlightbackground ("#e0dfde") -highlightcolor ("#141312") -text ("") -value ("0"); pack (".nbSSF.frameNB2.lfForType.radDet") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("13") -pady ("0") -side ("top"); pack (".nbSSF.frameNB2.lfForType") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("0") -pady ("16") -side ("top"); pack (".nbSSF.frameNB2.lfForType.comboFor", ".nbSSF.frameNB2.lfForType.radAtt", ".nbSSF.frameNB2.lfForType.radDet") -in (".nbSSF.frameNB2.lfForType") ; labelframe (".nbSSF.frameNB2.lfCert") -borderwidth ("4") -foreground ("#141312") -relief ("ridge") -text ("  ") -background ("#e0dfde") -height ("100") -width ("100") ; entry (".nbSSF.frameNB2.lfCert.entCert") -background ("#FFFAFA") -foreground ("#141312") -highlightbackground ("#ffffff") -highlightcolor ("#141312") -selectbackground ("#418bd4") -selectforeground ("#ffffff") -width ("40"); pack (".nbSSF.frameNB2.lfCert.entCert") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("9") -pady ("0") -side ("left"); button (".nbSSF.frameNB2.lfCert.butCert") -activebackground ("#e0dfde") -activeforeground ("#141312") -background ("#e0dfde") -foreground ("#141312") -highlightbackground ("#e0dfde") -highlightcolor ("#141312") -text (" "); pack (".nbSSF.frameNB2.lfCert.butCert") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("0") -pady ("0") -side ("left"); pack (".nbSSF.frameNB2.lfCert") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("0") -pady ("8") -side ("top"); pack (".nbSSF.frameNB2.lfCert.entCert", ".nbSSF.frameNB2.lfCert.butCert") -in (".nbSSF.frameNB2.lfCert"); labelframe (".nbSSF.frameNB2.lfAtCert") -borderwidth ("4") -foreground ("#141312") -relief ("ridge") -text ("   ") -background ("#00FF00") -height ("100") -width ("100"); radiobutton (".nbSSF.frameNB2.lfAtCert.radAtCert") -activebackground ("#e0dfde") -activeforeground ("#141312") -background ("#e0dfde") -foreground ("#141312") -highlightbackground ("#e0dfde") -highlightcolor ("#141312") -text ("  ") -value ("1"); pack (".nbSSF.frameNB2.lfAtCert.radAtCert") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("0") -pady ("0") -side ("left"); radiobutton (".nbSSF.frameNB2.lfAtCert.radDetCert") -activebackground ("#e0dfde") -activeforeground ("#141312") -background ("#e0dfde") -foreground ("#141312") -highlightbackground ("#e0dfde") -highlightcolor ("#141312") -text (" ") -value ("0"); pack (".nbSSF.frameNB2.lfAtCert.radDetCert") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("10") -pady ("0") -side ("top"); pack (".nbSSF.frameNB2.lfAtCert") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("0") -pady ("0") -side ("top"); pack (".nbSSF.frameNB2.lfAtCert.radAtCert", ".nbSSF.frameNB2.lfAtCert.radDetCert") -in (".nbSSF.frameNB2.lfAtCert"); button (".nbSSF.frameNB2.butSign") -activebackground ("#e0dfde") -activeforeground ("#141312") -background ("#20B2AA") -borderwidth ("7") -foreground ("#141312") -highlightbackground ("#e0dfde") -highlightcolor ("#141312") -relief ("ridge") -text (" "); pack (".nbSSF.frameNB2.butSign") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("0") -pady ("14") -side ("top"); pack (".nbSSF.frameNB2.lfSignDoc", ".nbSSF.frameNB2.lfForType", ".nbSSF.frameNB2.lfCert", ".nbSSF.frameNB2.lfAtCert", ".nbSSF.frameNB2.butSign") -in (".nbSSF.frameNB2"); frame (".nbSSF.frameNB3") -borderwidth ("2") -relief ("raised") -background ("#e0dfde") -height ("30") -highlightbackground ("#e0dfde") -highlightcolor ("#141312") -width ("30") ; pack (".nbSSF") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("0") -pady ("0") -side ("top"); labelframe (".lfP11") -borderwidth ("4") -foreground ("#141312") -relief ("ridge") -text ("   ") -background ("#FFE4B5") -height ("100") -width ("100"); entry (".lfP11.entP11") -background ("#FFFAFA") -foreground ("#141312") -highlightbackground ("#ffffff") -highlightcolor ("#141312") -selectbackground ("#418bd4") -selectforeground ("#ffffff") -width ("40"); pack (".lfP11.entP11") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("8") -pady ("0") -side ("left") ; button (".lfP11.butP11") -activebackground ("#e0dfde") -activeforeground ("#141312") -background ("#e0dfde") -borderwidth ("4") -foreground ("#141312") -highlightbackground ("#e0dfde") -highlightcolor ("#141312") -relief ("ridge") -text ("  "); pack (".lfP11.butP11") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("9") -pady ("1") -side ("top") ; pack (".lfP11") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("0") -pady ("14") -side ("top") ; pack (".lfP11.entP11", ".lfP11.butP11") -in (".lfP11"); addtab (".nbSSF", ".nbSSF.frameNB1") -padding ("0") -sticky ("nsew") -state ("normal") -text ("") -compound ("none") -underline ("-1"); addtab (".nbSSF", ".nbSSF.frameNB2") -padding ("0") -sticky ("nsew") -state ("normal") -text ("") -compound ("none") -underline ("-1"); addtab (".nbSSF", ".nbSSF.frameNB3") -padding ("0") -sticky ("nsew") -state ("normal") -text ("") -compound ("none") -underline ("-1"); pack (".lfSSF", ".nbSSF", ".lfP11") -in ("."); /*proc TPcloseWindow. {} {}*/ runEventLoop(); } catch (exception const &e) { cerr << "Error: " << e.what() << '\n'; } } 


To get the bar code, put the forBook.cc file in the directory with the patched CPPTK library (see above) and execute the following command:

 $ g++ -DUSE_INTERP_RESULT cpptk.cc base/cpptkbase.cc -o forBook forBook.cc -I./cpptk -Ibase -ltcl8.6 -ltk8.6 –pthread $ 

If we now launch the resulting forBook binary module, then we will see a familiar image on the monitor screen (see above). Unfortunately, pressing the buttons will not lead to any result, and the icon does not suit us. And we append the resulting program. We include the icon code in it:

 images(create, photo, "stamp_32x32") -data ( "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr … "); 

Bind it to the main window:

  wm (iconphoto, ".", "stamp_32x32"); 

But the most important thing that we do is to attach certain functions to the buttons, which will have to be performed when they are pressed:

  ".lfSSF.butSSF" << configure () -command (compute); ".nbSSF.frameNB2.lfSignDoc.butSignDoc" << configure () -command (findDoc); ".nbSSF.frameNB2.lfCert.butCert" << configure () -command (findCert); ".lfP11.butP11" << configure () -command (findPrivKey); ".nbSSF.frameNB2.lfForType.radAtt" << configure () -command (updateRad); ".nbSSF.frameNB2.lfForType.radDet" << configure () -command (updateRad); ".nbSSF.frameNB2.lfAtCert.radAtCert" << configure () -command (updateRad); ".nbSSF.frameNB2.lfAtCert.radDetCert" << configure () -command (updateRad); ".nbSSF.frameNB2.butSign" << configure () -command (createSign); 

Naturally, we write the code of the functions themselves.
In its final form, the code looks like this.
 //Get file tcl from=GUIforSSFfromPAGE_PACK.tcl //Code for CPP generate LISSI-Soft #include "cpptk.h" /*           >  \>   */ #include <iostream\> using namespace Tk; using namespace std; string str; string selSignType = "1"; string selCert = "1"; int len; void compute() { string fileName(tk_getOpenFile() -filetypes ("{{ SSF} {.so}} {{ SSF MS} {.dll}} {{ } {*}}")); ".lfSSF.entSSF" << deleteentry (0, end); ".lfSSF.entSSF" << insert(end, fileName.c_str()); // ".nbSSF.frameNB2" << configure () -state (normal); // ".nbSSF.frameNB3" << configure () -state (normal); tab (".nbSSF", ".nbSSF.frameNB2") -state ("normal"); tab (".nbSSF", ".nbSSF.frameNB3") -state ("normal"); ".nbSSF" << select (".nbSSF.frameNB2"); cout << "Hello Button C++/Tk!" << endl; /*           >  \>   */ len = static_cast<int\>(str.size()); } void findDoc() { string fileName(tk_getOpenFile() -filetypes ("{{  } {.doc}} {{ } {.txt}} {{ } {*}}")); ".nbSSF.frameNB2.lfSignDoc.entSignDoc" << deleteentry (0, end); ".nbSSF.frameNB2.lfSignDoc.entSignDoc" << insert(end, fileName.c_str()); } void findCert() { string fileName(tk_getOpenFile() -filetypes ("{{   DER} {.der}} {{   DER} {.cer}} \ {{   PEM} {.pem}} {{   PEM} {.crt}} {{ } {*}}")); ".nbSSF.frameNB2.lfCert.entCert" << deleteentry (0, end); ".nbSSF.frameNB2.lfCert.entCert" << insert(end, fileName.c_str()); ".lfP11.butP11" << configure () -state (normal); } void findPrivKey() { string fileName(tk_getOpenFile() -filetypes ("{{  PKCS#12} {.p12}} {{  PKCS#12} {.pfx}} \ {{ PKCS#11} {.so}} {{ PKCS#11 MS} {.dll}} {{ } {*}}")); ".lfP11.entP11" << deleteentry (0, end); ".lfP11.entP11" << insert(end, fileName.c_str()); ".nbSSF.frameNB2.butSign" << configure () -state (normal); } void updateRad() { ".nbSSF.frameNB2.lfForType.radAtt" << configure () -state (normal); ".nbSSF.frameNB2.lfForType.radDet" << configure () -state (normal); ".nbSSF.frameNB2.lfAtCert.radAtCert" << configure () -state (normal); ".nbSSF.frameNB2.lfAtCert.radDetCert" << configure () -state (normal); // update(); } void createSign() { char mesSign [1000]; cout << " " << endl; cout << selSignType.c_str() << endl; cout << selCert.c_str() << endl; // string response(tk_dialog(".", " ?", "   \n\n", warning, "OK", "OK", "Cancel")); string content(".nbSSF.frameNB2.lfSignDoc.entSignDoc" << get()); strcpy(mesSign, "   \n"); if (strlen (content.c_str()) == 0) return; strcat(mesSign, content.c_str()); strcat(mesSign, "\n  = "); string content1(".nbSSF.frameNB2.lfForType.comboFor" << get()); strcat(mesSign, content1.c_str()); if (strcmp(selSignType.c_str(), "1")) { strcat(mesSign, "\n    \n"); } else { strcat(mesSign, "\n   \n"); } strcat(mesSign, "   \n"); string content2(".nbSSF.frameNB2.lfCert.entCert" << get()); if (strlen (content2.c_str()) == 0) return; strcat(mesSign, content2.c_str()); if (strcmp(selCert.c_str(), "1")) { strcat(mesSign, "\n    \n"); } else { strcat(mesSign, "\n   \n"); } strcat(mesSign, "      \n\n"); string content3(".lfP11.entP11" << get()); if (strlen (content3.c_str()) == 0) return; strcat(mesSign, content3.c_str()); string response(tk_messageBox() -title(" ") -icon(question) -messagetext (mesSign) -messagetype (okcancel)); cout << response.c_str() << endl; } int main(int, char *argv[]) { try { images(create, photo, "stamp_32x32") -data ( "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\ RK5CYII="); init(argv[0]); /*proc TPopenWindow. {} {}*/ "." << configure() -background ("#00F5FF"); fonts( configure, "TkDefaultFont") -size(12); wm(title, ".", "   (PKCS7, CADES_BES, CADES_XLT1)"); wm(aspect, "."); wm(focusmodel, ".", "passive"); wm(grid, "."); wm(geometry, ".", "723x618+383+57"); wm(iconmask, "."); wm(iconposition, "."); wm(maxsize, ".", "1585", "870"); wm(minsize, ".", "1", "1"); wm(overrideredirect, ".", "0"); wm(positionfrom, ".", "user"); wm(resizable, ".", "1", "1"); wm(sizefrom, "."); wm(state, ".", "normal"); wm(transient, "."); labelframe (".lfSSF") -borderwidth ("4") -foreground ("#141312") -relief ("ridge") -text ("  SSF") -background ("#FFDEAD") -height ("100") -padx ("4") -width ("100"); entry (".lfSSF.entSSF") -background ("#FFFAFA") -foreground ("#141312") -highlightbackground ("#ffffff") -highlightcolor ("#141312") -selectbackground ("#418bd4") -selectforeground ("#ffffff") -width ("40"); pack (".lfSSF.entSSF") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("0") -pady ("0") -side ("left") ; button (".lfSSF.butSSF") -activebackground ("#e0dfde") -activeforeground ("#141312") -background ("#e0dfde") -foreground ("#141312") -highlightbackground ("#e0dfde") -highlightcolor ("#141312") -text (" "); pack (".lfSSF.butSSF") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("9") -pady ("0") -side ("right") ; pack (".lfSSF") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("0") -pady ("10") -side ("top") ; pack (".lfSSF.entSSF", ".lfSSF.butSSF") -in (".lfSSF"); notebook (".nbSSF") -width ("700") -height ("400") -padding ("7"); frame (".nbSSF.frameNB1") -borderwidth ("4") -relief ("sunken") -background ("#FF7256") -height ("30") -highlightbackground ("#e0dfde") -highlightcolor ("#141312") -width ("30") ; label (".nbSSF.frameNB1.labLogo") -activebackground ("#e0dfde") -activeforeground ("#141312") -background ("#e0dfde") -foreground ("#141312") -height ("329") -highlightbackground ("#e0dfde") -highlightcolor ("#141312") -relief ("raised") -text ("    ") -width ("509"); pack (".nbSSF.frameNB1.labLogo") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("0") -pady ("28") -side ("top"); pack (".nbSSF.frameNB1.labLogo") -in (".nbSSF.frameNB1"); frame (".nbSSF.frameNB2") -borderwidth ("2") -relief ("raised") -background ("#FF4500") -height ("30") -highlightbackground ("#e0dfde") -highlightcolor ("#141312") -pady ("19") -width ("30"); labelframe (".nbSSF.frameNB2.lfSignDoc") -borderwidth ("4") -foreground ("#141312") -relief ("ridge") -text (" ") -background ("#e0dfde") -height ("100") -width ("100"); entry (".nbSSF.frameNB2.lfSignDoc.entSignDoc") -background ("#FFFAFA") -foreground ("#141312") -highlightbackground ("#ffffff") -highlightcolor ("#141312") -selectbackground ("#418bd4") -selectforeground ("#ffffff") -width ("40"); pack (".nbSSF.frameNB2.lfSignDoc.entSignDoc") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("5") -pady ("0") -side ("left"); button (".nbSSF.frameNB2.lfSignDoc.butSignDoc") -activebackground ("#e0dfde") -activeforeground ("#141312") -background ("#e0dfde") -foreground ("#141312") -highlightbackground ("#e0dfde") -highlightcolor ("#141312") -text (""); pack (".nbSSF.frameNB2.lfSignDoc.butSignDoc") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("6") -pady ("0") -side ("top"); pack (".nbSSF.frameNB2.lfSignDoc") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("0") -pady ("6") -side ("top"); pack (".nbSSF.frameNB2.lfSignDoc.entSignDoc", ".nbSSF.frameNB2.lfSignDoc.butSignDoc") -in (".nbSSF.frameNB2.lfSignDoc") ; labelframe (".nbSSF.frameNB2.lfForType") -borderwidth ("4") -foreground ("#141312") -relief ("ridge") -text ("   ") -background ("#e0dfde") -height ("100") -padx ("1") -pady ("5") -width ("100"); combobox (".nbSSF.frameNB2.lfForType.comboFor") -values ("PKCS7 CADES_BES CADES_XLT1") -cursor ("xterm"); pack (".nbSSF.frameNB2.lfForType.comboFor") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("4") -pady ("0") -side ("left"); radiobutton (".nbSSF.frameNB2.lfForType.radAtt") -activebackground ("#e0dfde") -activeforeground ("#141312") -background ("#e0dfde") -foreground ("#141312") -highlightbackground ("#e0dfde") -highlightcolor ("#141312") -text ("") -value ("1") -variable (selSignType) ; pack (".nbSSF.frameNB2.lfForType.radAtt") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("26") -pady ("0") -side ("left"); radiobutton (".nbSSF.frameNB2.lfForType.radDet") -activebackground ("#e0dfde") -activeforeground ("#141312") -background ("#e0dfde") -foreground ("#141312") -highlightbackground ("#e0dfde") -highlightcolor ("#141312") -text ("") -value ("0") -variable (selSignType) ; pack (".nbSSF.frameNB2.lfForType.radDet") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("13") -pady ("0") -side ("top"); pack (".nbSSF.frameNB2.lfForType") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("0") -pady ("16") -side ("top"); pack (".nbSSF.frameNB2.lfForType.comboFor", ".nbSSF.frameNB2.lfForType.radAtt", ".nbSSF.frameNB2.lfForType.radDet") -in (".nbSSF.frameNB2.lfForType") ; labelframe (".nbSSF.frameNB2.lfCert") -borderwidth ("4") -foreground ("#141312") -relief ("ridge") -text ("  ") -background ("#e0dfde") -height ("100") -width ("100") ; entry (".nbSSF.frameNB2.lfCert.entCert") -background ("#FFFAFA") -foreground ("#141312") -highlightbackground ("#ffffff") -highlightcolor ("#141312") -selectbackground ("#418bd4") -selectforeground ("#ffffff") -width ("40"); pack (".nbSSF.frameNB2.lfCert.entCert") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("9") -pady ("0") -side ("left"); button (".nbSSF.frameNB2.lfCert.butCert") -activebackground ("#e0dfde") -activeforeground ("#141312") -background ("#e0dfde") -foreground ("#141312") -highlightbackground ("#e0dfde") -highlightcolor ("#141312") -text (" "); pack (".nbSSF.frameNB2.lfCert.butCert") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("0") -pady ("0") -side ("left"); pack (".nbSSF.frameNB2.lfCert") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("0") -pady ("8") -side ("top"); pack (".nbSSF.frameNB2.lfCert.entCert", ".nbSSF.frameNB2.lfCert.butCert") -in (".nbSSF.frameNB2.lfCert"); labelframe (".nbSSF.frameNB2.lfAtCert") -borderwidth ("4") -foreground ("#141312") -relief ("ridge") -text ("   ") -background ("#00FF00") -height ("100") -width ("100"); radiobutton (".nbSSF.frameNB2.lfAtCert.radAtCert") -activebackground ("#e0dfde") -activeforeground ("#141312") -background ("#e0dfde") -foreground ("#141312") -highlightbackground ("#e0dfde") -highlightcolor ("#141312") -text ("  ") -value ("1") -variable (selCert) ; pack (".nbSSF.frameNB2.lfAtCert.radAtCert") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("0") -pady ("0") -side ("left"); radiobutton (".nbSSF.frameNB2.lfAtCert.radDetCert") -activebackground ("#e0dfde") -activeforeground ("#141312") -background ("#e0dfde") -foreground ("#141312") -highlightbackground ("#e0dfde") -highlightcolor ("#141312") -text (" ") -value ("0") -variable (selCert) ; pack (".nbSSF.frameNB2.lfAtCert.radDetCert") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("10") -pady ("0") -side ("top"); pack (".nbSSF.frameNB2.lfAtCert") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("0") -pady ("0") -side ("top"); pack (".nbSSF.frameNB2.lfAtCert.radAtCert", ".nbSSF.frameNB2.lfAtCert.radDetCert") -in (".nbSSF.frameNB2.lfAtCert"); button (".nbSSF.frameNB2.butSign") -activebackground ("#e0dfde") -activeforeground ("#141312") -background ("#20B2AA") -borderwidth ("7") -foreground ("#141312") -highlightbackground ("#e0dfde") -highlightcolor ("#141312") -relief ("ridge") -text (" ") -image ("stamp_32x32") -compound("left"); pack (".nbSSF.frameNB2.butSign") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("0") -pady ("14") -side ("top"); pack (".nbSSF.frameNB2.lfSignDoc", ".nbSSF.frameNB2.lfForType", ".nbSSF.frameNB2.lfCert", ".nbSSF.frameNB2.lfAtCert", ".nbSSF.frameNB2.butSign") -in (".nbSSF.frameNB2"); frame (".nbSSF.frameNB3") -borderwidth ("2") -relief ("raised") -background ("#e0dfde") -height ("30") -highlightbackground ("#e0dfde") -highlightcolor ("#141312") -width ("30") ; pack (".nbSSF") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("0") -pady ("0") -side ("top"); labelframe (".lfP11") -borderwidth ("4") -foreground ("#141312") -relief ("ridge") -text ("   ") -background ("#FFE4B5") -height ("100") -width ("100"); entry (".lfP11.entP11") -background ("#FFFAFA") -foreground ("#141312") -highlightbackground ("#ffffff") -highlightcolor ("#141312") -selectbackground ("#418bd4") -selectforeground ("#ffffff") -width ("40"); pack (".lfP11.entP11") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("8") -pady ("0") -side ("left") ; button (".lfP11.butP11") -activebackground ("#e0dfde") -activeforeground ("#141312") -background ("#e0dfde") -borderwidth ("4") -foreground ("#141312") -highlightbackground ("#e0dfde") -highlightcolor ("#141312") -relief ("ridge") -text ("  "); pack (".lfP11.butP11") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("9") -pady ("1") -side ("top") ; pack (".lfP11") -anchor ("center") -expand ("0") -ipadx ("0") -ipady ("0") -padx ("0") -pady ("14") -side ("top") ; pack (".lfP11.entP11", ".lfP11.butP11") -in (".lfP11"); addtab (".nbSSF", ".nbSSF.frameNB1") -padding ("0") -sticky ("nsew") -state ("normal") -text ("") -compound ("none") -underline ("-1"); addtab (".nbSSF", ".nbSSF.frameNB2") -padding ("0") -sticky ("nsew") -state ("normal") -text ("") -compound ("none") -underline ("-1"); addtab (".nbSSF", ".nbSSF.frameNB3") -padding ("0") -sticky ("nsew") -state ("normal") -text ("") -compound ("none") -underline ("-1"); pack (".lfSSF", ".nbSSF", ".lfP11") -in ("."); /*proc TPcloseWindow. {} {}*/ ".lfSSF.butSSF" << configure () -command (compute); ".nbSSF.frameNB2.lfSignDoc.butSignDoc" << configure () -command (findDoc); ".nbSSF.frameNB2.lfCert.butCert" << configure () -command (findCert); ".lfP11.butP11" << configure () -command (findPrivKey); ".nbSSF.frameNB2.lfForType.radAtt" << configure () -command (updateRad); ".nbSSF.frameNB2.lfForType.radDet" << configure () -command (updateRad); ".nbSSF.frameNB2.lfAtCert.radAtCert" << configure () -command (updateRad); ".nbSSF.frameNB2.lfAtCert.radDetCert" << configure () -command (updateRad); ".nbSSF.frameNB2.butSign" << configure () -command (createSign); ".nbSSF.frameNB2.butSign" << configure () -state (disabled); ".lfP11.butP11" << configure () -state (disabled); ".nbSSF.frameNB2.lfForType.comboFor" << deleteentry (0, end); ".nbSSF.frameNB2.lfForType.comboFor" << insert(end, "PKCS7"); tab (".nbSSF", ".nbSSF.frameNB2") -state (disabled); tab (".nbSSF", ".nbSSF.frameNB3") -state (disabled); wm (iconphoto, ".", "stamp_32x32"); runEventLoop(); } catch (exception const &e) { cerr << "Error: " << e.what() << '\n'; } } 


And after receiving the binary code, run it and see the following:

image

That's all.But there are still two things that I would like to talk about. This is the creation of extensions for Tcl through dynamic libraries and Tcl / Tk in Android.

Source: https://habr.com/ru/post/344526/


All Articles