199,114 Archived Topics
Remove Filter ![]() | |
Nothing fancy. just shows a simple monthly calendar in a Tkinter label. The trick is to use a fixed font so spaces take up the same area as numbers. | |
Inspired by Bumsfeld's color tester, and wanting to give my students some practice at interpreting color strings, I wrote a little Tkinter program that asks the user to chose one of six buttons whose color most closely matches the color string printed at top. Comments welcome, and does anyone know … | |
Yes, the Python module 'zipfile' can handle an archive of files. This snippet shows you how to pack a PKZIP format zip file with several files and then unpack these archived files to individual files again. | |
So I needed a way to represent a line in Python. My first stab was to create a function dynamically. But classes are so much ... classier, so here's a simple implementation of a line object, with plenty of room for additional methods. The line is created as l = … | |
A simple guessing game for amatuer programmers like myself. | |
Here is an example of a random spin button using a button surrounded by labels to create the feeling of a spin animation. This example uses the Tkinter GUI and lets you select numbers 1 to 6. If your game requires more then this, just add additional labels. You are … | |
The FlashWindow component of wxPython will play those nice animated flash files found on the internet. They have file extension .swf usually. | |
For all functions, a domain error occurs if an input argument is outside the domain over which the mathematical function is defined. On a domain error, the function returns an implementation-defined value. | |
This program solves the geometric problem, called the Convex Hull problem. Given a set of points, the objective is to find a region such that the line joining any two points lies within that region. Informally, it is the polygon of largest area that can be formed out of the … | |
Let's say you had a list of full names, where the name would consist of a title, followed by first, middle and last name, or maybe just title and last name. You can sort this list by last name only, by creating a temporary list of sublists of type [last … | |
This module is a Python Library to support all IP2Locationâ„¢ database products. It has been optimized for speed and memory utilization. Developers can use the API to qeury all IP2Locationâ„¢ binary databases for applications written in Python. | |
this's daoremon's song code i hope you ever see doraemon's movie... | |
![]() | Evaluates an expression as a string using reverse polish notation. |
This snippet uses [INLINECODE]strtod[/INLINECODE] to be a little more stringent. | |
This code snippet actually contains a few nifty things. There are two functions, hasVisited() and main(). hasVisited() makes use of a very handy function for CGI programmers: getenv. You can see I use it to retrieve REMOTE_ADDR which is the person's IP address. In main() it gets the count from … | |
This little snippet combines a Tkinter GUI application with sound from the pygame mixer. The snippet should do fairly well across platforms. I tested it on a Windows XP machine, but let me know your experience with other platforms. | |
The program uses doubly linked lists to store the numbers where each node contains a single digit . Hence numbers of any length can be used as operands . Program works only with +ve integers | |
This is ASP script to enable lookup country, region, city, latitude, longitude, ZIPcode, Timezone and netspeedomain and netspeed from IP address by using IP2Location database. Free sample database available at [URL]http://www.ip2location.com[/URL]. The script supports several database types such as Microsoft Access, MS SQL and mySQL. Internet geolocation has been widely … | |
You want your object to do a number of different things when it's clicked, and you've used up onmouseup, onmousedown and onclick. There are some properietry solutions to this, but it's quite a simple thing really. Copy and paste the MultiHandle object into an empty js file, include it in … | |
Ever wanted to evaluate a user-provided expression, maybe from a form input or otherwise, and return the result? eval($expr) is dangerous because eval(open $out, "> file.what"); will open the file, infact, eval(everything) will pretty much do everything. checking though everything is tedious, and manually parsing everything seems like a waste … | |
Regex to match the dd/mm/yyyy date format. | |
This can be used for plotting radioactive decay of an unlimited* number of elements, decaying into each other. *Limited only by memory and user attention span. | |
![]() | This game takes a random word from a list, gives you five prompts to guess letters in the word, and then it shows you a "masked word," filling in the letters you've guessed. Say the word is "hockey" and the user guesses: 'h,' 'e,' 't,' 'r,' and 's.'The masked word … |
the code now contains snippet to create the linked list too! any questions can be directed to [U]raghu_tillu@hotmail.com[/U] | |
The snippet shows the use of a list of class instances to form a sortable and searchable database for solvents, or for that matter other chemicals. The list can be expanded and all the needed data added at the same time. | |
![]() | A simple example of date (day and month) translation. The code is for Welsh, but can be easily modified for any language - especially those without "full" support. I have used the code in a footer to display the last updated date and time. //EDIT - a few years later … |
You can use the Tkinter canvas and the canvas.create_line() function to draw a line plot of a mathematical function. The canvas.create_line() function accepts a list of x, y points that you can create within a for loop. The resulting plot is centered and can be stretched along the x and … | |
The wxPython GUI tool makes it very simple to create nice looking analog clock. The analog clock component was put into simple dialog frame and can be moved about the screen. | |
For those of you who live at home, run this on your parents' computer fullscreen, blue background, white font. Then put the mouse over the block in the upper lefthand corner, and enjoy the show.:twisted: | |
This code will let you play Battleship against the computer (bad graphics, I know) for a while, upon which it quits without so much as an error message. Could an experienced coder look this over and tell me why? Thanks. Venomlash :?: | |
Hello to everyone out there. Recently many people on different forums have been asking how to make a recursive function which reverses the string passed to it. But unlike the normal recrusive funtion which only prints out the reversed string, this implementation returns a pointer to reversed string. | |
Based on [url]http://astronomy.swin.edu.au/~pbourke/geometry/insidepoly/[/url] Converted to Delphi by Lord Soth | |
The program parses the digits in the number supplied to it and converts it to aplhabetical equivalent. Fore eg. input: 1234 output: one two three four This is a simple exercise for newbies, must try out. Tested and works under ideal input conditions. | |
A list of tuples is easy to sort for items in the tuples. This snippet shows you how to sort a (character, frequency) tuple either by character or by frequency. One useful example would be the sorting and display of a list of (player, score) tuples, you might find in … | |
This is my first working perl script that does anything useful; that being to count the hits made on a web page and display the count graphically. To make the counter work on your web page (should you wish to), you will need to create images for the number tiles … | |
This is a short code example using the function os.stat() to get some of the basic file information. Things like file size, times the file was created (Windows), last modified, and last accessed. The program uses a dictionary in an interesting way to store and display the information. The times … | |
This Python code shows a way to retrieve a picture from a web page and save it to a file. | |
This algorithm proved to be effective when two images are combined. The picture beneath (background) is seen if alpha component of fronth picture is less then 0xFF. If alpha of front picture (src in snippet) is zero then all we see is background picture. The format of colour is ARGB … | |
Java Code that creates a random number between 1 and 100 and then asks the user to guess the number and tells if the guess was too high, too low or, the right number. Loops until right number is guessed. | |
A simple program to calculate combinations of a string using recursion, I have used a malloc string of size 100 , you can change it to whatever value you want. The author is currently working at Microsoft. for eg if input string is abcd and you want all 3 letter … | |
Convert 1000000 into 1,000,000 using a perl regexp. | |
[LEFT]This is a program I wrote for my x86 assembly class which revolves a "roulette wheel" around. Wait about a minute and it will eventually slow down to a stop. It uses Irvine32.inc which came with the textbook.[/LEFT] | |
This is a program I wrote for my x86 assembly class which bounces an ASCII ball across the screen. It uses Irvine32.inc which came with the textbook. | |
Use the List::Util module. I believe List::Util is a core module starting with perl 5.8. For older versions of perl you may need to install the module. See the module documentation for more details: [URL="http://perldoc.perl.org/List/Util.html"]List::Util[/URL] | |
I've seen this question (or similar) asked many times on forums: I have a variable in a file (text) and want to expand it. For example, I have this line in a text file: Mary had a little $lamb and I want to be able to expand $lamb but text … | |
"How can I find all the permutations of a list (or a word)"? I have seen this question asked a number of times on forums. There is a module that makes this task very easy: List::Permutor. It is not a core module so you may need to install it. See … | |
You will need to install the Email::Valid module if it's not already installed. See the module documentation for further details. [URL="http://search.cpan.org/~rjbs/Email-Valid-0.176/lib/Email/Valid.pm"]Email::Valid[/URL] | |
The [URL="http://perldoc.perl.org/File/Basename.html"]File::Basename[/URL] module is used to parse file paths into directory, filename and suffix (or file extension). My simple example shows how to get just the file extensions. |
The End.