Bonjour,
Windows7, 64 bits, Python 3.2 32 bits
j'ai réalisé un cahier de recettes que j'ai envie de partager avec d'autres mais voilà tout marche sur mon ordi quand je lance l'application a partir de IDLE....
Notamment j'imprime une fiche technique avec 2 photos, voici le bout du code :
Je crée un exe avec cx_Freeze et quand j'essaye d'imprimer a partir de l'appli, lancer avec l'exe, je n'ai plus de photo mais simplement un rectangle grisé.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 #images printer = QtGui.QPrinter() printer.setPaperSize(QtGui.QPrinter.A4) printer.setOrientation(QtGui.QPrinter.Portrait) orderTableFormat = QtGui.QTextTableFormat() orderTableFormat.setAlignment(QtCore.Qt.AlignHCenter) orderTableFormat.setBorder(0) orderTable = cursor.insertTable(1,2, orderTableFormat) orderFrameFormat = cursor.currentFrame().frameFormat() cursor.currentFrame().setFrameFormat(orderFrameFormat) ch=os.path.join(rep_images,image_1) if os.path.isfile(ch): imageFormat = QtGui.QTextImageFormat() imageFormat.setWidth(printer.width()/4) imageFormat.setName(ch) cursor = orderTable.cellAt(0, 0).firstCursorPosition().setBlockFormat(alignCentrer) cursor = orderTable.cellAt(0, 0).lastCursorPosition() cursor.insertImage(imageFormat) ch=os.path.join(rep_images,image_2) if os.path.isfile(ch): imageFormat1 = QtGui.QTextImageFormat() imageFormat1.setWidth(printer.width()/4) imageFormat1.setName(ch) cursor = orderTable.cellAt(0, 1).firstCursorPosition().setBlockFormat(alignCentrer) cursor = orderTable.cellAt(0, 1).lastCursorPosition() cursor.insertImage(imageFormat1) cursor.setPosition(topFrame.lastPosition()) fleche(self) self.withdraw()#cache la feuille principale dialog = QtGui.QPrintPreviewDialog() dialog.paintRequested.connect(editor.print_) dialog.exec_()
Voici le code de mon setup :
J'en ai déduit que le "compilage en exe" doit créer un problème
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53 #!/usr/bin/python # -*- coding: utf-8 -*- # Python 3.2 # 02/2012 import sys, os from cx_Freeze import setup, Executable # chemins de recherche des modules path = sys.path + ["fonctions"] # options d'inclusion/exclusion des modules includes = ["os","sys","pickle","tkinter","PIL","PySide","socket","asyncore"] excludes = [] packages = [] includefiles = [] if sys.platform == "win32": includefiles += [(r"C:\Python32\Lib\site-packages\PIL","PIL")] includefiles += [(r"C:\Python32\Lib\site-packages\PySide","PySide")] includefiles += [(r"C:\Users\Robert\fonctions","fonctions")] includefiles += [(r"C:\Users\Robert\ressources","ressources")] includefiles += [(r"C:\Users\Robert\data","data")] includefiles += [(r"C:\Users\Robert\images","images")] options = {"path": path, "includes": includes, "excludes": excludes, "packages": packages, "include_files": includefiles, } base = None if sys.platform == "win32": base = "Win32GUI" cible_1 = Executable( script = "Lancer le cahier.pyw", base = base, compress = True, icon = "Eclair.ico", ) setup( name = "Cahier de recettes", version = "1.0.0", description = "", author = "", options = {"build_exe": options}, executables = [cible_1] )
Toutes aides me sera précieuses.
Partager