Entradas Programación

Arduino Day 2015, the anniversary event of this programming board

Arduido Day is an annual celebration that coincides with the birthday of this little free programming board. An event takes place for 24 hours, organized by both the community and the Arduino team itself where users get together, carry out different events and share opinions and experiences in order to continue expanding their knowledge.

Any user, regardless of their knowledge or profession, can attend any of these events simply by sending the corresponding subscription. The main official events have been prepared in different countries such as the United States, Italy, Sweden, India and Hungary, although thanks to the community, events have been prepared throughout the world to commemorate this day.

In Spain there are a total of 8 events scheduled to celebrate this day, which will be tomorrow 28th March:

We can see the location of these events and more information about them from the main event website.

Just as users can attend these events freely, those in charge of organizing them have the support of the platform, who provide them with a series of elements to carry out said event:

  • Official posters on the occasion of Arduino Day.
  • Pamphlets (“flyers”) of the event.
  • Official signaling system.
  • Badges and graphics.
  • 10% discount to buy in the Arduino store.

Without a doubt, it is a great opportunity that any user of this programming environment should take advantage of and attend the event, where they can meet people with similar tastes and share experiences with other people from the world of electronics.

Are you an Arduino programmer? Will you attend any of these events?

Entradas Programación

Can you create apps for mobile phones without knowing how to program?

These applications are designed so that you can create those apps that you want so much without knowing programming. All of them have graphic editors that will help you build that application step by step and show the result you are going to have at all times. Of course, these mobile apps will not be very elaborate, nor will they have the level of detail, customization or finishing that one made through a programmer who is dedicated to it.

Before we start talking about these applications, we are going to explain the difference between mobile web applications and native mobile applications. Mobile web applications are simply a “wrapper” created in HTML5 and specially designed for mobile devices, this may contain a version of your website or online service. They are the simplest, easiest and cheapest applications to create.

Native apps are a product. And they are the applications that you can find in the corresponding app store. In addition, these applications allow, among other things, to use the phone’s resources and send “push” notifications to users. They are a bit more expensive to produce, but they also have greater functionality and allow you to create a more elaborate interface, providing greater interactivity with the user.

The platforms that we are going to present to you with which you can create apps without knowing how to program, may charge a fee (annual, semi-annual or monthly). Although, as you will be able to verify, in many cases they will allow us to try them for free for a limited time, or even have a free use plan, although with certain limitations.


Goodbarber is a platform that will allow us to create apps with a lot of emphasis on an attractive design and a good user experience. If you access their website, you can see that these characteristics can be seen reflected. Also, as you access the web, you can create your user account, and you will get access to the online editor.

According to the creators of Goodbarber, creating an app consists of very simple steps:

  1. Design the application environment.
  2. Add content
  3. Test it

In the design part, you will have a wide variety of themes provided by the application to choose from, as well as a variety of options to customize sections of the app, menus, icons, toolbars and more. In the content section you can add articles, images, videos, integrated social networks and more. And once you have finished everything, to be able to test the app you will have two options: directly on your mobile or through the Goodbarber application.

We think Goodbarber is really easy to use, and it is very flexible, allowing a wide variety of application content and layouts. In addition, as we have mentioned, it allows us to test the app at all times directly on your own mobile, which helps a lot.

The Goodbarber team allows us to test your application for free for 30 days, which once finished will force us to choose a payment plan (which starts at 16 euros per month). In his web page You can find some examples of apps created with this tool.


Mobincube It is another platform that will allow us to easily create apps and also earn some money with them, or at least that is what they sell us on their website. What we can tell you is that it has a very simple design editor, perhaps the simplest that exists in this type of tool, although we also have to mention that we have noticed that it takes longer than the others to load between section and section.

It allows us to choose between several design templates, which are arranged by categories or we can create a totally new design from scratch. So all we have to do is add the various elements that we want our app to contain on the template, whether blank or not, customize the color scheme or the main image of the app, among other things.

Mobincube is a very interesting option for all those who want to try creating an app for the first time, since its free plan allows us to create native apps that we can publish in the corresponding application store, with support also for “push” notifications (although they show advertising, yes). Although if we want options of a more advanced level, we will have to opt for a payment plan. These payment plans are from 9.99 euros per month.


