-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaccent_window.py
37 lines (31 loc) · 1.3 KB
/
accent_window.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from PyQt6.QtWidgets import QWidget, QVBoxLayout, QLabel
from PyQt6 import QtCore
from dictionnary import DICTIONNARY
# Accent selection window
class AccentWindow(QWidget):
def __init__(self, accent_callback, vowel):
super().__init__()
self.accent_callback = accent_callback # Callback function to print the selected accent
self.vowel = vowel # Target vowel
self.initUI()
def initUI(self):
self.setWindowTitle('Sélection d\'Accent')
self.setWindowFlags(QtCore.Qt.WindowType.FramelessWindowHint)
self.layout = QVBoxLayout()
self.label = QLabel('Appuyez sur un chiffre pour choisir un accent :')
self.layout.addWidget(self.label)
self.accents = DICTIONNARY[self.vowel]
for i, accent in enumerate(self.accents):
self.layout.addWidget(QLabel(f'{i+1}: {accent}'))
self.setLayout(self.layout)
# Print the accent (with the callback function, and close the selection window)
def select_accent(self, accent):
self.accent_callback(accent)
print('accent callback ok')
self.deleteLater()
print('close OK')
def closeEvent(self, event):
self.accent_callback(None)
print('accent callbacknn ok')
event.accept()
print('event ok')