The Tkinter Canvas Widget

The Canvas widget provides structured graphics facilities for Tkinter. This is a highly versatile widget that can be used to draw graphs and plots, create graphics editors, and implement various kinds of custom widgets. When to use the Canvas Widget  The canvas is a general-purpose widget, which is typically used to display and edit graphs and other …

The Tkinter Canvas Widget Read More »

Tkinter Popup Menus

Tkinter is a standard library in Python that is used to create Graphical User Interface (GUI) based desktop applications. It is pronounced (Tk inter).  You can learn more about Tkinter in the tkinter tutorial. How to create pop-up menus in tkinter?

HTTP 404 Error, htp 404

In this post, we have talked about http 404 which is also misspelled some time as htp 404. Have you ever come across a situation where you eagerly click on a link, hoping to discover something interesting or valuable, only to be met with a disappointing message? The HTTP 404 error, also known as the …

HTTP 404 Error, htp 404 Read More »

The email Package

(New in 2.2) Tools for manipulation of all sorts of email messages. The email package replaces simpler modules, such as rfc822 and mimetools, with a much more flexible message object, and associated parsers. Parsing Messages  The easiest way to parse messages is to use the message_from_file or message_from_string helpers in the email toplevel module. The former takes a file handle, the latter a string object: Parsing …

The email Package Read More »

Pixel Access Objects

I just added support for a new “pixel access” method to PIL 1.1.6. The load method now returns a pixel access object, which behaves like a 2-dimensional mapping. You can use the access object on both sides of an assignment statement; as an expression, it fetches the given pixel value, and as an assignment target, it updates …

Pixel Access Objects Read More »

SQLite Basics

The SQLite library is a light-weight embedded SQL engine, with a nice DB API compliant Python binding, originally developed by Michael Owens. A newer version, called sqlite3, was added to Python’s standard library in Python 2.5. import sqlite3 db = sqlite3.connect(“database.db”) c = db.cursor() c.execute(“create table mytable (timestamp, size, file)”) for file in os.listdir(“.”): c.execute( “insert into mytable values (?, ?, …

SQLite Basics Read More »

Is it possible to write obfuscated one-liners in Python?

Is it possible to write obfuscated one-liners in Python? Yes. Usually this is done with nested lambda forms. See the following three examples, due to Ulf Bartelt: # Primes < 1000 print filter(None,map(lambda y:y*reduce(lambda x,y:x*y!=0, map(lambda x,y=y:y%x,range(2,int(pow(y,0.5)+1))),1),range(2,1000))) # First 10 Fibonacci numbers print map(lambda x,f=lambda x,f:(x<=1) or (f(x-1,f)+f(x-2,f)): f(x,f), range(10)) # Mandelbrot set print (lambda Ru,Ro,Iu,Io,IM,Sx,Sy:reduce(lambda x,y:x+y,map(lambda y, …

Is it possible to write obfuscated one-liners in Python? Read More »

The Standard Python Library: New Modules in Python 2.1

__future__ A registry of features supported by the from __future__ compiler directive.difflib Tools to detect differences and calculate deltas between lists of objects.distutils (package) Tools to distribute and install Python extensions.doctest A test framework, based on docstrings. To use this for general testing, you can write test scripts and use doctest to make sure the test scripts work as …

The Standard Python Library: New Modules in Python 2.1 Read More »

The Tkinter BitmapImage Class

The Tkinter BitmapImage Class The BitmapImage class provides a simple image class, for monochrome (two-color) images. When to use the BitmapImage Class This class can be used to display bitmap images in labels, buttons, canvases, and text widgets. The bitmap loader reads X11 bitmap files. To use other formats, use the PhotoImage class. Patterns An X11 bitmap image consists of …

The Tkinter BitmapImage Class Read More »

A Python Code Generator

A Python Code Generator A common complaint about Python’s syntax is that it’s impossible to generate Python code on the fly, from a program. Here’s a simple helper class that helps you do exactly that: # # a Python code generator backend # # fredrik lundh, march 1998 # # fredrik@pythonware.com # http://www.pythonware.com # import sys, …

A Python Code Generator Read More »

The ImageGrab Module

The ImageGrab Module The ImageGrab module can be used to copy the contents of the screen or the clipboard to a PIL image memory. The current version works on Windows only. Functions  grab  ImageGrab.grab() ⇒ image ImageGrab.grab(bbox) ⇒ image (New in 1.1.3) Take a snapshot of the screen, and return an “RGB” image. The bounding box argument can be used …

The ImageGrab Module Read More »

Element Library Functions

Element Library Functions March 22, 2004 | Fredrik Lundh ElementTree 1.3 may include a new module, ElementLib, with a number of convenient helper functions. The exact contents are yet to be determined; here are some of the current proposals (from various sources, in no specific order): Helpers to add subelements, with a nicer syntax. Wrappers to access …

Element Library Functions Read More »

Idea In Progress: Dynamic Creation of Type Description

Idea In Progress: Dynamic Creation of Type Description In today’s Python, type records are implemented as ordinary struct‘s, using a flag field to indicate what version of the struct a given extension implements. You can see an example on this page (dead link) (Scroll down to the “static PyTypeObject NoddyType” definition). I propose to replace this with a …

Idea In Progress: Dynamic Creation of Type Description Read More »

Host Europe Webmailer

Host Europe Webmailer Host Europe is a web hosting company based in Germany. They provide various hosting services, including web hosting and email hosting. If you are a customer of Host Europe and want to access the Host Europe Webmailer, you can follow these steps: What is Host Europe? Host Europe is a company that …

Host Europe Webmailer Read More »

Outsource web development services

Outsourcing web development has become an increasingly popular strategy for businesses looking to optimize their resources and stay competitive in the digital landscape. In this post, we will explore the benefits and considerations of outsourcing web development services. What is web development outsourcing? Web development outsourcing refers to the practice of hiring external individuals or …

Outsource web development services Read More »

Tkinter Classes

Widget classes Tkinter supports 15 core widgets: Button A simple button, used to execute a command or other operation. Canvas Structured graphics. This widget can be used to draw graphs and plots, create graphics editors, and to implement custom widgets. Checkbutton Represents a variable that can have two distinct values. Clicking the button toggles between …

Tkinter Classes Read More »

The StringIO module

This module implements an in-memory file object. This object can be used as input or output to most functions that expect a standard file object. Example: Using the StringIO module to read from a static file # File: stringio-example-1.py import StringIO MESSAGE = “That man is depriving a village somewhere of a computer scientist.” file …

The StringIO module Read More »