Example Faculty – Python Gtk

We wanted to create a program that can do something like take an entry and select an option to choose a faculty where you study  and finally return the name and the faculty where belongs instead of message


we enter the name of the student(alumno) “fiorella effio saldivar” and then select the faculty(facultad) “Facultad Ciencias Matematicas”, finally press send(enviar) and we will have “name of the student” + of(de la) + “faculty”


Now we are going to see the taxonomy of this program


The first part of the code


Here we set the title for the window in line 8 (UNMSM), in line 11 create a Gtk.Box called box_outer to contain all the items(select_message, listbox, button, final_label), in line 12 we add this box_outer to our main window,  in line 13 we create a Gtk.Label called select_message and then in line 14 add it to our box_outer.

Now in line 16 we create a Gtk.ListBoxRow called listbox to contain the row1 and row2, in line we set the selection mode to NONE, in line 19 we create row1 to contain hbox11, in line 20 create hbox11 to contain label1 and entry1.

In line 28 we create row2 to contain hbox21, in line 29 create hbox21 to contain label2 and combo.

The second part5.pngin line 32 we create a Gtk.ComboBoxText called combo, then in line 33, 34, 35, 36 we define the options for  combo, in line 41 we create a Gtk.Button called button and in line 42 create a Gtk.Label called final_label to show the result for our program.

In line 44 we are going to called for button when it is clicked the function on_clicked_me, we add the button and final_label to box_outer.

Finally we define the function on_clicked_me that ask us for 5 parameters (self, button, entry, label,combo), first we get the text written in a variable text, then in text2 we get the string for our combo option selected, in text3 we combine text and text2, and finally we set the text for final_label 🙂

You can check the code here.



Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión /  Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión /  Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión /  Cambiar )

Conectando a %s