Пример #1
0
 def __init__(self, Universe, name, parent=None):
     super(SpeakingLineEdit, self).__init__(parent)
     
     self.Universe = Universe
     self.name = name
     
     self.Spell = Spell(self.Universe)
     self.cursor_old_position = self.cursorPosition()
Пример #2
0
class SpeakingLineEdit(QtGui.QLineEdit):
    def __init__(self, Universe, name, parent=None):
        super(SpeakingLineEdit, self).__init__(parent)
        
        self.Universe = Universe
        self.name = name
        
        self.Spell = Spell(self.Universe)
        self.cursor_old_position = self.cursorPosition()
        
    def setText(self, text):
        QtGui.QLineEdit.setText(self, text)
        self.cursor_old_position = self.cursorPosition()
        
    def focusInEvent(self, event):
        self.Universe.SpeakOut.synthOut(self.text())
        QtGui.QLineEdit.focusInEvent(self, QtGui.QFocusEvent(QtCore.QEvent.FocusIn))
        
    def keyPressEvent(self, e):
        if (e.modifiers() & QtCore.Qt.ControlModifier):
            if e.key() == QtCore.Qt.Key_Left:
                QtGui.QLineEdit.keyPressEvent(self, e)
                self.Spell.goWordLeft( self.text().toUtf8(), self.cursorPosition(), self.cursor_old_position )
                self.cursor_old_position = self.cursorPosition()
                #self.emit(QtCore.SIGNAL("lineEdit_ctrl_key_left()"))
                
            elif e.key() == QtCore.Qt.Key_Right:
                QtGui.QLineEdit.keyPressEvent(self, e)
                self.Spell.goWordRight( self.text().toUtf8(), self.cursorPosition(), self.cursor_old_position )
                self.cursor_old_position = self.cursorPosition()
                #self.emit(QtCore.SIGNAL("lineEdit_ctrl_key_right()"))
                
            elif e.key() == QtCore.Qt.Key_Home:
                self.emit(QtCore.SIGNAL("lineEit_ctrl_key_home()"))
                QtGui.QLineEdit.keyPressEvent(self, e)
            elif e.key() == QtCore.Qt.Key_End:
                self.emit(QtCore.SIGNAL("lineEdit_ctrl_key_end()"))
                QtGui.QLineEdit.keyPressEvent(self, e)
                
            elif e.key() == QtCore.Qt.Key_Up:
                self.emit(QtCore.SIGNAL("lineEdit_ctrl_up()"))
            elif e.key() == QtCore.Qt.Key_Down:
                self.emit(QtCore.SIGNAL("lineEdit_ctrl_down()"))
        elif e.key() == QtCore.Qt.Key_Up:
                self.emit(QtCore.SIGNAL("lineEdit_up()"))
        elif e.key() == QtCore.Qt.Key_Down:
            self.emit(QtCore.SIGNAL("lineEdit_down()"))
                
        elif e.key() == QtCore.Qt.Key_Left:
            self.Spell.goCharLeft( self.text().toUtf8(), self.cursorPosition() )
            #self.emit(QtCore.SIGNAL("lineEdit_key_left()"))
            QtGui.QLineEdit.keyPressEvent(self, e)
        elif e.key() == QtCore.Qt.Key_Right:
            self.Spell.goCharRight( self.text().toUtf8(), self.cursorPosition() )
            #self.emit(QtCore.SIGNAL("lineEdit_key_right()"))
            QtGui.QLineEdit.keyPressEvent(self, e)
        elif e.key() == QtCore.Qt.Key_Backspace:
            self.Spell.goCharLeft( self.text().toUtf8(), self.cursorPosition() )
            #self.emit(QtCore.SIGNAL("lineEdit_key_backspace()"))
            QtGui.QLineEdit.keyPressEvent(self, e)
        else:
            return QtGui.QLineEdit.keyPressEvent(self, e)
Пример #3
0
import requests
from lib.spell import Spell

base_url="http://dnd5eapi.co"
uri = "/api/spells"

request = requests.get(base_url+uri)
data = request.json()

for spell in data['results']:
    request = requests.get(base_url + spell['url'])
    spell_data = request.json()
    spell_obj = Spell(cred_file_loc="creds/db.json")
    spell_obj.graph()
    context = spell_obj.graph().begin()

    spell_obj.create_or_update("Spell", spell_data, context)

    spell_obj.handle_relations(context)
    context.commit()