Commit 28ea24e8 authored by Bruno Guillaume's avatar Bruno Guillaume

keep scroll position

parent 9e7a8d25
......@@ -87,6 +87,7 @@ class Dep2pict(QMainWindow):
self.web_view = QWebView()
right_hbox.addWidget(self.web_view)
self.web_view.loadFinished.connect(self.post_draw) #keep scroll position
slider1 = QSlider(Qt.Vertical)
slider1.setMaximum(300)
......@@ -95,6 +96,7 @@ class Dep2pict(QMainWindow):
slider1.valueChanged.connect(lambda v:self.web_view.setZoomFactor(v/100))
right_hbox.addWidget(slider1)
def menu_file_action(self, q):
action=q.text()
if action == "Quit":
......@@ -118,6 +120,7 @@ class Dep2pict(QMainWindow):
new_position = index.model().itemFromIndex(index).row()
if self.position != new_position:
self.position = new_position
self.scroll_pos = None
self.draw()
def draw (self):
......@@ -125,6 +128,10 @@ class Dep2pict(QMainWindow):
svg_file = conll.to_svg (sentence)
self.web_view.setUrl(QUrl("file://"+svg_file))
def post_draw(self):
if self.scroll_pos != None:
self.web_view.page().mainFrame().setScrollPosition (self.scroll_pos)
def open_new_file(self, filename):
self.conll_file = filename
self.setWindowTitle('Dep2pict -- '+filename)
......@@ -151,6 +158,7 @@ class Dep2pict(QMainWindow):
self.data_view.setCurrentIndex(self.model.index(self.position,0))
self.draw()
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Dep2pict()
......
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