Feeds:
Posts
Comments

Image

Frequentemente encontramos na lista do python-brasil novatos perguntando qual a melhor IDE para se programar em Python. São tantas as vezes que isso ocorre que o python-brasil conta, na sua wiki, com uma página para responder somente a essa pergunta. A página esta acessível aqui.

Uma IDE que deve ser em breve adicionada a lista é o Editra. Demos uma breve olhada nessa IDE e gostamos. Ficamos devendo uma análise da mesma. No entanto, o que assusta muitos iniciantes é o fato dos veteranos recomendarem o uso do Vim. Ele realmente assusta as pessoas e, por isso, em cursos de computação é comum que os alunos comecem a programar com o Gedit ou o Kate. Ao longo do curso o panorama vai mudando e são muitos os que se tornam mais habilidosos com o uso do Vim e permanecem nele.

O Vim já conta com várias funcionalidades de interesse dos programadores mas acredito que uma das melhores seja a possibilidade de extendê-lo via plugins. Além de todo o conjunto de recursos já fornecidos pelo Vim, muitos das quais passamos anos e anos sem nem sequer conhecer, muitos plugins de terceiros são realmente úteis.

Uso Vim para programar em Python há algum tempo e hoje encontrei um post que contém tudo que é necessário para a pessoa começar a usar o Vim de forma confortável, contendo todas as funcionalidades encontradas nas grandes IDEs. O post é esse aqui. Um excelente post, dispensa qualquer adição da minha parte.

O único plugin que não foi mencionado pelo autor mas não passou desapercebido pelo leitores é o NERDTree. Seguindo todos os passos e instalando também o NERDTree você terá em mãos uma IDE muito próxima das gráficas, com a vantagem de ser leve 😀

Forum Nokia

So, as S60 C++ involves the learning of C++ (which is kinda complex), Nokia has been releasing rapid development tools on the last couple of years. The very first one was Java followed by Python and, as I found out a while ago, Html/CSS/Javascript.

On the last hour, Daniel Rocha hosted a Webinar to explain the main features of the Widget Runtime which is the engine developers will use to develop web apps.

These new web apps will be accessible from the main menu and there will be no difference between them and the common native apps used ’til today. It’s very similar to what Apple allowed on its first gen iPhones.

This tool is aimed on usual web developpement, so it uses the Model-View-Control (HTML-CSS-Javascript) paradigm. As Daniel said on the webinar, the HTMLs are, most times, the simplest of the three as it only needs to define some regions to display things on the screen.

As CSS and Javascript weren’t powerful enough, Nokia guys developped the WRTkit, which is a library which defines buttons, text areas, gradients and many other input, output and customization.

With all that, the structure of the files is very simple:

  • info.pl
  • [name].html
  • [name].css
  • [name].js
  • [name].png

The first one is a manifest file written in xml and used to define some characteristics of it. The other ones, are html, css and javascript files and the last is the icon which will be used by the program.

After defining all that, it’s only needed to zip the folder, rename it to wgz and install it on the phone.

It’s indeed very very simple to use but it will only work on S60 Feature Pack 2 (and some chosen Feature Pack 1) phones.

Daniel will also release some very interesting links he used on his presentation, for now, I googled the Web Runtime wiki.

And as one of its 100,000 users, I’m very excited to announce David Siegel released the new version of GNOME Do!

The fighting 0.5 (as the new version is being referred to) brings back the “Open with” functionality!

The Open with... action has been re-enabled.

And adds an window for us to control our growing number of plugins!

Plugin management window

And some new great plugins are also available as the “Skype plugin”, to control your skype account, and the “WindowManager” to minimize, maximize, bring to front, and all that kind of stuff you do with your windows 😀

Check the official release post in order to get more information. All pics were taken from Dave’s blog.

3D Modelling

Maya

As it can be seen from other posts (Python + Maya – Part 1 and Python + Maya – Part 2) I also work with computer graphics besides programming in Python and writing here at Linil.

So, I’ve never posted screenshots of my work in here because of confidentiality issues in there, but recently I’ve worked on some little project I built myself of some children’s clinic.

This scene was built using only Autodesk Maya 2008 and, as you may see, it’s not done yet as it’s missing some bed to examine the kids and a sink for the doc to wash his/her hands, but this is what I got ’till now.

Liked it? Leave it a comment with your opinion and suggestions and when the final product comes out, you’ll receive an enormous “Thanks” for your contribution! 😀

Note for brazilian readers: this text was already posted as “GEdit completando código Python automaticamente” and we are making it available in English now.

It’s been a while since I’ve started to develop a plugin to make Gedit able of completing python code. After a while, it became clearer that this was a functionality desired by many users and it is also of interest for the group that keeps the project. Actually, I will be posting this to the wiki of plugins of the GEdit.

So, for this to happen, I decided to take a look at the code used on Vim to complete python codes. For my surprise, that code was also written in python and after some reading, I realized that it could be ported to other text editors. One of the reasons I chose GEdit is that it makes the plugin creation process very easy and understandable by new developers (I recommend the article the Python Plugin How, which explains how to develop plugins for this editor). Using Osmo Salomaa Autocomplete words plugin, made this process even easier.

Long story short, what I did was to connect the two parts: the code for Vim auto-complete (authored by Aaron Griffin) and the code for Autocomplete words (authored by Osmo Salomaa). This is, indeed, a good example of the benefits of free software: providing easy ways for me not having to repeat the work of both authors and rendering me able to use both codes to provide a new for another text editor.

During the trip, which came up being more complicated than expected, I lost many files at my old computer, so the work was stopped until I had the guts to start again. The restart was even better: development was faster and the old errors were quickly solved.

The plugin works on Gedit through the shortcut Ctrl+Alt+Space and allows fast code completing for python scripts and python modules are also supported. Basically, it works the same way it did on Vim, apart from some small adjustments I made in the code. Aaron Griffin alerted me that the code contained some small known problems and that would be corrected soon. I will keep myself up to date with Aaron for the plugin not to become outdated.

This is an alpha version which wasn’t by any means put through rough tests yet. That said, I believe it can already be used but, surely, bugs will come up. I am available to assist whoever is interested on the plugin. On the sequence, there are some screenshots demonstrating the use of the plugin. Today, Gedit has a lot of plugins for Python development, which is taking it nearer to becoming Python development environment. But I still use Vim.

The installation of plugin is relatively easy: the user must unpack the archive into the directory gnome2/gedit/plugins of its home, restart gedit and activate plugin in edit – > preferences – > plugins. This plugin will only work with python code. I hope the community can help on the development and that it makes it more and more usable over time.

Auto in completes code real teams.Show doc strings

The plugin of auto complete Python code is avaliable here.

we are sorry

ImageWe, the Linil Team, would like to present our humble apologies for this enormous gap on our blog. Work, College and a lot of other aspects intended to get on the way.

That said, we would also like to let you all know: we are back

So getting back to business, let’s talk about PyS60.

As the idea of this post is not to present a full introduction, it would be good if you all got familiarized with the idea by reading this great article the guys at AllAboutSymbian wrote about it.

So, I bought my N73 on june, 2007. My cellphone plan only covers 50 text messages per month, and I usually pass that limit. One of many reasons this happened on the begining was because S60 platform won’t allow you to separate your messages by month. To keep track of that 50 messages, I needed to erase all my sent messages every first day of each month but I kept forgetting about it what made me pay a lot of extra message taxes.

I installed PyS60 on my phone somewhere between September and October last year, but until last week I still haven’t thought about using it to help solve that problem. So a solution came and it was simple (as Alan Kay says: “Simple things should be simple, complex things should be possible”).

The idea is to look through all the sent messages box and put them into a dictionary, using the months as keys and the number of messages sent on it as values as seen below on part 0 of the code.

