Hi, I'm having trouble with a tk scale widget. So far no one at the python forum has an answer so I found this site. As long as the resolution is set to 1, the start value can be anything I want but as soon as I set the resolution any higher it changes the start value. Ex: I have from_=3 for a start parameter. Here's what I get for different resolutions r: r start 2 4 3 3 4 4 5 5 6 6 7 0 8 0 9 0 10 0 And if I want my start to …
|+0 forum 5|
Code Snippet Check if a number is a prime number (Python)
This simple isprime(number) function checks if the given integer number is a prime number and returns True or False. The function makes sure that the number is a positive integer, and that 1 is not considered a prime number. To find out if an integer n is odd one can use `n & 1`, to check for even one can then use `not n & 1` or the more traditional `n % 2 == 0` which is about 30% slower.
|+2 forum 36|
Code Snippet To create login program in python
|+0 forum 1|
Code Snippet Sending Text to the Printer (Python)
The printer seems to be a much ignored computer peripheral when it comes to programming. This little code snippet explores one way to send text to the default printer. It actually draws the text into an imaginary box on the paper. You can specify the upper left and lower right corners of this box.
|+2 forum 1|
Code Snippet Tkinter Keypress Event (Python)
If you press any key on your keyboard, this small Tkinter GUI program will tell you which key and what type of key has been pressed. Great for applications where a simple key stroke is required.
|+1 forum 1|
Code Snippet wxPython Plays Audio and Video Files
An example showing how to use the wx.media.MediaCtrl() widget to play MIDI, MP3, WAV, AU, AVI and MPG audio and video files. I have only tested it with Windows. If you are very ambitious, you could use a random graphics display with the sound, or tie the slider position to a slide presentation.
|+2 forum 7|
Code Snippet Tkinter Digital Clock (Python)
This short Python code gets the local time from the PC as a formatted string using time.strftime('%H:%M:%S'). The time string is displayed in a label using a larger font. A recursive function checks the time five times per second, and updates the time string, if it has changed. Five times per second may sound like overkill, but keeps the display from acting spasmodic.
|+2 forum 13|
Code Snippet Hide Private Message in an Image (Python)
Let's say you want to send a short private message to your friend, but don't want grandma to snoop around and find it. One way is to use the Python Image Library (PIL) and hide the message in a picture file's pixels. Just looking at the picture you will barely detect any difference between the before and after picture. All your friend needs is the decode_image portion of this simple code to get the message back.
|+5 forum 15|
Code Snippet Simple Tkinter Toggle Button
A simple way to create a toggle button for the Tkinter Python GUI toolkit.
|+1 forum 13|
Code Snippet Display An Image From A URL (Tkinter, Python)
This code shows how to obtain and display a GIF image from an internet website using the Tkinter GUI toolkit that comes with the Python installation.
|+4 forum 7|
Code Snippet Tkinter Image Slide Show (Python)
Shows how to create a basic slide show with the Python Tkinter GUI toolkit.
|+4 forum 19|
Code Snippet A tooltip class for Tkinter
This class gives a specified Tkinter widget a tooltip that appears as the mouse is above the widget. You can improve the code by putting in a time delay.
|+7 forum 4|
This is one small snippet of after event usage. You could express if you find this kind of simple code to be usefull as snippet. Notice also vegaseat's sticky message threads in begining of Python forum in addition to code snippets.
|+0 forum 4|
Code Snippet A Simple PySide Digital Clock
PySide (public license PyQT) is my preferred Python GUI toolkit. Here we explore how to test some of the widgets available and create a digital clock.
|+3 forum 2|
Code Snippet Creating and playing a sine wave sound (Python)
This code creates a sound file in Sun's simple AU audio format of a sine wave of given frequency, duration and volume.
|+1 forum 4|
Code Snippet Number to Word Converter (Python)
Sometimes when you get a large check from your employer, the value is written out in words. I get those all the time of course. So I wrote this little Python code to convert an integer value to english words. Numbers as high as 999 vigintillion can be used. In case you don't know, a vigintillion is 10 to the power 60. That is what our national deficit will be soon.
|+3 forum 4|
Code Snippet Embed and Play Midi Music in your Code (Python)
Another application of Python module base64, this time to embed midi music data in your program. You also need the module pygame to execute this Python code. Enjoy the music!
|+5 forum 9|
Code Snippet An Image Button (Python and Tk)
You can put an image and text on a Tkinter button widget. This small code shows you how. The GIF image file you want to use for the button should be in the working directory, or you have to give it the full path. Incorporate the Python Image Library (PIL) for other image formats.
|+1 forum 3|
Code Snippet Tiny Tkinter Calculator (Python)
Just a relatively simple calculator using the Tkinter GUI. It has a few nice features such as correcting division by an integer (for older Python versions), error trapping, to and from memory buttons, and an editable display. The editable display allows you to backspace mistakes, and also to enter things not on the key pad, like hexnumbers. For instance if you enter 0xFF and press equals, it will give you the decimal (denary) equivalent of 255 The program also has a guard against the bad guys that like to abuse the underlying eval() function to wipe out files. I wrote …
|+5 forum 14|
Code Snippet Restart your python program.
This snippet defines a function restart_program() which restarts your python program from within your python program.
|+4 forum 27|
Code Snippet secure proxy objects for frontend API
**Usage:** Provides a secure frontend object with restricted access to attributes of the backend object.
|+0 forum 1|
Code Snippet Turtle random fun (Python)
A little fun with Python's turtle module drawing a number of random stars in the dark sky.
|+2 forum 3|
Code Snippet Display an image from the WEB (PyGame)
A short example of Pygame showing an image with a known internet url.
|+0 forum 1|
Code Snippet Count seconds in the background (Python)
Use Python module threading to count intervals (in seconds) in the background. You can use this to time any relatively slow event like the time it took to finish a game or play some music. You can also peek at the current interval value as the event goes on. Go ahead and explore. Just an example how to run time.sleep() in a thread.
|+0 forum 6|
Code Snippet A List of Class Objects (Python)
A list of class objects mimics a C array of structures. The snippet explores how to setup the list, and sort the list according to a selected attribute. Then we use a format string to display the sorted list. Take a look at how to search the list. All in all an easy way to handle structured data.
|+2 forum 5|
Code Snippet Farmer crossing river with wolf, duck, bag of corn
This snippets contains a python program to find a shortest solution to the problem of the farmer who whishes to cross a river. The boat can only contain two things, including the rower. The farmer comes with a wolf, a duck and a bag of corn, and he can't leave the duck alone with one of the other items because the wolf would eat the duck, or the duck would eat the corn. The program shows how to use a `collections.OrderedDict` to implement a stack without repetitions. This is used to traverse a tree of states. These states, encoded as …
|+0 forum 5|
Code Snippet Applying PySide's QAbstractTableModel
Using PySide's QAbstractTableModel allows you to easily customize a widget like QTableView and make it more generic in its application. Here we use it to present solvent data in tabular form and sort each column content by simply clicking on the header. You can feed it any data as long as you stick to the format of the data used, a header list and a list of data tuples/lists.
|+4 forum 7|
Code Snippet Tkinter to put a GIF Image on a Canvas (Python)
The Tkinter module comes with the normal Python installation. It allows you to create Python GUI programs for Windows, Linux or Unix on the Mac. In this snippet we put a GIF image (.gif) onto a form's canvas with just a few lines of code. Most of the lines are remarks to explain what is going on.
|+0 forum 6|
Code Snippet Read PDF Files with wxPython
Using the wx.lib.pdfwin.PDFWindow one can read Adobe PDF files (.pdf) with wxPython. The PDF file format is popular document file format allowing mixing of text and graphics. The GUI toolkit wxPython's newer wx.activex module allows one to use the ActiveX control, as if it would be one wx.Window. It actually embeds the Adobe Acrobat Reader into the wx.Window.
|+0 forum 9|
Code Snippet Exploring Tkinter's ScrolledText Widget (Python)
The Tkinter GUI toolkit comes with a scrolled text widget that is called ScrolledText. To get access to it you have to import it separately. It allows you to display large amounts of text in a small space.
|+0 forum 2|