 the slide on how to open up a socket and who and inter process communication IPC using the tickle commands these are some of the commands on the I use and processes essentially so using these commands actually you can run external command using tickle so exe c or exec is one of the commands that can start a process you define the process and programs in the very first lecture remember and then the exe c can also use ampersand you know what this means this is basically to run the process in the background so we can actually run the process in the background or in the foreground over it is so to use that here is a typical example we set the favorite editor command to emacs and then we just say exe c color favorite editor and then with an ampersand to run it in the background and then yeah for the file names actually like I mean you can use the glob command to expand the files instead of just giving the file name expansion itself so here is an eval command of exe c and the exe c is essentially like I mean it is a ls of glob star dot c and you notice couple of things one is making this command is actually enclosed in the quotes meaning during the interpreter time this itself this everything will be this command like for example the globe command will be executed and it will be expanded so this is the command substitution therefore and the star dot c will be expanded based on the globe of c glob command and so basically it will become ls the entire list everything with dot c and so and then exe c will actually print out that values and then you can also open pipes using open command for example if you want to pipe the command to grip for the word foo in the bar dot tickle with a feed only option we can actually set this thing as an open with an open command and then the open command will pipe that into that into the app and then here basically like I mean this only just until the end of the file basically or in the file basically read the the dollar there so this command essentially searches for the word foo in bar dot tickle so that is the way to look at it basically so this is the one of the command then there are some runtime information of facilities so basically for example the during the command line arguments argc is the count and argv 0 is the interpreter name and argv is the list of arguments we will look at it this in more details as to how to set the very same interpreters so this is one of the things basically so if we query the argc that gives you the command and then the first argv is actually the interpreter name and then the remaining is the list of arguments so and then you can also query for the tickle tickle version the commands are the tickle version and TK version and then it can print out numbers like 7.5 4.1 for perspective then there are platform specific information that you can query so one such thing is basically the TK platform array that prints out for bunch of information we can also query the OS information machine platform and voice actually actually this prints out these various things and in that order so it is the OS version what kind of machine it is what platform it is in and then what is the OS so so so these are some of the other commands and then there is also info command and info command can have additional variables so info wars is one command info global is another one info locals and then info exists these things can give you information about the very good various variables that you are using for problem and then if you have defined the procedures and how you have defined the procedures those you can get it through this info procs info args info default info body and then there is also a rename command this is you can rename any command even the built-in commands you can rename to another command and also then because of the rename you can actually replace any built-in command with your own commands so you can use like for example RM and basically one of the commands for a different one then there is an auto loading feature in TCL when the command is does not exist usually an unknown is invoked and then basically the auto loading actually loads TCL procedures on demand from libraries it uses the search path of the directories then we also have a loaded TCL command essentially this is the long-awaited the standard interface for dynamic loading of TCL commands from BLLs and dot SS etc. So if you have a compile the TCL scripts basically you can use load TCL to load it at the runtime interrupt TCL command this is a interrupt is another command basically which is you can create multiple independent TCL interpreters in a single process so and then there are also like options along with it the dash safe option creates a safe TCL interpreter in the the versions 7.6 and 4.2 basically this is like the main improvements over the previous versions are one is the grid geometry manager has been revised and then it is needed for spectacle code generation or the GUI builder there is also CPC API changes for the channel drivers this will eliminate the TCL file usage and then as I mentioned like the here the GUI stands for the Japanese interface and then there are a whole bunch of bug fixes that went into these releases even though it says like beta I think like this all the releases and then we talked about some of the issues with TCL so for example in this command so some these these ones we have empowered much but assume that this is some command and then here is a command which has puts a CD out $ label with quotes and this quotes once you specify this quotes this may not work correctly because here the text label where we specify the $ label and somewhere else you have specifying set label this label can have multiple words so when we say like standard out with multiple words and since it is quotes as you know like I mean interpreter substitutes the variable this is a variable substitution so it can substitute into those multiple words for example if it is label is my name then you have my space name so now the puts command does not take those multiple words it needs to take only one word so to fix that we can actually define it like this basically where we define this as a list the command so that it executes as a list and then for each one is treated as a separate entity so even if you have multiple words the those words will be combined and treated as a single word so that when you say like puts standard out that particular word like say my name it produces the correct output and then we went through this particular particular program in a lot of details so here is this program is mainly for sorting and one thing quickly we notice is basically said as the arguments as ARGS and we know that that stands for variable length arguments so in this case actually it is basically it takes in a set of files and then basically it thoughts the files essentially or the lines in the files to see which order they should be so here we start the program by seeing like what is the number of arguments or number of files in the arguments so essentially like we just do an L search of of the arguments and that gives you like I mean how many files are there and if it is greater than 0 then we start processing the files so it is greater than or equal to 0 then a set files the range is the index minus 1 to the end so we split that into like 2 2 2 things basically so this is the IDX so here this argument will have like some options plus the file names so the options we need to delineate those things and then only like sort the so that is why we are doing this basically and then so the files are in the second part and options are in the first part so we detect that here and then we just say basically like now if we do not know exactly like I mean how to match this so here basically like all the arguments are starting with the dash so that is how we know that they are the options essentially so now if you do not know then now we need to just guess so basically when we set the files and the options and then we just go through each of the argument and see basically whether that belongs to an option or belongs to a file so we appropriately like increment one of them now once you know that then now we need to read the the lines from the files so we start reading the file basically and then if the length of the file itself is equal to 0 then we read it from the standard in if you want and then otherwise for each of those file basically we see like if the string equal to dash then maybe actually like close the file otherwise we open the file for rhythm and then set the close to one and then here we just start reading line by line until we in the in the file and then here is where we sort the lines and then this is like in place sorting and what we do is we set those the lines essentially which is this particular array here essentially like I mean we do this this command so let us go through this one by one we do an eval there is a list basically which converts the whatever the output into a list then we do an L sort which is a list sort of the options and then basically we give a range and here basically like we convert the lines into the list and then essentially like I mean lines initial lines is actually set to nothing null so this this particular command actually starts the lines in place and basically it gives you the whole list as one I mean all the lines as just one loop and then we then go through the sorted lines and then just print out those lines throughout the line so this command is fairly simple it is just a for each and then we just read the the list lines line by line and then just put each line into the standard apps so this is what we covered for last time now we will start some new thing basically I hope like I mean once you start understanding this particular program you will be okay to actually do the any kind of typical program and here I actually like mentioned that basically if you look at the levels that will give you the good indication as to how this whole sorting program works so I marked it as like one and then two then list is L sort is for three and then we have these options actually like there L range and then the list and then the set lines so as you know like I mean it is all evaluated from inside one by one so this is the nested command that gets executed and then here the range is okay so now we will go to the next module let me talk about that so today we will be taking it to the next level we will actually review the we will actually go through the TK today so TK stands for toolkit it is a very concise or very precise term because what TK is about is nothing but this toolkit for doing doing graphical user interfaces with tickle commands so that is what we will be we will talk about but before we go there I want to give you a quick recap of our previous lectures actually we started learning about tickle a couple of weeks ago you understood that actually tickle has like it is a language that really not a language but mostly for scripting so it is very easy to use and not a big heavy heavyweight functionalities and typically tickle is just a set of commands which are separated by new line characters or semicolons and each command is just words separated by white space and the tickle interpreter itself does not put any kind of restriction on this and it passes pretty much everything to the parser and typically in the command structure is first word is function and then we have some arguments only the functions can apply meaning to the arguments so that is why like I mean the interpreter does not put any kind of restriction on the commands themselves and then passes everything faithfully to the parser and then it also allows you with single pass tokenizing and substitution so all the variables the commands themselves they are all like substituted at once but if you have like next nested command the parser will send it back to the interpreter and the freedom and send it back to parser again in a recursive manner and then we also learned about dollar being the symbol for the variable substitution and then the square brackets will pass the command substitution any kind of quotes prevents any substitution actually like it prevents the word break but it allows all the suspicious but if you are using a braces and that braces prevents all those institutions you also learned about the escape characters which is backslash to escape specific characters and the key thing to note from all these things that tickle has no grammar we also learned about procedures and some of the special commands in tickle or various activities whether it is file IO regular IO or just executing a command things like that we learned in the last lecture so today we are going to shift gears and focus more on the TK which is the toolkit so what is the TK so TK is a very efficient way to and mostly like fun way to build user interface of the grasp is an interface with tickle and then it has this three basic structures the windows widgets and processes we will learn about these things and then we can create widgets using class commands and then there are specific widget commands as well and most of the geometry management is through these two commands called placer and packer the commands themselves are place and pack and then we will learn about bindings because the bindings are how we can map a particular button or any kind of graphical interface unit into executable command and then there are other commands like send focus selection into manager and a couple of examples of commands essentially make sure ours is one for now is the other one so now let us look at how a TK application is organized the TK application has a widget hierarchy it still uses just one tickle interpreter and one process but you can have like more than one application in a given process so what is a widget so widget is nothing but a window with a particular look and feel and it is generated by the TK and widget is again it is a class by itself and the classes are implemented by TK the particular classes that got in that gets implemented with TK our frame so a widget can have a frame you can have a label you can have a button you can have a check button radio button menu button menu message entry text canvas scroll bar scale list box and top level so again the widgets can be nested for this because we have a top level widget that can that you can specify so now let us look at the widget hierarchy so at the top level it is specified as this dot that is the the top most level for a widget and then under the dot as three things basically three objects a list box so it is denoted as dot list box and then menu which has dot menu and then the scroll which is dot scroll so in this case essentially you can see that basically the this is all the top ones basically with the list box and then here is the menu and here is the scroll those are the three main things essentially so listed out here so the widget basically this empty box as one that is the list box then you have menu item and then scroll bar so and then under the menu itself we can have a menu file and a menu so you will see like how we can do these things so those are file and so this entire thing so now let us see how it works so there are three types of windows as you can see here one is the main window which is this whole thing which is in red you can have an internal window which is scroll has its own window as you can see and then the menu help has its own window when you click and open and then file will have its own window now if you click something and then it opens a dialogue the dialogue comes under the main window so dot dialogue that is that is what is also called as the top level window and for this one actually there is a message which is essentially like this text here and then yes and no those are the only two more additional things for this now how do we create widgets each widget has a class it can be a button it can be a list box and the scroll bar etc. And one class command for each class used to create the instance so if you want to create a widget called dot a dot B we need to use one of these commands in the button or list box or a scroll bar and then here we say like button space dollar I mean dot a dot B and then what is the text for that button split and then the command is actually exit and then here is another one another widget which is a scroll bar and then it has the name is dot X and then the orient is actually horizontal. So now you have three things that you can use it to different one is a class name and the window name itself and then the configuration options so each of the class as several configuration options so here is the class here is the configuration option for buttons as a class so you have an active background active foreground anchor background bitmap water width command cursor disable foreground font foreground height height background height like her height like thickness image justify pad X pad Y really state take focus text text variable underline width and wrap length these are all most of the the buttons that are available the class I mean the configuration options for buttons so it is not specified in a command the options are taken from an options database usually it is the resource manager property or just loads it from the X default file. So once you have the button defined if any kind of configuration option is not specified during the command line it takes it from the resource manager property or X default file and then in this one you can also like use that command to set it set an option and then we can actually query these options with the option command itself if it is not in the option database the default is provided by its class so title command for each widget is named after the widget and it is used to reconfigure and manipulate widgets so here let us see basically so here we define a button dot a dot b and then we configure the dot a dot b with release as sunken and then dot a dot b is flash then we also define a scroll bar and we set the width and the height and then we also you know get those numbers essentially so these are all we can try to reconfigure these widget and then we can also delete a widget when the particular widget is destroyed it automatically is deleted as well so the key principle with widget is all states should be readable modifiable at any time so the other one is how can I get any option from any widget at any time so when we give the widget name so here this dot my button and configure minus foreground then it gives you the foreground at foreground and foreground so this is the thing and here we if you do just my button configure then it gives you the all the items in that widget that is active background is what is that the background what is the active foreground what is the anchor what is the background and then what is the border width and the background the whole thing basically you get now how do we manage the geometries of these four widgets one key principle is widgets don't control their own position or even sizes only the geometry manager can do that and widgets don't even appear on the screen until it is getting managed by the jump and then the geometry manager is essentially some algorithm or arranging slave in those relative to the master windows so here on the right-hand side there is a picture showing how it works so we get the parameters from the application designer into the geometry manager we also get the requested size of the slave size on the same and then we also know the geometry of the master from looking at the window now the geometry manager provides the size and the location for the slave and then it also like provides the requested size for the master we talked about the placer as being one of the classes essentially so here the placer is actually it is very simple not a very powerful tool and it is not described in the text essentially so only thing to notice is basically like each slave buttons or any kind of objects will be placed relative to the its master for example if you say like we create a button called X within this scope of this window and we say basically like button dot X X is X and then place with respect to dot X basically X coordinate at Y 0 and Y coordinate at 0 so it puts it at the top of the window now we can move this window to the middle or put somewhere other another place here just by issuing another place for not so again we place the dot dot X now at the X direction it is one setting info and then relative Y is basically 0.5 so on the Y you just move it by 0.5 so that it is only like related to the previous value and then on the X direction it is sorry in the Y direction it is 0.5 0.5 centimeter on the Y direction it is just one centimeter and then with an anchor as so these are some of the coolest thing that you can do another one is essentially now relative X is actually 0.5 and relative Y is 0.5 but the height is in close you increase to two centimeters so now we have this kind of thing and then the anchor is at the center all the words so in this example actually we place it with the relative Y of relative X of 0 relative Y is 0.5 so that is the center and then relative height is 0.5 as well so it adds up to things and then the relative bit is 0.5 so you get a widget looking like this but in today's event we use what is called a packer or a pack command this pack is more powerful than the placer it arranges the group groups of slaves together that forms the packing list the packs slaves around the and it also packs the slaves around the edge of the master's cavity so the way to place is essentially like you pick the side of the cavity slice off the parcel for slave so this is gone and then optionally grow the slide slave to fill the parcel so so you have to increase it this and then fill it up as well and then finally like save the position the slave in the parcel where to put the position and where to put the slave in inside the parcel another thing is like how do you choose sites with packer so in fact packer with packer it will become much easier because now you can say like so in this example we have defined three buttons okay cancel and help and then we just issue one command to pack everything from left to right so okay cancel and help goes from go to the side left sorry it is not left to right but it is towards the left now we can reconfigure the cancel button this time we are going to configure the text as cancel command so basically just one command and it will do it for you and then the other thing is to place these buttons one on top of each other for that we just change the option from side left or to the side top now we can also put paddings on either side of any command so here we say like I mean for all the commands we do an left padding X of 2 millimeter and then boy padding distance of 1 millimeter so it achieves that way and then we can also like increase or decrease the pad padding link and now in this example actually you are doing some additional padding using the ipad X and ipad Y which are the internal padding essentially so internal padding is 1 millimeter and 2 millimeter 1 millimeter 2 millimeter on X and 1 on Y and then outside also is 2 millimeter and 1 millimeter so final output the command will be something like this because it needs a bigger wider area one other thing is oftentimes we need to fill a button or fill a particular widget with the button so for that we use this fill command so as you can see here we need to find without the fill command you can see that it leaves this white because this command is so long so now with fill X what happens is basically the each and every button is increased in its size to match the widget itself so here is another example where we specify the pack menu is top side side top so there is this menu and then we also coded a scroll bar as you can see it is a tiny scroll bar here and then we coded a list box essentially which is here you know actually this is the menu so the list box is here so the menu is here the top right scroll bar is here and then here list box so oftentimes what we want is for this this actually looks very happy and it is not like really pleasing so in order to make those kind of changes we use fill X and fill Y so here we say like so menus side top fill X so originally like file was here but since we say fill X it actually moves to the front of the line so here is the file and then this button itself is extended all the way so that is fill X and then the scroll bar we want to fill it fill the Y direction so we put this thing here so that basically it is top to bottom the scroll bar and then we can have our little list box which is here so now we come to the expansion so how do we expand the thing basically so we increase the partial size of the extra space in the master so this is something that we saw already like we have these three dot okay dot cancel and dot help that we pack towards the left side essentially now we say the okay and cancel we need to pack it to the left side but the okay and cancel and then the help can itself be pushed to the other side and then basically like we say that here pack the dot help the side is left and then the expand this through so that way we can actually have some control but now if we do a expand the true filler X that will fill up all the space with the button itself so here we can see basically once you say okay can so set the help side left so that is within this and then we say dash expand true fill X so if the X axis is true then it basically fills out the whole button so that is the difference between the expand and expand fill so now with if you say like expand equal to true then it puts those buttons further they still look okay only thing is like I remember all these white spaces here and here and so we can issue the command with expand as one and fill as both so that means that it can it is going to do the filling on either side and so here on the same token basically like since they have this apart using expand now the expand is one and then fill is both so it actually extends here is some more packing so if you want to create like more complex argument it is always better to use additional frames so here is one example the frame left so here we call this frame as dot left and then what does dot then left have basically we pack the dot left side towards the side left and X is three millimeter and Y is three millimeter and then we decide to put a frame on the right-hand side a frame called dot right and then the dot right is essentially like I mean we put it at the right and then with a padding of three millimeter and Y of three millimeter and then we also have these radio buttons which is we are just generating one by one and then here essentially like it has the variable points variable size and then text so the size will be taken for packing so here is one example so we have like all these machines pts 8 pts 10 pts 12 pts 18 pts 24 so we can just say basically pack everything in the left side with the top at anchor at recall to W then we can have various buttons to check basically dot bold is basically like the text is bold and variable is bold dot italic is the text is italic and then variable is italic and then here check button underline and text underline variable underline so for the text basically like in this underline check both button has these text and then you can also say like dot bold dot italic and dot under under mind in the same pack so here basically like these are the main formats and then input is dot write and then output is so today we will also like learn about these connections and probably like stop at that point I think like we will continue one point in the next class so the connections essentially like I mean so questions are how to make widgets work together with multiplication and other widgets so this is the whole purpose of tickle so we put the tickle commands and then it should work there and the widget actions are tickle commands for example button E dot B dash command command exit the button release is kept there and then every time you press basically the program just and widgets use tickle commands now to communicate with each other so here is an example scroll bar S different as a scroll bar and it takes dot Y view also the application themselves use widget commands to come communicate between the widgets so that is pretty much for today so as a review what we did was we started looking at TK today which is the toolkit that goes hand-in-hand with tickle we looked at the main data structure in tickle in TK which is nothing but generating widgets so this is another thing that we saw basically tickle is nothing but the whole bunch of widget commands and then create the widget and using the class command and then do some geometry management and then finally binding bind the user interface to the particular command and then there are other commands very similar to the class commands stand focus selection windows so this is something that we saw today then we also like mentioned detail about the widget hierarchy as to what different flavors are there that the top level basically the dot and then after the dot it is after the dot it goes through the various other commands then we also looked at the creating widgets how to create a widget and then some of the options for the third command we use some of these options in the program then we went into like the widget commands themselves and finally we started looking at laser and the packer mainly the packer which is the most versatile command in TK so here we looked at the various ways of arranging the widgets using the pack commands and also like make it more easy to look at and then finally we looked at the connections and yeah mainly the connections so how to make the other tickle scripts work together as one unit so there are many ways of doing it basically like they can communicate to one another using a tickle they can communicate or use a widget commands to communicate with widgets and then basically like widget actions on how they relate to the tickle commands so I think that's pretty much covers this lecture we will take it up in the next lecture thank you.