#part 0
import inbox
from e32db import format_time
i = inbox.Inbox( inbox.ESent )
m = i.sms_messages()
message_by_time = {}
for message in m:
    time_date = format_time(message_time).split(' ')[0]
    month = time_date.split('/')[0]
    message_time = i.time(message)
    year = time_date.split('/')[2]
    if not message_by_time.has_key( (year,month) ):
        message_by_time[(year,month)] = 0
        message_by_time[(year,month)] += 1

The first lines get a list of sent messages (m) and initialize the dictionary I will use. Through the for, all the messages are analyzed and their times are taken and formatted. After that, their years and months are used to create a tuple to index the dictionary and the element associated is incremented. The if test is used to avoid KeyError exceptions and will assign a number to the key if the dictionary doesn’t already has it.

After that, it was all about creating the interface to allow for better user experience. The idea was to provide a menu where the user could see how many messages he sent on the current month and an option to access a list and show how many messages he has sent on all months.

#part 1
k = message_by_time.keys()
k.sort()

#part 2
time_picker_list = []
for x in k:
    a = u"%s/%s" % (x[1],x[0])
    b = u"%s messages sent" % (message_by_time[x])
    time_picker_list.append((a,b))</div>

Part 1 gets the keys of the dictionary (years and months of messages) and sorts them. After that, on part 2, a new list is created to contain pairs of strings (a,b), where ‘a’ stands for strings formatted as yyyy,mm and ‘b’ stands for another string containing the number of messages sent.

#part 3
time_picker = None
def list_handler():
    month_year = k[time_picker.current()]
    appuifw.note(u"You have sent %d messages on %s/%s" % (message_by_time[month_year], month_year[1], month_year[0]), "info")

#part 4
options = [u"This Month", u"Messages by time"]
options_menu = None

#part 5
def handler_options():
    if options_menu.current() == 0 :
        appuifw.note(u"You have sent %d messages this month" % (message_by_time[k[-1]]), "info")</div>
    else:
        global time_picker
        time_picker = appuifw.Listbox(time_picker_list, list_handler)
        appuifw.app.body = time_picker
        appuifw.app.exit_key_handler = exit_picker

#part 6
options_menu = appuifw.Listbox(options, handler_options)

#part 7
def exit_key_handler():
app_lock.signal()
def exit_picker():
    appuifw.app.body = options_menu
    appuifw.app.exit_key_handler = exit_key_handler</div>

#part 8
app_lock = e32.Ao_lock()
appuifw.app.title = u'SentCounter'
appuifw.app.body = options_menu
appuifw.app.exit_key_handler = exit_key_handler
app_lock.wait()

From part 3, the interface begins to be described. This part defines the function that will be called every time the user selects a month on the list of messages sent through all months. On part 4, the initial menu is defined as a list of two options. Part 5 describes the function that will be called whenever the user select one of the initial menu options. Part 6 creates the menu and part 7 defines the exiting functions, first for when the exit key is pressed on the initial screen and then for when the user presses it on the list of messages by month.
Part 8, at last, creates the application, sets its name and exit functions, and displays it on the screen.

Please be aware that this explanation of PyS60 interface is superficial. For a real better understanding of it, you should take a look at the more than helpful. tutorials.

So the code will be posted in a while (as soon as I get home).
Hope you enjoyed 😀

Python + Maya
After some new training, here comes the second part of the Python + Maya Linil Tutorial. If you have no idea of what am I talking about in here, please feel free to check the first part of this tutorial Python + Maya – Part 1.

For you to get a grasp of what we’ll be building this time, take a look at the video from the final output.

Looks pretty better than the other time, huh? Let’s get started.

First of all, much of this new part is based on creating materials and changing their attributes, so before we turn into coding, it’s necessary to understand how Maya material system works.
In Maya, one material (let’s say, wood) is not applied directly to an object (let’s say, a table). It’s applied to a Shading Group and the objects are associated to the Shading Group. The purpose of this post is not to discuss this, but it’s very important for you to understand that. So, the chain is:
Material (wood) -> Shading Group -> Object (table)

