Tk – Special Variables

Tk – Special Variables ”; Previous Next In Tk, we classify some of the variables as special variables and they have a predefined usage/functionality. The list of special variables is listed below. Sr.No. Special Variable & Description 1 tk_library Used for setting the location of standard Tk libraries. 2 tk_patchLevel Refers to the current patch level of the Tk interpreter. 3 tk_strictMotif When non-zero, Tk tries to adhere to Motif look-and-feel as closely as possible. 4 tk_version Displays the Tk version. The above special variables have their special meanings for the Tk interpreter. Examples for using Tk special variables Lets see the examples for special variables. TK VERSION #!/usr/bin/wish puts $tk_version When you run the program, you will get a similar output as shown below. 8.5 TK LIBRARY PATH #!/usr/bin/wish puts $tk_library When you run the program, you will get a similar output as shown below. /Library/Frameworks/Tk.framework/Versions/8.6/Resources/Scripts TK PATCH LEVEL #!/usr/bin/wish puts $tk_patchLevel When you run the program, you will get a similar output as shown below. 8.6.1 TK STRICTMOTIF #!/usr/bin/wish puts $tk_strictMotif When you run the program, you will get a similar output as shown below. 0 Print Page Previous Next Advertisements ”;

Tk – Layout Widgets

Tk – Layout Widgets ”; Previous Next Layout widgets are used to handle layouts for the Tk application. Frame widget is used group other widgets and place, pack, and grid are layout manager to give you total control over your adding to windows. The list of available layout widgets are as shown below − Sr.No. Widgets & Description 1 Frame Container widget to hold other widgets. 2 Place Widget to hold other widgets in specific place with coordinates of its origin and an exact size. 3 Pack Simple widget to organize widgets in blocks before placing them in the parent widget. 4 Grid Widget to nest widgets packing in different directions. A simple Tk example is shown below for layout widgets − #!/usr/bin/wish frame .myFrame1 -background red -relief ridge -borderwidth 8 -padx 10 -pady 10 -height 100 -width 100 frame .myFrame2 -background blue -relief ridge -borderwidth 8 -padx 10 -pady 10 -height 100 -width 50 pack .myFrame1 pack .myFrame2 When we run the above program, we will get the following output − Print Page Previous Next Advertisements ”;

Tk – Canvas Widgets

Tk – Canvas Widgets ”; Previous Next Canvas is used for providing drawing areas. The syntax for canvas widget is shown below − canvas canvasName options Options The options available for the canvas widget are listed below in the following table − Sr.No. Syntax & Description 1 -background color Used to set background color for widget. 2 -closeenough distance Sets the closeness of mouse cursor to a displayable item. The default is 1.0 pixel. This value may be a fraction and must be positive. 3 -scrollregion boundingBox The bounding box for the total area of this canvas. 4 -height number Used to set height for widget. 5 -width number Sets the width for widget. 6 -xscrollincrement size The amount to scroll horizontally when scrolling is requested. 7 -yscrollincrement size The amount to scroll vertically when scrolling is requested. A simple example for canvas widget is shown below − #!/usr/bin/wish canvas .myCanvas -background red -width 100 -height 100 pack .myCanvas When we run the above program, we will get the following output − Widgets for Drawing in Canvas The list of the available widgets for drawing in canvas is listed below − Sr.No. Widget & Description 1 Line Draws a line. 2 Arc Draws an arc. 3 Rectangle Draws a rectangle. 4 Oval Draws an oval. 5 Polygon Draws a polygon. 6 Text Draws a text. 7 Bitmap Draws a bitmap. 8 Image Draws an image. An example using different canvas widgets is shown below − #!/usr/bin/wish canvas .myCanvas -background red -width 200 -height 200 pack .myCanvas .myCanvas create arc 10 10 50 50 -fill yellow .myCanvas create line 10 30 50 50 100 10 -arrow both -fill yellow -smooth true -splinesteps 2 .myCanvas create oval 50 50 100 80 -fill yellow .myCanvas create polygon 50 150 100 80 120 120 100 190 -fill yellow -outline green .myCanvas create rectangle 150 150 170 170 -fill yellow .myCanvas create text 170 20 -fill yellow -text “Hello” -font {Helvetica -18 bold} .myCanvas create bitmap 180 50 -bitmap info When we run the above program, we will get the following output − Print Page Previous Next Advertisements ”;

