15,190 Topics

Member Avatar for
Member Avatar for bumsfeld

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.

0
724
Member Avatar for vegaseat

Another famous fractal called the Sierpinski Triangle named after Polish mathematician Waclaw Sierpinski. He seemed to have played around with it the most. To state it simple, you start with an equilateral triangle and then form smaller triangles by connecting the midpoints of each of the sides. Some folks shade …

1
1K
Member Avatar for Ene Uran

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 …

0
248
Member Avatar for vegaseat

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 …

0
2K
Member Avatar for vegaseat

There are situations in Python code when a function is used as an object rather then a function call. Handling arguments becomes a mild problem, that can easily be handled by wrapping the function object and its arguments. One common way is the use of a curry function or class. …

1
201
Member Avatar for vegaseat
Member Avatar for RonaldDuncan
0
2K
Member Avatar for vegaseat

Some computer languages have a goto statement to break out of deeply nested loops. Python has chosen not to implement the much abused goto. There are other, really more elegant, ways to accomplish the same outcome. Here are three examples.

Member Avatar for jrcagle
1
3K
Member Avatar for bumsfeld

Here we search a Python script file (or other text file) for one certain string, and copy any files containing this string to another folder.

0
210
Member Avatar for bumsfeld

Search for a file given its name and the starting search directory. The search is limited to a set depth of subdirectories. Python makes this easy to do.

0
218
Member Avatar for bumsfeld

This Python code will search for given filename starting with given directory. It will also search all the subdirectories in the given directory. The search will end at the first hit.

0
150
Member Avatar for bumsfeld

Code snippet to show you how to verify exit events from wxPython using dialog window. One event is from menu exit and the other from frame exit (x symbol in corner).

0
709
Member Avatar for bumsfeld

This short code shows how to indicate the mouse-over event on wxPython button, similar to the mouse-over in web pages. Button changes colour when mouse pointer is over its area.

0
2K
Member Avatar for bumsfeld

The myth is around that while loop is faster than the corresponding for loop. I checked it out with Python module timeit, and came to surprising conclusion. This snippet can easily be modified to time any of your functions you write.

Member Avatar for Begjinner
0
2K
Member Avatar for vegaseat

Yet Another Calculator using wxPython, smaller, but more advanced than the previous one. Wrote this one to test the Curry class, but it didn't work well. So there is no curry there. I found out that one has to be careful with the eval() function. If you write 012 instead …

1
152
Member Avatar for vegaseat

Let mathematics do your art work! It is amazing how a simple mathematical formula can draw very intricate shapes. Here we draw a fractal tree on a Python Image Library (PIL) blank image, and save the finished drawing as an image file in one of the popular formats. Look at …

0
683
Member Avatar for vegaseat

The wx.BitmapButton shows an image, great for those folks who think that a picture is worth a thousand words. The snippet gives an example how to load the image, size the button, and put the image on the the button.

Member Avatar for InfoClock
0
818
Member Avatar for bumsfeld

The program takes text and establishes dictionary of character:frequency. This dictionary is then presented sorted by character. Since it is important to show the most frequent characters, two methods are given to present dictionary sorted by frequency. Should all be very good for learning Python.

0
616
Member Avatar for vegaseat

Just a small Python program to calculate monthly payments and other costs. I have compared it with some of the calculators available from many of the online mortgage companies, and results seem to match.

2
1K
Member Avatar for vegaseat

In this snippet we are playing around with wxPython's buttons, showing you how to bind the mouse click event, enable and disable, show and hide the buttons. Each button also has a tool-tip (hint) associated with itself.

Member Avatar for Racoon200
0
4K
Member Avatar for vegaseat

If you want a variable in a C function to retain its last assigned value, you simply declare it as static. Python does not have static variables, but you can impersonate one in different ways. The default list argument is my preferred option. Here are some examples.

0
600
Member Avatar for vegaseat

Py2Exe takes your Python code file and packages it into an executable file that you can distribute to a client that does not have Python installed. The executable file contains your byte code, all the required modules and the Python interpreter. It is not a small file. The snippet is …

Member Avatar for Aestter
1
373
Member Avatar for bumsfeld

Do you think that people act demented during full moon nights? This small python program will tell you moon phase of a date you give it, so you can take precautions!

0
4K
Member Avatar for vegaseat

This small snippet shows how to load and display HTML (Hyper Text Markup Language) with wxPython's HtmlWindow(). This could be particularly useful with instruction and help text. HTML allows you to include pictures, fancy fonts and links.

0
1K
Member Avatar for vegaseat

When I first met folks in Las Vegas that used biorhythm values of the top players in a team to place their bet, I thought they were a little odd. Some of them were successful, but I am sure biorhythms were not the only thing they considered. You can read …

0
3K
Member Avatar for vegaseat

Just in time, a short Python code snippet to calculate the date of Easter Sunday of a given year. This can be expanded to calculate the important date of Mardi Gras too.

0
4K
Member Avatar for vegaseat

I took the data of an old State Trivia game and applied it to Python. The data forms a series of lists with matching indexes. One example of how to ask a trivia question, present four possible answers, and how to evaluate the correct answer is given. You can expand …

0
744
Member Avatar for bumsfeld

Question of wordcount program similar to Unix wc came up in the forum and I worked on a solution. Program shows number of lines, number of words, number of characters and text file's name. Good learning for commandline, file and string handling.

1
3K
Member Avatar for bumsfeld

The little program allows eye patients to test their color skills. They are given a random color rectangle by the computer and are then asked to match the color as closely as they can using sliders of the three basic colors. An evaluation button examines the closeness of the results.

0
409
Member Avatar for vegaseat

A list comprehension derives a new list from an existing list, and was adopted by Python from the Haskell language. This snippet tries to explain the development of list comprehension and shows a number of uses, including nested list comprehension. The benefits are simplicity (after an initial learning bump) and …

1
249
Member Avatar for vegaseat

The lowly soundcard in your PC has fascinating capabilities. All you need is a module that can handle the Musical Instrument Digital Interface (MIDI). Tell the soundcard which instrument to play, specify the musical note, the duration, the beat and other things. The sound chip makes 127 instruments available and …

Member Avatar for caribedude
1
674

The End.