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_()
def getHTML(self): mainText = '\n'.join( ['Hello Friend', '', self.mainEmailCanvas.toPlainText().strip()]) try: html = convert_string_RST(mainText) # html = core.processValidHTMLWithPNG( html, self.pngWidget.getAllDataAsDict( ) ) return True, html except Exception as e: return False, None
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
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_()
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_()
def sendEmail(self): myString = self.getTextOutput() htmlString = convert_string_RST(myString) if len(htmlString.strip()) == 0: self.statusLabel.setText('OBVIOUSLY NO HTML. PLEASE FIX.') return subject = self.subjLineEdit.text().strip() if len(subject) == 0: self.statusLabel.setText('NO SUBJECT. PLEASE FIX.') return fullEmailString = formataddr( (self.allData['from name'], self.allData['from email'])) if fullEmailString == '': self.statusLabel.setText('NO FROM EMAIL ADDRESS. PLEASE FIX.') return to_emails = set(self.allData['to']) cc_emails = set(self.allData['cc']) bcc_emails = set(self.allData['bcc']) | set([fullEmailString]) logging.info('to_emails: %s.' % to_emails) logging.info('cc_emails: %s.' % cc_emails) logging.info('bcc_emails: %s.' % bcc_emails) logging.info('htmlString: %s.' % htmlString) if len(to_emails | cc_emails) == 0: self.statusLabel.setText( 'NO TO OR CC EMAIL ADDRESSES. PLEASE FIX.') return # ## now send the email out time0 = time.time() num_emails = len(to_emails | cc_emails | bcc_emails) howdy_email.send_collective_email_full(htmlString, subject, fullEmailString, to_emails, cc_emails, bcc_emails, verify=self.verify) logging.info('sent out %d TO/CC/BCC emails in %0.3f seconds.' % (num_emails, time.time() - time0)) self.statusLabel.setText('SUCCESSFULLY SENT OUT EMAILS.')