Tcl – Built-in Functions

Tcl – Built-in Functions ”; Previous Next Tcl provides a number of built-in functions (procedures) for various operations. This includes − Functions for list handling. Functions for string handling. Functions for array handling. Functions for dictionary handling. Functions for File I/O handling. Functions for creating namespaces and packages. Functions for Math operations. Functions for System operations. Each of the above except for math and system functions are covered in earlier chapters. Math and system built-in functions are explained below. Math Functions The math functions available in Tcl are listed in the following table − Sr.No. Method & Description 1 abs arg Calculates the absolute value of arg. 2 acos arg Calculates the arccosine of arg. 3 asin arg Calculates the arcsine of arg. 4 atan arg Calculates the arctangent of arg. 5 atan2 y x Calculates the arctangent of the quotient of its arguments(y/x). 6 ceil arg Calculates the smallest integer greater than or equal to a number. 7 cos arg Calculates the cosine of arg. 8 cosh arg Calculates the hyperbolic cosine of arg. 9 double arg Calculates if arg is a floating-point value, returns arg, otherwise converts arg to floating-point and returns the converted value. 10 exp arg Calculates an exponential function (e raised to the power of arg). 11 floor arg Calculates the largest integer less than or equal to arg. 12 fmod x y Calculates the floating-point remainder of the division of x by y. If y is 0, an error is returned. 13 hypot x y Calculates the length of the hypotenuse of a right-angled triangle sqrt(x*x+y*y). 14 int arg Calculates if arg is an integer value of the same width as the machine word, returns arg, otherwise converts arg to an integer. 15 log arg Calculates the natural logarithm of arg. 16 log10 arg Calculates the base 10 logarithm of arg. 17 pow x y Calculates the value of x raised to the power y. If x is negative, y must be an integer value. 18 rand Calculates a pseudo-random number between 0 and 1. 19 round arg Calculates the value of arg rounded to the nearest integer. 20 sin arg Calculates the sine of arg. 21 sinh arg Calculates the hyperbolic sine of arg. 22 sqrt arg Calculates the square root of arg. arg must be positive. 23 srand arg Calculates a pseudo-random number between 0 and 1. The arg, which must be an integer, is used to reset the seed for the random number generator of rand. 24 tan arg Calculates the tangent of arg. 25 tanh arg Calculates the hyperbolic tangent of arg. 26 wide arg Calculates integer value at least 64-bits wide (by sign-extension if arg is a 32-bit number) for arg if it is not one already. Some examples using math functions are given below − Live Demo #!/usr/bin/tclsh namespace import ::tcl::mathfunc::* puts [tan 10] puts [pow 10 2] puts [ceil 10.34] puts [hypot 10 20] puts [srand 45] puts [log 10] puts [srand 45] When the above code is executed, it produces the following result − 0.6483608274590866 100.0 11.0 22.360679774997898 0.0003521866166741525 2.302585092994046 0.0003521866166741525 System Functions The important system functions in Tcl includes, clock − seconds function, which returns current time in seconds. clock − format function, which formats the seconds into date and time. clock − scan function, which scans the input string and converts it into seconds. open − function, which is used to open a file. exec − function, which is used to execute a system command. close − function, which is used to close a file. Some examples for the above functions are listed below − #!/usr/bin/tclsh #get seconds set currentTime [clock seconds] puts $currentTime #get format puts “The time is: [clock format $currentTime -format %H:%M:%S]” puts “The date is: [clock format $currentTime -format %D]” set date “Jun 15, 2014″ puts [clock scan $date -format {%b %d, %Y}] puts [exec ls] puts [exec dir] set a [open input.txt] puts [read $a]; puts $a close $a When the above code is executed, it produces the following result − 1402819756 The time is: 03:09:16 The date is: 06/15/2014 1402808400 input.txt main.tcl input.txt main.tcl This is the file you can use to provide input to your program and later on open it inside your program to process the input. file3 The following table provides the list strings that can be used to format the date and time. Sr.No. Format & Description 1 %a Day in short form, eg:Sun. 2 %A Day in full form eg:Sunday. 3 %b Month in short form. 4 %B Month in full form. 5 %d Day of month. 6 %j Julian day of year. 7 %m Month in number. 8 %y Year in two digits. 9 %Y Year in four digits. 10 %H Hour in 24 hour clock. 11 %I Hour in 12 hour clock. 12 %M Minutes. 13 %S Seconds. 14 %p AM or PM. 15 %D Date in number, mm /dd/yy. 16 %r Time in 12 hour clock. 17 %R Time in 24 hour clock without seconds. 18 %T Time in 24 hour clock with seconds. 19 %Z Time Zone Name like GMT, IST, EST and so on. Print Page Previous Next Advertisements ”;