Finally we are going to talk about AppMachine. This platform seems one of the most powerful that we can find, since with it you have different possibilities when creating the app: you can create a simple app in HTML5 (using, or create an authentic native mobile application.

Its editor is divided into several sections, and it can be somewhat complicated to use at first since it has a large number of options and customization possibilities.

The general structure of the app will be shown as blocks, and all the sections (content, design, settings …) will be shown in a side menu. Also on the right side of the editor, you will find the preview of the app in real time. It also allows us to make these previews in our terminal.

The creators of AppMachine allow us to use their editor for free and without obligation, although at the moment we want to publish the app created in the corresponding application store, we will be required to contract a payment plan. These plans start at a price of 39 euros per month.

These are the tools that we have found the simplest and most complete to start in this world, all of them will allow us to start for free although at the moment we want to publish our application we will have to pay for one of their plans. We invite you to try these platforms and tell us about your experiences. In addition, we remind you that if you are interested in learning to program you can visit our online courses section.

Entradas Programación

Python course. Volume XVI: Standard Libraries. Part ii

Tell you that whenever you want to know how the libraries are used, you just have to execute the following command in the Python console:

help (nombre de la librería)

If you look at the previous article you will see that we use it with the “os” library.


Binary data

To handle this data we have the “struct” library that provides us with two functions “pack ()” and “unpack ()” to work with binary formats of variable length. In the following example we are going to show you how to read the header information of a ZIP file without using the “zipfile” library. “Pack” encodes “H” and “I” as two-byte and four-byte unsigned numbers respectively. Also comment that the symbol “<" indicates that they are of standard size and in "Little-endian" byte order:

import struct

with open('', 'rb') as f:
data =
start = 0

for i in range(3): # show the first 3 file headers

start += 14
fields = struct.unpack('<IIIHH', data[start:start+16])
crc32, comp_size, uncomp_size, filenamesize, extra_size = fields
start += 16
filename = data[start:start+filenamesize]
start += filenamesize
extra = data[start:start+extra_size]
print(filename, hex(crc32), comp_size, uncomp_size)
start += extra_size + comp_size # skip to the next header


The “logging” library offers us a complete and very flexible “log” system. It is also very simple, since the “log” messages are sent to a file or to “sys.stderr”. For example:

import logging
logging.debug('Informacion de Debug)'Mensaje informatico)
logging.warning('Warning:el fichero de configuracion %s no se ha encontrado', 'server.conf')
logging.critical('Error critico – apagando el sistema')

This code will provide us with the following output:

WARNING:root: 'Warning:el fichero de configuracion server.conf no se ha encontrado
CRITICAL:root: 'Error critico – apagando el sistema'

List tools

The “array” library provides us with the “array ()” object that behaves like a list, which stores the information in a more compact way, although it has to be all homogeneous. In the following example we show an “array” of 2-byte unsigned binary numbers (typecode “H”) instead of the 16 bytes that would normally be used if we were using the “int” type:

>>> from array import array
>>> a = array('H', [4000, 10, 700, 22222])
>>> sum(a)
>>> a[1:3]
array('H', [10, 700])

If we use the “deque” module included in the “collections” library, we can use the “deque ()” object that will help us add and extract data quickly. It is widely used in “LIFO” (last in first out) lists:

>>> from collections import deque
>>> d = deque(["task1", "task2", "task3"])
>>> d.append("task4")
>>> print("Handling", d.popleft())&lt;/pre&gt;
Handling task1

Another way it can be used is to search width:

unsearched = deque([starting_node])
def breadth_first_search(unsearched):
node = unsearched.popleft()
for m in gen_moves(node):
if is_goal(m):
return m

Finally I am going to mention the “bisect” library, this library provides us with tools to work with ordered lists in a quick and easy way:

>>> import bisect
>>> scores = [(100, 'perl'), (200, 'tcl'), (400, 'lua'), (500, 'python')]
>>> bisect.insort(scores, (300, 'ruby'))
>>> scores
[(100, 'perl'), (200, 'tcl'), (300, 'ruby'), (400, 'lua'), (500, 'python')]

Floating point decimals

Floating point decimals are widely used as they have various applications. This library can be used to multiply decimals, calculate%, apply rounding, etc. It can also provide us with great accuracy

>>> from decimal import *
>>> round(Decimal('0.70') * Decimal('1.05'), 2)
>>> round(.70 * 1.05, 2)
>>> Decimal('1.00') % Decimal('.10')
>>> 1.00 % 0.10
>>> sum([Decimal('0.1')]*10) == Decimal('1.0')
>>> sum([0.1]*10) == 1.0

This library can give us as much precision as we want:

>>> getcontext().prec = 36
>>> Decimal(1) / Decimal(7)

This is all for today, we hope that these libraries will facilitate your programming task and help you to have new ideas to complement your programs. There are more libraries that Python provides us by default, but we wanted to highlight those that we consider most common in their use.

We remind everyone that it is never too late to start the Python course since we have an index where you can find everything that we have been dealing with in the course.

Entradas Programación

Python course. Volume VI: Conditional Sentences

Conditional statements are used as flow control structures. In the same way that the loops that I explained in the previous chapter. Conditional statements are used primarily to execute specific code when certain conditions are met.

The structure of this code is usually as follows:

If (Condición):

Sentencia a ejecutar

This structure can be seen in the menu of the example program:

if opcion == '1':

The condition can be formed by several conditions and for that we have two operators that are commonly used “and” and “or”.


The “and” operator is used when two or more conditions must be met to execute the statement.

If (condición1 and condición2 and condición3)

Sentencias a ejecutar

if (opcion > '0') and (opcion < '2'):

Second example of conditionals in python
In this case, displayAccounts () will be executed when option is 1.


The “or” operator is used when we want the instruction to be executed, as long as at least one condition is met.

If (condición1) or (condición2) or (condición3)…..

Sentencias a ejecutar

if (opcion<'0') or (opcion >'6'):
print("Opcion no valida")

Third example of conditionals in python
The operators that I just showed you, you can also use in the “while” loops that I showed you in the previous article. Sometimes there is a need to use several conditional statements but they really depend on each other, as in the menu of our program. As you could see, all you have to do is:

If (Condición):

Sentencia a ejecutar

Elseif (Condición):

Sentencia a ejecutar

And so on as many times as necessary.

if opcion == '1':
elif opcion == '2':
crearCuenta(clientes, numCuentas)
elif opcion == '3':
elif opcion == '4':
elif opcion == '5':

Fourth example of conditionals in python

In Python there is no “switch … case” structure as in other languages. This is because its creator did not consider it necessary, since as you can see from the previous code, it can be done through the “if’s”.

Also, tell you that these condition statements can be nested, that is, inside an if you can put another.

If (Condición):

If (Condición):

Sentencia a ejecutar

So the code looks like this:

if (opcion > '0'):
if(opcion < '2'):

Fifth example of conditionals in python

Remember that the condition can be of any type. The only thing that the operation that is put must return a true or false, to know if the condition is met. For example:

if (2 + x ==12)
print (“El valor de x es válido”)

Sixth example of conditionals in python

And this is all I can teach you about conditional statements today. As always, I invite you to review the program that we made as an example, since as you have seen, they are elements that we have used in it and I hope that with today’s explanation it will be a little clearer how they are used.

You can read all the articles of our Python Course at this link from RedesZone.

Entradas Programación

Python course. Volume XIX: Django Framework. Part iv

Handling the Django API for Python

The first thing we are going to do is invoke the Python shell from Django. For this we will have to execute the following command:

$ python shell

We use this command instead of directly opening the Python console because inside “” we have the environment variable “DJANGO_SETTINGS_MODULE” set, which gives Django the “import path” to the file “mysite /”.

Although if on the contrary you do not want to use “”, there would be no problem. It would be enough to set the environment variable “DJANGO_SETTINGS_MODULE” to “mysite.settings”, run a Python “Shell”, and set “Django”:

import django

If when executing these lines an “AttributeError” exception is thrown, probably what is happening is that the version of “Django” that does not match the one we are using in the course. If this is the case, we advise you to use the same version that we are using in the course. Don’t forget that you have to run Python in the same directory as “”, or you can also configure the “Python path” in this directory so that “import.mysite” works for you. You can find more information here.

Now that we have a “Shell” started, we are going to explore the database API:

from polls.models import Pregunta, Opcion
# Import the model classes we just wrote.
# No hay preguntas en el sistema todavia.


# Creamos una nueva pregunta.
# Esta activado el soporte para time zones por defecto. Por lo que
# Django espera a datetime con tzinfo para fecha_publi. Usar

>>>from django.utils import timezone
>>>q = Pregunta(texto_pregunta ="¿Qué hay de nuevo viejo?", fecha_publi

# Guardar el objeto.

# Vamos a recuperar el ID de la pregunta guardada

# Acceder a los campos del modelo utilizando Python.
>>> q.texto_pregunta
"¿Qué hay de nuevo viejo?"
>>> q.fecha_publi
>>>datetime.datetime(2017, 5, 23, 18, 0, 0, 325257, tzinfo=<UTC>)

# Cambiando los valores.
>>> q.texto_pregunta = "¿Qué pasa?"

# objects.all() nos muestra todas las preguntas guardadas.
>>> Pregunta.objects.all()

[<Pregunta: Pregunta object>]

We see that it shows us “” and this is not a very useful representation of the object “Question”. We can correct this by re-editing the models (remember that it is the file “polls /”) and adding the method “__str __ ()” to “Question” and “Option”:

from django.db import models

class Pregunta(models.Model):

# ...

def __str__(self):

return self.texto_pregunta

class Opcion(models.Model):

# ...

def __str__(self):
return self.texto_opcion

It is important that we add the “__str __ ()” method to our models, as it is the representation that “Django” uses in the autogenerated admin interface. If you are using the Python 2 version, you should define the “__unicode __ ()” method that returns unicode values. Django models have a default implementation of “__str __ ()” that calls “__unicode __ ()” and converts the result to a “UTF-8 bytestring”. This means that unicode (p) returns a Unicode string, and str (p) returns a bytestring, encoded in UTF-8. Python does the opposite: object has a __unicode__ method that calls __str__ and interprets the result as an ASCII bytestring. This difference can be confusing.

So far we have used common Python methods. So let’s add one more. The method we are going to add uses the Python “datetime” library and the Django “timezone” library. The first library is one of the standard Python libraries that helps us manage dates and the second offers us the “Django” utilities to manage time zones:

import datetime

from django.db import models
from django.utils import timezone

class Pregunta(models.Model):

# ...

def seHaPublicadoAhora(self):
return self.fecha_publi >= - datetime.timedelta(days=1)

We save these changes and open a new session in the “Shell” by executing “python shell” again and executing the following lines:

>>>from polls.models import Pregunta, Opcion

[<Pregunta: ¿Qué pasa?>]

# Vamos a utilizar filtros de busqueda
>>> Pregunta.objects.filter(id=1)

[<Pregunta: ¿Qué pasa?>]

>>> Pregunta.objects.filter(texto_pregunta__startswith="¿Qué")

[<Pregunta: ¿Qué pasa?>]

# Recuperar las preguntas del ultimo año.
>>> from django.utils import timezone
>>> ano_actual=
>>> Pregunta.objects.get(fecha_publi__year= ano_actual)
<Pregunta: ¿Qué pasa?>

# Preguntamos por un id que no existe para que de un error.

>>> Question.objects.get(id=2)

Traceback (most recent call last):


DoesNotExist: Pregunta matching query does not exist.

# Buscar por primary key. Es muy normal en Django
# Es igual que Pregunta.objects.get(id=1).

>>> Pregunta.objects.get(pk=1)

<Pregunta: ¿Qué pasa?>

# Ejecutar nuestro nuevo método.

>>> q = Pregunta.objects.get(pk=1)
>>> q.seHaPublicadoAhora()


# Vamos a añadir a la pregunta opciones.
>>> q = Pregunta.objects.get(pk=1)

# Mostramos todos las opciones

>>> q.opcion_set.all()

# Creamos 3 opciones.
>>> q.opcion_set.create(texto_opcion='No mucho', votos=0)
<Opcion: No mucho>

>>> q.opcion_set.create(texto_opcion ='El mar', votes=0)

<Opcion: El mar>

>>> c = q.opcion_set.create(texto_opcion ='Nada nuevo', votes=0)

# El objeto Opcion tiene acceso a sus objetos Pregunta relacionados

>>> c.pregunta

<Pregunta: ¿Qué pasa?>

# Al reves tambien.

>>> q.opcion_set.all()

[<Opcion: No mucho>, <Opcion: El mar>, <Opcion: Nada nuevo>]

>>> q.opcion_set.count()

# La API reconoce la relacion existente entre objetos de manera automatica
# Usaremos dos guiones bajos para serparar las relaciones.
# Encontrar todas las opciones de cualquier pregunta que se haya publicado este ano
# (reutilizar la variable 'current_year' que creamos anteriormente).

>>> Opcion.objects.filter(pregunta__fecha_publi__year=current_year)

[<Opcion: No mucho>,<Opcion: El mar>,<Opcion: Nada nuevo>]

# Vamos a borrar una opcion.

>>> c = q.opcion_set.filter(texto_opcion__startswith="Nada")
>>> c.delete()

If you want more information about the relationships between the models, We advise you to go to the documentation of “Django”. If you want more information about how the two scripts are used, let’s do searches using the API, access here. Finally if you want to see the complete database API of “Django” access here.

This is all for today, we have taken another small step to continue studying and understanding this framework. As always, we invite you to keep trying and in this case to read the links that we are leaving you. And for all those who have just joined indicate that we have an index with all the chapters of the courseas it is never too late to start.

Entradas Programación

Get free programming and networking books in PDF format

In this article we are going to talk about a web platform called OpenLibra, a portal designed to distribute all kinds of open books (OpenSource) completely free of charge and for all users without the need to register on the platform or enter any type of personal data.

All documents available on this portal can be download to computer (to save or copy them to an e-book, for example) or view them online (as long as our browser supports the viewing of PDF documents, for example, Google Chrome).

One of the most interesting categories that we find in this portal is with a complete collection of programming manuals. At OpenLibra we have free books for practically any programming language: Java, C, C ++, .Net, PHP, etc. They also have books on mobile programming for those who want to develop applications for this expanding market.

We can view and download the 667 books related to programming from the link below.

We also have a category on networks and sysadmin with several manuals related to these topics with which we can expand our knowledge about point-to-point access points, peer connection, how networks work and much more.


We can download the 46 books on networking and sysadmin from the link below.

Apart from the 2 mentioned categories, we can see on the left a series of additional categories with all kinds of content: languages, robotics, web development, seo, software and several more.

Finally, it should be noted that although most of the available books are in English, some of them can also be found in Spanish to facilitate reading and understanding for those who do not understand the language correctly. Undoubtedly an excellent website where we can spend hours searching for content and many more hours increasing our knowledge of any of the categories available for free.

Do you know more websites to download books for free similar to this?

Source: Pointgeek

Entradas Programación

Python course. Volume XIV: Graphical Interfaces. Part iii

“Qt” is a multiplatform library for developing graphical user interfaces. “Qt” is developed as free and open source software through “QtProject”, where both the community and developers from Nokia, Digia and other companies participate. It uses the programming language “C ++” natively, and there are also multiple bindings for other languages.

We are going to use “PyQt” which are the Python libraries that will allow us to use “Qt”. In this way we can use “Qt” to create the graphical interfaces and Python for the functional part. To use “PyQt” we will have to install additional software.

The software installation that we propose will install the following components:

  • PyQt5.
  • Qt.
  • Qt Designer: It is a “Qt” tool for the design and creation of graphical user interfaces (GUI).
  • Qt Linguist: It is a tool to add translations of “Qt” applications.
  • Qt Assistant: It is an online documentation tool.
  • Pyuic5: Convert “.ui” files into “.py”.
  • pylupdate5: Extract all translatable strings from python code and create or update translation files. These are then used by “Qt Linguist” to manage the translation of those strings.
  • Pyrcc5: Tool necessary to embed resources (icons, images, translation files) in a Python module.
  • QScintilla.


Below we will detail the steps to follow to install the additional software that we will need in order to facilitate the use of the “Qt” library in our applications and it will also facilitate the design of the interfaces.

Step 1

We will go to the “sourceforge” page and look for “PyQt”, to facilitate the search we leave the link below: Direct link to PyQt.

Step 2

Once downloaded we will run the installer. The first thing it will show us on the screen is the following message:

This is because we are using “Python 3.6”. We will have to press «Yes» and we will continue with the installation.

As we can see, it is like any other installer that you may have used. We will leave the default options except for the installation directory, since we will have to select our Python installation directory. This is because it is going to add to our libraries everything necessary to be able to use “PyQt”

Step 3

Once installed we will have to perform 2 steps to know that it has been installed correctly. The first is to open the Python console and type the following command: “import PyQt5” and we will check that there are no errors.

The second step will be to go to the start menu and check that we have installed the “Qt Desinger”

In this simple way we will have everything we need installed, in the following installments we will show you how this environment benefits us when making graphical interfaces, and how we integrate it into our Python code. And for all those who have just joined, tell them that we have an index with all the chapters of the courseas it is never too late to start.

Entradas Programación

The new Visual Studio 2017 is now available

Visual studio is the integrated development environment (IDE) that Microsoft launched in 2017 for Windows systems in order to offer users of its system a complete development platform to empower application development. During its 20 years of life, this environment has changed and improved remarkably to the point that, today, it has become a complete multi-platform tool that allows you to create all kinds of projects for Android, iOS, Linux, MacOS and, of course, Windows.

A few hours ago, Microsoft released the new version of its programming IDE, Visual Studio 2017, which comes with a large number of changes and novelties to adapt to modern times, such as:

  • Productivity has been improved with improvements in code navigation, IntelliSense, clearer refactoring, and new debugging functions.
  • The fundamentals have been redefined, giving a renewed focus to fundamental tasks, something that many developers have been asking for for a long time.
  • Visual Studio 2017 bets on the cloud, specifically for Azure, facilitating the development and implementation of cloud services.
  • Thanks to Xamarin, this IDE now allows you to create applications for mobile devices like Android and iOS in a much more efficient way even than Google and Apple’s own IDEs. Developers can build their applications with Apache, Cordova, or C ++.

The installation process has also been simplified to the maximum, as well as the startup time, being able to have the IDE running in much less time than before. Extensions and projects also load much faster than before.

Visual Studio 2017 is now free to download

We can see the complete list with all the changes in Visual Studio 2017 and download this new version from the following link. This IDE has been, for a long time, paid, however, unless we need the Professional or Enterprise versions, we can download and use the Visual Studio Community 2017 version for free, mainly focused on students and free software developers and individual programmers.

In addition, from this very moment, and until tomorrow, Microsoft has prepared two full days with a large number of events, courses and workshops related to this tool, all of them available at the following web enabled for that event.

Visual Studio Code, the simplest and open source alternative

For many years, Microsoft has been against free software, even calling it a “cancer” for computing. However, thanks to its current CEO, this mentality has changed, to the point that a brand as leading as Visual Studio has received an open source version, a simple programming environment called Visual Studio Code that, without a doubt, has been won the trust of all users.

What do you think of the new Visual Studio 2017? Do you think Microsoft is working to meet the needs of developers?

Entradas Programación

OpenSource development book pack

Humble Book Bundle: Open Source Bookshelf It is a pack consisting of a total of 14 Bleeding Edge Press programming books valued at more than $ 350 with which we will be able to learn very interesting concepts related to development and Open Source programming.

All these books (and a video that is included in the pack) are distributed without any kind of DRM, so we won’t have any problem reading them on any device. In addition, we can download the books in various formats by default, and convert them without problems to the format that we need.

As always, this book pack is divided into 3 categories, and we can unlock them depending on the money we pay, starting with a single dollar and unlocking all the books for only 15 dollars.

Books included in the Humble Book Bundle: Open Source Bookshelf

The first of these packs is unlocked, as we have said, paying any amount above one dollar (about 0.89 euros to change). This first pack of books includes the following titles:

  • Building Apps with Riot
  • Creating Interfaces with Bulma
  • Developing a hapi Edge
  • Developing a React.js Edge

The second of the packs is unlocked by paying from 8 dollars (7.09 euros) and, in addition to including the books of the first pack, we will additionally unlock the following titles:

  • Deep Learning in the Browser
  • Kong: Becoming a King of API Gateways
  • Chatbots for eCommerce
  • TensorFlow For Machine Intelligence

In addition, it also includes a video course called “Bleeding Edge Press Video Course: Kong” and that will help us better understand King’s book in its 20 minutes.

Humble Book Bundle - Open Source Bookshelf - Pack 2

Finally, the third of the packs we unlock by paying the maximum amount, 15 dollars (13.29 euros), and it will give us access to all the books of the two previous packs, in addition to the following titles:

  • Vue.js: Understanding its Tools and Ecosystem
  • Nest.js: A Progressive Node.js Framework
  • Practical gRPC
  • Progressive Web Apps with Preact
  • Developing an Electron Edge
  • Developing a gulp Edge

Humble Book Bundle - Open Source Bookshelf - Pack 3

We can access this pack of books from the following link. Of course, it will only be available for 10 days, so we should not wait too long if we want to get hold of it.

The truth is that these books are focused on a very specific audience: developers who use OpenSource technologies, but we must admit that it is a very complete collection that touches all branches, from the use of APIs and JavaScript to the use of Deep Learning and TensorFlow for artificial intelligence.

Of course, we must bear in mind that all the books are in English, and they are also very technical, so before buying them we must make sure that we know how to function without problems in this language.

Entradas Programación

Pygame, video games in python. Part I

The first thing I want to tell you is that “Pygame” is a multimedia library that works on SDL libraries, and that it will allow us to create two-dimensional video games in a simple way.

The “SDL” (Simple DirectMedia Layer) libraries are a set of libraries that provide the basic functionality to carry out 2D drawing operations, the management of sound effects, music, loading and image management, these are important since as I just finished commenting “Pygame” works on them. Basically it is a library similar to OpenGL or DirectX (only in the 2D part), designed to be easier to use than these others, in addition, OpenGL only takes care of the graphical part, on the other hand SDL includes other things such as sounds.

As I have mentioned before using “Pygame”, we are going to program some video games. They are not going to be a huge 3D game with spectacular graphics that requires a state-of-the-art computer. The games that we are going to teach you to program are 2D games similar to those of consoles such as the Super Nintendo, a Game Boy Advance or a NintendoDS (without the touch part) etc. To give you an idea of ​​how the games programmed with “Pygame” are, they will be games of the style “frets on fire”, “SolarWolf” or “pydance”. You can find more examples on the Pygame site.

“Pygame” is responsible for handling the most complicated part of programming a video game, that is, it is responsible for loading and displaying images (in formats such as PNG, BMP, PCX, TGA, …), sound (OGG formats, MP3, MIDI, …), videos, game windows and monitor input devices (such as mouse, keyboard and joystick) quite simply. So basically one has to worry about the programming of the game itself.

Prerequisites (recommended)

As we already have Python installed, what we need is to install “Pygame”. “Pygame” is available for various systems (such as Windows, GNU / Linux, Mac, etc.) so the games created can be multiplatform.

It will also be necessary to have a basic knowledge of mathematics and physics, because it will be useful when programming games in general, that is, the level of mathematics and physics that is handled in high school. Since it will work with the physical concepts of speed, acceleration, etc. and the mathematical concepts of points, coordinates in space, etc.

First steps

The first thing to do is import the “Pygame” module, which is done as follows:

import pygame
from pygame.locals import *

The second line is optional, although its use is recommended, since we use it to import a series of constants that “Pygame” has (such as keyboard keys). Next, we show you the general structure that our application created with “Pygame” will have:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Importacion de los módulos
import pygame
from pygame.locals import *

# y cualquier otro modulo usado

# ----------------------------------------------
# Constantes, como anchos y largo de pantalla, etc.
# ----------------------------------------------

# ----------------------------------------------
# Clases y Funciones utilizadas
# ----------------------------------------------

def main():

# La clase o función principal que crea o ejecuta el juego
# Contiene principalmente loop del juego (el alma de este)

if __name__ == "__main__":

If you look at the function “main”, we use the instruction “pygame.init ()”, this is to start “Pygame” and it is necessary to execute it before starting to use “Pygame” (that is why it was included in start of the main function of the game). We could also have invoked this instruction before calling the function “main ()”

Here we leave it for today so that you can assimilate the new concepts that we have explained to you, we invite you as always to try everything you have learned so far.

And for all those who have just joined, indicate that we have an index with all the chapters of the courseas it is never too late to start.