HOME       >>       Programming

Install Python On Xp And Create Two Pop-up Windows In 3 Minutes! See for yourself why Python is popular.


docduke

If you follow this tutorial you will:
1. Install Python 2.5.1 on Microsoft Windows
2. Run a one-line "Hello World" interactive program
3. Pop up a "Hello World" Windows Message Box.
4. Pop up a two-button Windows dialog box which interacts with your program.
5. Learn where to find more tutorials and documentation
The first 4 of these can be done in 3 minutes if you are focused!

This is a cookbook. Before "cooking" the recipe, you need a few ingredients:
1. Get the python installer at Python 2.5.1 Windows installer.
2. Create a folder, and know its location. Mine is at D:\b\Wins
3. Copy the following program, paste it into an editor and save it as a file in the folder.

from Tkinter import *class App: def __init__(self, master): frame = Frame(master) frame.pack() self.button = Button(frame, text="QUIT", fg="red", bg="yellow", command=master.destroy) self.button.pack(side=LEFT) self.hello = Button(frame, text="Hello", command=self.say_hi) self.hello.pack() def say_hi(self): print "Hello, new Python programmer!"root = Tk()app = App(root)root.mainloop()
I saved it as D:\b\Wins\Buttons.py

Do the preceding things to prepare for the 3 minutes. There are additional items you may need if you are on an earlier Windows platform. If your platform does not recognize a .msi Windows installer file, you may need Windows Installer 2.0 Redistributable for Windows 95, 98, and Me, or a later version for Windows 2000 or NT. The text editor you use to save the program should not convert blanks to tabs. White space is significant in Python programs, and there is no standard for how many blanks equals one tab.

Recipe:

Ready to go? Start your stopwatch!

1. Double-click the Python installer. (Take all defaults.)


2. Click Start | All Programs | Python 2.5 | Idle (Python GUI).

3. Next, type in the five-line program that appears below this outline. It is case-sensitive!

4. From the Shell menu, select File | Open, navigate to the file you saved before, and select it. In my case, it is D:\b\Wins\Buttons.py

This five-line program creates a label window using standard Windows system calls and messages. The iconize, minimize, and close buttons function as usual. Clicking the top-left corner of the window produces the same menu as right-clicking the task bar button. If you want to play with it some more, do the following:

Copy the text (from here, not from the Shell). From the menu on the Buttons.py window, select File | New Window and paste the text into that window. Then select File | Save As and give it a File Name ending in ".py". It will be saved in the same folder as Buttons.py.

The Buttons.py program puts two buttons in a frame. One, which closes the window, is given unusual colors. The other performs a "call-back," executing the "say_hi" method when it is pressed.

I have been programming for 50 years. Python is by far the easiest, most productive, least-error-prone language I have ever used. However, like any language, it must be learned. More complex tasks require more study. Fortunately, there are many excellent tutorials, and comprehensive documentation. Here are a few resources:

In any Python window, click Help | Python Docs | Tutorial. Alternatively, when any Python window has focus, press the F1 function key. The tutorial will introduce you to basic, and not-so-basic Python tools. The Global Module Index introduces you to many available resources, like Tkinter. And yes, all of this came in that 10 MB package you installed!

For the essentials of pop-up windows on a Microsoft platform, see: An Introduction to Tkinter .

Most of these programming tools also work on Linux, Mac, Java, .NET and many other platforms.

Enjoy!




OpaQue

Python Completed in 4 hours. Well, I was not into it completely and while I was learning, I installed e-accelerator. Activated it on forums. Then learn't memcached module and how it works. Installed it on server and put some codes in forum config files to use it. Got 1 GB Ram on server shree installed by Theplanet engineers. ;)Thank you for the tutorial docduke :-).The best part of python that I liked was the way it could get inside Windows Env. :-)


docduke

The main reason I put this tutorial up was to show how easy it can be to produce Windows code.

 

I'll never forget the first time I got set up to make Windows with Microsoft Visual Studio .NET. I tried to install it on a fresh install of Windows 2000 Pro. Wouldn't go -- said it needed .NET first. I tried installing .NET and got some cryptic error message. It turned out that .NET wouldn't go until I had Windows 2000 updated. It needed Service Release 3 or so, but the error message didn't tell me that. I think it took me 2 days to figure out how to get it done. Even then, the successful formula was to prevent a "reboot" when one of the partial installs asked for it, and proceed with the next install.

 

If I need to make a professional-looking window with all the components in just the right place, something like Visual Studio may be necessary. For just getting windows up with the necessary elements in default locations, Python is very much faster. There are books such as Python and Tkinter Programming that explain how to do detailed layout. Mark Hammond is responsible for really integrating Python into Windows. He is an author of another book, Python programming on Win32, which covers much more general programming on Windows. I remember reading somewhere that his tools are powerful enough that a programmer can fairly easily run a message loop exclusively in Python, and completely take control of a computer away from Microsoft!

 

Finally, the primary author of Python is Guido van Rossum. He was a professor in the Netherlands when he began it. Now he is in the U.S. tasked by Google to produce an improved version, Python 3.0. Python has been used in numerous commercial tasks, including movie-making and Google itself. There was a growing list of testimonials on the Python website, but it has now been replaced by a long, organized list of success stories.



VIEW DESKTOP VERSION REGISTERGET FREE HOSTING

Xisto.com offers Free Web Hosting to its Members for their participation in this Community. We moderate all content posted here but we cannot warrant full correctness of all content. While using this site, you agree to have read and accepted our terms of use, cookie and privacy policy. Copyright 2001-2019 by Xisto Corporation. All Rights Reserved.