Tk – Fonts

Tk – Fonts ”; Previous Next There are a number of widgets that supports displaying text. Most of these provides the option of font attribute. The syntax for creating a font is shown below − font create fontName options Options The options available for the font create are listed below in the following table − Sr.No. Syntax & Description 1 -family familyName The name of font family. 2 -size number The size of font. 3 -weight level The weight for font. A simple example for a font creation is shown below − #!/usr/bin/wish font create myFont -family Helvetica -size 18 -weight bold pack [label .myLabel -font myFont -text “Hello World”] When we run the above program, we will get the following output − To get all the fonts available, we can use the following command − #!/usr/bin/wish puts [font families] When we run the above command, we will get the following output − {Abadi MT Condensed Extra Bold} {Abadi MT Condensed Light} {Al Bayan} {Al Nile} {Al Tarikh} {American Typewriter} {Andale Mono} Arial {Arial Black} {Arial Hebrew} {Arial Narrow} {Arial Rounded MT Bold} {Arial Unicode MS} Athelas Avenir {Avenir Next} {Avenir Next Condensed} Ayuthaya Baghdad {Bangla MN} {Bangla Sangam MN} {Baoli SC} Baskerville {Baskerville Old Face} Batang {Bauhaus 93} Beirut {Bell MT} {Bernard MT Condensed} BiauKai {Big Caslon} {Book Antiqua} {Bookman Old Style} {Bookshelf Symbol 7} Braggadocio {Britannic Bold} {Brush Script MT} Calibri {Calisto MT} Cambria {Cambria Math} Candara Century {Century Gothic} {Century Schoolbook} Chalkboard {Chalkboard SE} Chalkduster {Charcoal CY} Charter Cochin {Colonna MT} {Comic Sans MS} Consolas Constantia {Cooper Black} Copperplate {Copperplate Gothic Bold} {Copperplate Gothic Light} Corbel {Corsiva Hebrew} Courier {Courier New} {Curlz MT} Damascus {DecoType Naskh} Desdemona {Devanagari MT} {Devanagari Sangam MN} Didot {DIN Alternate} {DIN Condensed} {Diwan Kufi} {Diwan Thuluth} {Edwardian Script ITC} {Engravers MT} {Euphemia UCAS} Eurostile Farah Farisi {Footlight MT Light} {Franklin Gothic Book} {Franklin Gothic Medium} Futura Gabriola Garamond {GB18030 Bitmap} {Geeza Pro} Geneva {Geneva CY} Georgia {Gill Sans} {Gill Sans MT} {Gloucester MT Extra Condensed} {Goudy Old Style} {Gujarati MT} {Gujarati Sangam MN} Gulim GungSeo {Gurmukhi MN} {Gurmukhi MT} {Gurmukhi Sangam MN} Haettenschweiler {Hannotate SC} {Hannotate TC} {HanziPen SC} {HanziPen TC} Harrington HeadLineA Hei {Heiti SC} {Heiti TC} Helvetica {Helvetica CY} {Helvetica Neue} Herculanum {Hiragino Kaku Gothic Pro} {Hiragino Kaku Gothic ProN} {Hiragino Kaku Gothic Std} {Hiragino Kaku Gothic StdN} {Hiragino Maru Gothic Pro} {Hiragino Maru Gothic ProN} {Hiragino Mincho Pro} {Hiragino Mincho ProN} {Hiragino Sans GB} {Hoefler Text} Impact {Imprint MT Shadow} InaiMathi {Iowan Old Style} Kai Kailasa {Kaiti SC} {Kaiti TC} {Kannada MN} {Kannada Sangam MN} Kefa {Khmer MN} {Khmer Sangam MN} {Kino MT} Kokonor Krungthep KufiStandardGK {Lantinghei SC} {Lantinghei TC} {Lao MN} {Lao Sangam MN} {Libian SC} {LiHei Pro} {LiSong Pro} {Lucida Blackletter} {Lucida Bright} {Lucida Calligraphy} {Lucida Console} {Lucida Fax} {Lucida Grande} {Lucida Handwriting} {Lucida Sans} {Lucida Sans Typewriter} {Lucida Sans Unicode} {Malayalam MN} {Malayalam Sangam MN} Marion {Marker Felt} Marlett {Matura MT Script Capitals} Meiryo Menlo {Microsoft Sans Serif} Mishafi Mistral {Modern No. 20} Monaco {MS Gothic} {MS Mincho} {MS PGothic} {MS PMincho} {MS Reference Sans Serif} {MS Reference Specialty} Mshtakan {MT Extra} Muna {Myanmar MN} {Myanmar Sangam MN} Nadeem {Nanum Brush Script} {Nanum Gothic} {Nanum Myeongjo} {Nanum Pen Script} {New Peninim MT} {News Gothic MT} Noteworthy Onyx Optima {Oriya MN} {Oriya Sangam MN} Osaka Palatino {Palatino Linotype} Papyrus PCMyungjo Perpetua {Perpetua Titling MT} PilGi {Plantagenet Cherokee} Playbill PMingLiU {PT Mono} {PT Sans} {PT Sans Caption} {PT Sans Narrow} {PT Serif} {PT Serif Caption} Raanana Rockwell {Rockwell Extra Bold} Sana Sathu {Savoye LET} Seravek Silom SimSun {Sinhala MN} {Sinhala Sangam MN} Skia {Snell Roundhand} {Songti SC} {Songti TC} Stencil STFangsong STHeiti STIXGeneral STIXIntegralsD STIXIntegralsSm STIXIntegralsUp STIXIntegralsUpD STIXIntegralsUpSm STIXNonUnicode STIXSizeFiveSym STIXSizeFourSym STIXSizeOneSym STIXSizeThreeSym STIXSizeTwoSym STIXVariants STKaiti STSong Superclarendon Symbol Tahoma {Tamil MN} {Tamil Sangam MN} TeamViewer8 {Telugu MN} {Telugu Sangam MN} Thonburi Times {Times New Roman} {Trebuchet MS} {Tw Cen MT} Verdana Waseem {Wawati SC} {Wawati TC} Webdings {Weibei SC} {Weibei TC} {Wide Latin} Wingdings {Wingdings 2} {Wingdings 3} {Xingkai SC} {Yuanti SC} YuGothic YuMincho {Yuppy SC} {Yuppy TC} {Zapf Dingbats} Zapfino {Apple Braille} {Apple Chancery} {Apple Color Emoji} {Apple LiGothic} {Apple LiSung} {Apple SD Gothic Neo} {Apple Symbols} AppleGothic AppleMyungjo {Monotype Corsiva} {Monotype Sorts} Print Page Previous Next Advertisements ”;