Note We will get to coding now and I’ll be explaining just the procedure to create and animate only the balls that stand over the x axis, you’ll notice that animating the other ones (over the z axis) will be a matter of parameter setting. As WordPress has a lot of problems with syntax highlighting, you might think it’s better to follow the code through the original file. The link to the code without the z axis animation is: pythonMaya_xaxis.py and the link to the complete animation is: pythonMaya.py

Let’s get to coding now. As we’ll be creating lots of materials, we must define three functions in order to maintain the readability of the code.

def createMaterial( name, color, type ):

cmds.sets( renderable=True, noSurfaceShader=True, empty=True, name=name + ‘SG’ )
cmds.shadingNode( type, asShader=True, name=name )
cmds.setAttr( name+”.color”, color[0], color[1], color[2], type=’double3′)
cmds.connectAttr(name+”.outColor”, name+”SG.surfaceShader”)

The first line creates a Shading Group by calling the function sets, which returns nothing more than a set, in this case, an empty set for a while. The next line, creates a Material with the function shadingNode. Its first argument defines the type of material (lambert, blinn, anisotropic, etc), the second one is necessary for the system to understand it’s creating a real shading node, and the last one is the new material’s name.
After that, we set the color attribute. Notice that it doesn’t take a tuple for argument, but three different numbers and a fourth argument defining that the last three are a vector of 3 double integers. The last line connects the output color of the material we created to the surfaceShader of the Shading Group.

def assignMaterial (name, object):

cmds.sets(object, edit=True, forceElement=name+’SG’)

This one gets one object (the first argument) and assigns it to a correspondent Shading Group (the third argument and which must have already been created through createMaterial).

def assignNewMaterial( name, color, type, object):

createMaterial (name, color, type)
assignMaterial (name, object)

The third, and easiest of them, is just a way to call both others in one line.

After that and as you’ve seen in the movie, you’ll know the purpose of this time is to create some balls and then make them move in wave form. Before moving on to the balls, we need to create the ground plane (15×15).

cmds.polyPlane(name = ‘ground’, sw = 15, sh = 15, w = 15, h = 15)

To animate the balls, the easiest way is to set their vertical positions using a sinus function. We need to initialize the balls’ position and color and create a new material for each one of the plane’s faces that will have a ball on top:

for i in xrange(0,13):

cmds.polySphere(name = ‘ball’ + str(i), radius = 0.5)
pos = 2 + 1.5*sin( (1.6/pi)*(6-i) )
val = (1 + sin( (1.6/pi)*(6-i) ))/2
cmds.setAttr( ‘ball’ + str(i) + ‘.translateX’, 6-i)
cmds.setAttr( ‘ball’ + str(i) + ‘.translateY’, pos)
assignNewMaterial( ‘ballShader’ + str(i), (val, val, 1), ‘blinn’, ‘ball’ + str(i) )
assignNewMaterial( ‘ground’ + str(i), (1, 1, 1), ‘lambert’, ‘ground.f[‘ + str(118-i) + ‘]’ )

As we have 13 balls, we use a for from 0 to 12. In each step we:

  • Create a new Polygon Sphere with radius 0.5 and name ballX where X stands for an index from 0 to 12;
  • Calculate their vertical position using a sin function;
  • Calculate the color value which will be used ahead. The idea here is for the ball to be completely white (1,1,1) on it’s uppermost position and completely blue (0,0,1) on its downermost part;
  • Set the balls X position to coincide with each of the faces of our ground plane;
  • Assign the vertical value to the translateY attribute;
  • Create a new material for the ball;
  • Create a new material for the plane face (the faces of an object are accessed through an indexed list of faces, so the middle line will be like 7*15 + 1 = 106).

After that, it’s time to animate. Keyframe setting comes inside two for loops. The first one, from 0 to 200 (the number of frames of our animation) and the other from 0 to 13 (the number of spheres on the x axis).

for itr in xrange(0,200):

for i in xrange(0,13):

