4,305 Posted Topics

Member Avatar for vegaseat

Years ago I wrote a little screen-saver in Delphi that randomly put colorful circles all over the screen. A hit with the secretaries in the office. I modified a simple Tkinter based snippet to put the same colorful circles all over a window form at random locations, random radii and …

0
1K
Member Avatar for bumsfeld
Member Avatar for vegaseat
0
283
Member Avatar for vegaseat

VPython's fame is with 3D animated modeling, but it's plotting abilities, while not flashy, are easy to understand and very useful. This program uses VPython to plot math functions y = sin(x) and y = cos(x) and y = sin(x)*cos(x).

2
305
Member Avatar for vegaseat

This question came up on the forum. How do you swap two numbers without using a temporary variable? I used all the power of my brain to solve this at four o'clock in the morning. In all fairness, swapping two numbers using a temporay variable is about five times faster. …

Member Avatar for Duoas
0
222
Member Avatar for vegaseat

Python has a module specifically made for timing built-in or owner coded functions. This code snippet explains how to use this feature.

1
243
Member Avatar for vegaseat

The psyco module has been around for a while and has been used to speed up the Python interpreter. For those of you who think speed is all important, take a look at a typical example. Psyco is similar to Java's just in time compiler. How does psyco do it? …

0
226
Member Avatar for vegaseat

Python24 introduces the function decorator that lends itself nicely to the timing of a function. As a sample function we are using the ever popular and rather stodgy prime number generator. The prime number generator seems to exist only to fluster students and to make niggling comparisons of the speed …

Member Avatar for vegaseat
1
2K
Member Avatar for vegaseat

The Python module zlib allows you to compress a typical text string to about one half its original size. A handy feature when you have to transmit or save a large amount of text or data. It saves you time both writing and later reading back the compressed file. The …

0
1K
Member Avatar for vegaseat

Python uses C syntax to perform bitwise operations. Take a look at code that introduces you to bitwise operations at the binary level.

1
304
Member Avatar for vegaseat

If you have a Windows computer you can play musical beeps through the internal speaker. In this case it will sound like a very tiny Big Ben, brought to you by the module winsound and its method Beep().

2
2K
Member Avatar for vegaseat

Did you ever want to know how how many square inches are in a square meter? This short Python code allows you to get the answer. It uses a dictionary to simplify the conversions. Could be the start of a nice GUI program using radio buttons.

Member Avatar for vegaseat
2
3K
Member Avatar for vegaseat

The Python list container can be used for many practical things. In this somewhat light-hearted introspection of modern day politics we are looking at two lists and attempt to clear out elements that shouldn't be in both lists. No offense to anyone is intended, the outcome with the sets was …

Member Avatar for vegaseat
2
227
Member Avatar for vegaseat

A while ago I created a code snippet in C for the same question. Solving this question with Python is a lot simpler, and on top of that Python takes care of impossible dates with the appropriate error message.

Member Avatar for Lingson
2
225
Member Avatar for vegaseat

A simple experiment with the ever so popular Mandelbrot fractal graphics, call it mathematical art, nice to look at. This set of experiments loops through a number of colors to make the whole thing more exciting.

Member Avatar for bumsfeld
1
181
Member Avatar for vegaseat

Jumping through a few extra hoops allows you to display the common image format jpeg on a panel of the wxPython GUI window. All you need to do is to read in the image file as a binary, convert to a byte stream image and then to a bitmap. Now …

Member Avatar for Erik Vandamme
0
3K
Member Avatar for vegaseat

The other day I was looking at my family tree. There are my parents Antonio and Lucy Vegaseat, then my grandparents Alfonso and Ludmilla Vegaseat on my father's side and Roland and Helga Gruenspan on my mother's side. Then come my great grandparents, by now there are eight of those. …

Member Avatar for vegaseat
0
198
Member Avatar for vegaseat

While the calculation of the total resistance of two resistors in parallel is simple, this code shows you how to trap a number of potential errors that come with the entry of the required data. All is wrapped easily into a colorful GUI program, due to the simplicity of the …

2
3K
Member Avatar for vegaseat

The wxNotebook method from the wxPython module allows you to show a lot of data in a limited window space. It brings up tabbed pages you can click on to open each page. Enough said, run the code and experience the possibilities this humble method gives you.

Member Avatar for vegaseat
0
301
Member Avatar for vegaseat

This is another GUI program using the Tkinter module. It shows you how to change the background and foreground color of a component/widget. In this case it is a button. The button itself is used to toggle the color selection via a color dialog box. Enough comments have been added …

0
905
Member Avatar for iacobus

Don't feel too bad. I don't think the DaniWeb code-field handles foreign characters. I had trouble with spanish characters too, and they are simple ASCII. Interesting project though!

Member Avatar for vegaseat
0
158
Member Avatar for vegaseat

I was looking for a somewhat meaningful and interesting example to explain the Python class to beginners. A room full of multilingual students makes this phrase translator a good choice. You can experiment with it and add more languages and phrases.

Member Avatar for vartotojas
1
207
Member Avatar for vegaseat

Python's Tkinter module can be used to create a Graphics User Interface (GUI). This sample code creates a windows type form and positions a label and a canvas on the form. A simple shape is drawn on the canvas.

0
242
Member Avatar for letmec
Member Avatar for vegaseat

A common way to represent an inventory is with a list of tuples. Each tuple represents the item name and the item count. You can sort this inventory list by item name or item count. Here is an example to pick a sort key. It's your summer job to run …

1
582
Member Avatar for vegaseat

Where you ever curious what the most common letter is in a typical text file? Just another question to ask a friend. The answer is right here in this tiny code snippet. The program converts the text to all lower case letters, and then list them out alphabetically showing the …