Tcl – Commands

Tcl – Commands ”; Previous Next As you know, Tcl is a Tool command language, commands are the most vital part of the language. Tcl commands are built in-to the language with each having its own predefined function. These commands form the reserved words of the language and cannot be used for other variable naming. The advantage with these Tcl commands is that, you can define your own implementation for any of these commands to replace the original built-in functionality. Each of the Tcl commands validates the input and it reduces the work of the interpreter. Tcl command is actually a list of words, with the first word representing the command to be executed. The next words represent the arguments. In order to group the words into a single argument, we enclose multiple words with “” or {}. The syntax of Tcl command is as follows − commandName argument1 argument2 … argumentN Let”s see a simple example of Tcl command − Live Demo #!/usr/bin/tclsh puts “Hello, world!” When the above code is executed, it produces the following result − Hello, world! In the above code, ‘puts’ is the Tcl command and “Hello World” is the argument1. As said before, we have used “” to group two words. Let”s see another example of Tcl command with two arguments − Live Demo #!/usr/bin/tclsh puts stdout “Hello, world!” When the above code is executed, it produces the following result − Hello, world! In the above code, ‘puts’ is the Tcl command, ‘stdout’ is argument1, and “Hello World” is argument2. Here, stdout makes the program to print in the standard output device. Command Substitution In command substitutions, square brackets are used to evaluate the scripts inside the square brackets. A simple example to add two numbers is shown below − Live Demo #!/usr/bin/tclsh puts [expr 1 + 6 + 9] When the above code is executed, it produces following result − 16 Variable Substitution In variable substitutions, $ is used before the variable name and this returns the contents of the variable. A simple example to set a value to a variable and print it is shown below. Live Demo #!/usr/bin/tclsh set a 3 puts $a When the above code is executed, it produces the following result − 3 Backslash Substitution These are commonly called escape sequences; with each backslash, followed by a letter having its own meaning. A simple example for newline substitution is shown below − Live Demo #!/usr/bin/tclsh puts “HellonWorld” When the above code is executed, it produces the following result − Hello World Print Page Previous Next Advertisements ”;