name = ‘ball’ + str(i)
name2 = ‘ballShader’ + str(i)
pos = 2 + 1.5*sin( (1.6/pi)*(6-i) +itr/5.0 )
val = (1 + sin( (1.6/pi)*(6-i) +itr/5.0 ))/2
cmds.setKeyframe(name, attribute=’translateY’, value=pos, t=itr )
cmds.setAttr( name2 + ‘.color’, val, val, 1, type=’double3′ )
cmds.setKeyframe(name2, attribute = ‘color’, t=itr )
if(pos < 0.55):

cmds.setAttr( ‘ground’ + str(i) + ‘.color’, 0, 0, 1, type=’double3′ )
cmds.setKeyframe(‘ground’+str(i), attribute = ‘color’, t=itr )

else:

cmds.setAttr( ‘ground’ + str(i) + ‘.color’, 1, 1, 1, type=’double3′ )
cmds.setKeyframe(‘ground’+str(i), attribute = ‘color’, t=itr )

On the beginning of each loop, we set two names, the name of the ball to be animated (name) and the name of the shader to be animated (name2). Then we calculate the new position and color value the same way we did on our initialization. Then we set a keyframe for the ball’s position. To animate the material’s color, it’s needed to first set the attribute of it and then set a keyframe (we can’t use the value tag of the setKeyframe function but I don’t know why this happens yet, so expect some news in here).
After that, we analyze if the ball is sufficiently near the ground for us to set it’s face’s color. It’s done through the if and else statement.

So, you execute it and voilà! A new set of waving and color-changing balls! As I said, doing the z axis balls initialization and animation stands for homework for you all 😀
Again, hope you enjoyed this new part (a lot more complicated than the first one but a lot more beautiful) and stay tuned for new parts.
Ah, don’t forget to comment and tell us your experience, doubts, impressions, etc.

P.S.: I did some tweaking with the render in order to get that nice look, but this will be covered in other post! [=

Esse texto já esta na web há algum tempo, no entanto, muitos ainda não o leram. O texto fala sobre como os desenvolvedores Java costumam programar quando migram para a linguagem Python. O texto demonstra “erros” cometidos por esses programadores ao escrever uma aplicação, além disso contém várias dicas de como se evitar tais “erros” e tenta ensinar a pensar como programador Python. O texto original é em inglês mas recentemente foi traduzido e colocado a disposição no site do pythonbrasil.

De certa forma eu passei pela experiência de migrar do Java para a linguagem Python. Confesso que não gostava tanto de programar enquanto não conhecia essa nova linguagem. Desenvolver qualquer projeto pequeno para usufruir no meu próprio desktop em Java durava mais tempo que a minha empolgação.

O texto me foi bastante útil e por isso recomendo a leitura do mesmo. Minha experiência com Java veio por obrigação da faculdade, talvez se eu tivesse visto Python desde o começo do curso não tivesse achado as aulas tão enfadonhas. Migrar do Java pro Python, ao meu ver, é um caminho sem volta. A produtividade que se ganha é enorme, você vai conseguir terminar seus projetos antes do que você imaginava e isso vai lhe dar tempo para mais projetos ainda. Para ganhar tal produtividade é necessário que o programador deixe de pensar como fazia as coisas em Java e se pergunte como fazer essa mesma tarefa com os recursos do Python. Essa é a parte principal da migração para uma nova linguagem e do texto recomendado.

This video shows how to edit ID3 tags from your MP3 files using Emacs
keyboard macros and EMMS.

This link points to the high quality version in Ogg Video format.

Image

This morning, Trolltech announced on its site that they have made an agreement with Nokia that the Finland guys will make a public offer to buy the company.

Trolltech’s QT, a cross-platform software development framework which is used in popular software such as Skype, Google Earth, Adobe Photoshop Elements, Lucasfilm and by more than 5000 customers worldwide, will now be owned, supported and developed by Nokia.

The Finland Giant announced they will keep developing Trolltech products and supporting them.

For Nokia, it’s an amazing leap which will allow them to accelerate its cross-platform software strategy for mobile devices and desktop applications, and develop its Internet services business. With Trolltech, Nokia and third party developers will be able to develop applications that work in the Internet, across Nokia’s device portfolio and on PCs.

Source: Trolltech

Design a site like this with WordPress.com
Get started