Saturday, March 23, 2013

Beginning jQuery (Beginning Apress)


Beginning jQuery is your step-by-step guide to learning the jQuery library. jQuery is the most popular JavaScript library in the web developer’s toolkit. Jack Franklin takes you from the basics of getting you started with jQuery, right through to extending jQuery by writing your own plug-ins. You'll discover best practices you can follow, how you can avoid common mistakes, and you'll learn about so many of the things that jQuery has to offer, including how you can:
  • Use jQuery’s powerful tools to dynamically update content on your site, including DOM manipulation.
  • Extend jQuery’s capabilities by writing your own plugins on top of the framework.
  • Animate elements and build your own jQuery slider.
  • Employ best practices and avoid common errors made by beginners.
JavaScript is a powerful language but every web developer must navigate the tricky issues around cross-browser inconsistencies. Beginning jQuery teaches you how to use jQuery to avoid spending your time fixing these browser bugs - letting you concentrate on what really matters to you. Throughout Beginning jQuery, you'll discover how expressive yet concise jQuery’s code is and how much quicker and efficient you can develop with jQuery!

What you’ll learn

  • Learn why jQuery is so popular and how to get started.
  • Use jQuery’s powerful manipulation tools to dynamically update your website’s content.
  • Animate content and build your own image slider with jQuery’s animation tools.
  • Extend the library by writing your own custom plug-ins.
  • Avoid common beginner errors, and learn how to use best practices.
  • Use plug-ins created by others in the community and integrate them into your website.

Who this book is for

Beginning jQuery is for the web developer confident with HTML and CSS and now ready to get to grips with JavaScript. If you’ve tried to integrate some JavaScript into your website and wondered how you could add functionality easier, jQuery is for you. Beginning jQuery is great for the developer wanting to enhance their skillset and learn new tools.

Table of Contents

  1. JavaScript You Need to Know
  2. The Basics of jQuery
  3. DOM Traversal with jQuery
  4. DOM Manipulation with jQuery
  5. An Introduction to Events
  6. Advanced Events
  7. Animation
  8. Ajax with jQuery
  9. Writing a jQuery Plug-in
  10. Advanced jQuery Plug-ins
  11. Writing a Slider Plug-in

Wednesday, March 20, 2013

Python: set font of tkinter.Label

Set font of tkinter.Label
Set font of tkinter.Label


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

import tkinter

def quit():
    global tkTop
    tkTop.destroy()

def setTextSize(ev=None):
    global tkLabel
    global tkScale
    tkLabel.config(font="Helvetica -%d bold" %tkScale.get())

tkTop = tkinter.Tk()
tkTop.geometry('300x200')

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

tkLabel = tkinter.Label(text="Hello Python")
tkLabel.pack()

tkScale = tkinter.Scale(tkTop, from_=1, to=40, orient=tkinter.HORIZONTAL, command=setTextSize)
tkScale.set(18)
tkScale.pack(anchor=tkinter.CENTER)

tkinter.mainloop()


Implement Scale bar of Tkinter

Scale bar of Tkinter
Scale bar of Tkinter


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

import tkinter

def quit():
    global tkTop
    tkTop.destroy()

tkTop = tkinter.Tk()
tkTop.geometry('300x200')

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

tkScale = tkinter.Scale(tkTop, from_=1, to=30, orient=tkinter.HORIZONTAL)
tkScale.set(18)
tkScale.pack(anchor=tkinter.CENTER)

tkinter.mainloop()


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