Tcl/Tk – Quick Guide

Tcl-Tk – Quick Guide ”; Previous Next Tcl – Overview Tcl is shortened form of Tool Command Language. John Ousterhout of the University of California, Berkeley, designed it. It is a combination of a scripting language and its own interpreter that gets embedded to the application, we develop with it. Tcl was developed initially for Unix. It was then ported to Windows, DOS, OS/2, and Mac OSX. Tcl is much similar to other unix shell languages like Bourne Shell (Sh), the C Shell (csh), the Korn Shell (sh), and Perl. It aims at providing ability for programs to interact with other programs and also for acting as an embeddable interpreter. Even though, the original aim was to enable programs to interact, you can find full-fledged applications written in Tcl/Tk. Features of Tcl The features of Tcl are as follows − Reduced development time. Powerful and simple user interface kit with integration of TK. Write once, run anywhere. It runs on Windows, Mac OS X, and almost on every Unix platform. Quite easy to get started for experienced programmers; since, the language is so simple that they can learn Tcl in a few hours or days. You can easily extend existing applications with Tcl. Also, it is possible to include Tcl in C, C++, or Java to Tcl or vice versa. Have a powerful set of networking functions. Finally, it”s an open source, free, and can be used for commercial applications without any limit. Applications Tcl is a general-purpose language and you can find Tcl everywhere. It includes, Scalable websites that are often backed by databases. High performance web servers build with TclHttpd. Tcl with CGI based websites. Desktop GUI applications. Embedded applications. Tcl – Environment Setup Local Environment Setup If you are willing to set up your environment for Tcl, you need the following two software applications available on your computer − Text Editor Tcl Interpreter. Text Editor This will be used to type your program. Examples of a few text editors include Windows Notepad, OS Edit command, Brief, Epsilon, EMACS, and vim or vi. Name and version of a text editor can vary on different operating systems. For example, Notepad will be used on Windows, and vim or vi can be used on windows as well as Linux or UNIX. The files you create with your text editor are called source files and contain program source code. The source files for Tcl programs are named with the extension “.tcl”. Before starting your programming, make sure you have one text editor in place and you have enough experience to write a computer program, save it in a file, build it, and finally execute it. The Tcl Interpreter It is just a small program that enables you to type Tcl commands and have them executed line by line. It stops execution of a tcl file, in case, it encounters an error unlike a compiler that executes fully. Let”s have a helloWorld.tcl file as follows. We will use this as a first program, we run on a platform you choose. #!/usr/bin/tclsh puts “Hello World!” Installation on Windows Download the latest version for windows installer from the list of Active Tcl binaries available. The active Tcl community edition is free for personal use. Run the downloaded executable to install the Tcl, which can be done by following the on screen instructions. Now, we can build and run a Tcl file say helloWorld.tcl by switching to folder containing the file using ”cd” command and then execute the program using the following steps C:Tcl> tclsh helloWorld.tcl We can see the following output. C:Tcl> helloWorld C:Tcl is the folder, I am using to save my samples. You can change it to the folder in which you have saved Tcl programs. Installation on Linux Most of the Linux operating systems come with Tcl inbuilt and you can get started right away in those systems. In case, it”s not available, you can use the following command to download and install Tcl-Tk. $ yum install tcl tk Now, we can build and run a Tcl file say helloWorld.tcl by switching to folder containing the file using ”cd” command and then execute the program using the following steps − $ tclsh helloWorld.tcl We can see the following output − $ hello world Installation on Debian based Systems In case, it”s not available in your OS, you can use the following command to download and install Tcl-Tk − $ sudo apt-get install tcl tk Now, we can build and run a Tcl file say helloWorld.tcl by switching to folder containing the file using ”cd” command and then execute the program using the following steps − $ tclsh helloWorld.tcl We can see the following output − $ hello world Installation on Mac OS X Download the latest version for Mac OS X package from the list of Active Tcl binaries available. The active Tcl community edition is free for personal use. Run the downloaded executable to install the Active Tcl, which can be done by following the on screen instructions. Now, we can build and run a Tcl file say helloWorld.tcl by switching to folder containing the file using ”cd” and then execute the program using the following steps − $ tclsh helloWorld.tcl We can see the following output − $ hello world Installation from Source Files You can use the option of installing from source files when a binary package is not available. It is generally preferred to use Tcl binaries for Windows and Mac OS X, so only compilation of sources on unix based system is shown below. Download the source files. Now, use the following commands to extract, compile, and build after switching to the downloaded folder. $ tar zxf tcl8.6.1-src.tar.gz $ cd tcl8.6.1 $ cd unix $ ./configure —prefix=/opt —enable-gcc $ make $ sudo make install Note − Make sure, you change the file name to the version you downloaded on commands 1 and 2 given above. Tcl – Special Variables In Tcl, we

