Commit a7117702 authored by Bruno Guillaume's avatar Bruno Guillaume

code cleaning

parent ad298691
......@@ -33,7 +33,9 @@ class Dep2pict(QMainWindow):
def __init__(self, parent = None):
super(Dep2pict, self).__init__(parent)
self.start()
self.watcher = QFileSystemWatcher()
self.watcher.fileChanged.connect(self.data_refresh)
self.init_menu()
self.initUI()
......@@ -45,17 +47,6 @@ class Dep2pict(QMainWindow):
vbox = QVBoxLayout()
central.setLayout(vbox)
hbox = QHBoxLayout()
loadButton = QPushButton("Load")
nextButton = QPushButton("Next")
hbox.addWidget(loadButton)
hbox.addWidget(nextButton)
vbox.addLayout(hbox)
loadButton.clicked.connect(self.load_fct)
nextButton.clicked.connect(self.next_fct)
self.dataView = QTreeView()
self.dataView.setEditTriggers(QAbstractItemView.NoEditTriggers)
......@@ -126,6 +117,7 @@ class Dep2pict(QMainWindow):
print (fname[0])
conll_file = fname[0]
self.data_refresh()
self.update_watcher()
def test(self, index):
# http://doc.qt.io/qt-5/qstandarditem.html
......@@ -149,51 +141,33 @@ class Dep2pict(QMainWindow):
"""Called whenever the global filesystem watcher detects a change."""
print (filename)
def start(self):
"""Start the document watcher."""
global watcher
if watcher is None:
watcher = QFileSystemWatcher()
watcher.addPath("/Users/guillaum/code/pyqt/WebKit/wh.svg")
watcher.fileChanged.connect(self.fileChanged)
watcher.fileChanged.connect(self.data_refresh)
def update_watcher(self):
self.watcher.removePaths (self.watcher.files());
self.watcher.addPath(conll_file);
# """Start the document watcher."""
# global watcher
# if watcher is None:
# watcher = QFileSystemWatcher()
# watcher.addPath(conll_file)
# watcher.fileChanged.connect(self.fileChanged)
#watcher.fileChanged.connect(self.data_refresh)
def data_refresh(self):
print ("[data_refresh]")
global sentences
if conll_file:
sentences = conll.load_conll(conll_file)
# Remove the current rows in self.model
self.model.removeRows(0,self.model.rowCount ())
#self.model.clear()
for s in reversed(sentences):
self.add(self.model, conll.get_sentid (s))
def draw (self,filename):
self.webView_1.setUrl(QUrl("file://"+filename))
def load_fct(self):
req = {
"command": "load_corpus",
"files": ["/users/guillaum/gitlab/deep-sequoia/trunk/sequoia.surf.conll"]
}
reply = network.send_and_receive(req)
print (reply)
__cpt = 123
def next_fct(self):
req = {
"command": "svg_corpus",
"corpus_index": 1,
"position": self.__cpt,
}
self.__cpt += 1
reply = network.send_and_receive(req)
self.draw(reply)
print (reply)
if __name__ == '__main__':
app = QApplication(sys.argv)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment