April 24, Filetype: PDF | views. system_update_alt Download. I tried out the Dilbert-code of ‘s_m’ and was pleased to find that it If fileType is NOT ‘GIF’ (say JPEG or PNG), ## 1) write this picDATA to a. Click to download Sit, Dogbert icon from Dilbert Iconset by Bo. Iconset: Dilbert Icons (21 icons) License: Free for non-commercial Filetype sit icon · ICOICNS.
|Published (Last):||2 June 2011|
|PDF File Size:||2.74 Mb|
|ePub File Size:||7.18 Mb|
|Price:||Free* [*Free Regsitration Required]|
On my ‘bio’ page at uniquenameI mentioned that I have not done any socket programming with Tcl-Tk. On my ‘to-do’ list on the uniquename page, for several months, I have had the item ‘tkGetToons – to fetch some of my favorite cartoons from Internet sites that offer them for example, Agnes, Baby Blues, Bizarro, Dilbert, Doonesbury, Rhymes with Orange, Speed Bump, Zits, and perhaps the sites of some editorial-page political cartoonists’.
The Tcl ‘http’ package was available ffiletype the Tcl-Tk 8. However, I also have a little Acer netbook computer that I often use to test Tk scripts in its Linux environment. For some reason unbeknownst to me at this timethe Tcl-Tk 8. So I did all my testing,as well as development, on my desktop computer. Note that to run this code, you will need the ‘http’ package with your Tcl-Tk installation. However I wanted to do more than that I wanted to be able to retrieve any of the old Dilbert cartoons from a Dilbert archive site.
And not just Dilbert. I wanted to be able to retrieve old cartoons from archive sites like those of Doonesbury, Rhymes with Orange, Speed Bump, and Zits fjletype allow for easily adding more sites in filetyp future.
Note the entry fields for year-month-day. Fortunately, all the archive sites that I have implemented so far allow for specifying a particular comic by year-month-day. If necessary, in the future, more widgets could be added to the GUI to handle different methods of ‘indexing’ archived comics.
Those buttons are to provide a way to easily decrement and increment the day-number by simply clicking on those buttons, rather than keying into the Day entry field. The procs take into account whether a month has 30 or 31 or 28 or 29 days. Note also the scrollbars on the ‘canvas’ widget.
They come in handy for large comic images like the following. Some comics are a single panel, in which case the scrollbars of the canvas are not needed as in the following. Click on a line of the listbox to choose a web-site. The filstype name is followed by a separation character after which there may be some description of the web-site. Date fields year,month,day provide the user a way to select a specific comic to retrieve if a web site supports retrieval by date.
You can skip to a different year or month by simply entering a new number in the Year or Month entry fi,etype. After each date is set, click on the ‘Retrieve’ button to display the corresponding comic.
The ‘Retrieve’ button causes a filethpe of Tcl ‘http’ commands to be issued, commands such as. Occasionally, at a comic archive site, there may not be a comic for a specified date. In that case, you may see an error message popup in a window. Simply dismiss the window and try another date.
Also, if your network connection is not active, you will get a popup that reminds you that you need to establish your internet connection. This Tk coding structure is discussed in more detail on the page A Canonical Structure for Tk Code and variations.
This structure makes it easy for me to find code sections while generating and testing a Tk dilbwrt, and when looking for code snippets to include in other scripts code re-use. I call your attention to step-zero. One filetyppe that I started doing in is use of a text-array for text in labels, buttons, ciletype other widgets in the GUI. This can make it easier for people to internationalize my scripts.
I will be using a text-array like this in most of my scripts in the future. In this script, motivated by the many instances of popup messages in the code, I included message text in the text-array.
As in all my scripts that use the ‘pack’ geometry manager which is all of my plus scripts, so farI provide the four main pack parameters ‘-side’, ‘-anchor’, ‘-fill’, ‘-expand’ on all of the ‘pack’ commands for the frames and widgets. That helps me when I am initially testing the behavior of a GUI the various widgets within it as I resize the main window. I think that I have used a pretty nice choice of the ‘pack’ parameters.
Also, the WIDTH of the ‘listbox’ stays FIXED, while the ‘canvas’ can expand horizontally as well as vertically allowing more room for the canvas that is, large comics if the user expands the window. You can experiment with the ‘-side’, ‘-anchor’, ‘-fill’, and ‘-expand’ parameters on the ‘pack’ commands for the various frames and widgets to get the widget behavior that you want. You might want to change the fonts used for the various GUI widgets.
For example, you could change ‘-weight’ from ‘bold’ to ‘normal’ or ‘-slant’ from ‘roman’ to ‘italic’. Or change font families. In fact, you may NEED to change the font families, because the families I used may not be available on your computer and the default font that the ‘wish’ interpreter chooses may not be very pleasing. I use variables to set geometry parameters of widgets parameters such as border-widths and padding.
And I have included the ‘-relief’ parameter on the definitions of frames and widgets. Feel free to experiment with those ‘appearance’ parameters as well. That said, here’s the code with plenty of comments to describe what most of the code-sections are doing. You can look at the top of the PROCS section of the code to see a list of the procs used in this script, along with brief descriptions of how they are called and what they do.
It is my hope that the copious comments in the code will help Tcl-Tk coding ‘newbies’ get started in making GUI’s like this. Without the comments, potential young Tcler’s might be tempted to return to their iPhones and iPads and iPods to watch videos of Daniel Tosh providing people who have posted videos on the internet the opportunity for ‘web redemption’. Then the user can use their desktop system such as Gnome or KDE to set up the Tk script as an icon on the desktop.
How to Fail at Almost Everything and Still Win Big
Then the user can click on the icon to startup the GUI. This Tk script is the first utility that I have added to the bottom of my ‘bio’ page at uniquename in the ‘CNP’ Code using Network Protocols group. I have many more scripts in various states of development in the other categories of ‘done and to-do’ projects on my ‘bio’ page. But I may return to this ‘get-comics’ Tk script to provide some enhancements, such as:.
In using this utility, I may discover error conditions that I did not encounter in testing. I may add ways to ‘trap’ the errors and provide some pop-up messages in addition to the ones I already implemented during the testing phase. Some additional comics may be added. These comic archive sites occasionally change their web pages and the ways that they store and access the comics. I want to thank those who authored the ‘http’ package ‘beedub’ and others?
The following 3 images confirm that the Agnes, BabyBlues, and Bizarro comics are retrievable and the images show some of the almost unnoticeable changes to the GUI.
tkGetComics – to get ‘old’ comics from comic archive web-sites
Note that the text lines in the site-selection listbox now indicate a date-range for the comics at a site. By the way, many of the Agnes comics ‘miss the mark’ for me, but the ones where the teacher sends her to the principal’s office are usually quite good.
Many of the old BabyBlues comics were in black-and-white on weekdays, but in color on Sundays. Among future enhancements that I am considering: In particular, my fioetype for the Tcl-Tk script were: A ‘ ‘ in column 1 of the line makes the line a comment line for example, to allow for indicating comics for which retrieval has not been implemented, and dlbert the user to keep looking for a method to retrieve those comics.
If some sites offer a different way, from year-month-day, of identifying individual comics, this code could activate a different widget or widgets by which to specify a comic according to the site selected by the user. The ‘Retrieve’ button causes a series of Tcl ‘http’ commands to be issued, commands such as – http:: The code Below, I provide the Tk script code for this ‘get-comics’ utility.
I follow my usual ‘canonical’ structure for Tk code for this Tk script: Within each frame, define ALL the widgets. Then filetyoe the widgets. Experimenting dilberg the GUI As in all my scripts that use the ‘pack’ geometry manager which is all of my plus scripts, so farI provide the four main pack parameters ‘-side’, ‘-anchor’, ‘-fill’, ‘-expand’ dilbeet all of the ‘pack’ commands for the frames and widgets.
Some features in the code That said, here’s the code with plenty of comments to describe what most dilbbert the code-sections are doing. To avoid repeating code that is common to all the procs after the URL of the image file has been determined.
This Tk script offers a GUI on which the user can – choose a comics site such as dilbert. A particular comic at a site is selected by a date or some other type of ‘index’where the date or other index is user-selected via widgets on the GUI.
The temporary directory location can be changed by changing the setting of the ‘DIRtemp’ variable in this code. A ‘listbox’ on the GUI offers a list of comic sites from which to choose. If some sites offer a different way of identifying the cartoons, this code may activate a different widget or widgets by which to specify a comic depending on the site selected by the user.
A ‘Retrieve’ button causes a series filetyle Tcl ‘http’ commands to be issued, commands such as – http:: A ‘package require http’ statement is used to determine whether the Tcl ‘http’ package is available. The scroll-bar ‘arrow-heads’ are drawn as follows: The year,month,day entry fields could be filetgpe with today’s date or changed to a date suited to the user-selected web site.
This GUI will contain about: When all widgets are defined for a frame, pack them. The code-structure detail for this particular script: These procs will need to be changed as the sites change the way they store their comics.
The ‘DIRtemp’ variable is set here. Change this ‘set’ statement to change where the image files will be created when the ‘SaveAsGIF’ button is used.
Got the GUI up, with dummied out procs. Blaise Montandon mar07 Added scrollbars to canvas. Started developing and testing the procs. We use leading spaces to provide left-padding, separating the YEAR label from filetyoe left side of the window.
First chars are: If you want to make the window un-resizable, you can use the following statement. We want to make sure the canvas has plenty of room, esp.