Exemple #1
0
 def getHTML(self):
     sectionTitle = self.sectionNameWidget.text().strip()
     mainText = '\n'.join([
         sectionTitle, '\n'.join(['='] * len(sectionTitle)), '',
         self.textEdit.toPlainText().strip()
     ])
     if not check_valid_RST(mainText):
         return False, None
     #
     html = convert_string_RST(mainText)
     return True, html
Exemple #2
0
 def sendValidRST(self, showSection=False):
     if self.NoButton.isChecked(): return ""
     #
     myStr = self.textEdit.toPlainText().strip()
     sectionTitle = self.sectionNameWidget.text().strip()
     if not showSection or len(sectionTitle) == 0: mainText = myStr
     else:
         mainText = '\n'.join([
             sectionTitle, ''.join(['='] * len(sectionTitle)), '', myStr
         ])
     if not check_valid_RST(mainText):
         return ""
     return mainText
Exemple #3
0
 def printHTML(self):
     """
     launches a new :py:class:`HtmlView <howdy.core.core_text_gui.HtmlView>` that contains the rich HTML view of the reStructuredText_ that lives within the ``textOutput`` object's canvas.
     """
     self.statusLabel.setText('')
     myString = self.getTextOutput()
     if not check_valid_RST(myString):
         self.statusLabel.setText('COULD NOT CONVERT FROM %s TO HTML' %
                                  form.upper())
         return
     #
     qdl = QDialogWithPrinting(self, doQuit=False, isIsolated=True)
     #
     qdl.setModal(True)
     backButton = QPushButton('BACK')
     forwardButton = QPushButton('FORWARD')
     resetButton = QPushButton('RESET')
     #
     ##
     qte = HtmlView(qdl, convert_string_RST(myString))
     qdlLayout = QVBoxLayout()
     qdl.setLayout(qdlLayout)
     qdlLayout.addWidget(qte)
     bottomWidget = QWidget()
     bottomLayout = QHBoxLayout()
     bottomWidget.setLayout(bottomLayout)
     bottomLayout.addWidget(resetButton)
     bottomLayout.addWidget(backButton)
     bottomLayout.addWidget(forwardButton)
     qdlLayout.addWidget(bottomWidget)
     qf = QFont()
     qf.setFamily('Consolas')
     qf.setPointSize(11)
     qfm = QFontMetrics(qf)
     #qte.setWidth( 85 * qfm.width( 'A' ) )
     #qte.setHeight( 550 )
     #qdl.width( 85 * qfm.width( 'A' ) )
     #qdl.height( 550 )
     qte.setMinimumSize(85 * qfm.width('A'), 550)
     qdl.setMinimumSize(85 * qfm.width('A'), 550)
     #
     resetButton.clicked.connect(qte.reset)
     backButton.clicked.connect(qte.back)
     forwardButton.clicked.connect(qte.forward)
     qte.setHtml(convert_string_RST(myString))
     #
     qte.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
     qdl.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
     self.statusLabel.setText('SUCCESS')
     qdl.show()
     qdl.exec_()
Exemple #4
0
 def checkRST(self):
     self.statusLabel.setText('')
     myStr = self.mainEmailCanvas.toPlainText().strip()
     if len(myStr) == 0:
         self.emailSendButton.setEnabled(False)
         self.emailTestButton.setEnabled(False)
         self.statusLabel.setText('INVALID RESTRUCTUREDTEXT')
         return
     mainText = '\n'.join(['Hello Friend,', '', myStr])
     if not check_valid_RST(mainText):
         self.emailSendButton.setEnabled(False)
         self.emailTestButton.setEnabled(False)
         self.statusLabel.setText('INVALID RESTRUCTUREDTEXT')
         return
     html = convert_string_RST(mainText)
     self.emailSendButton.setEnabled(True)
     self.emailTestButton.setEnabled(True)
     self.statusLabel.setText('VALID RESTRUCTUREDTEXT')
     #
     qdl = QDialogWithPrinting(self, doQuit=False, isIsolated=True)
     qdl.setWindowTitle('HTML EMAIL BODY')
     qte = HtmlView(qdl)
     qter = QTextEdit(self)
     qter.setReadOnly(True)
     qter.setPlainText('%s\n' % html)
     qdlLayout = QVBoxLayout()
     qdl.setLayout(qdlLayout)
     tw = QTabWidget(self)
     tw.addTab(qte, 'RENDERED HTML')
     tw.addTab(qter, 'RAW HTML')
     qdlLayout.addWidget(tw)
     qf = QFont()
     qf.setFamily('Consolas')
     qf.setPointSize(int(11 * self.resolution))
     qfm = QFontMetrics(qf)
     qdl.setFixedWidth(85 * qfm.width('A'))
     qdl.setFixedHeight(550)
     qte.setHtml(html)
     qdl.show()
     #
     ##
     result = qdl.exec_()
Exemple #5
0
 def checkRST(self):
     self.statusLabel.setText('')
     myStr = self.textEdit.toPlainText().strip()
     if len(myStr) == 0:
         self.statusLabel.setText('INVALID RESTRUCTUREDTEXT')
         self.isValidRST = False
         return
     sectionTitle = self.sectionNameWidget.text().strip()
     mainText = '\n'.join(
         [sectionTitle, ''.join(['='] * len(sectionTitle)), '', myStr])
     if not check_valid_RST(mainText):
         self.statusLabel.setText('INVALID RESTRUCTUREDTEXT')
         self.isValidRST = False
         return
     self.isValidRST = True
     html = convert_string_RST(mainText)
     self.statusLabel.setText('VALID RESTRUCTUREDTEXT')
     #
     qdl = QDialogWithPrinting(self, doQuit=False, isIsolated=True)
     qdl.setWindowTitle('HTML EMAIL BODY')
     qte = HtmlView(qdl)
     qter = QTextEdit(self)
     qter.setReadOnly(True)
     qter.setPlainText('%s\n' % html)
     qdlLayout = QVBoxLayout()
     qdl.setLayout(qdlLayout)
     tw = QTabWidget(self)
     tw.addTab(qte, 'RENDERED HTML')
     tw.addTab(qter, 'RAW HTML')
     qdlLayout.addWidget(tw)
     qf = QFont()
     qf.setFamily('Consolas')
     qf.setPointSize(int(11))
     qfm = QFontMetrics(qf)
     qdl.setFixedWidth(85 * qfm.width('A'))
     qdl.setFixedHeight(550)
     qte.setHtml(html)
     qdl.show()
     #
     ##
     result = qdl.exec_()