Commit 5f99a80b authored by Bruno Guillaume's avatar Bruno Guillaume

add file loading

parent 7637d8e4
......@@ -2,8 +2,8 @@
# -*- coding: utf-8 -*-
import sys
from PyQt5.QtWidgets import (QWidget, QPushButton, QSlider, QSplitter, QAbstractItemView,
QHBoxLayout, QVBoxLayout, QApplication, QTextEdit, QScrollArea, QTreeView, QAction, QMainWindow)
from PyQt5.QtWidgets import (qApp, QWidget, QPushButton, QSlider, QSplitter, QAbstractItemView,
QHBoxLayout, QVBoxLayout, QApplication, QTextEdit, QScrollArea, QTreeView, QAction, QMainWindow, QFileDialog)
from PyQt5.QtWebKitWidgets import QWebView , QWebPage
from PyQt5.QtWebKit import QWebSettings
from PyQt5.QtCore import QUrl, Qt, QFileSystemWatcher
......@@ -21,12 +21,15 @@ global watcher
watcher = None
global sentences
global ids
sentences = conll.load_conll("/users/guillaum/gitlab/deep-sequoia/trunk/sequoia.surf.conll")
sentences=[]
global conll_file
conll_file=None
class Dep2pict(QMainWindow):
def __init__(self, parent = None):
super(Dep2pict, self).__init__(parent)
......@@ -90,11 +93,6 @@ class Dep2pict(QMainWindow):
self.dataView.clicked.connect(self.test)
self.refresh()
self.setGeometry(0, 0, 1920, 600)
self.setWindowTitle('Dep2pict')
self.show()
......@@ -103,23 +101,31 @@ class Dep2pict(QMainWindow):
def init_menu(self):
bar = self.menuBar()
file = bar.addMenu("File")
file.addAction("New")
save = QAction("Save",self)
save.setShortcut("Ctrl+S")
file.addAction(save)
file.triggered[QAction].connect(self.menu_file_action)
edit = file.addMenu("Edit")
edit.addAction("copy")
edit.addAction("paste")
open_ = QAction("Open",self)
open_.setShortcut("Ctrl+O")
file.addAction(open_)
quit = QAction("Quit",self)
quit.setShortcut("Ctrl+Q")
file.addAction(quit)
file.triggered[QAction].connect(self.processtrigger)
def menu_file_action(self, q):
action=q.text()
if action == "Quit":
qApp.quit()
if action == "Open":
self.showDialog()
def showDialog(self):
global conll_file
fname = QFileDialog.getOpenFileName(self, 'Open file')
def processtrigger(self, q):
print(q.text()+" is triggered")
if fname[0]:
print (fname[0])
conll_file = fname[0]
self.data_refresh()
def test(self, index):
# http://doc.qt.io/qt-5/qstandarditem.html
......@@ -150,11 +156,15 @@ class Dep2pict(QMainWindow):
watcher = QFileSystemWatcher()
watcher.addPath("/Users/guillaum/code/pyqt/WebKit/wh.svg")
watcher.fileChanged.connect(self.fileChanged)
watcher.fileChanged.connect(self.refresh)
watcher.fileChanged.connect(self.data_refresh)
def refresh (self):
self.webView_1.setUrl(QUrl("file:///Users/guillaum/gitlab/dep2pict/pyqt/clickable.svg"))
def data_refresh(self):
global sentences
if conll_file:
sentences = conll.load_conll(conll_file)
for s in reversed(sentences):
self.add(self.model, conll.get_sentid (s))
def draw (self,filename):
self.webView_1.setUrl(QUrl("file://"+filename))
......
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