fundamentos de python con orientación a objetos y basado en problemas y bases de datos relacionales
TRANSCRIPT
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
1/152
Fundamentos de Python con Orientación a Objetos y Basado en Problemas
Caso Gestión Información de Proyectos con Bases de Datos Relacionales
1. El Problema
Profesor: Carlos Arturo Castro Castro
El departamento de gestión de proyectos de una empresa desea manejar la información de sus proyectos
mediante una base de datos. De cada proyecto se tiene el código, título, fecha de inicio, fecha de finalización,
costo y los responsables de desarrollarlo. De cada responsable se conoce el código, nombre, teléfono fijo y
de algunos de ellos, el teléfono móvil. Una persona puede ser responsable de algunas actividades de varios
proyectos a la vez. Se conoce la fecha de asignación de un responsable a una actividad determinada. Una
actividad puede ser desarrollada por varios responsables. De cada actividad se conoce código, descripción,
fecha de inicio y fecha de finalización. La fecha de finalización de una actividad no puede ser superior a la
fecha de finalización del proyecto al que pertenece la actividad.
El Modelo Relacional Versión1 se presenta a continuación:
Nota: La clave primaria de la tabla resp_act_proy es la combinación de: CODRESP+CODACTIV+CODPROY
Elaborar un programa en Python que cargue un formulario con un menú con las opciones:
1.Proyectos 2. Actividades 3. Responsables 4. ActividadesxProyectos con Responsables 5. Listados
6. Terminar
Si se selecciona Proyectos, Cargar un formulario con los cuadros de texto Código, Nombre, Teléf ono Fijo,
Teléfono Móvil y los botones para Ingresar, Consultar, Modificar y Borrar un Proyecto.
Si se selecciona Actividades, Cargar un formulario con los cuadros de texto y los botones para Ingresar,
Consultar, Modificar y Borrar una actividad.
Si se selecciona Responsables, Cargar un formulario con los cuadros de texto y los botones para Ingresar,
Consultar, Modificar y Borrar Un responsable.
Si se selecciona ActividadesxProyectos con Responsables Cargar un formulario con los cuadros de texto y
los botones para Ingresar, Consultar, Modificar y Borrar ActividadesxProyectos con Responsables.
Si selecciona Listados, Mostrar un formulario con los botones: 1 Listado de Proyectos con sus actividades. 2.
Listados de Responsables con sus actividades. Los listados se deben mostrar en QTableView
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
2/152
2. La herramientas
Intérprete de Python: Versión 2.7.8
https://www.python.org/downloads/
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
https://www.python.org/downloads/https://www.python.org/downloads/http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttps://www.python.org/downloads/
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
3/152
Diseñador de Ambiente gráfico para python 2.7
PYQT (Windows 32 bit installer)
http://www.riverbankcomputing.co.uk/software/pyqt/download
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.riverbankcomputing.co.uk/software/pyqt/downloadhttp://www.riverbankcomputing.co.uk/software/pyqt/downloadhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.riverbankcomputing.co.uk/software/pyqt/download
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
4/152
IDE para python 2.7
PyScripter-v2.5.3 (32 bit)
https://code.google.com/p/pyscripter/downloads/list
MYSQL para python 2.7
http://dev.mysql.com/downloads/file.php?id=454383d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
5/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
6/152
3. Instalar Herramientas
Instalar Python 2.7
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
7/152
Finalizar
Instalar PyQt4-4.11.3-gpl-Py2.7-Qt4.8.6-x32
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
8/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
9/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
10/152
Finalizar
Instalar PyScripter-v2.5.3-Setup
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
11/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
12/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
13/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
14/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
15/152
Finalizar
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
16/152
Instalar Mysql para Python
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
17/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
18/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
19/152
El motor de bases de datos seleccionado es MYSQL y utilizará la herramienta portable denominada
MOWES, que permite trabajar con la herramienta web PHPMYADMIN para crear y administrar la Base de
datos que se llamará BDPROYECTOS (Nota: Se requiere tener instalado MYSQL o levantar los servicios de
MYSQL desde un portable. Para este problema se usará MOWES portable, ya que existen otros):
3.1 Ejecutar MOWES:
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
20/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
21/152
3.2 Abrir PHPMYADMIN en un Navegador WEB:
Se digita: http://localhost:81/phpmyadmin
Mowes Fue configurado para salir por el puerto 81
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://localhost:81/phpmyadminhttp://localhost:81/phpmyadminhttp://localhost:81/phpmyadminhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://localhost:81/phpmyadmin
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
22/152
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
23/152
3.3 Crear la Base de Datos BDPROYECTOS
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
24/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
25/152
3.4 Crear la tabla RESPONSABLE:
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
26/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
27/152
Click en Grabar
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
28/152
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
29/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
30/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
31/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
32/152
Igual para la tabla Actividad:
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
33/152
Como la Clave Primaria de la tabla RESP_ACT_PROY está compuesta por CODRESP+CODACTIV+CODPROY,
Se procede un poco diferente:
3.6 Se crea la Tabla RESP_ACT_PROY sin Clave Primaria
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
34/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
35/152
3.7 Se crea la clave primaria compuesta con los tres campos
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
36/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
37/152
3.8 Crear las tres claves foráneas
3.8.1 Clave Foránea CODRESP
3.8.1.1 Se crea un índice para CODRESP
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
38/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
39/152
3.8.1.2 Click en el link Vista Relaciones
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
40/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
41/152
3.8.1.3 En la segunda columna del Item relaciones internas se selecciona la clave primaria en la tabla
RESPONSABLE (en la fila de la Clave Foránea CODRESP):
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
42/152
Click en grabar
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
43/152
Click en el link RESP_ACT_PROY, para crear las otras claves foráneas:
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
44/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
45/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
46/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
47/152
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
48/152
Click en grabar
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
49/152
Click en el link BDPROYECTOS para ver el diagrama:
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
50/152
Click en Diseñador:
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
51/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
52/152
Click el ícono Pequeños/grandes todos, para ver el contenido de las tablas:
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
53/152
Y Se reorganizan al gusto:
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
54/152
Click en el link BDPROYECTOS para luego crear el script de la Base de Datos
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
55/152
Click en exportar:
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
56/152
Chequear la opción Enviar (genera un archivo descargable)
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
57/152
Click en continuar
Se crear un archivo de texto llamado BDPROYECTOS.sql y se guarda en la carpeta configurada para
descargas
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
58/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
59/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
60/152
4. Arquitectura del Software
4.1 Se crearán tres paquetes: modelo, vista y control
4.1.1 El Paquete modelo, contendrá una clase por cada tabla de la base de datos. Cada Clase un
atributo por cada campo de la tabla. Un método inicializador de atributos, un método get y un
método set por cada atributo.
4.1.2 El Paquete control, contendrá una clase por cada tabla, cada Clase un método inicializador de
objeto tipo modelo, un método insertar, un método consultar, un método modificar, un
método borrar y un método listar (CRUD - Create, Read, Update and Delete-)
4.1.3 El Paquete vista, contendrá una interfaz gráfica diseñada con PYQT4 para dar respuesta al
problema planteado.
5. Código
5.1 Se crea una carpeta llamada pryProyectos, con tres carpetas: modelo, vita y control:
5.2 desde PYSCRIPTER se crea un módulo llamado __init__.py dentro de cada carpeta para
relacionarlas como paquetes:
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
61/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
62/152
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
63/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
64/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
65/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
66/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
67/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
68/152
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
69/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
70/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
71/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
72/152
5.3 con PYQT4, se diseña la interfaz gráfica:
5.3.1 Diseño del Formulario frmMenuPricipal
5.3.1.1 Ejecutar designer que está en la carpeta C:\Python27\Lib\site-packages\PyQt4
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
73/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
74/152
5.3.1.2 Crear un Main Window
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
75/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
76/152
5.3.1.3 Guardar el archivo con el nombre de frmMenuPricipal.ui en la carpeta C:\Python27\Lib\site-
packages\PyQt4
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
77/152
5.3.1.4 Crear el archivo frmMenuPrincipal.py utilizando el aplicativo que crea archivos .py a partir de
archivos.ui
5.3.1.5 Se ejecuta el cmd de DOS y se cambia a la carpeta C:\Python27\Lib\site-packages\PyQt4
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
78/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
79/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
80/152
5.3.1.6 Se ejecuta el siguiente comando para obtener el archivo .py de Python
pyuic4 -x frmMenuPrincipal.ui -o frmMenuPrincipal.py
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
81/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
82/152
5.3.1.7 copiar el archivo frmMenuPrincipal.py en la carpeta vista del proyecto
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
83/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
84/152
5.3.1.8 Abrir y ejecutar el formulario en PYSCRIPTER
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
85/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
86/152
5.3.2 Se crean los Formularios tipo Widget, para Proyectos, Actividades, Responsables,
FrmResp_Act_Proy, Listados, Listado de Proyectos con sus actividades y Listados de
Responsables con sus actividades
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
87/152
5.3.2.1 El Formulario para proyectos se llama FrmProyectosd
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
88/152
5.3.2.2 FrmProyectos contiene 6 etiquetas (Labels)(una de ellas para el título), 5 cuadros de texto
(Plain Text Edit) llamados txtCod, txtTit, txtFini,txtFfin y txtCos. 4 botones de comando (Push
Button) llamdos btnGuardar, btnConsultar, btnModificar y btnBorrar
Se guarda con el nombre de FrmProyectos
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
89/152
5.3.2.3 FrmActividades contiene 5 etiquetas, 4 cuadros de texto y 4 botones de comando
5.3.2.4 FrmResponsables contiene 5 etiquetas, 4 cuadros de texto y 4 botones de comando
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
90/152
5.3.2.5 FrmResp_Act_Proy contiene 5 etiquetas, 4 cuadros de texto , 4 botones de comando y 1 Table
View
5.3.2.6 Se crean los archivos FrmProyectos.py, FrmActividades.py, FrmResponsables.py,
FrmResp_Act_Proy.py con el comando
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
91/152
pyuic4 archivo.ui -o archivo.py no es necesario la opción –x, ya que no se requiere de un ejecutable
interno. Estos formularios serán llamados externamente al darle click a las opciones del del menú qu
están el el formulario principal
pyuic4 FrmProyectos.ui -o FrmProyectos.py
pyuic4 FrmActividades.ui -o FrmActividades.py
pyuic4 FrmResponsables.ui -o FrmResponsables.py
pyuic4 FrmResp_Act_Proy.ui -o FrmResp_Act_Proy.py
5.3.2.7 Copiar los Archivos creados en la carpeta vista del proyecto y abrirlos con PYSCRIPTER
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
92/152
6. Codificación
Los formularios Ui_FrmProyectos, Ui_FrmActividades, Ui_FrmResponsables y Ui_FrmResp_Act_Proy,
requieren acceder al método show (para ser mostrados desde el menú principal). El método show se
encuentra implementado en la clase QWidget del módulo QtGui. Ver http://qt-project.org/doc/qt-
4.8/qtgui.html . Por lo tanto se debe expresar la herencia de los formularios con QtGui. QWidget y no conobject como viene desde el diseñador PYQT4.
Adicionalmente se debe implementar el método __init__, en la clase de cada formulario para lograr el
efecto del llamado al método show():
def __init__(self):
QtGui.QWidget.__init__(self)
self.setupUi(self)
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://qt-project.org/doc/qt-4.8/qtgui.htmlhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://qt-project.org/doc/qt-4.8/qtgui.htmlhttp://qt-project.org/doc/qt-4.8/qtgui.html
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
93/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
94/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
95/152
En el formulario Principal se deben importar la clase de cada formulario:
En el Formulario principal se define la acción para cada menú de barra, y que no tiene submenú:
Como Listado de proyectos con sus actividades y Listado de Responsables con sus actividades, son
submenús, ya vienen adicionados desde el diseñador PYQT4.
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
96/152
Al Formulario principal se le adiciona la acción a cada menú de la barra y que no tiene submenú:
A los Menús, que no tienen submenú, se cambia la propiedad setTitle por setText, y el nombre del menú,
por el nombre de la acción.
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
97/152
Se invoca el método connect de la clase QObject del módulo QtCore, de tal manera que al darle click al
menú o submenú invoque los métodos asociados y que permiten mostrar cada formulario según sea el
caso:
Se programan los métodos para cada acción:
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
98/152
Al ejecutar el Formulario principal queda:
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
99/152
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
100/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
101/152
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
102/152
6.1 Codificar las clases del paquete modelo
6.1.1 Ver http://elviajedelnavegante.blogspot.com/2010/10/las-propiedades-property-de-
python.html
6.1.2 Clase Proyecto
# -*- coding: utf-8 -*-
#-------------------------------------------------------------------------------
# Name: module1
# Purpose:
# Author: Carlos Arturo
#
# Created: 06/12/2014
# Copyright: (c) Carlos Arturo 2014
# Licence:
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://elviajedelnavegante.blogspot.com/2010/10/las-propiedades-property-de-python.htmlhttp://elviajedelnavegante.blogspot.com/2010/10/las-propiedades-property-de-python.htmlhttp://elviajedelnavegante.blogspot.com/2010/10/las-propiedades-property-de-python.htmlhttp://elviajedelnavegante.blogspot.com/2010/10/las-propiedades-property-de-python.htmlhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://elviajedelnavegante.blogspot.com/2010/10/las-propiedades-property-de-python.htmlhttp://elviajedelnavegante.blogspot.com/2010/10/las-propiedades-property-de-python.html
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
103/152
#-------------------------------------------------------------------------------
class Proyecto(object):
def __init__(self, param_codigo, param_titulo, param_fechaIni,param_fechaFin,param_costo):
self.__codigo=param_codigo
self.__titulo=param_titulo
self.__fechaIni=param_fechaIni
self.__fechaFin=param_fechaFin
self.__costo=param_costo
def __getCodigo(self):
return self.__codigo
def __setCodigo(self, param_codigo = None):
self.__codigo = param_codigo
def __getTitulo(self):
return self.__titulo
def __setTitulo(self, param_titulo = None):
self.__titulo = param_titulo
def __getFechaIni(self):
return self.__fechaIni
def __setFechaIni(self, param_fechaIni = None):
self.__fechaIni = param_fechaIni
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
104/152
def __getFechaFin(self):
return self.__fechaFin
def __setFechaFin(self, param_fechaFin = None):
self.__fechaFin = param_fechaFin
def __getCosto(self):
return self.__costo
def __setCosto(self, param_costo = None):
self.__costo = param_costo
codigo = property(fget = __getCodigo, fset = __setCodigo, doc = 'Código')
titulo = property(fget = __getTitulo, fset = __setTitulo, doc = 'Título del proyecto')
fechaIni = property(fget = __getFechaIni, fset = __setFechaIni, doc = 'Fecha de Inicio del proyecto')
fechaFin = property(fget = __getFechaFin, fset = __setFechaFin, doc = 'Fecha de Finalización delproyecto')
costo = property(fget = __getCosto, fset = __setCosto, doc = 'Costo')
6.1.3 Clase Actividad
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
105/152
# -*- coding: utf-8 -*-
#-------------------------------------------------------------------------------
# Name: module1
# Purpose:
#
# Author: Carlos Arturo
#
# Created: 08/12/2014
# Copyright: (c) Carlos Arturo 2014
# Licence:
#-------------------------------------------------------------------------------
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
106/152
class Actividad(object):
def __init__(self, param_codigo, param_descripcion, param_fechaIni,param_fechaFin):
self.__codigo=param_codigo
self.__descripcion=param_descripcion
self.__fechaIni=param_fechaIni
self.__fechaFin=param_fechaFin
def __getCodigo(self):
return self.__codigo
def __setCodigo(self, param_codigo = None):
self.__codigo = param_codigo
def __getDescripcion(self):
return self.__descripcion
def __setDescripcion(self, param_descripcion = None):
self.__descripcion = param_descripcion
def __getFechaIni(self):
return self.__fechaIni
def __setFechaIni(self, param_fechaIni = None):
self.__fechaIni = param_fechaIni
def __getFechaFin(self):
return self.__fechaFin
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
107/152
def __setFechaFin(self, param_fechaFin = None):
self.__fechaFin = param_fechaFin
codigo = property(fget = __getCodigo, fset = __setCodigo, doc = 'Código')
descripcion = property(fget = __getDescripcion, fset = __setDescripcion, doc = 'Descripción de la
Actividad')
fechaIni = property(fget = __getFechaIni, fset = __setFechaIni, doc = 'Fecha de Inicio de la actividad')
fechaFin = property(fget = __getFechaFin, fset = __setFechaFin, doc = 'Fecha de Finalización de la
Actividad')
6.1.3 Clase Responsable
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
108/152
# -*- coding: utf-8 -*-
#-------------------------------------------------------------------------------
# Name: module1
# Purpose:
#
# Author: Carlos Arturo
#
# Created: 08/12/2014
# Copyright: (c) Carlos Arturo 2014
# Licence:
#-------------------------------------------------------------------------------
class Responsable(object):
def __init__(self, codigo, nombre, telFijo,telMovil):
self.__codigo=codigo
self.__nombre=nombre
self.__telFijo=telFijo
self.__telMovil=telMovil
def __getCodigo(self):
return self.__codigo
def __setCodigo(self, codigo = None):
self.__codigo = codigo
def __getNombre(self):
return self.__nombre
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
109/152
def __setNombre(self, nombre = None):
self.__nombre = nombre
def __getTelFijo(self):
return self.__telFijo
def __setTelFijo(self, telFijo = None):
self.__telFijo = telFijo
def __getTelMovil(self):
return self.__telMovil
def __setTelMovil(self, telMovil = None):
self.__telMovil = telMovil
codigo = property(fget = __getCodigo, fset = __setCodigo, doc = 'Código')
nombre = property(fget = __getNombre, fset = __setNombre, doc = 'Nombre')
telFijo = property(fget = __getTelFijo, fset = __setTelFijo, doc = 'Teléfono Fijo')
telMovil = property(fget = __getTelMovil, fset = __setTelMovil, doc = 'Teléfono Móvil')
6.1.4 Clase Resp_Act_Proy
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
110/152
# -*- coding: utf-8 -*-
#-------------------------------------------------------------------------------
# Name: module1
# Purpose:
#
# Author: Carlos Arturo
#
# Created: 08/12/2014
# Copyright: (c) Carlos Arturo 2014
# Licence:
#-------------------------------------------------------------------------------
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
111/152
class Resp_Act_Proy(object):
def __init__(self, codResp, codActiv, codProy,fecha_Asig):
self.__codResp=codResp
self.__codActiv=codActiv
self.__codProy=codProy
self.__fecha_Asig=fecha_Asig
def __getCodResp(self):
return self.__codResp
def __setCodResp(self, codResp = None):
self.__codResp = codResp
def __getCodActiv(self):
return self.__codActiv
def __setCodActiv(self, codActiv = None):
self.__codActiv = codActiv
def __getCodProy(self):
return self.__codProy
def __setCodProy(self, codProy = None):
self.__codProy = codProy
def __getFecha_Asig(self):
return self.__fecha_Asig
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
112/152
def __setFecha_Asig(self, fecha_Asig = None):
self.__fecha_Asig = fecha_Asig
codResp = property(fget = __getCodResp, fset = __setCodResp, doc = 'Código Responsable')
codActiv = property(fget = __getCodActiv, fset = __setCodActiv, doc = 'Código Actividad')
codProy = property(fget = __getCodProy, fset = __setCodProy, doc = 'Código Proyecto')
fecha_Asig = property(fget = __getFecha_Asig, fset = __setFecha_Asig, doc = 'Fecha Asignación de la
Actividad')
6.2 Codificar las clases del paquete control
6.2.1 Clase ConexionMySQL
# -*- coding: utf-8 -*-
#!/usr/bin/python
#-------------------------------------------------------------------------------
# Name: module1
# Purpose:
#
# Author: Carlos Arturo
#
# Created: 06/12/2014
# Copyright: (c) Carlos Arturo 2014
# Licence:
#-------------------------------------------------------------------------------
import MySQLdb
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
113/152
class ConexionMySQL(object):
mensaje="ok"
conexion=None
cursor=None
lista=None
def __init__(self):
pass
def getLista(self):
return self.lista
def abrirBd(self,usuario,contrasena,baseDeDatos):
mensaje="ok"
try:
self .conexion = MySQLdb.Connect(host="127.0.0.1", port=3306, user=usuario,
passwd=contrasena, db=baseDeDatos)
self .cursor = self.conexion.cursor()
except MySQLdb.Error,msgError:
self .mensaje= "Problemas con la Base de Datos Error :%s"%msgError
except AttributeError as objAttributeError:
self .mensaje= "Problemas con la Base de Datos Error :"+objAttributeError[0]
return self.mensaje
def cerrarBd(self):
mensaje="ok"
try:
self.cursor.close()
self.conexion.close()
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
114/152
except MySQLdb.Error,msgError:
self.mensaje= "Problemas con la Base de Datos Error :%s"%msgError
except AttributeError as objAttributeError:
self.mensaje= "Problemas con la Base de Datos Error :"+objAttributeError[0]
return self.mensaje
def ejecutarComandoSql(self,comandoSql):
mensaje="ok"
try:
self .cursor.execute(comandoSql)
self .lista = list(self.cursor)
self .conexion.commit()
except MySQLdb.Error,msgError:
self .mensaje= "Problemas con la Base de Datos Error :%s"%msgError
except AttributeError as objAttributeError:
self .mensaje= "Problemas con la Base de Datos Error :"+objAttributeError[0]
return self.mensaje
6.2.2 Clase CtrProyecto
# -*- coding: utf-8 -*-
#-------------------------------------------------------------------------------
# Name: module1
# Purpose:
#
# Author: Carlos Arturo
#
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
115/152
# Created: 04/12/2014
# Copyright: (c) Carlos Arturo 2014
# Licence:
#-------------------------------------------------------------------------------
from modelo.Proyecto import *
from control.ConexionMySQL import *
from control.CtrProyecto import *
def main():
pass
if __name __ == '__main__':
main()
class CtrProyecto(object):
mensaje='ok'
objProyecto=None
lista=None
def __init__(self,Proyecto):
self.objProyecto=Proyecto
def getLista(self):
return self.lista
def getObjProyecto(self):
return self.objProyecto
def guardar(self):
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
116/152
codigo=self.objProyecto.codigo
titulo=self.objProyecto.titulo
fechaIni=self.objProyecto.fechaIni
fechaFin=self.objProyecto.fechaFin
costo=self.objProyecto.costo
comandoSql="INSERT INTO PROYECTO
VALUES('"+codigo+"','"+titulo+"','"+fechaIni+"','"+fechaFin+"',"+str(costo)+")"
objConexionMySQL=ConexionMySQL()
self.mensaje=objConexionMySQL.abrirBd("root","","bdproyectos")
if self.mensaje=='ok':
self .mensaje=objConexionMySQL.ejecutarComandoSql(comandoSql)
if self.mensaje=='ok':
self.mensaje= objConexionMySQL.cerrarBd()
return self.mensaje
def modificar(self):
codigo=self.objProyecto.codigo
titulo=self.objProyecto.titulo
fechaIni=self.objProyecto.fechaIni
fechaFin=self.objProyecto.fechaFin
costo=self.objProyecto.costo
comandoSql="UPDATE PROYECTO SET TITULO='"+
titulo+"',FECHAINI='"+fechaIni+"',FECHAFIN='"+fechaFin+"',COSTO="+str(costo)+" WHERE
CODIGO='"+codigo+"'"
objConexionMySQL=ConexionMySQL()
self.mensaje=objConexionMySQL.abrirBd("root","","bdproyectos")
if self.mensaje=='ok':
self.mensaje=objConexionMySQL.ejecutarComandoSql(comandoSql)
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
117/152
if self.mensaje=='ok':
self.mensaje= objConexionMySQL.cerrarBd()
return self.mensaje
def borrar(self):
codigo=self.objProyecto.codigo
comandoSql="DELETE FROM PROYECTO WHERE CODIGO='"+codigo+"'"
objConexionMySQL=ConexionMySQL()
self.mensaje=objConexionMySQL.abrirBd("root","","bdproyectos")
if self.mensaje=='ok':
self .mensaje=objConexionMySQL.ejecutarComandoSql(comandoSql)
if self.mensaje=='ok':
self.mensaje= objConexionMySQL.cerrarBd()
return self.mensaje
def consultar(self):
codigo=self.objProyecto.codigo
comandoSql="SELECT * FROM PROYECTO WHERE CODIGO='"+codigo+"'"
objConexionMySQL=ConexionMySQL()
self.mensaje=objConexionMySQL.abrirBd("root","","bdproyectos")
if self.mensaje=='ok':
self.mensaje=objConexionMySQL.ejecutarComandoSql(comandoSql)
self.lista=objConexionMySQL.getLista()
self.objProyecto.titulo= self.lista[0][1]
self.objProyecto.fechaIni= self.lista[0][2]
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
118/152
self.objProyecto.fechaFin= self.lista[0][3]
self.objProyecto.costo= self.lista[0][4]
if self.mensaje=='ok':
self.mensaje= objConexionMySQL.cerrarBd()
return self.mensaje
def listar(self):
codigo=self.objProyecto.codigo
comandoSql="SELECT * FROM PROYECTO"
objConexionMySQL=ConexionMySQL()
self.mensaje=objConexionMySQL.abrirBd("root","","bdproyectos")
if self.mensaje=='ok':
self .mensaje=objConexionMySQL.ejecutarComandoSql(comandoSql)
self .lista=objConexionMySQL.getLista()
if self.mensaje=='ok':
self.mensaje= objConexionMySQL.cerrarBd()
return self.mensaje
6.2.3 Clase CtrActividad
# -*- coding: utf-8 -*-
#-------------------------------------------------------------------------------
# Name: module1
# Purpose:
#
# Author: Carlos Arturo
#
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
119/152
# Created: 04/12/2014
# Copyright: (c) Carlos Arturo 2014
# Licence:
#-------------------------------------------------------------------------------
from modelo.Actividad import *
from control.ConexionMySQL import *
from control.CtrActividad import *
def main():
pass
if __name__ == '__main__':
main()
class CtrActividad(object):
mensaje='ok'
objActividad=None
lista=None
def __init__(self,Actividad):
self.objActividad=Actividad
def getLista(self):
return self.lista
def getObjActividad(self):
return self.objActividad
def guardar(self):
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
120/152
codigo=self.objActividad.codigo
descripcion=self.objActividad.descripcion
fechaIni=self.objActividad.fechaIni
fechaFin=self.objActividad.fechaFin
comandoSql="INSERT INTO ACTIVIDAD
VALUES("+codigo+",'"+descripcion+"','"+fechaIni+"','"+fechaFin+"')"
objConexionMySQL=ConexionMySQL()
self.mensaje=objConexionMySQL.abrirBd("root","","bdproyectos")
if self.mensaje=='ok':
self.mensaje=objConexionMySQL.ejecutarComandoSql(comandoSql)
if self.mensaje=='ok':
self.mensaje= objConexionMySQL.cerrarBd()
return self.mensaje
def modificar(self):
codigo=self.objActividad.codigo
descripcion=self.objActividad.descripcion
fechaIni=self.objActividad.fechaIni
fechaFin=self.objActividad.fechaFin
comandoSql="UPDATE ACTIVIDAD SET
DESCRIPCION='"+descripcion+"',FECHAINI='"+fechaIni+"',FECHAFIN='"+fechaFin+"' WHERE
CODIGO="+codigo
objConexionMySQL=ConexionMySQL()
self.mensaje=objConexionMySQL.abrirBd("root","","bdproyectos")
if self.mensaje=='ok':
self.mensaje=objConexionMySQL.ejecutarComandoSql(comandoSql)
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
121/152
if self.mensaje=='ok':
self.mensaje= objConexionMySQL.cerrarBd()
return self.mensaje
def borrar(self):
codigo=self.objActividad.codigo
comandoSql="DELETE FROM ACTIVIDAD WHERE CODIGO="+codigo
objConexionMySQL=ConexionMySQL()
self.mensaje=objConexionMySQL.abrirBd("root","","bdproyectos")
if self.mensaje=='ok':
self.mensaje=objConexionMySQL.ejecutarComandoSql(comandoSql)
if self.mensaje=='ok':
self.mensaje= objConexionMySQL.cerrarBd()
return self.mensaje
def consultar(self):
codigo=self.objActividad.codigo
comandoSql="SELECT * FROM ACTIVIDAD WHERE CODIGO="+codigo
objConexionMySQL=ConexionMySQL()
self.mensaje=objConexionMySQL.abrirBd("root","","bdproyectos")
if self.mensaje=='ok':
self.mensaje=objConexionMySQL.ejecutarComandoSql(comandoSql)
self.lista=objConexionMySQL.getLista()
self.objActividad.descripcion= self.lista[0][1]
self.objActividad.fechaIni= self.lista[0][2]
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-now
-
8/19/2019 Fundamentos de Python Con Orientación a Objetos y Basado en Problemas y Bases de Datos Relacionales
122/152
self.objActividad.fechaFin= self.lista[0][3]
if self.mensaje=='ok':
self.mensaje= objConexionMySQL.cerrarBd()
return self.mensaje
def listar(self):
codigo=self.objActividad.codigo
comandoSql="SELECT * FROM ACTIVIDAD"
objConexionMySQL=ConexionMySQL()
self.mensaje=objConexionMySQL.abrirBd("root","","bdproyectos")
if self.mensaje=='ok':
self.mensaje=objConexionMySQL.ejecutarComandoSql(comandoSql)
self.lista=objConexionMySQL.getLista()
if self.mensaje=='ok':
self.mensaje= objConexionMySQL.cerrarBd()
return self.mensaje
6.2.4 Clase CtrResponsable
# -*- coding: utf-8 -*-
#-------------------------------------------------------------------------------
# Name: module1
# Purpose:
#
# Author: Carlos Arturo
d
e
s
k
P
F
S
t
u
d
i
o
T
r
ia
l
http://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskpdf/pdf-studio/buy-studio-x-nowhttp://www.docudesk.com/deskp