1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| #! /usr/bin/env python
#-*-coding: utf-8 -*-
# Python 3.2
import os,sys
from PySide import QtCore,QtGui
app = QtGui.QApplication(sys.argv)
alignCentrer= QtGui.QTextBlockFormat()
alignCentrer.setAlignment(QtCore.Qt.AlignCenter)
editor = QtGui.QTextEdit()
cursor = editor.textCursor()
cursor.movePosition(QtGui.QTextCursor.Start)
TableFormat = QtGui.QTextTableFormat()
#centre la table sur la feuille
TableFormat.setAlignment(QtCore.Qt.AlignHCenter)
TableFormat.setCellPadding(2)#marge a l'interieur des cellules
#creer ligne et colone
entete = cursor.insertTable(1,1,TableFormat)
FrameFormat = cursor.currentFrame().frameFormat()
FrameFormat.setMargin(0)#marge autour du cadre
FrameFormat.setPadding(0)#marge entre les traits du cadre
FrameFormat.setBorderStyle(QtGui.QTextFrameFormat.BorderStyle_Solid)
FrameFormat.setBorderBrush(QtGui.QColor(0,0,0))
FrameFormat.setBorder(1)#determine la bordure
cursor.currentFrame().setFrameFormat(FrameFormat)
cursor = entete.cellAt(0, 0).firstCursorPosition()
cursor = entete.cellAt(0, 0).lastCursorPosition()
cursor.insertText("Titre")
dialog = QtGui.QPrintPreviewDialog()
dialog.paintRequested.connect(editor.print_)
dialog.exec_() |
Partager