[pyar] "Hola mundo"
Juan Carlos Ojeda
juancarlospaco en gmail.com
Lun Jun 28 18:30:47 ART 2010
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
#----------------------------------------------------------------------------
# Name: hellowolrd.py
# Purpose: Hello World GUI for Ubuntu.
# Target: Hello World that dont need GTK or QT or WxWidgets.
# Author: JuanCarlosPaco ( Argentina )
# Contact: juancarlospaco en gmail.com , @juancarlospaco at Identi.Ca
# License: GPL v3
#----------------------------------------------------------------------------
# Dependencies : sudo apt-get install python python-tk ubuntu-standard
# Suggested : sudo apt-get install python-psyco
#
try:
import psyco # Speed Up if avaliable
psyco.full()
except ImportError:
print(" ")
print(" No PYTHON-PSYCO avaliable, this application can run faster... ")
print(" ")
pass
# Documentation:
# epydoc --verbose --pdf --output $HOME --name HelloWorld --graph=all
--redundant-details `pwd`/helloworld.py
try:
from Tkinter import * # Python2
except ImportError:
from tkinter import * # Python3
import time
#
root = Tk()
root.title(' Hello World ')
root.wm_attributes("-alpha", 1)
root.focus()
#
try:
root.wm_iconbitmap('@'+'/usr/share/hello-world/helloworld.xbm') #
Optional Icon
except TclError:
print(" ")
print(" ERROR: Icon File not found... ")
print(" ")
pass
#
def rgb2hex(r, g, b):
""" Colors in hex too look hax0r """
return '#' + "".join(["%02x"%x for x in (r,g,b)])
#
def KillMe():
""" This is an Quick'N'Dirty but Handy program exit """
root.iconify()
time.sleep(0.5)
root.destroy()
#
def HideMenu():
""" This is Hide the Menu Bar """
menubar.destroy()
#
label = Label(root, font=('times', 36, 'bold'), text=' Hello World™ ',
bg='black', fg='white')
label.pack(pady=25, padx=25, anchor = 'center')
#
menubar = Menu(root)
## menu
filemenu = Menu(menubar, tearoff=0)
filemenu.add_command(label="Nuevo", state='disabled')
filemenu.add_separator()
filemenu.add_command(label="Cerrar ✗", command=KillMe)
menubar.add_cascade(label="Archivo", menu=filemenu)
root.config(menu=menubar)
#
optmenu = Menu(menubar, tearoff=0)
optmenu.add_command(label='Ocultar barra de Menu', command = HideMenu)
menubar.add_cascade(label='Opciones', menu=optmenu)
##
for x in range(1,100):
root['bg'] = 'red'
time.sleep(1.0/x)
root.update()
if x < 50:
root['bg'] = 'white'
else:
if x%2:
root['bg'] = 'red'
else:
root['bg'] = 'green'
time.sleep(1.0/x)
root.update()
root['bg'] = 'blue'
#
for k in range(200):
""" This is an EyeCandy Hack to Fade-In GUI Effect, just because Tkinter
Rulez """
time.sleep(0.01) # Time
root.update()
r = g = b = 200 - k # Direction
shades_gray = rgb2hex(r, g, b)
label.config(fg=shades_gray)
#
root.mainloop()
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <http://listas.python.org.ar/pipermail/pyar/attachments/20100628/3d72c117/attachment.html>
More information about the pyar
mailing list