Wednesday, March 20, 2013

Tkinter, set window size using geometry

set window size using geometry
set window size using geometry


#tkinter for Python 3.x
#Tkinter for Python 2.x

import tkinter

tkTop = tkinter.Tk()
tkTop.geometry('300x200')
tkButtonQuit = tkinter.Button(tkTop, text="Quit", command=tkTop.quit)
tkButtonQuit.pack()
tkinter.mainloop()


Simple example using tkinter Button with command

example using tkinter Button with command
example using tkinter Button with command


#tkinter for Python 3.x
#Tkinter for Python 2.x

import tkinter

tkTop = tkinter.Tk()
tkButtonQuit = tkinter.Button(tkTop, text="Quit", command=tkTop.quit)
tkButtonQuit.pack()
tkinter.mainloop()


Simple example using tkinter Label

Simple example using tkinter Label
Simple example using tkinter Label



#tkinter for Python 3.x
#Tkinter for Python 2.x

import tkinter

tkTop = tkinter.Tk()
tkLabel = tkinter.Label(tkTop, text="Hello python.beginner")
tkLabel.pack()
tkinter.mainloop()


Monday, March 18, 2013

Check if Tkinter installed in Python

Tkinter is Python's de-facto standard GUI (Graphical User Interface) package. It is a thin object-oriented layer on top of Tcl/Tk.

To check if Tkinter installed, type the following command in IDLE(Python Shell), for Python 2.x:

>>> import Tkinter


import Tkinter for Python 2.x
import Tkinter for Python 2.x


for Python 3.x:

>>> import tkinter

import tkinter for Python 3.x
import tkinter for Python 3.x


Install Python on Ubuntu

To install Python on Ubuntu. simple search Python in Ubuntu Software Center.

Install Python on Ubuntu
Install Python on Ubuntu


You can install both Python 2.x and 3.2 together.

Both Python 2.7.3 and 3.2.3 installed
Both Python 2.7.3 and 3.2.3 installed

google-code-prettify: syntax highlighting of source code in html page



google-code-prettify is a Javascript module and CSS file that allows syntax highlighting of source code snippets in an html page.

For an example, see the README.

Features
  • Works on HTML pages
  • Works even if code contains embedded links, line numbers, etc.
  • Simple API : include some JS&CSS and add an onload handler.
  • Lightweights : small download and does not block page from loading while running.
  • Customizable styles via CSS.
  • Supports all C-like, Bash-like, and XML-like languages. No need to specify the language
  • Extensible language handlers for other languages. You can specify the language.
  • Widely used with good cross-browser support. Powers code.google.com and stackoverflow.com


Sunday, March 17, 2013

Getting started with wxPython


Hello World using wxPython

wxPython is a GUI toolkit for the Python programming language. It allows Python programmers to create programs with a robust, highly functional graphical user interface, simply and easily. It is implemented as a Python extension module (native code) that wraps the popular wxWidgets cross platform GUI library, which is written in C++.

Like Python and wxWidgets, wxPython is Open Source which means that it is free for anyone to use and the source code is available for anyone to look at and modify. Or anyone can contribute fixes or enhancements to the project.

wxPython is a cross-platform toolkit. This means that the same program will run on multiple platforms without modification. Currently supported platforms are 32-bit Microsoft Windows, most Unix or unix-like systems, and Macintosh OS X.

Getting started with wxPython >>