PyGUI is a cross-platform GUI toolkit designed to be lightweight and have a highly Pythonic API.
It's works with Python 3 on MacOSX and Windows.
You use the OpenGL facilities but you will need PyOpenGL and GtkGLExt and PyGtkGLExt.
Official site is here.
In this image you can see some controls created with PyGUI.
Is a blog about python programming language. You can see my work with python programming language, tutorials and news.
Friday, March 25, 2011
Tuesday, March 22, 2011
Python Tools for Visual Studio
I just read that python will be placed in the tools in Visual Studio.
This can only be good news for the python community.
More about this here.
This can only be good news for the python community.
More about this here.
Monday, March 21, 2011
The discovery of an ancient ancestors linux ...
Who says penguins are weak?
Linux is a good system if it is used by smart people.
Since ancient times people are born with penguins.
It seems that dinosaurs could not survive, but the Penguins have managed well.
They became smaller but everyone loves them.
Whether they are small and fast as gentoo, or slower ... we are glad that we have no windows open.
More infos here.
Linux is a good system if it is used by smart people.
Since ancient times people are born with penguins.
It seems that dinosaurs could not survive, but the Penguins have managed well.
They became smaller but everyone loves them.
Whether they are small and fast as gentoo, or slower ... we are glad that we have no windows open.
More infos here.
Monday, March 14, 2011
IronPython released on 12 and updated on 13 march.
What is it?
IronPython is an implementation of the Python programming language and is running under .NET and Silverlight.
How does it work?
When you run a .NET program written in a language such as C# or VB.NET, your code gets compiled to Intermediate Language (IL) code.
IronPython contains the code and classes for IronPython itself, including the IronPython interpreter. When you run the IronPython interpreter, you are running the IL code for IronPython itself.
More simplistic, the classes you create in your Python code are created dynamically at runtime.
What's New?
This release numerous bug fixes, also includes a IronPython Tools for Visual Studio, support for extension methods and more...
You can see more on official site.
IronPython is an implementation of the Python programming language and is running under .NET and Silverlight.
How does it work?
When you run a .NET program written in a language such as C# or VB.NET, your code gets compiled to Intermediate Language (IL) code.
IronPython contains the code and classes for IronPython itself, including the IronPython interpreter. When you run the IronPython interpreter, you are running the IL code for IronPython itself.
More simplistic, the classes you create in your Python code are created dynamically at runtime.
What's New?
This release numerous bug fixes, also includes a IronPython Tools for Visual Studio, support for extension methods and more...
You can see more on official site.
Saturday, March 12, 2011
Tutorials from PyCon 2011
PyCon 2011 is held from March 9th through the 17th, 2011 in Atlanta, Georgia.
It is the annual Python community conference.
More on this page:Pycon 2011 tutorials
It is the annual Python community conference.
More on this page:Pycon 2011 tutorials
Wednesday, February 23, 2011
Just a simple python weather script.
Sometimes we need simple solutions. An example is displaying data on a computer screen using conky. under Linux.
Another example is the display of data without using the browser.
Whether you use Windows or Linux python scripts come to help. Here's a simple example written in python that can display weather data.
Another example is the display of data without using the browser.
Whether you use Windows or Linux python scripts come to help. Here's a simple example written in python that can display weather data.
import urllib
from xml.dom import minidom
wurl = 'http://xml.weather.yahoo.com/forecastrss?p=%s'
wser = 'http://xml.weather.yahoo.com/ns/rss/1.0'
def weather_for_zip(zip_code):
url = wurl % zip_code +'&u=c'
dom = minidom.parse(urllib.urlopen(url))
forecasts = []
for node in dom.getElementsByTagNameNS(wser, 'forecast'):
forecasts.append({
'date': node.getAttribute('date'),
'low': node.getAttribute('low'),
'high': node.getAttribute('high'),
'condition': node.getAttribute('text')
})
ycondition = dom.getElementsByTagNameNS(wser, 'condition')[0]
return {
'current_condition': ycondition.getAttribute('text'),
'current_temp': ycondition.getAttribute('temp'),
'forecasts': forecasts ,
'title': dom.getElementsByTagName('title')[0].firstChild.data
}
def main():
a=weather_for_zip("ROXX0003")
print '=================================='
print '|',a['title'],'|'
print '=================================='
print '|current condition=',a['current_condition']
print '|current temp =',a['current_temp']
print '=================================='
print '| today =',a['forecasts'][0]['date']
print '| hight =',a['forecasts'][0]['high']
print '| low =',a['forecasts'][0]['low']
print '| condition =',a['forecasts'][0]['condition']
print '=================================='
print '| tomorrow =',a['forecasts'][1]['date']
print '| hight =',a['forecasts'][1]['high']
print '| low =',a['forecasts'][1]['low']
print '| condition =',a['forecasts'][1]['condition']
print '=================================='
main()
Here is the result of script execution:
>>>
==================================
| Yahoo! Weather - Bucharest, RO |
==================================
|current condition= Light Snow
|current temp = -3
==================================
| today = 23 Feb 2011
| hight = 0
| low = -5
| condition = Light Snow
==================================
| tomorrow = 24 Feb 2011
| hight = 0
| low = -4
| condition = Mostly Cloudy
==================================
>>>
Thursday, February 3, 2011
Read feed from sites.
Is a simple example for reading some feed.
I use two functions , first read url and secondary extract data.
This is the code source:
I use two functions , first read url and secondary extract data.
This is the code source:
from xml.dom import minidom as dom
import urllib
def fetchPage(url):
a = urllib.urlopen(url)
return ''.join(a.readlines())
def extract(page):
a = dom.parseString(page)
item2 = a.getElementsByTagName('SendingDate')[0].firstChild.wholeText
print "DATA ",item2
item = a.getElementsByTagName('Cube')
for i in item:
if i.hasChildNodes() == True:
e = i.getElementsByTagName('Rate')[10].firstChild.wholeText
d = i.getElementsByTagName('Rate')[26].firstChild.wholeText
print "EURO ",e
print "DOLAR ",d
if __name__=='__main__':
page = fetchPage("http://www.bnro.ro/nbrfxrates.xml")
extract(page)
Result is :
DATA 2011-02-03
EURO 4.2609
DOLAR 3.0921
This is all...
Python - calendar
Two simple example about calendar python module.
Show calendar 04 - 2011 :
This is all .
Show calendar 04 - 2011 :
>>> import calendar
>>> tc = calendar.TextCalendar(calendar.SUNDAY)
>>> print tc.formatmonth(2011,04)
April 2011
Su Mo Tu We Th Fr Sa
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
>>>
Show calendar in HTML format :>>> import calendar
>>> hc = calendar.HTMLCalendar(calendar.SUNDAY)
>>> print hc.formatmonth(2011,04)
;
The result is a HTML table with the calendar.This is all .
Tuesday, August 3, 2010
Random module - another example
Random module is a module used in everyday programming.
Even if it is not used in the final software, he helps us to test various types of random data.
We present you a simple example - play with cards.
We chose a list of cards of one color for not having a large number of elements.
We exemplify the use of random module by analogy with a game of cards.
That it means: shuffle cards , select just one from cards and a choice selection of a defined number of cards.
Below you see the code used as an example.
Even if it is not used in the final software, he helps us to test various types of random data.
We present you a simple example - play with cards.
We chose a list of cards of one color for not having a large number of elements.
We exemplify the use of random module by analogy with a game of cards.
That it means: shuffle cards , select just one from cards and a choice selection of a defined number of cards.
Below you see the code used as an example.
>>> import random
>>> choice=random.choice
>>> shuffle=random.shuffle
>>> for i in range (9):
... print choice(cards)
...
Q
K
10
Q
2
2
10
K
6
>>> shuffle(cards)
>>> cards
[4, 7, 10, 'J', 3, 'Q', 6, 2, 'K', 9, 'A', 8, 5]
>>> sample=random.sample
>>> sample(cards,5)
[8, 'J', 2, 'Q', 10]
>>> sample(cards,5)
['A', 9, 4, 'K', 'Q']
>>>
The random module docsSaturday, July 3, 2010
The module matplotlib-0.99.3
The module matplotlib is a python 2D plotting library with a variety of hardcopy formats and interactive environments across platforms.
With just a few lines of code we can generate plots, histograms, power spectra, bar charts, errorcharts, scatterplots, etc...
See images bellow or visit the gallery.
This module is version 0.99.3 for Python 2.5 and 2.6. We have modules for installation on operating systems like MacOS, Windows and Linux.
To use this module you must have install numpy module.
Now download module from here.
With just a few lines of code we can generate plots, histograms, power spectra, bar charts, errorcharts, scatterplots, etc...
See images bellow or visit the gallery.
This module is version 0.99.3 for Python 2.5 and 2.6. We have modules for installation on operating systems like MacOS, Windows and Linux.
To use this module you must have install numpy module.
Now download module from here.
$python setup.py build
Use super user:#python setup.py install
Try to load module:$python
Python 2.5.1 (r251:54863, Jun 15 2008, 18:24:51)
[GCC 4.3.0 20080428 (Red Hat 4.3.0-8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>>
It's working fine.Sunday, June 27, 2010
Add text on image with PIL module.
It's easy to create images with PIL module.
This is the script:
In this case you must change the code line:
This is the script:
import PIL from PIL import ImageFont from PIL import Image from PIL import ImageDraw font = ImageFont.truetype("/usr/share/fonts/dejavu/DejaVuSans.ttf",25) img=Image.new("RGBA", (200,200),(120,20,20)) draw = ImageDraw.Draw(img) draw.text((0, 0),"This is a test",(255,255,0),font=font) draw = ImageDraw.Draw(img) draw = ImageDraw.Draw(img) img.save("a_test.png")The only error that can occur is not to find the font.
In this case you must change the code line:
font = ImageFont.truetype("/usr/share/fonts/dejavu/DejaVuSans.ttf",25)Here is the result script:
Wednesday, June 2, 2010
The HTMLParser module - just simple example
Basically this module is for parsing text files formatted in HTML (HyperText Mark-up Language) and XHTML.
On HTMLParse docs.
You will see the same example but with no explanation. The example is :
I use python to import this file:
This arguments, tag and attrs is used to return values.
Note :
The HTMLParser module has been renamed to html.parser in Python 3.0. The 2to3 tool will automatically adapt imports when converting your sources to 3.0.
Use "http://" not just "www". If don't use "http://" you see errors.
Seam urllib2 have some troubles with:
You can use all functions HTTParser class.
On HTMLParse docs.
You will see the same example but with no explanation. The example is :
import HTMLParser
from HTMLParser import *
import urllib2
from urllib2 import urlopen
class webancors(HTMLParser):
def __init__(self, url):
HTMLParser.__init__(self)
r = urlopen(url)
self.feed(r.read())
def handle_starttag(self, tag, attrs):
if tag == 'a' and attrs:
print "Link: %s" % attrs[0][1]
I named the python file : spiderweb.py I use python to import this file:
>>> import spiderweb
>>> spiderweb.webancors('http://www.yahoo.com')
Link: y-mast-sprite y-mast-txt web
Link: y-mast-link images
Link: y-mast-link video
Link: y-mast-link local
Link: y-mast-link shopping
Link: y-mast-link more
Link: p_13838465-sa-drawer
Link: y-hdr-link
>>>
The method handle_starttag takes two arguments from HTMLParser.This arguments, tag and attrs is used to return values.
Note :
The HTMLParser module has been renamed to html.parser in Python 3.0. The 2to3 tool will automatically adapt imports when converting your sources to 3.0.
Use "http://" not just "www". If don't use "http://" you see errors.
Seam urllib2 have some troubles with:
File "/usr/lib/python2.5/urllib2.py", line 241, in get_type
raise ValueError, "unknown url type: %s" % self.__original
You can use all functions HTTParser class.
Saturday, May 22, 2010
The beauty of Python: subprocess module - part 3
This is just a simple example about module subprocess.
We need to install "espeak" . On fedora usse this command:
Now the example is:
This will speak "This is a test".
This is all .
We need to install "espeak" . On fedora usse this command:
#yum install espeak
Now the example is:
>>> import subprocess
>>> subprocess.call(["espeak", "-s 120","-p 100","This is a test"])
0
>>>
This will speak "This is a test".
This is all .
Posted by
Cătălin George Feștilă
Labels:
2.7,
modules,
python,
python modules,
subprocess,
tutorial,
tutorials
Subscribe to:
Posts (Atom)