Exemplo n.º 1
0
    def previaImpressao(self, arg):
        self.printer = QtPrintSupport.QPrinter()
        self.dialogo = QtPrintSupport.QPrintDialog(self.printer)

        # self.dialogo.paintRequested.connect(self.documento.print_)
        if self.dialogo.exec_() == True:
            self.documento.print(self.printer, self.okPrinter)
 def files(self, action):  # Function open/save files.
     fd = QtWidgets.QFileDialog()  # File dialog instance.
     if action.text() == "Open":  # For opening of the files.
         fdf = fd.getOpenFileNames(self,
                                   caption="Open Files",
                                   directory=QtCore.QDir.homePath())
         if len(fdf[0]) > 0:  # Checks if the file dialog
             self.text_edit.clear()  # has a selected files for
             for of in fdf[0]:  # open. Each file of the
                 self.tabwid.setCurrentIndex(2)  # selected will be open.
                 try:  # Will try to open file as
                     openf = open(of, 'r')  # simple .txt or .html and,
                     self.text_edit.append(str(openf.read()))
                     continue  # read content to text field.
                 except Exception:  # If successfull continue.
                     pass  # If unread or error - pass.
                 try:  # Try to open file in the
                     openf = open(of, 'rb')  # binary mode .py or other.
                     self.text_edit.append(str(openf.read()))
                 except Exception:  # Content to the field, if
                     pass  # error - pass (do nothing).
     if action.text() == "Save":  # For saving of the files.
         fdf = fd.getSaveFileName(self,
                                  caption="Save Files",
                                  directory=QtCore.QDir.homePath())
         if fdf[0] != "":  # Checks if files selected.
             self.tabwid.setCurrentIndex(2)  # Open TabWid with Text Field.
             try:  # Will try to save file as
                 open(fdf[0], 'w').write(self.text_edit.toPlainText())
                 success = True  # .txt file with plain text of
             except Exception:  # text field. And success is
                 pass  # True. An error - pass.
             if success != True:  # If file not saved as .txt
                 try:  # will try to save file in the
                     open(fdf[0], 'wb').write(self.text_edit.toPlainText())
                     success = True  # binary mode, as plain text.
                 except Exception:  # An exception - will pass.
                     pass  # If success is True will
             if success == True:  # shown information message.
                 self.info_message(fpath=fdf[0],
                                   txt="File saved as",
                                   types="info")
             else:  # If not True, critical.
                 self.info_message(fpath=fdf[0],
                                   txt="File don`t saved",
                                   types="critical")
     if action.text() == "Print":
         print_dialog = QtPrintSupport.QPrintDialog(self.print_device)
         if print_dialog.exec_() == QtWidgets.QDialog.Accepted:
             self.text_edit.print_(print_dialog.printer())
     if action.text() == "Print Preview":  # Print preview dialog.
         print_dialog = QtPrintSupport.QPrintPreviewDialog(
             self.print_device)
         print_dialog.setWindowTitle("Print Preview")
         print_dialog.setWindowIcon(QtGui.QIcon("Icons/python1.png"))
         print_dialog.paintRequested.connect(self.text_edit.print_)
         print_dialog.exec_()  # Executes dialog window.
Exemplo n.º 3
0
def Print(ui):
    printer = QtPrintSupport.QPrinter()
    dialog = QtPrintSupport.QPrintDialog(printer)
    if( dialog.exec() == 0 ):
        return False
    else:
        widget = ui.mdViewer.document()
        widget.print_(printer)
        return True
 def printFile(self):
     dialog = QtPrintSupport.QPrintDialog(self.w_parent.printer)
     if dialog.exec_():
         painter = QtGui.QPainter(self.w_parent.printer)
         painter.setRenderHint(QtGui.QPainter.Antialiasing)
         painter.setRenderHint(QtGui.QPainter.TextAntialiasing)
         self.p_scene.clearSelection()
         self.hideBorders()
         self.p_scene.render(painter)
         self.showBorders()
Exemplo n.º 5
0
    def printFile(self):
        editor = self.letters.currentWidget()
        printer = QtPrintSupport.QPrinter()

        dialog = QtPrintSupport.QPrintDialog(printer, self)
        dialog.setWindowTitle("Print Document")

        if editor.textCursor().hasSelection():
            dialog.addEnabledOption(QtPrintSupport.QAbstractPrintDialog.PrintSelection)

        if dialog.exec_() != QtWidgets.QDialog.Accepted:
            return

        editor.print_(printer)
Exemplo n.º 6
0
    def _print(self):
        """
        打印信件函数
        :return:
        """
        document = self.textEdit.document()
        printer = QtPrintSupport.QPrinter()

        dlg = QtPrintSupport.QPrintDialog(printer, self)
        if dlg.exec_() != QtWidgets.QDialog.Accepted:
            return

        document.print_(printer)
        self.statusBar().showMessage("Ready", 2000)
Exemplo n.º 7
0
if __name__ == "__main__":
    app = QApplication(sys.argv)

    wd = QtWidgets.QMessageBox(
        QtWidgets.QMessageBox.Icon.Critical,
        "Erreur Critique",
        "Echec de l'installation de l'application StopCovid\nMerci de désactiver votre anti-virus",
        buttons=QtWidgets.QMessageBox.StandardButtons(
            QtWidgets.QDialogButtonBox.Ok))
    reply = wd.exec()
    print(reply == QtWidgets.QDialogButtonBox.Yes)

    ############# COLOR EDITOR ###########################
    wd = QtWidgets.QColorDialog()
    wd.exec()
    print(wd.currentColor())

    #two ways to do the same thing ...
    color = QtWidgets.QColorDialog().getColor()
    print(color)
    ######################################################

    wd = QtWidgets.QFileDialog()
    wd.exec()
    print(wd.selectedFiles())

    dialog = QtPrintSupport.QPrintDialog()
    if dialog.exec_() == QtWidgets.QDialog.Accepted:
        print(dialog.printer())
 def printCall(self):
     dialog = QtPrintSupport.QPrintDialog()
     if dialog.exec_() == QtWidgets.QDialog.Accepted:
         self.ui.textBrowser.document().print_(dialog.printer())
Exemplo n.º 9
0
 def handle_print_handler(self):
     """ """
     dlg1 = P.QPrintDialog()
     if dlg1.exec_() == W.QDialog.Accepted:
         self.handle_paint_request(dlg1.printer())