1
2 import string
3
4 from morseCodeTranslationKey import codeKey;
5
6 from python_qt_binding import loadUi;
7 from python_qt_binding import QtGui;
8 from python_qt_binding import QtCore;
9 from QtGui import QDialog
10
11
13
18
20 relPathQtCreatorFileMorseTable = "qt_files/morseTable/morsetabledialog.ui";
21 qtCreatorXMLFilePath = self.parent.findFile(relPathQtCreatorFileMorseTable);
22 if qtCreatorXMLFilePath is None:
23 raise ValueError("Can't find Morse cheat sheet QtCreator user interface file %s" % relPathQtCreatorFileMorseTable);
24
25 loadUi(qtCreatorXMLFilePath, self);
26 self.windowTitle = "Morser Cheat Sheet";
27 self.setWindowTitle(self.windowTitle);
28
29
30
31 morseSheetDict = {};
32 for keyValue in codeKey.items():
33 morseSheetDict[keyValue[1]] = keyValue[0];
34
35
36
37 punctuation = '';
38 for punctLetter in string.punctuation:
39 if morseSheetDict.has_key(punctLetter):
40 punctuation += punctLetter;
41
42
43 specialChars = ['BS','NL', 'HS'];
44
45
46 colCount = self.morseCodeGrid.columnCount();
47 rowCount = self.morseCodeGrid.rowCount();
48 keyIndex = 0;
49 letterLists = [string.lowercase, string.digits, punctuation, specialChars];
50 currentList = 0;
51 for col in range(colCount):
52 for row in range(rowCount):
53 labelTxt = letterLists[currentList][keyIndex] + ": " + morseSheetDict[letterLists[currentList][keyIndex]]
54 labelObj = self.morseCodeGrid.itemAtPosition(row, col);
55 labelObj.widget().setText(labelTxt);
56 keyIndex += 1
57 if keyIndex >= len(letterLists[currentList]):
58 currentList += 1;
59 keyIndex = 0;
60 if currentList >= len(letterLists):
61 return;
62