aboutsummaryrefslogtreecommitdiffstats
path: root/Lib/defconQt/groupsView.py
diff options
context:
space:
mode:
authorAdrien Tétar2015-05-29 00:09:44 +0200
committerAdrien Tétar2015-05-29 00:09:44 +0200
commitb588ee3ca0dc77c37b7cc180ba1bdab04bd7de4e (patch)
tree583cdab1fadacb8a865d7816bb07c23fed4bb4c0 /Lib/defconQt/groupsView.py
parent82a6fe3e119bbc52f76da41c4e430f59ee240d11 (diff)
downloadtrufont-b588ee3ca0dc77c37b7cc180ba1bdab04bd7de4e.tar.bz2
Twix
Diffstat (limited to 'Lib/defconQt/groupsView.py')
-rw-r--r--Lib/defconQt/groupsView.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/Lib/defconQt/groupsView.py b/Lib/defconQt/groupsView.py
new file mode 100644
index 0000000..96d9c86
--- /dev/null
+++ b/Lib/defconQt/groupsView.py
@@ -0,0 +1,33 @@
+from PyQt5.QtCore import *
+from PyQt5.QtGui import *
+from PyQt5.QtWidgets import *
+
+class GroupsWindow(QWidget):
+ def __init__(self, font, parent=None):
+ super(GroupsWindow, self).__init__(parent, Qt.Window)
+ self.font = font
+ self.groups = sorted(font.groups.keys(), key=lambda t: t[0])
+
+ self.groupsList = QListWidget(self)
+ #self.groupsList.addItems(self.font.groups.keys())
+ #self.groupsList.setEditTriggers(QAbstractItemView.DoubleClicked | QAbstractItemView.EditKeyPressed)
+ for groupName in self.font.groups.keys():
+ item = QListWidgetItem(groupName, self.groupsList)
+ #item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsEditable)
+ item.setFlags(item.flags() | Qt.ItemIsEditable)
+ self.groupsList.itemChanged.connect(self._groupRenamed)
+
+ layout = QVBoxLayout(self)
+ layout.addWidget(self.groupsList)
+ self.setLayout(layout)
+
+ self.setWindowTitle("%s%s%s%s" % ("Groups window – ", self.font.info.familyName, " ", self.font.info.styleName))
+
+ def _groupRenamed(self):
+ cur = self.groupsList.currentItem()
+ # XXX: perf?
+ index = self.groupsList.indexFromItem(cur)
+ newKey = cur.text()
+ self.font.groups[newKey] = self.font.groups.pop(self.groups[index])
+ self.groups[index] = newKey
+ #print(self.groupsList.currentItem().text()) \ No newline at end of file