def showIcons(): import sys if 'qt'not in sys.modules: try: import Object3DQt as qt except: import qt else: import qt a= qt.QApplication(sys.argv) a.connect(a, qt.SIGNAL("lastWindowClosed()"), a.quit) w= qt.QWidget() g= qt.QGridLayout(w) idx= 0 for name,icon in IconDict.items(): #print "name",name lab= qt.QLabel(w) lab.setText(str(name)) g.addWidget(lab, idx, 0) lab= qt.QLabel(w) lab.setPixmap(qt.QPixmap(icon)) g.addWidget(lab, idx, 1) idx+= 1 w.show() if qt.qVersion () < '4.0.0': a.exec_loop() else: a.exec_()
def updateView(self, expand=False): self.treeWidget.updateView() if expand: if qt.qVersion() >= '4.2.0': self.treeWidget.expandAll() objectList = self.getSelectedObjectList() if len(objectList): self.__current = objectList[0]
self.emit(qt.SIGNAL('Object3DConfigSignal'), ddict) def getConfiguration(self): ddict = self.propertiesWidget.getParameters() ddict['common'].update(self.movementsWidget.getParameters()) ddict['common'].update(self.scaleWidget.getParameters()) ddict['common'].update(self.clippingPlaneWidget.getParameters()) ddict['common'].update(self.colormapWidget.getParameters()) return ddict def setConfiguration(self, ddict): self.movementsWidget.setParameters(ddict['common']) self.scaleWidget.setParameters(ddict['common']) self.propertiesWidget.setParameters(ddict) self.clippingPlaneWidget.setParameters(ddict['common']) self.colormapWidget.setParameters(ddict['common']) if __name__ == "__main__": import sys app = qt.QApplication(sys.argv) def myslot(ddict): print "Signal received" print "dict = ", ddict w = Object3DConfig() qt.QObject.connect(w, qt.SIGNAL('Object3DConfigSignal'), myslot) w.show() app.exec_()
def __init__(self, *args): qt.QWidget.__init__(self, *args) self.setSizePolicy( qt.QSizePolicy(qt.QSizePolicy.Fixed, qt.QSizePolicy.Expanding))
self.sceneWidget.updateView() xmin, ymin, zmin, xmax, ymax, zmax = self.scene.getLimits() autoscale = self.scene.getAutoScale() ddict = {} ddict['autoscale'] = autoscale ddict['xmin'] = xmin ddict['ymin'] = ymin ddict['zmin'] = zmin ddict['xmax'] = xmax ddict['ymax'] = ymax ddict['zmax'] = zmax self.coordinatesWidget.setParameters(ddict) if __name__ == "__main__": import Object3DBase app = qt.QApplication([]) w = SceneControl() def slot(ddict): print " ddict = ", ddict objectList = w.scene.tree.getList() selected = [] for item in objectList: if hasattr(item, 'name'): if hasattr(item, 'selected'): if item.selected(): selected.append(item.name()) print selected qt.QObject.connect(app, qt.SIGNAL("lastWindowClosed()"), app, qt.SLOT("quit()")) qt.QObject.connect(w, qt.SIGNAL("SceneControlSignal"), slot)
try: if self.privateWidget != widget: self.privateWidget.close() except ReferenceError: if DEBUG: print("Reference error") pass self.privateWidget = widget if widget is not None: self.privateWidget.setCallBack(self._privateCallBack) self.privateWidget.setParameters(ddict['private']) if __name__ == "__main__": import sys app = qt.QApplication(sys.argv) def myslot(ddict): print("Signal received") print("ddict = ", ddict) if 1: w = Object3DProperties() qt.QObject.connect(w, qt.SIGNAL('Object3DPropertiesSignal'), myslot) elif 0: w = Object3DDrawingModeWidget() qt.QObject.connect(w, qt.SIGNAL('Object3DDrawingModeSignal'), myslot) elif 0: w = Object3DAspect() qt.QObject.connect(w, qt.SIGNAL('Object3DAspectSignal'), myslot) elif 1:
self.deleteButtonIcon = qt.QIcon(qt.QPixmap(IconDict['delete'])) self.deleteButton = qt.QPushButton(self) self.deleteButton.setIcon(self.deleteButtonIcon) self.deleteButton.setText('Delete') self.replaceButton = qt.QPushButton(self) self.replaceButton.setText('Replace') self.mainLayout.addWidget(self.cutButton) self.mainLayout.addWidget(self.pasteButton) self.mainLayout.addWidget(self.deleteButton) self.mainLayout.addWidget(self.replaceButton) if __name__ == "__main__": import Object3DBase app = qt.QApplication([]) qt.QObject.connect(app, qt.SIGNAL("lastWindowClosed()"), app, qt.SLOT("quit()")) o0 = Object3DBase.Object3D("DummyObject0") o1 = Object3DBase.Object3D("DummyObject1") o01 = Object3DBase.Object3D("DummyObject01") w = Object3DObjectTree() w.addObject(o0, update=False) w.addObject(o1, update=False) w.addObject(o01, update=True) tree = w.tree.find("DummyObject0") w.tree.delChild("DummyObject01") tree.addChild(o01) w.updateView() w.show()
else: ffile.write( "<tr><td colspan=%d bgcolor=skyblue><center><b>%s</b></center></td></tr>\n" % (nb, name)) for child in self.childList(): ffile.write("<td valign=top>\n") child.htmlTable(ffile) ffile.write("</td>\n") ffile.write("</table>\n") if __name__ == "__main__": import Object3DQt as qt import Object3DBase app = qt.QApplication([]) o0 = Object3DBase.Object3D("DummyObject0") o1 = Object3DBase.Object3D("DummyObject1") o01 = Object3DBase.Object3D("DummyObject01") w = ObjectTree('__Scene__', name='root') t0 = w.addChild(o0) t1 = w.addChild(o1) if 0: t0.addChild(o01) else: #append DummyObject01 to DummyObject0' tree = w.find("DummyObject0") tree.addChild(o01) print(w) print("LIST") print(w.getList())
def test(): app = qt.QApplication([]) w = TestWidget() w.show() app.exec_()
import Object3DQt as qt try: from PyMca import PyMcaDirs as Object3DDirs except: import Object3DDirs import os QTVERSION = qt.qVersion() def getFileList(parent=None, filetypelist=None, message=None, mode=None, getfilter=None): if filetypelist is None: fileTypeList = ['All Files (*)'] else: fileTypeList = filetypelist if message is None: message = "Please select a file" if mode is None: mode = "OPEN" else: mode = mode.upper() if mode == "OPEN": wdir = Object3DDirs.inputDir else: wdir = Object3DDirs.outputDir if getfilter is None: getfilter = False
def getFileList(parent=None, filetypelist=None, message=None, mode=None, getfilter=None): if filetypelist is None: fileTypeList = ['All Files (*)'] else: fileTypeList = filetypelist if message is None: message = "Please select a file" if mode is None: mode = "OPEN" else: mode = mode.upper() if mode == "OPEN": wdir = Object3DDirs.inputDir else: wdir = Object3DDirs.outputDir if getfilter is None: getfilter = False if getfilter: if QTVERSION < '4.5.1': native_possible = False else: native_possible = True else: native_possible = True filterused = None if native_possible and Object3DDirs.nativeFileDialogs: filetypes = "" for filetype in fileTypeList: filetypes += filetype + "\n" if getfilter: if mode == "OPEN": filelist, filterused = qt.QFileDialog.getOpenFileNamesAndFilter( parent, message, wdir, filetypes) filterused = str(filterused) else: filelist = qt.QFileDialog.getSaveFileNameAndFilter( parent, message, wdir, filetypes) if len(filelist): filterused = filelist[1] filelist = filelist[0] else: filelist = [] else: if mode == "OPEN": filelist = qt.QFileDialog.getOpenFileNames( parent, message, wdir, filetypes) else: filelist = qt.QFileDialog.getSaveFileName( parent, message, wdir, filetypes) filelist = str(filelist) if len(filelist): filelist = [filelist] else: filelist = [] if not len(filelist): if getfilter: return [], filterused else: return [] else: sample = str(filelist[0]) for filetype in fileTypeList: ftype = filetype.replace("(", "") ftype = ftype.replace(")", "") extensions = ftype.split()[2:] for extension in extensions: if sample.endswith(extension[-3:]): filterused = filetype break else: fdialog = qt.QFileDialog(parent) fdialog.setModal(True) fdialog.setWindowTitle(message) strlist = qt.QStringList() for filetype in fileTypeList: strlist.append(filetype) fdialog.setFilters(strlist) if mode == "OPEN": fdialog.setFileMode(fdialog.ExistingFiles) else: fdialog.setAcceptMode(fdialog.AcceptSave) fdialog.setFileMode(fdialog.AnyFile) fdialog.setDirectory(wdir) if QTVERSION > '4.3.0': history = fdialog.history() if len(history) > 6: fdialog.setHistory(history[-6:]) ret = fdialog.exec_() if ret != qt.QDialog.Accepted: fdialog.close() del fdialog if getfilter: return [], filterused else: return [] else: filelist = fdialog.selectedFiles() filterused = str(fdialog.selectedFilter()) if mode != "OPEN": if "." in filterused: extension = filterused.replace(")", "") if "(" in extension: extension = extension.split("(")[-1] extensionList = extension.split() txt = str(filelist[0]) for extension in extensionList: extension = extension.split(".")[-1] if extension != "*": txt = str(filelist[0]) if txt.endswith(extension): break else: txt = txt + "." + extension filelist[0] = txt fdialog.close() del fdialog filelist = map(str, filelist) if not (len(filelist)): return [] if mode == "OPEN": Object3DDirs.inputDir = os.path.dirname(filelist[0]) if Object3DDirs.outputDir is None: Object3DDirs.outputDir = os.path.dirname(filelist[0]) else: Object3DDirs.outputDir = os.path.dirname(filelist[0]) if Object3DDirs.inputDir is None: Object3DDirs.inputDir = os.path.dirname(filelist[0]) filelist.sort() if getfilter: return filelist, filterused else: return filelist
def __init__(self, parent=None): qt.QWidget.__init__(self, parent) self.mainLayout = qt.QHBoxLayout(self) self.mainLayout.setMargin(0) self.mainLayout.setSpacing(0) self.build()
def build(self): IconDict = Object3DIcons.IconDict self.cubeFrontIcon = qt.QIcon(qt.QPixmap(IconDict["cube_front"])) self.cubeBackIcon = qt.QIcon(qt.QPixmap(IconDict["cube_back"])) self.cubeTopIcon = qt.QIcon(qt.QPixmap(IconDict["cube_top"])) self.cubeBottomIcon = qt.QIcon(qt.QPixmap(IconDict["cube_bottom"])) self.cubeRightIcon = qt.QIcon(qt.QPixmap(IconDict["cube_right"])) self.cubeLeftIcon = qt.QIcon(qt.QPixmap(IconDict["cube_left"])) self.cube45Icon = qt.QIcon(qt.QPixmap(IconDict["cube_45"])) #the buttons self.cubeFront = qt.QToolButton(self) self.cubeFront.setIcon(self.cubeFrontIcon) self.cubeBack = qt.QToolButton(self) self.cubeBack.setIcon(self.cubeBackIcon) self.cubeTop = qt.QToolButton(self) self.cubeTop.setIcon(self.cubeTopIcon) self.cubeBottom = qt.QToolButton(self) self.cubeBottom.setIcon(self.cubeBottomIcon) self.cubeRight = qt.QToolButton(self) self.cubeRight.setIcon(self.cubeRightIcon) self.cubeLeft = qt.QToolButton(self) self.cubeLeft.setIcon(self.cubeLeftIcon) self.cube45 = qt.QToolButton(self) self.cube45.setIcon(self.cube45Icon) #the tool tips self.cubeFront.setToolTip("See from front (X+)") self.cubeBack.setToolTip("See from back (X-)") self.cubeTop.setToolTip("See from top (Z+)") self.cubeBottom.setToolTip("See from bottom (Z-)") self.cubeRight.setToolTip("See from right (Y+)") self.cubeLeft.setToolTip("See from left (Y-)") self.cube45.setToolTip("See from diagonal ( 1, 1, 1)") self.mainLayout.addWidget(self.cubeFront) self.mainLayout.addWidget(self.cubeBack) self.mainLayout.addWidget(self.cubeTop) self.mainLayout.addWidget(self.cubeBottom) self.mainLayout.addWidget(self.cubeRight) self.mainLayout.addWidget(self.cubeLeft) self.mainLayout.addWidget(self.cube45) self.connect(self.cubeFront, qt.SIGNAL('clicked()'), self.cubeFrontSlot) self.connect(self.cubeBack, qt.SIGNAL('clicked()'), self.cubeBackSlot) self.connect(self.cubeTop, qt.SIGNAL('clicked()'), self.cubeTopSlot) self.connect(self.cubeBottom, qt.SIGNAL('clicked()'), self.cubeBottomSlot) self.connect(self.cubeRight, qt.SIGNAL('clicked()'), self.cubeRightSlot) self.connect(self.cubeLeft, qt.SIGNAL('clicked()'), self.cubeLeftSlot) self.connect(self.cube45, qt.SIGNAL('clicked()'), self.cube45Slot)
def applyCube(self, cubeFace): ddict = {} ddict['event'] = 'ApplyCubeClicked' ddict['face'] = cubeFace self.emit(qt.SIGNAL('GLToolBarSignal'), ddict)
def _signal(self, ddict): self.emit(qt.SIGNAL('Object3DConfigSignal'), ddict)
import sys import os import Object3DQt as qt DEBUG = 0 __revision__ = "$Revision: 1.0 $" # TODO: # - automatic picture centering # - print quality QTVERSION = qt.qVersion() ################################################################################ ################## Object3DPreview ################### ################################################################################ class Object3DPrintPreview(qt.QDialog): def __init__(self, parent = None, printer = None, name = "Object3DPrintPreview", \ modal = 0, fl = 0): qt.QDialog.__init__(self, parent) self.setWindowTitle(name) self.setModal(modal) self.resize(400, 500) if printer is None: printer = qt.QPrinter(qt.QPrinter.HighResolution) printer.setPageSize(qt.QPrinter.A4) printer.setFullPage(True) if (printer.width() <= 0) or (printer.height() <= 0): if QTVERSION < '4.2.0': #this is impossible (no QGraphicsView)
def __init__(self, parent=None): qt.QWidget.__init__(self, parent) self.mainLayout = qt.QVBoxLayout(self) self.mainLayout.setMargin(4) self.mainLayout.setSpacing(4) #drawing self.mainTab = qt.QTabWidget(self) self.tabDrawing = qt.QWidget(self.mainTab) self.tabDrawing.mainLayout = qt.QVBoxLayout(self.tabDrawing) self.tabDrawing.mainLayout.setMargin(0) self.tabDrawing.mainLayout.setSpacing(0) self.movementsWidget = Object3DMovement.Object3DMovement( self.tabDrawing) self.scaleWidget = Object3DProperties.Object3DScale(self.tabDrawing) self.propertiesWidget = Object3DProperties.Object3DProperties( self.tabDrawing) self.tabDrawing.mainLayout.addWidget(self.movementsWidget) self.tabDrawing.mainLayout.addWidget(self.scaleWidget) self.tabDrawing.mainLayout.addWidget(self.propertiesWidget) self.mainTab.addTab(self.tabDrawing, "DRAWING") #clipping self.tabClipping = qt.QWidget(self.mainTab) self.tabClipping.mainLayout = qt.QVBoxLayout(self.tabClipping) self.tabClipping.mainLayout.setMargin(0) self.tabClipping.mainLayout.setSpacing(0) self.clippingPlaneWidget = ClippingPlaneConfiguration.ClippingPlaneWidget( self.tabClipping) self.colormapWidget = Object3DColormap.Object3DColormap( self.tabClipping) self.tabClipping.mainLayout.addWidget(self.clippingPlaneWidget) self.tabClipping.mainLayout.addWidget(self.colormapWidget) self.tabClipping.mainLayout.addWidget(VerticalSpacer()) self.mainTab.addTab(self.tabClipping, "CLIP and COLOR") self.mainLayout.addWidget(self.mainTab) self.connect(self.movementsWidget, qt.SIGNAL('Object3DMovementSignal'), self._movementsSlot) self.connect(self.scaleWidget, qt.SIGNAL('Object3DScaleSignal'), self._scaleSlot) self.connect(self.propertiesWidget, qt.SIGNAL('Object3DPropertiesSignal'), self._propertiesSlot) self.connect(self.clippingPlaneWidget, qt.SIGNAL('ClippingPlaneWidgetSignal'), self._clippingPlaneSlot) self.connect(self.colormapWidget, qt.SIGNAL('Object3DColormapSignal'), self._colormapSlot)
def _buildToolbar(self): # --- command buttons buttonSize = 65 toolBar = qt.QWidget(self) # a layout for the toolbar toolsLayout = qt.QHBoxLayout(toolBar) toolsLayout.setMargin(0) toolsLayout.setSpacing(0) # Margin """ marginLabel = qt.QLabel("Margins:", toolBar) if QTVERSION < '4.0.0': self.marginSpin = qt.QSpinBox(0, 50, 10, toolBar) else: self.marginSpin = qt.QSpinBox(toolBar) self.marginSpin.setRange(0, 50) self.marginSpin.setSingleStep(10) self.connect(self.marginSpin, qt.SIGNAL("valueChanged(int)"), \ self.__marginChanged) """ # Scale / Zoom scaleLabel = qt.QLabel("Zoom:", toolBar) scaleCombo = qt.QComboBox(toolBar) self.scaleValues = [20, 40, 60, 80, 100, 150, 200] if QTVERSION < '4.0.0': for scale in self.scaleValues: scaleCombo.insertItem("%3d %%" % scale) else: for scale in self.scaleValues: scaleCombo.addItem("%3d %%" % scale) self.scaleCombo = scaleCombo self.connect(self.scaleCombo, qt.SIGNAL("activated(int)"), \ self.__scaleChanged) hideBut = qt.QPushButton("Hide", toolBar) #hideBut.setFixedWidth(buttonSize-10) self.connect(hideBut, qt.SIGNAL("clicked()"), self.hide) cancelBut = qt.QPushButton("Clear All", toolBar) #cancelBut.setFixedWidth(buttonSize+10) self.connect(cancelBut, qt.SIGNAL("clicked()"), self.__clearAll) removeBut = qt.QPushButton("Remove", toolBar) #removeBut.setFixedWidth(buttonSize) self.connect(removeBut, qt.SIGNAL("clicked()"), self.__remove) setupBut = qt.QPushButton("Setup", toolBar) #setupBut.setFixedWidth(buttonSize-5) self.connect(setupBut, qt.SIGNAL("clicked()"), self.__setup) printBut = qt.QPushButton("Print", toolBar) #printBut.setFixedWidth(buttonSize-5) self.connect(printBut, qt.SIGNAL("clicked()"), self.__print) zoomPlusBut = qt.QPushButton("Zoom +", toolBar) #zoomPlusBut.setFixedWidth(buttonSize-5) self.connect(zoomPlusBut, qt.SIGNAL("clicked()"), self.__zoomPlus) zoomMinusBut = qt.QPushButton("Zoom -", toolBar) #zoomMinusBut.setFixedWidth(buttonSize-5) self.connect(zoomMinusBut, qt.SIGNAL("clicked()"), self.__zoomMinus) # now we put widgets in the toolLayout toolsLayout.addWidget(hideBut) toolsLayout.addWidget(printBut) toolsLayout.addWidget(cancelBut) toolsLayout.addWidget(removeBut) toolsLayout.addWidget(setupBut) #toolsLayout.addStretch() #toolsLayout.addWidget(marginLabel) #toolsLayout.addWidget(self.marginSpin) toolsLayout.addStretch() #toolsLayout.addWidget(scaleLabel) #toolsLayout.addWidget(scaleCombo) toolsLayout.addWidget(zoomPlusBut) toolsLayout.addWidget(zoomMinusBut) #toolsLayout.addStretch() self.toolBar = toolBar self.mainLayout.addWidget(self.toolBar)
def __init__(self, parent=None): qt.QGroupBox.__init__(self, parent) self.setTitle('Object Actions') self.mainLayout = qt.QVBoxLayout(self) self.mainLayout.setSpacing(0) self.mainLayout.setMargin(0) self.cutButtonIcon = qt.QIcon(qt.QPixmap(IconDict['cut'])) self.cutButton = qt.QPushButton(self) self.cutButton.setIcon(self.cutButtonIcon) self.cutButton.setText('Cut') self.pasteButtonIcon = qt.QIcon(qt.QPixmap(IconDict['paste'])) self.pasteButton = qt.QPushButton(self) self.pasteButton.setIcon(self.pasteButtonIcon) self.pasteButton.setText('Paste') self.deleteButtonIcon = qt.QIcon(qt.QPixmap(IconDict['delete'])) self.deleteButton = qt.QPushButton(self) self.deleteButton.setIcon(self.deleteButtonIcon) self.deleteButton.setText('Delete') self.replaceButton = qt.QPushButton(self) self.replaceButton.setText('Replace') self.mainLayout.addWidget(self.cutButton) self.mainLayout.addWidget(self.pasteButton) self.mainLayout.addWidget(self.deleteButton) self.mainLayout.addWidget(self.replaceButton)
def __init__(self, parent = None, printer = None, name = "Object3DPrintPreview", \ modal = 0, fl = 0): qt.QDialog.__init__(self, parent) self.setWindowTitle(name) self.setModal(modal) self.resize(400, 500) if printer is None: printer = qt.QPrinter(qt.QPrinter.HighResolution) printer.setPageSize(qt.QPrinter.A4) printer.setFullPage(True) if (printer.width() <= 0) or (printer.height() <= 0): if QTVERSION < '4.2.0': #this is impossible (no QGraphicsView) filename = "Object3D_print.pdf" else: filename = "Object3D_print.ps" if sys.platform == 'win32': home = os.getenv('USERPROFILE') try: l = len(home) directory = os.path.join(home, "My Documents") except: home = '\\' directory = '\\' if os.path.isdir('%s' % directory): directory = os.path.join(directory, "Object3D") else: directory = os.path.join(home, "Object3D") if not os.path.exists('%s' % directory): os.mkdir('%s' % directory) finalfile = os.path.join(directory, filename) else: home = os.getenv('HOME') directory = os.path.join(home, "Object3D") if not os.path.exists('%s' % directory): os.mkdir('%s' % directory) finalfile = os.path.join(directory, filename) printer.setOutputFileName(finalfile) printer.setColorMode(qt.QPrinter.Color) if (printer.width() <= 0) or (printer.height() <= 0): self.message = qt.QMessageBox(self) self.message.setIcon(qt.QMessageBox.Critical) self.message.setText( "Unknown library error \non printer initialization") self.message.setWindowTitle("Library Error") self.message.setModal(0) self.badNews = True self.printer = None return else: self.badNews = False self.printer = printer self.mainLayout = qt.QVBoxLayout(self) self.mainLayout.setMargin(0) self.mainLayout.setSpacing(0) self._buildToolbar() self.scene = qt.QGraphicsScene() self.scene.setBackgroundBrush(qt.QColor(qt.Qt.lightGray)) self.page = qt.QGraphicsRectItem(0, 0, printer.width(), printer.height()) self.page.setBrush(qt.QColor(qt.Qt.white)) self.scene.setSceneRect( qt.QRectF(0, 0, printer.width(), printer.height())) self.scene.addItem(self.page) self.view = qt.QGraphicsView(self.scene) self.mainLayout.addWidget(self.view) self._buildStatusBar() self.view.fitInView(self.page.rect(), qt.Qt.KeepAspectRatio) self._viewScale = 1.00
return True def hasPrivateConfigurationWidget(self): if self._privateConfigurationWidget is not None: return True else: return False def getObject3DInstance(config=None): return Object3D() if __name__ == "__main__": import sys app = qt.QApplication(sys.argv) name = "Base 3D-Object" object3D = Object3D(name) object3D.setLimits(10.0, 10.0, 10., 30., 30., 30) object3D.setSelected(1) #otherways we'll see nothing if 0: import SceneGLWidget window = SceneGLWidget.SceneGLWidget() window.addObject3D(object3D, name) window.show() else: import SceneGLWindow window = SceneGLWindow.SceneGLWindow() #Needed to initialize SceneGLWidget window.show() window.addObject(object3D, name, update_scene=False)
def testSimple(): import sys import os filename = sys.argv[1] a = qt.QApplication(sys.argv) w = qt.QWidget() l = qt.QVBoxLayout(w) button = qt.QPushButton(w) button.setText("Print") scene = qt.QGraphicsScene() pixmapItem = qt.QGraphicsPixmapItem( qt.QPixmap.fromImage(qt.QImage(filename))) pixmapItem.setFlag(pixmapItem.ItemIsMovable, True) printer = qt.QPrinter(qt.QPrinter.HighResolution) printer.setPageSize(qt.QPrinter.A4) printer.setFullPage(True) printer.setOutputFileName(os.path.splitext(filename)[0] + ".ps") page = qt.QGraphicsRectItem(0, 0, printer.width(), printer.height()) scene.setSceneRect(qt.QRectF(0, 0, printer.width(), printer.height())) scene.addItem(page) scene.addItem(pixmapItem) view = qt.QGraphicsView(scene) view.fitInView(page.rect(), qt.Qt.KeepAspectRatio) #view.setSceneRect( view.scale(2, 2) #page.scale(0.05, 0.05) def printFile(): painter = qt.QPainter(printer) scene.render( painter, qt.QRectF(0, 0, printer.width(), printer.height()), qt.QRectF(page.rect().x(), page.rect().y(), page.rect().width(), page.rect().height()), qt.Qt.KeepAspectRatio) painter.end() l.addWidget(button) l.addWidget(view) w.resize(300, 600) w.show() w.connect(button, qt.SIGNAL('clicked()'), printFile) a.exec_()
#############################################################################*/ __author__ = "V.A. Sole - ESRF Data Analysis" __contact__ = "*****@*****.**" __license__ = "LGPL2+" __copyright__ = "European Synchrotron Radiation Facility, Grenoble, France" import sys import os import Object3DQt as qt DEBUG = 0 __revision__="$Revision: 1.0 $" # TODO: # - automatic picture centering # - print quality QTVERSION = qt.qVersion() ################################################################################ ################## Object3DPreview ################### ################################################################################ class Object3DPrintPreview(qt.QDialog): def __init__(self, parent = None, printer = None, name = "Object3DPrintPreview", \ modal = 0, fl = 0): qt.QDialog.__init__(self, parent) self.setWindowTitle(name) self.setModal(modal) self.resize(400, 500) if printer is None: