-
Notifications
You must be signed in to change notification settings - Fork 1
/
MetadataTab.py
50 lines (44 loc) · 1.76 KB
/
MetadataTab.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
__author__ = 'Jan Grewe'
try:
from PyQt4 import QtGui, QtCore, Qt
except Exception, details:
print 'Unfortunately, your system misses the PyQt4 packages.'
quit()
import odml
from MetadataEntry import MetadataEntry
class MetadataTab(QtGui.QWidget):
"""This class creates label-and-lineedit-combinations in the tabs and allows for feedback communication."""
def __init__(self, section, parent):
QtGui.QWidget.__init__(self, parent)
self.parent = parent
self.section = section.clone()
self.layout = QtGui.QHBoxLayout()
self.setLayout(self.layout)
self.page_scroll = Qt.QScrollArea()
self.layout.addWidget(self.page_scroll)
self.scroll_contents = QtGui.QWidget()
self.scroll_layout = QtGui.QVBoxLayout(self.scroll_contents)
self.parent.addTab(self, self.section.type)
self.name_entry = None
self.entries = {}
self.create_tab()
def create_tab(self):
self.entries.clear()
self.name_entry = None
self.scroll_contents.setLayout(self.scroll_layout)
self.page_scroll.setWidgetResizable(False)
self.populate_tab()
self.page_scroll.setWidget(self.scroll_contents)
def populate_tab(self):
p = odml.Property("name", self.section.name)
self.name_entry = MetadataEntry(p, self)
self.scroll_layout.addWidget(self.name_entry)
for p in self.section.properties:
entry = MetadataEntry(p, self)
self.entries[p.name] = entry
self.scroll_layout.addWidget(entry)
def metadata(self):
s = odml.Section(self.name_entry.get_property().value.value, type=self.section.type)
for e in self.entries.values():
s.append(e.get_property())
return s