|
@@ -10,7 +10,7 @@ class MagpyPlainTextEdit(QPlainTextEdit):
|
|
def focusOutEvent(self, event):
|
|
def focusOutEvent(self, event):
|
|
super().focusOutEvent(event)
|
|
super().focusOutEvent(event)
|
|
if event.lostFocus():
|
|
if event.lostFocus():
|
|
- self.parentWidget().to_view(event)
|
|
|
|
|
|
+ self.parentWidget().to_display(event)
|
|
|
|
|
|
|
|
|
|
class MagpyTextToggle(QStackedWidget):
|
|
class MagpyTextToggle(QStackedWidget):
|
|
@@ -18,11 +18,6 @@ class MagpyTextToggle(QStackedWidget):
|
|
QStackedWidget.__init__(self, parent)
|
|
QStackedWidget.__init__(self, parent)
|
|
|
|
|
|
self.editbox = MagpyPlainTextEdit(self)
|
|
self.editbox = MagpyPlainTextEdit(self)
|
|
- self.displaybox = QTextEdit(self)
|
|
|
|
- self.displaybox.setReadOnly(True)
|
|
|
|
- self.addWidget(self.editbox)
|
|
|
|
- self.addWidget(self.displaybox)
|
|
|
|
-
|
|
|
|
if doc:
|
|
if doc:
|
|
self.doc = doc
|
|
self.doc = doc
|
|
else:
|
|
else:
|
|
@@ -31,18 +26,20 @@ class MagpyTextToggle(QStackedWidget):
|
|
|
|
|
|
self.editbox.setDocument(self.doc)
|
|
self.editbox.setDocument(self.doc)
|
|
|
|
|
|
|
|
+ self.displaybox = QTextEdit(self)
|
|
|
|
+ self.displaybox.setReadOnly(True)
|
|
self.displaybox.mouseReleaseEvent=self.to_edit
|
|
self.displaybox.mouseReleaseEvent=self.to_edit
|
|
|
|
|
|
- self.to_view(None)
|
|
|
|
|
|
+ self.addWidget(self.editbox)
|
|
|
|
+ self.addWidget(self.displaybox)
|
|
|
|
|
|
|
|
+ self.to_display(None)
|
|
|
|
|
|
|
|
|
|
def to_edit(self, event):
|
|
def to_edit(self, event):
|
|
- print("to_edit!")
|
|
|
|
self.setCurrentIndex(0)
|
|
self.setCurrentIndex(0)
|
|
|
|
|
|
- def to_view(self, event):
|
|
|
|
- print("to_view!")
|
|
|
|
|
|
+ def to_display(self, event):
|
|
self.setCurrentIndex(1)
|
|
self.setCurrentIndex(1)
|
|
self.displaybox.setMarkdown(self.doc.toPlainText())
|
|
self.displaybox.setMarkdown(self.doc.toPlainText())
|
|
|
|
|
|
@@ -80,16 +77,15 @@ class ProtoMagpy(QMainWindow):
|
|
self.actions['quit'].triggered.connect(self.close)
|
|
self.actions['quit'].triggered.connect(self.close)
|
|
|
|
|
|
s = QShortcut(QKeySequence('Ctrl+T'), self)
|
|
s = QShortcut(QKeySequence('Ctrl+T'), self)
|
|
- s.activated.connect(self.pagedown)
|
|
|
|
|
|
+ s.activated.connect(self.widgprint)
|
|
|
|
|
|
- def pagedown(self):
|
|
|
|
|
|
+ def widgprint(self):
|
|
print(QApplication.focusWidget())
|
|
print(QApplication.focusWidget())
|
|
|
|
|
|
def initUI(self):
|
|
def initUI(self):
|
|
top_level = MagpyContainer(self)
|
|
top_level = MagpyContainer(self)
|
|
self.setCentralWidget(top_level)
|
|
self.setCentralWidget(top_level)
|
|
|
|
|
|
-
|
|
|
|
self.statusbar = self.statusBar()
|
|
self.statusbar = self.statusBar()
|
|
|
|
|
|
self.setGeometry(100, 100, 1030, 800)
|
|
self.setGeometry(100, 100, 1030, 800)
|