Skip to content

Commit

Permalink
Base para sistema de login de Usuarios en FlashCards
Browse files Browse the repository at this point in the history
  • Loading branch information
fdanesse committed Jan 24, 2015
1 parent 0eaa9d2 commit 967963e
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 11 deletions.
9 changes: 6 additions & 3 deletions FlashCardView.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def __init__(self):
self.modify_bg(gtk.STATE_NORMAL, COLORES["contenido"])
self.set_border_width(4)

self.user = False
self.topic = False
self.vocabulario = []
self.imagenplayer = False
Expand Down Expand Up @@ -87,7 +88,7 @@ def __siguiente(self, widget, respuesta):
r = 3
elif respuesta == 3:
r = 0
guardar(self.topic, self.vocabulario[self.index_select][0], r)
guardar(self.user, self.topic, self.vocabulario[self.index_select][0], r)
if self.index_select < len(self.vocabulario) - 1:
self.index_select += 1
gobject.timeout_add(500, self.__load, self.index_select)
Expand Down Expand Up @@ -134,19 +135,21 @@ def stop(self):
del(self.imagenplayer)
self.imagenplayer = False

def run(self, topic):
def run(self, data):
"""
Carga Vocabulario, pone widgets a estado inicial y
carga primera palabra.
"""
topic, _dict = data
self.user = _dict
parser = SafeConfigParser()
metadata = os.path.join(topic, "topic.ini")
parser.read(metadata)

self.cabecera.titulo.set_text("Topic: " + parser.get('topic', 'title'))

self.derecha.run()
vocabulario = get_vocabulario(topic)
vocabulario = get_vocabulario(topic, _dict)
self.show()
if vocabulario:
self.vocabulario = vocabulario
Expand Down
2 changes: 2 additions & 0 deletions GameView.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@
import gobject

class GameMenu(gtk.EventBox):

def __init__(self):

gtk.EventBox.__init__(self)

vb = gtk.VBox()
Expand Down
20 changes: 16 additions & 4 deletions Globales.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,17 @@ def __read_cvs(topic):
return vocabulario[1:]


def guardar(topic, palabra, respuesta):
def guardar(_dict, topic, palabra, respuesta):
dirpath = os.path.join(os.environ["HOME"], ".Ple")
if not os.path.exists(dirpath):
os.mkdir(dirpath)
filepath = os.path.join(dirpath, os.path.basename(topic))
userpath = os.path.join(dirpath,
"%s %s" % (_dict["Nombre"], _dict["Apellido"]))
if not os.path.exists(userpath):
os.mkdir(userpath)
upath = os.path.join(userpath, "User")
__set_dict(upath, _dict)
filepath = os.path.join(userpath, os.path.basename(topic))

fecha = str(datetime.date.today())
_dict = __get_dict(filepath)
Expand All @@ -111,14 +117,20 @@ def get_flashcards_previews(topic):
return __read_cvs(topic)


def get_vocabulario(topic):
def get_vocabulario(topic, _dict):
vocabulario = __read_cvs(topic)

# Cargar Persistencia
dirpath = os.path.join(os.environ["HOME"], ".Ple")
if not os.path.exists(dirpath):
os.mkdir(dirpath)
filepath = os.path.join(dirpath, os.path.basename(topic))
userpath = os.path.join(dirpath,
"%s %s" % (_dict["Nombre"], _dict["Apellido"]))
if not os.path.exists(userpath):
os.mkdir(userpath)
upath = os.path.join(userpath, "User")
__set_dict(upath, _dict)
filepath = os.path.join(userpath, os.path.basename(topic))
_dict = __get_dict(filepath)

# Verificar Fechas
Expand Down
21 changes: 19 additions & 2 deletions VideoView.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class VideoView(gtk.EventBox):

__gsignals__ = {
"flashcards": (gobject.SIGNAL_RUN_FIRST,
gobject.TYPE_NONE, (gobject.TYPE_STRING, )),
gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT, )),
"game": (gobject.SIGNAL_RUN_FIRST,
gobject.TYPE_NONE, (gobject.TYPE_STRING, ))}

Expand Down Expand Up @@ -100,7 +100,11 @@ def __emit_game(self, widget, event):
self.emit("game", self.topic)

def __emit_flashcards(self, widget):
self.emit("flashcards", self.topic)
dialog = DialogLogin(self.get_toplevel())
ret = dialog.run()
dialog.destroy()
if ret == gtk.RESPONSE_ACCEPT:
self.emit("flashcards", (self.topic, {"Nombre": "Andres", "Apellido": "Rodriguez", "edad": 8, "Escuela": "N° 35", "Grado": "4°"}))

def set_full(self, widget):
tabla = self.get_child()
Expand Down Expand Up @@ -236,3 +240,16 @@ def load(self, topic):
if not self.control:
self.control = gobject.timeout_add(3000, self.__run_secuencia)
return False


class DialogLogin(gtk.Dialog):

def __init__(self, parent_window=None):

gtk.Dialog.__init__(self, title="Loging", parent=parent_window,
buttons= ("OK", gtk.RESPONSE_ACCEPT,
"Cancelar", gtk.RESPONSE_CANCEL))

# self.set_decorated(False)
self.modify_bg(gtk.STATE_NORMAL, COLORES["window"])
self.set_border_width(15)
Empty file modified peru_learns_english_run
100755 → 100644
Empty file.
4 changes: 2 additions & 2 deletions ple.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ def __game_return_to_video(self, widget, topic):
def __play_game(self, widget, topic):
self.__switch(False, "game", topic)

def __play_flashcards(self, widget, topic):
self.__switch(False, "flashcards", topic)
def __play_flashcards(self, widget, data):
self.__switch(False, "flashcards", data)

def __play_video(self, widget, topic):
self.__switch(False, "Topics", topic)
Expand Down

0 comments on commit 967963e

Please sign in to comment.