Member Avatar for programtrav
0
188
Member Avatar for vegaseat

The module datetime allows you to call several functions that can do computation with dates and times. How many days since my birth? How many days till Xmas? What's the date 77 days from now? The code snippet should give you a flavor, enough to explore on your own.

2
823
Member Avatar for vegaseat

Many of the code samples on the internet are written in Turbo C. The clrscr() function litters these samples, and even to this day people want to wipe your screen. You can use system("CLS"), but that uses a DOS command. DOS commands are with us only at the whim of …

1
738
Member Avatar for vegaseat

Quick and dirty way to change your console program colors using DOS command "Color BackgroundForeground" where Background is hex 0 = black to F = white, dito for Foreground.

1
291
Member Avatar for vegaseat

The wxPython library allows Python to create Windows GUI programs. Here is a look at the listbox component. Click a button to load the listbox with names, select the name by clicking on it on the list, and display it in the title bar of the window frame. Another button …

Member Avatar for vegaseat
2
3K
Member Avatar for vegaseat

This program uses WinApi function SetPixel() to plot math functions y = sin(x) and y = cos(x) and y = sin(x)*cos(x) along a y-axis centered on the console screen. Make sure that gdi32.lib is included in the libraries to be linked.

Member Avatar for brale
2
305
Member Avatar for vegaseat

Just a simple way to separate the words contained in a sentence. As an option you can store the words in a vector. If you are not familiar with a vector, use an array instead.

0
192
Member Avatar for vegaseat

I look at BCX-basic as a modernized qbasic. This simple code creates a Windows GUI program that plays a midi instrumental music file. To keep it simple, the file it looks for is "TheRose.mid" file. If you don't have this file, you have the option of editing the code, or …

Member Avatar for billzilla
0
220
Member Avatar for vegaseat

Shows how to connect a button onclick event to a javascript function to change the background color of the document. Just cut and paste the code into Notepad or other editor, save as BGchanger.htm and run it on your browser.

Member Avatar for Mohan0704
0
191
Member Avatar for vegaseat

Remember the Spirograph? It used geared circles to create some rather artistic geometric designs. This program uses triangles to follow in the Spirograph's foot steps. The math is rather simple, just a couple of sine and cosine functions, also the ubiquitous for loops, everything wrapped up in the using() statement. …

0
173
Member Avatar for vegaseat

The set is an unordered collection of unique hashable elements. All the elements/items in a set are treated as keys. There are several functions that compare two sets. Right now, I will just give you a taste ...

3
334
Member Avatar for vegaseat

The code shows you how to create a window without a titlebar that can be dragged with the mouse. Set the FormStyle property to fsStayOnTop. The form contains a small 18 button calculator. When you create the form and calculator components, try to make it tiny, it is cute that …

0
322
Member Avatar for vegaseat

Using wxPython and the Boa Constructor, a VB/Delphi like IDE and Visual Builder, this little calculator was a breeze to make. Boa did 90% of the code generation, and I simply added code to each button click event to make the calculations work. I wish every project would go that …

Member Avatar for vegaseat
1
486
Member Avatar for vegaseat

The Simple DirectMedia Layer (SDL) library allows for manageable multimedia programming in console mode. Now you can mix graphics, animated or otherwise, with sound and make your game project more interesting. I am showing an example for Dev-C++ using math generated graphics, purloined from the NET, and give some instructions …

2
220
Member Avatar for Tight_Coder_Ex

Nice idea! We have a little thread going on DaniWeb under: [url]http://www.daniweb.com/techtalkforums/thread18331.html[/url] Would be nice to get the asm Hello World! from you.

Member Avatar for vegaseat
0
186
Member Avatar for Tight_Coder_Ex
Member Avatar for vegaseat
0
206
Member Avatar for Tight_Coder_Ex
Member Avatar for vegaseat

Many moons ago I wrote a Delphi program that could tell the exact character in a ListBox, as you clicked on it with a mouse. I found a little info on the NET that lets you get at least the item in a ListBox using C#. I made it work …

0
267
Member Avatar for vegaseat

You can look at a selected file's date and time stamp and change it with this Delphi program. XP files need a little extra TLC, but it's taken care of too.

0
547
Member Avatar for vegaseat

Swap two images as you move your mouse in and out of the image field. Uses onMouseOver, onMouseOut and a short javascript code.

Member Avatar for almostbob
0
171
Member Avatar for vegaseat

A data stream is used to load a bitmap image and convert it to a jpeg image. The converted image is displayed and saved to a .jpg file.

0
1K
Member Avatar for vegaseat

The WinBGI package allows you to do some of the Borland BGI graphics in a specially created window form. So don't throw out the old Borland manuals, you can still use them to do some fancy graphing! Yes, you can gotoxy() again! This code was modified for Dev-C++, a real …

1
571
Member Avatar for vegaseat

An example how to line up your decimal points in a column like output of floating point numbers. Both C and C++ versions are shown. Thanks are given to Bud Tugly, my 77 year old senior student.

Member Avatar for vegaseat
2
217
Member Avatar for Mahen
Member Avatar for berkcan
0
316
Member Avatar for vegaseat

Another application of the Python Image Library (PIL). This time we are loading an image and rotate it counterclockwise by a specified number of degrees. The image is shown rotated and then saved to the working folder. PIL handles a fair amount of image file formats easily.

Member Avatar for vegaseat
2
5K
Member Avatar for vegaseat

Shows a basic way to create a form with a wallpaper image on it. Also shows how to add a transparent label to blend in with the wallpaper. Getting the label to be transparent wasn't all that commodious! The wallpaper is generated using a texture brush and bitmap image. The …

0
3K

The End.