Skip to content
Snippets Groups Projects
Commit ffa7f4ce authored by Lucas Philippe's avatar Lucas Philippe
Browse files

Affichage du clavier

parent 1a06d9b4
No related branches found
No related tags found
No related merge requests found
......@@ -5,7 +5,7 @@ from src.widgets.EditeurWindow import EditeurWindow
def main():
app = QApplication(sys.argv)
window = EditeurWindow()
window.resize(1024, 800)
#window.resize(575, 200)
window.show()
sys.exit(app.exec_())
......
import json
from PyQt5.QtCore import Qt, QSize
from PyQt5.QtGui import QPainter
from PyQt5.QtWidgets import QWidget
from documents.FileDefinition import LAYOUT_FILE
from src.model.Key import Key
......@@ -13,6 +15,9 @@ class KeyboardWidget(QWidget):
self.keyHeight = None
self.keySpacing = None
self.keyboardWidth = 0
self.keyboardHeight = 0
# Initialiser le clavier
self.loadLayoutJson()
self.update()
......@@ -33,6 +38,25 @@ class KeyboardWidget(QWidget):
self.keys.append(self.createKey(keyData))
def createKey(self, keyData):
return Key(keyData['x'], keyData['y'], self.keyWidth, self.keyHeight, self.keySpacing, keyData['width'], keyData['symbol'])
key = Key(keyData['x'], keyData['y'], self.keyWidth, self.keyHeight, self.keySpacing, keyData['width'], keyData['symbol'])
bottomRightPoint = key.rect.bottomRight()
currentHeight = bottomRightPoint.y() + self.keySpacing
currentWidth = bottomRightPoint.x() + self.keySpacing
if self.keyboardHeight < currentHeight:
self.keyboardHeight = currentHeight
if self.keyboardHeight < currentWidth:
self.keyboardWidth = currentWidth
return key
def paintEvent(self, event):
self.sizeHint()
painter = QPainter(self)
for key in self.keys:
painter.drawRect(key.rect)
painter.drawText(key.rect, Qt.AlignCenter, key.symbol)
def sizeHint(self):
return QSize(self.keyboardWidth, self.keyboardHeight)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment