-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathboiler.py
75 lines (61 loc) · 2.16 KB
/
boiler.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import sys,random
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QApplication, QFileDialog, QDialog, QPlainTextEdit
from PyQt5.QtWidgets import QMainWindow, QWidget
from GUI.farsiDictionary import farsimap
from GUI.module_flashcards_ import UiModuleFlashcards
clicks=-1
clicks=0
I=0
J=0
shuffled_dictionary={}
fm_keys=list(farsimap.keys())
random.shuffle(fm_keys)
total_length=[]
cum_len=[]
for i in fm_keys:
total_length.append(len(list(farsimap[i].keys())))
if len(cum_len) > 0:
cum_len.append(total_length[-1]+cum_len[-1])
else:
cum_len.append(total_length[-1])
for i in fm_keys:
fm_keys_keys=list(farsimap[i].keys())
random.shuffle(fm_keys_keys)
shuffled_dictionary[i]={}
for j in fm_keys_keys:
shuffled_dictionary[i][j]=farsimap[i][j]
#print(shuffled_dictionary)
class ModuleFlashcardsWindow(QWidget):
global farsimap, clicks, shuffled_dictionary, total_length, cum_len, fm_keys, I, J
def __init__(self):
super().__init__()
self.settings = QtCore.QSettings('wbSettings','app8')
print(self.settings.fileName())
self.ModuleFlashcardsWindow = QMainWindow()
self.ui = UiModuleFlashcards()
self.ui.setupUi(self.ModuleFlashcardsWindow)
# EVENTS
self.ui.pushButton.clicked.connect(self.clicked)
def show(self):
self.ModuleFlashcardsWindow.show()
def clicked(self):
global farsimap, clicks, shuffled_dictionary, total_length, cum_len, fm_keys, I, J
clicks+=1
if clicks > cum_len[I]:
I+=1
J=0
new_word_list=list(shuffled_dictionary[fm_keys[I]].keys())
print(new_word_list)
self.ui.label.setText(fm_keys[I])
self.ui.label_2.setText(farsimap[fm_keys[I]][new_word_list[J]][0])
self.ui.label_3.setText("\""+new_word_list[J]+"\" : "+farsimap[fm_keys[I]][new_word_list[J]][-1])
J+=1
if __name__ == '__main__':
app = QApplication(sys.argv)
ModuleFlashcardsWindow = ModuleFlashcardsWindow()
ModuleFlashcardsWindow.show()
sys.exit(app.exec_())
# self.ui.pushButton.clicked.connect(self.clicked)
'''
'''