Tk – Basic Widgets

Tk – Basic Widgets ”; Previous Next Basic widgets are common widgets available in almost all Tk applications. The list of available basic widgets is given below − Sr.No. Widgets & Description 1 Label Widget for displaying single line of text. 2 Button Widget that is clickable and triggers an action. 3 Entry Widget used to accept a single line of text as input. 4 Message Widget for displaying multiple lines of text. 5 Text Widget for displaying and optionally edit multiple lines of text. 6 Toplevel Widget used to create a frame that is a new top level window. A simple Tk example is shown below using basic widgets − #!/usr/bin/wish grid [label .myLabel -text “Label Widget” -textvariable labelText] grid [text .myText -width 20 -height 5] .myText insert 1.0 “TextnWidgetn” grid [entry .myEntry -text “Entry Widget”] grid [message .myMessage -background red -foreground white -text “MessagenWidget”] grid [button .myButton1 -text “Button” -command “set labelText clicked”] When we run the above program, we will get the following output − Print Page Previous Next Advertisements ”;

Tk – Selection Widgets

Tk – Selection Widgets ”; Previous Next Selection widgets are used to select different options in a Tk application. The list of available selection widgets are as shown below. Sr.No. Widgets & Description 1 Radiobutton Widget that has a set of on/off buttons and labels, one of which may be selected. 2 Checkbutton Widget that has a set of on/off buttons and labels, many of which may be selected. 3 Menu Widget that acts as holder for menu items. 4 Listbox Widget that displays a list of cells, one or more of which may be selected. A simple Tk example is shown below using selection widgets − #!/usr/bin/wish grid [frame .gender ] grid [label .label1 -text “Male” -textvariable myLabel1 ] grid [radiobutton .gender.maleBtn -text “Male” -variable gender -value “Male” -command “set myLabel1 Male”] -row 1 -column 2 grid [radiobutton .gender.femaleBtn -text “Female” -variable gender -value “Female” -command “set myLabel1 Female”] -row 1 -column 3 .gender.maleBtn select grid [label .myLabel2 -text “Range 1 not selected” -textvariable myLabelValue2 ] grid [checkbutton .chk1 -text “Range 1″ -variable occupied1 -command {if {$occupied1 } { set myLabelValue2 {Range 1 selected} } else { set myLabelValue2 {Range 1 not selected} } }] proc setLabel {text} { .label configure -text $text } When we run the above program, we will get the following output − Print Page Previous Next Advertisements ”;

Tk – Windows Manager

Tk – Windows Manager ”; Previous Next Window manager is used to handle the top level window. It helps in controlling the size, position, and other attributes of the window. In Tk, . is used to refer the main window. The syntax for window command is shown below − wm option window arguments The list of options available for Tk wm command is shown in the following table − Sr.No. Syntax & Description 1 aspect windowName a b c d Tries to maintain the ratio of width/height to be between a/b and c/d. 2 geometry windowName geometryParams Use to set geometry for window. 3 grid windowName w h dx dy Sets the grid size. 4 group windowName leaderName leaderName gives the leader of a group of related windows. 5 deiconify windowName Brings the screen to normal if minimized. 6 iconify windowName Minimizes the window. 7 state windowName Returns the current state of window. 8 withdraw windowName Unmaps the window and removes its details in memory. 9 iconbitmap windowName image Sets or returns the icon bitmap. 10 iconPhoto windowName image Sets or returns the icon photo. 11 command windowName commandString Records the startup command in the WM_COMMAND property. 12 protocol windowName arguments Register a command to handle the protocol request name, which can be WM_DELETE_WINDOW, WM_SAVE_YOURSELF, WM_TAKE_FOCUS. Eg: wm protocol. WM_DELETE_WINDOW Quit. 13 minsize windowName size Determines the minimum window size. 14 maxsize windowName size Determines the maximum window size. 15 title windowName titleText Determines the title for window. 16 attributes subOptions There are lots of attributes available like alpha, full screen and so on. Some of the above commands are used in the following example − #!/usr/bin/wish wm maxsize . 800 800 wm minsize . 300 300 wm title . “Hello” wm attributes . -alpha “.90″ wm geometry . 300×200+100+100 When we run the above program, we will get the following output − As you can see alpha is one of the attributes available. The list of commonly used subcommands are listed below − Sr.No. Syntax & Description 1 -alpha number Sets the alpha for window. 2 -fullscreen number Number can be 0 for normal screen or 1 for full screen. 3 -topmost number Sets or returns whether window is topmost.Value can be 0 or 1. Creating Window We can use toplevel command to create window and an example is shown below − #!/usr/bin/wish toplevel .t When we run the above program, we will get the following output − Destroying Window We can use destroy command to destroy window and an example is shown below − #!/usr/bin/wish destroy .t The above command will destroy window named .t. Print Page Previous Next Advertisements ”;