[PyQt] (no subject)
Title: Flashmail Hello, I do not know how to have the same size for a QGraphicsScene and the graphicsView that contains the QGraphicsScene. When I launch my code there is two scroll bares and I just want the QGraphicsSceneexactly in the graphicsView. Sommeone can help me. Best regards. I put twocodes juste below. Code of TestDesin.py # -*- coding: utf-8 -*-#!/usr/bin/env python import sys,mathfrom PyQt4 import QtCore, QtGuifrom window_Dessin import Ui_window_Dessinclass window_Dessin_Plus(QtGui.QMainWindow, Ui_window_Dessin): def __init__(self): QtGui.QMainWindow.__init__(self) Ui_window_Dessin.__init__(self) self.setupUi(self) self.scene = QtGui.QGraphicsScene(self) self.scene.setSceneRect(1,1, 596,479) self. graphicsView.setScene(self.scene)if __name__ == "__main__": app = QtGui.QApplication(sys.argv) TestSouris = window_Dessin_Plus() TestSouris.show() sys.exit(app.exec_()) Code of window_Dessin.py from PyQt4 import QtCore, QtGuiclass Ui_window_Dessin(object): def setupUi(self, window_Dessin): window_Dessin.setObjectName("window_Dessin") window_Dessin.resize(697, 538) window_Dessin.setMinimumSize(QtCore.QSize(697, 538)) window_Dessin.setMaximumSize(QtCore.QSize(697, 538)) self.centralwidget = QtGui.QWidget(window_Dessin) self.centralwidget.setObjectName("centralwidget") self.layoutWidget = QtGui.QWidget(self.centralwidget) self.layoutWidget.setGeometry(QtCore.QRect(9, 9, 681, 481)) self.layoutWidget.setObjectName("layoutWidget") self.horizontalLayout = QtGui.QHBoxLayout(self.layoutWidget) self.horizontalLayout.setSizeConstraint(QtGui.QLayout.SetMaximumSize) self.horizontalLayout.setObjectName("horizontalLayout") self.graphicsView = GraphicsView_1(self.modifGraph,self.layoutWidget) self.graphicsView.setMaximumSize(QtCore.QSize(596, 479)) self.graphicsView.setRenderHints(QtGui.QPainter.Antialiasing|QtGui.QPainter.TextAntialiasing) self.graphicsView.setObjectName("graphicsView") self.horizontalLayout.addWidget(self.graphicsView) self.verticalLayout = QtGui.QVBoxLayout() self.verticalLayout. setObjectName("verticalLayout") self.bouton_Effacer = QtGui.QPushButton(self.layoutWidget) self.bouton_Effacer.setCheckable(False) self.bouton_Effacer.setObjectName("bouton_Effacer") self.verticalLayout.addWidget(self.bouton_Effacer) self.bouton_Point = QtGui.QPushButton(self. layoutWidget) self.bouton_Point.setCheckable(True) self.bouton_Point.setObjectName("bouton_Point") self.verticalLayout.addWidget(self.bouton_Point) self.bouton_Segment = QtGui.QPushButton(self.layoutWidget) self.bouton_Segment.setCheckable(True) self.bouton_Segment.setObjectName("bouton_Segment") self.verticalLayout.addWidget(self.bouton_Segment) self.bouton_LigneBrisee = QtGui.QPushButton(self.layoutWidget) self.bouton_LigneBrisee.setCheckable(True) self.bouton_LigneBrisee.setAutoDefault(False) self. bouton_LigneBrisee.setDefault(False) self.bouton_LigneBrisee.setFlat(False) self.bouton_LigneBrisee.setObjectName("bouton_LigneBrisee") self.verticalLayout.addWidget(self.bouton_LigneBrisee) self.bouton_Cercle = QtGui.QPushButton(self.layoutWidget) self.bouton_Cercle. setCheckable(True) self.bouton_Cercle.setObjectName("bouton_Cercle") self.verticalLayout.addWidget(self.bouton_Cercle) self.bouton_zigZag = QtGui.QPushButton(self.layoutWidget) self.bouton_zigZag.setCheckable(True) self.bouton_zigZag.setObjectName("bouton_zigZag") self.verticalLayout.addWidget(self.bouton_zigZag) self.horizontalLayout.addLayout(self.verticalLayout) window_Dessin.setCentralWidget(self.centralwidget) self.menubar = QtGui.QMenuBar(window_Dessin) self.menubar.setGeometry(QtCore.QRect(0, 0, 697, 21)) self.menubar.setObjectName("menubar") window_Dessin.setMenuBar(self.menubar) self.statusbar = QtGui.QStatusBar(window_Dessin) self.statusbar.setObjectName("statusbar") window_Dessin.setStatusBar(self.statusbar) self.retranslateUi(window_Dessin) QtCore.QMetaObject.connectSlotsByName(window_Dessin) def retranslateUi(self, window_Dessin): window_Dessin.setWindowTitle(QtGui.QApplication.translate("window_Dessin", "MainWindow", None, QtGui.QApplication.UnicodeUTF8)) self.bouton_Effacer.setText(QtGui.QApplication.translate("window_Dessin", "Effacer", None, QtGui.QApplication.UnicodeUTF8)) self.bouton_Point.setText(QtGui.QApplication.translate("window_Dessin", "Point", None, QtGui.QApplication.UnicodeUTF8)) self.bouton_Segment.setText(QtGui.QApplication.translate("window_Dessin", "Segment", None, QtGui.QApplication.UnicodeUTF8)) self.bouton_LigneBrisee.setText(QtGui.QApplication.translate("window_Dessin", "Ligne Brisée", None, QtGui.QApplication.UnicodeUTF8)) self.bouton_Cercle.setText(QtGui.QApplication.translate("window_Dessin", "Cercle", None, QtGui.QApplication.UnicodeUTF8)) self.bouton_zigZag.setText(QtGui.QApplication.translate("window_Dessin", "Zig Zag", None, QtGui.QApplication.UnicodeUTF8)) ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Splash Screen
Title: Flashmail Hello, I would to know how to do a Splash Screen with PyQT. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Add some text in QFileDialog
Hello, I would like to add some informations in a TextEdit or a Label in QFileDialog to help the users to know what it must searchs. How can I do that ? Best regards. Christophe. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: Re: [PyQt] Add some text in QFileDialog
Title: Flashmail Something like this? self.upgfile = QFileDialog.getOpenFileName(\ None, self.trUtf8("Select the UPG file"), self.upgfile, self.trUtf8("*.upg"), None) Thanks but indeed I would like to embed a QFileDialg in a pesronnal Dialog with a TextEdit just upon the QFileDialog. Is it possible ? ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] MatplotLib and PyQt
Title: Flashmail Hello,I'm looking for examples of little PyQt applications embending MatplotLib.Best regards.Christophe ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Mayavi, VTK and PyQt
Title: Flashmail Hello,I'm looking for examples of little PyQt applications embending Mayavi.Best regards.Christophe ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: Re: [PyQt] MatplotLib and PyQt
Hello, I'm looking for examples of little PyQt applications embending MatplotLib. Here is a good example: http://matplotlib.sourceforge.net/examples/user_interfaces/embedding_in_q t4.html. The matplotlib mailing list is probably a better place to follow up if you have additional questions specific to matplotlib. Darren Indeed I've already asked this question in the Matplotliib mailing list and I have not received good answers. Thanks. Christophe. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] (no subject)
I once addapted the QVTKRenderWindowInteractor to work with the latest release of pyqt. Unfortunately it's not perfect yet and it does work only on my windows machine. I'll look at your code and then try to understand what's wrong. If I find the answer, I'll send it here. So should you make improvements to it, please post it back. Indeed Erik, I'm working on a tutorial so as I'm doing my own project for editing math easily. So when all the tuto. will be finished, I would be glad to give the link here (the first version will be only in french but in a second time I'll do the english translation). Regards. Christophe ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: Re: [PyQt] Mayavi, VTK and PyQt
Hello, I'm looking for examples of little PyQt applications embending Mayavi. ETS from Enthought integrates Mayavi, VTK and PyQt (and wx). Phil Thanks but the problem is that there is no simple example in the official documentation of a very simple application embending Mayavi. That's what I'm looking for. Thanks. Christophe. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] (no subject)
Title: Flashmail Here's a relatively advanced example featuring many things you may want from the integration of PyQT and matplotlib: * Using the maplotlib navigation toolbar * Adding data to the plot dynamically * Dynamically modifying the plotâ??s properties * Processing matplotlib events in the GUI * Saving the plot to a file from a menu http://eli.thegreenplace.net/2009/01/20/matplotlib-with-pyqt-guis/ Eli Thanks a lot, this example is very interseting.Christophe ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] ContextMenu for a TreeView
Hello, is it possible to define a ContextMenu for a TreeView ? Christophe. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] (no subject)
Hello, is it possible to define a ContextMenu for a TreeView ? Yes, just override QWidget.contextMenuEvent for the view. Doug. Thanks but then I have a problem. How can I know that the mouse is over the TreeView ? Christophe. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Re : ContextMenu in TreeView
Hello, is it possible to define a ContextMenu for a TreeView ? Yes, just override QWidget.contextMenuEvent for the view. Doug. Thanks but then I have a problem. How can I know that the mouse is over the TreeView ? Christophe. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: Re: [PyQt] pygments patch for Scintilla
Title: Flashmail Thanks for the answer. Best regards. Christophe. PS for Phil : my proposition is to a future new release of PyQt. I know that you have a lot of works. Hello, I would like to know if the pygments patch of the software Eric could be add to the standard PyQt distribution because the real weakness of QScintilla is the impossibilty to define particular lexer. It has nothing to do with PyQt. I have the patch but don't intend to make a new release of QScintilla just for that. That is fair and reasonable seeing the amount of work scheduled for sip and PyQt4. Meanwhile people can apply the patch, which is included in the eric4 package themselfs. DetlevPhil ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Tr: [PyQt] Problems with QSystemTrayIcon
I'm under Windows XP with PyQt for Python 2-6 and your example works very well. I see the icon in the SysTray with the message. Christophe. Hi, I am having problem to get QSystemTrayIcon to work. I am running on windows XP and I never see any notification messages. My setup: windows XP, PyQt 4.3.3, python 2.5 See my attached simplified code, that runs standalone. Any idea what I could be doing wrong ? cheers, Philippe attachment: croquemonster.png# -*- coding: latin1 -*- # vim: set fileencoding=latin1 # # PyTiCroque - Copyright Philippe Fremy 2009 # # This file is released under the BSD License, see the accompanying file LICENSE.txt # import locale, sys locale.setlocale( locale.LC_ALL, '' ) from PyQt4 import QtGui, QtCore def dbg( s ): print (u'PTCrWindow: %s' % s).encode( locale.getlocale()[1] ) class PTCrWindow( QtGui.QTextEdit ): def __init__( self ): QtGui.QTextEdit.__init__( self ) self.initAppIcon() self.initSystray() self.timer = QtCore.QTimer() self.timer.start( 2 * 1000 ) QtCore.QObject.connect( self.timer, QtCore.SIGNAL('timeout()'), self.addMsg ) self.appendEvent( 'QPyTiCroque is alive !' ) def initAppIcon( self ): pixmap = QtGui.QPixmap( 'croquemonster.png' ) dbg( 'pixmap size: %dx%d' % (pixmap.width(), pixmap.height()) ) self.appIcon = QtGui.QIcon( pixmap ) self.setWindowIcon( self.appIcon ) def initSystray( self ): self.systray = QtGui.QSystemTrayIcon( self.appIcon , self ) self.systray.setToolTip( 'PyTiCroque' ) self.systray.show() dbg( 'SystemTray available: %s' % str( bool ( QtGui.QSystemTrayIcon.isSystemTrayAvailable() ) ) ) dbg( 'SystemTray supports messages: %s' % str( bool ( self.systray.supportsMessages() ) ) ) def addMsg( self ): self.appendEvent( 'timer event!' ) def appendEvent( self, s ): dbg( s ) self.append( s ) self.systray.showMessage( QtCore.QString(u'Evenement PyTiCroque'), QtCore.QString(s), QtGui.QSystemTrayIcon.Information, 100 * 1000 ) DEBUG_FLAG=False def main(): app = QtGui.QApplication([]) w = PTCrWindow() w.show() app.exec_() w.systray.hide() app.processEvents() if __name__ == '__main__': main() ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Subclass Undo of a QTextEdit
Title: Flashmail Hello,when I copy a text twice in a QTextEdit and I use CTRL+Z to use UNDO, I would like to go back just after the first copy and not before the first copy.So I would like to subclass the method UNDO of a QTextEdit but I don't know how to do that, how to catch a change.Best regards.Christophe ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Is there a signal sended by HighLight ?
Hello, I would like to know if there is a signal sended by the SyntaxHiglighter when it catches a change in the text ? Best regards. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Re : Signal and SyntaxHiglight
I would like to know if there is a signal sended by the SyntaxHiglighter when it catches a change in the text ? That class is designed to be subclassed rather than connected up with signals and slots, but you could emit your own signals when you handle the changes in format. Alternatively, you might want to look at the signals emitted by the QTextDocument object itself. These will tell you when the text has changed. The problem with this method is that a signal is emitted every time a change appears and not only when a word to highlight is typed. Best regards. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Reach a line in a QTextEdit
Hello, I would like to go for example to the fourth line in a QTextEdit. Is-it possible to do that directly or must I have to walk along the three first lines so as to go to the start of the fourth one ? Best regards. Christophe ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: Re: [PyQt] Reach a line in a QTextEdit
The first method works very well. Thanks a lot ! Christophe. I would like to go for example to the fourth line in a QTextEdit. Is-it possible to do that directly or must I have to walk along the three first lines so as to go to the start of the fourth one ? Use either: 1. QTextEdit::moveCursor(), but you need a for loop to go up/down for multiple lines. Example: editor = QtGui.QTextEdit() [...] for l in range(4): editor.moveCursor(QtGui.QTextCursor.Down, QtGui.QTextCursor.MoveAnchor) 2. QTextEdit::textCursor() to get the cursor, then QTextCursor::movePosition() and then QTextEdit::setTextCursor() so that it takes effects. Example: editor = QtGui.QTextEdit() [...] cursor = editor.textCursor() cursor.movePosition(QtGui.QTextCursor.Down, QtGui.QTextCursor.MoveAnchor, 4) editor.setTextCursor(cursor) Regards, Cyril ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Search for a simple example using OpenGL
Title: Flashmail Hello, I would like to draw for example a 3D triangle in an OpneGL.Best regards. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Help about the use of OpenGL with PyQt
Hello, I would like to draw for example a 3D triangle with OpenGL. I've tried to play with the example Hello GL proposed by PyQt. In the following code I would like to draw a red triangle and then a blue one. I also would like to set the xMin, xMax, yMin, yMax, zMin, zMax, for the point of view. My purpose would be to a 3D geometric viewers for educational purposes. Best regards. Christophe The code #!/usr/bin/env python PyQt4 port of the opengl/hellogl example from Qt v4.x import sys import math from PyQt4 import QtCore, QtGui, QtOpenGL try: from OpenGL import GL except ImportError: app = QtGui.QApplication(sys.argv) QtGui.QMessageBox.critical(None, OpenGL hellogl, PyOpenGL must be installed to run this example., QtGui.QMessageBox.Ok | QtGui.QMessageBox.Default, QtGui.QMessageBox.NoButton) sys.exit(1) class Window(QtGui.QWidget): def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.glWidget = GLWidget() self.xSlider = self.createSlider(QtCore.SIGNAL(xRotationChanged(int)), self.glWidget.setXRotation) self.ySlider = self.createSlider(QtCore.SIGNAL(yRotationChanged(int)), self.glWidget.setYRotation) self.zSlider = self.createSlider(QtCore.SIGNAL(zRotationChanged(int)), self.glWidget.setZRotation) mainLayout = QtGui.QHBoxLayout() mainLayout.addWidget(self.glWidget) mainLayout.addWidget(self.xSlider) mainLayout.addWidget(self.ySlider) mainLayout.addWidget(self.zSlider) self.setLayout(mainLayout) self.xSlider.setValue(15 * 16) self.ySlider.setValue(345 * 16) self.zSlider.setValue(0 * 16) self.setWindowTitle(self.tr(Hello GL)) def createSlider(self, changedSignal, setterSlot): slider = QtGui.QSlider(QtCore.Qt.Vertical) slider.setRange(0, 360 * 16) slider.setSingleStep(16) slider.setPageStep(15 * 16) slider.setTickInterval(15 * 16) slider.setTickPosition(QtGui.QSlider.TicksRight) self.glWidget.connect(slider, QtCore.SIGNAL(valueChanged(int)), setterSlot) self.connect(self.glWidget, changedSignal, slider, QtCore.SLOT(setValue(int))) return slider class GLWidget(QtOpenGL.QGLWidget): def __init__(self, parent=None): QtOpenGL.QGLWidget.__init__(self, parent) self.object = 0 self.xRot = 0 self.yRot = 0 self.zRot = 0 self.lastPos = QtCore.QPoint() self.trolltechGreen = QtGui.QColor.fromCmykF(0.40, 0.0, 1.0, 0.0) self.trolltechPurple = QtGui.QColor.fromCmykF(0.39, 0.39, 0.0, 0.0) def xRotation(self): return self.xRot def yRotation(self): return self.yRot def zRotation(self): return self.zRot def minimumSizeHint(self): return QtCore.QSize(50, 50) def sizeHint(self): return QtCore.QSize(400, 400) def setXRotation(self, angle): angle = self.normalizeAngle(angle) if angle != self.xRot: self.xRot = angle self.emit(QtCore.SIGNAL(xRotationChanged(int)), angle) self.updateGL() def setYRotation(self, angle): angle = self.normalizeAngle(angle) if angle != self.yRot: self.yRot = angle self.emit(QtCore.SIGNAL(yRotationChanged(int)), angle) self.updateGL() def setZRotation(self, angle): angle = self.normalizeAngle(angle) if angle != self.zRot: self.zRot = angle self.emit(QtCore.SIGNAL(zRotationChanged(int)), angle) self.updateGL() def initializeGL(self): self.qglClearColor(self.trolltechPurple.dark()) self.object = self.makeObject() GL.glShadeModel(GL.GL_FLAT) GL.glEnable(GL.GL_DEPTH_TEST) GL.glEnable(GL.GL_CULL_FACE) def paintGL(self): GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT) GL.glLoadIdentity() GL.glTranslated(0.0, 0.0, -10.0) GL.glRotated(self.xRot / 16.0, 1.0, 0.0, 0.0) GL.glRotated(self.yRot / 16.0, 0.0, 1.0, 0.0) GL.glRotated(self.zRot / 16.0, 0.0, 0.0, 1.0) GL.glCallList(self.object) def resizeGL(self, width, height): side = min(width, height) GL.glViewport((width - side) / 2, (height - side) / 2, side, side) GL.glMatrixMode(GL.GL_PROJECTION) GL.glLoadIdentity() GL.glOrtho(-0.5, +0.5, +0.5, -0.5, 4.0, 15.0) GL.glMatrixMode(GL.GL_MODELVIEW) def mousePressEvent(self, event): self.lastPos = QtCore.QPoint(event.pos()) def mouseMoveEvent(self, event): dx = event.x() - self.lastPos.x() dy = event.y() - self.lastPos.y() if event.buttons() QtCore.Qt.LeftButton: self.setXRotation(self.xRot + 8 * dy)
Re: [PyQt] Help about the use of OpenGL with PyQt
Your problem is with your OpenGL syntax. Simply change GL.GL_QUADS (which draw quadrilaterals) with GL.GL_TRIANGLES (self evident). Also, it would be better to move those declarations into your triangle routine as follows Thanks and sorry for this simple problem but I'm a real newbie with OpenGL. Where can I find documentations showing what kind of objects I can draw with OpenGL ? Best regards and thanks a lot. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Help about the use of OpenGL with PyQt
That seems to be very good. Thanks a lot. Christophe David Boddie a écrit : On Sat Apr 4 17:43:29 BST 2009, Jamie Riotto wrote: OpenGL Tutorial: http://cs.uccs.edu/~semwal/indexGLTutorial.html Also NeHe productions does a realy great job breaking down OpenGL into lessons: My favorite! http://nehe.gamedev.net/ Also, since your accessing OpenGL through PyOpenGL, you should look at: http://pyopengl.sourceforge.net/documentation/ for other links and examples. Enjoy - jaime Another good source of information is the Red Book. You can find an old version online here: http://www.opengl.org/documentation/red_book/ Although it only covers OpenGL 1.1, it should contain all the basic information you need to help you get started. David ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] [TreeWidget] Text and/or image over a node
Hello, I would like to show a text or a little picture (and why not the both at the same time) when the mouse is over a node of a TreeWidget. How can I try to do that ? Thanks a lot. Christophe. # -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'C:\Program Files\EasyPHP 2.0b1\www\Python 07-2008\DebuterAvecPythonEtPyQT\CodesProjets\03-Proj3_VueArborescente\dial_Projet3.ui ' # # Created: Tue Jul 29 23:37:30 2008 # by: PyQt4 UI code generator 4.3.3 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_dial_Projet3(object): def setupUi(self, dial_Projet3): dial_Projet3.setObjectName(dial_Projet3) dial_Projet3.resize(QtCore.QSize(QtCore.QRect(0,0,520,390).size()).expandedTo(dial_Projet3.minimumSizeHint())) dial_Projet3.setAutoFillBackground(True) self.treeWidget = QtGui.QTreeWidget(dial_Projet3) self.treeWidget.setGeometry(QtCore.QRect(270,40,240,340)) self.treeWidget.setObjectName(treeWidget) self.textUtilisateur = QtGui.QTextEdit(dial_Projet3) self.textUtilisateur.setGeometry(QtCore.QRect(10,40,240,340)) self.textUtilisateur.setObjectName(textUtilisateur) self.lineTitre_1 = QtGui.QLineEdit(dial_Projet3) self.lineTitre_1.setEnabled(False) self.lineTitre_1.setGeometry(QtCore.QRect(10,10,241,20)) palette = QtGui.QPalette() brush = QtGui.QBrush(QtGui.QColor(0,0,0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active,QtGui.QPalette.WindowText,brush) brush = QtGui.QBrush(QtGui.QColor(0,0,0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active,QtGui.QPalette.Dark,brush) brush = QtGui.QBrush(QtGui.QColor(0,0,0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active,QtGui.QPalette.Text,brush) brush = QtGui.QBrush(QtGui.QColor(0,0,0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active,QtGui.QPalette.ButtonText,brush) brush = QtGui.QBrush(QtGui.QColor(255,255,255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active,QtGui.QPalette.Base,brush) brush = QtGui.QBrush(QtGui.QColor(255,255,255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active,QtGui.QPalette.Window,brush) brush = QtGui.QBrush(QtGui.QColor(0,0,0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive,QtGui.QPalette.WindowText,brush) brush = QtGui.QBrush(QtGui.QColor(0,0,0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive,QtGui.QPalette.Dark,brush) brush = QtGui.QBrush(QtGui.QColor(0,0,0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive,QtGui.QPalette.Text,brush) brush = QtGui.QBrush(QtGui.QColor(0,0,0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive,QtGui.QPalette.ButtonText,brush) brush = QtGui.QBrush(QtGui.QColor(255,255,255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive,QtGui.QPalette.Base,brush) brush = QtGui.QBrush(QtGui.QColor(255,255,255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive,QtGui.QPalette.Window,brush) brush = QtGui.QBrush(QtGui.QColor(0,0,0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled,QtGui.QPalette.WindowText,brush) brush = QtGui.QBrush(QtGui.QColor(0,0,0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled,QtGui.QPalette.Dark,brush) brush = QtGui.QBrush(QtGui.QColor(0,0,0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled,QtGui.QPalette.Text,brush) brush = QtGui.QBrush(QtGui.QColor(0,0,0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled,QtGui.QPalette.ButtonText,brush) brush = QtGui.QBrush(QtGui.QColor(255,255,255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled,QtGui.QPalette.Base,brush) brush = QtGui.QBrush(QtGui.QColor(255,255,255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled,QtGui.QPalette.Window,brush) self.lineTitre_1.setPalette(palette) font = QtGui.QFont() font.setWeight(50) font.setBold(False) self.lineTitre_1.setFont(font) self.lineTitre_1.setAlignment(QtCore.Qt.AlignCenter) self.lineTitre_1.setObjectName(lineTitre_1) self.lineTitre_2 = QtGui.QLineEdit(dial_Projet3)
Re: [PyQt] Help about the use of OpenGL with PyQt
Thanks a lot. I will look at that but it seems that there is no Windows version for Python 2-6. Christophe. There are also the QGLViewer/PyQGLViewer couple. Basically QGLViewer is build on top of the Qt4 OpenGL widget and PyQGLViewer is its python bindings. http://www.libqglviewer.com/ http://pyqglviewer.gforge.inria.fr/wiki/doku.php bye Gianluca ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] How to show just a picture upon a window
Hello, I would like to show just a picture upon my window. I've find the following method. pixmap = QtGui.QPixmap(Collines.jpg) splash = QtGui.QSplashScreen(pixmap) splash.setMask(pixmap.mask()) splash.show() splash.showMessage(u'') t = time.sleep(1) This works but I would like to do something more usefull. 1. The picture must appear near the position of the mouse. 2. The picture must be visible for a time such 5 seconds except if the user do something like pressing a key, or clicking on the picture. Every klind of information is welcome. Best regards. Christophe. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Question about QFrame
Hello, I would like to make a frame that contains a QTextEdit and a picture, and then I would like to show it. Is-it possible ? Best regards. Christophe. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Re: SplashScreen and mousePressEvent
projetmbc a écrit : Hello, I would like to close a splashscreen if the user clicks on it. I decide to subclass QtGui.QSplashScreen to do that but the following code doesn't catch the mouse press event. Why ? Best regards. Christophe == The code == class mySplashScreen(QtGui.QSplashScreen): def __init__(self, pixmap): super(QtGui.QSplashScreen, self).__init__(pixmap) def mousePressEvent(self, event): print 'ok' The right indentation of the code is the following one : class mySplashScreen(QtGui.QSplashScreen): def __init__(self, pixmap): super(QtGui.QSplashScreen, self).__init__(pixmap) def mousePressEvent(self, event): print 'ok' ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] SplashScreen and mousePressEvent
Hello, I would like to close a splashscreen if the user clicks on it. I decide to subclass QtGui.QSplashScreen to do that but the following code doesn't catch the mouse press event. Why ? Best regards. Christophe == The code == class mySplashScreen(QtGui.QSplashScreen): def __init__(self, pixmap): super(QtGui.QSplashScreen, self).__init__(pixmap) def mousePressEvent(self, event): print 'ok' ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] SplashScreen and mousePressEvent
Ok. Thanks a lot for the informations. I've tried another method and it works well. Indeed I use a SplashScreen to show a single picture associated to a node in a TreeWidget when the user does a right click on it. A last question. Is it possible to choose the position where the SplashScreen appears ? Christophe. Brian Kelley a écrit : First, get rid of the mousePressEvent since the Splashscreen closes by default when the user clicks on it. Also, make sure you start the event loop otherwise qt can’t detect mouse events. (Note the following code won’t stop the application, you may need to kill it afterwards) from PyQt4 import QtGui import sys app = QtGui.QApplication(sys.argv) pixmap = QtGui.QPixmap(splash.png) splash = QtGui.QSplashScreen(pixmap) splash.show() app.exec_() On 4/8/09 7:56 AM, projetmbc projet...@club-internet.fr wrote: Hello, I would like to close a splashscreen if the user clicks on it. I decide to subclass QtGui.QSplashScreen to do that but the following code doesn't catch the mouse press event. Why ? Best regards. Christophe == The code == class mySplashScreen(QtGui.QSplashScreen): def __init__(self, pixmap): super(QtGui.QSplashScreen, self).__init__(pixmap) def mousePressEvent(self, event): print 'ok' ___ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] SplashScreen and mousePressEvent
Brian Kelley a écrit : The splashscreen is probably not what you want. You can make a QFrame and apply the following styles QFrame( parent, Qt.X11BypassWindowManagerHint | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint | Qt.Tool ) You will need to override the mouseClickEvent to close this window. To place it you can get the mouse’s x,y position when right clicking on the tree node and create the frame (with the appropriate images inside) and then place it appropriately. Brian On 4/8/09 8:41 AM, projetmbc projet...@club-internet.fr wrote: Ok. Thanks a lot for the informations. I've tried another method and it works well. Indeed I use a SplashScreen to show a single picture associated to a node in a TreeWidget when the user does a right click on it. A last question. Is it possible to choose the position where the SplashScreen appears ? Christophe. Brian Kelley a écrit : First, get rid of the mousePressEvent since the Splashscreen closes by default when the user clicks on it. Also, make sure you start the event loop otherwise qt can’t detect mouse events. (Note the following code won’t stop the application, you may need to kill it afterwards) from PyQt4 import QtGui import sys app = QtGui.QApplication(sys.argv) pixmap = QtGui.QPixmap(splash.png) splash = QtGui.QSplashScreen(pixmap) splash.show() app.exec_() On 4/8/09 7:56 AM, projetmbc projet...@club-internet.fr wrote: Hello, I would like to close a splashscreen if the user clicks on it. I decide to subclass QtGui.QSplashScreen to do that but the following code doesn't catch the mouse press event. Why ? Best regards. Christophe == The code == class mySplashScreen(QtGui.QSplashScreen): def __init__(self, pixmap): super(QtGui.QSplashScreen, self).__init__(pixmap) def mousePressEvent(self, event): print 'ok' ___ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt You're right. I will try to do that with a frame but the adventage of a SplashScreen is that it lives for a laps of time. Best regards. Christophe. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] context menus for QTreeWidgetItem?
Christian Aubert a écrit : I currently have a context menu for the whole QTreeWidget but I need finer-grained control on a per item basis. Has anyone implemented context menus for QTreeWidgetItems? Any pointers? Christian ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt Hello, here is a solution that works. I hope tha will help you. To call the menu, just use : self.connect(self.treeWidget, QtCore.SIGNAL(customContextMenuRequested(const QPoint )), self.menuContextTree) Here is the method menuContextTree : def menuContextTree(self, point): # Infos about the node selected. index = self.treeWidget.indexAt(point) if not index.isValid(): return item = self.treeWidget.itemAt(point) name = item.text(0) # The text of the node. # We build the menu. menu=QtGui.QMenu(self) action=menu.addAction(Souris au-dessus de) action=menu.addAction(name) menu.addSeparator() action_1=menu.addAction(Choix 1) action_2=menu.addAction(Choix 2) action_3=menu.addAction(Choix 3) print QtGui.QCursor.pos() menu.exec_(QtGui.QCursor.pos()) ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] SplashScreen and mousePressEvent
Thanks, I'll try to understand that. Maybe my problem is a problem of windowflag. Where are all the avaibale windowflag ? Best reagrds and a great thanks for your help. Christophe. Apologies for the C++ code, we have an info label that displays text in a popup QFrame, this is the method that sets the text and makes the widget visible. The things you will find interesting are mapping from the cursor to the current frame and then mapping this point (after moving out of the way of the mouse) to the mainwindow (which is the parent of the Qframe). Hope this helps. void InfoLabel::SetInfoLabel( const std::string s ) { if (s.empty()) { if (!_hidden) { hide(); _hidden = true; } } else { QPoint pos = mapFromGlobal(QCursor::pos()); setText(s.c_str()); adjustSize(); QPoint p(pos.x(), pos.y() - height()); move(this-mapTo(parent(), p)); raise(); if (_hidden) show(); else update(); _hidden = false; } } On 4/8/09 11:40 AM, projetmbc projet...@club-internet.fr wrote: Brian Kelley a écrit : You can have the same effect using a timer: class MyFrame(QFrame): def __init__(self, parent, pixmapfile): QFrame.__init__(self, parent, Qt.X11BypassWindowManagerHint | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint | Qt.Tool ) # do something with pixmapfile self.timer = QTimer() self.connect( self.timer, QtCore.SIGNAL(timeout()), self, QtCore.SLOT(hide()) ) def showEvent(self, evt): self.timer.start(3000) # 3 seconds QFrame.showEvent(self, evt) On 4/8/09 9:39 AM, projetmbc projet...@club-internet.fr wrote: You're right. I will try to do that with a frame but the adventage of a SplashScreen is that it lives for a laps of time. Best regards. Christophe. Qt.X11BypassWindowManagerHint | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint | Qt.Tool I do the following changes but there is still a very little problem concerning the position of the frame. How can I do to use QtGui.QCursor.pos() so as to put the frame where the mouse is ? I've tried to use rect=QtCore.QRect(position, QtCore.QPoint(1000,1000)) and self.setFrameRect(rect) but it doesn't work. Christophe. Code class MyFrame(QtGui.QFrame): # Squelette donné par Brian Kelley sur la liste de PyQt. def __init__(self, parent, titre, pixmapfile, position): QtGui.QFrame.__init__(self, parent, QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.Tool) # QtCore.Qt.X11BypassWindowManagerHint | QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.Tool self.setWindowTitle(titre) label = QtGui.QLabel(self) label.setPixmap(pixmapfile) label.show() self.timer = QtCore.QTimer() self.connect( self.timer, QtCore.SIGNAL(timeout()), self,QtCore.SLOT(hide()) ) def showEvent(self, evt): self.timer.start(1) # 10 seconds QtGui.QFrame.showEvent(self, evt) ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re:Re: [PyQt] context menus for QTreeWidgetItem?
Christian Aubert a écrit : I currently have a context menu for the whole QTreeWidget but I need finer-grained control on a per item basis. Has anyone implemented context menus for QTreeWidgetItems? Any pointers? Christian ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt Hello, here is a solution that works. I hope tha will help you. To call the menu, just use : self.connect(self.treeWidget, QtCore.SIGNAL(customContextMenuRequested(const QPoint )), self.menuContextTree) Here is the method menuContextTree : def menuContextTree(self, point): # Infos about the node selected. index = self.treeWidget.indexAt(point) if not index.isValid(): return item = self.treeWidget.itemAt(point) name = item.text(0) # The text of the node. # We build the menu. menu=QtGui.QMenu(self) action=menu.addAction(Souris au-dessus de) action=menu.addAction(name) menu.addSeparator() action_1=menu.addAction(Choix 1) action_2=menu.addAction(Choix 2) action_3=menu.addAction(Choix 3) print QtGui.QCursor.pos() menu.exec_(QtGui.QCursor.pos()) ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] SplashScreen and mousePressEvent - SOLVED
Hello. Finaly here is the solution to have a frame where the cursor is. We have to use setGeomtry and not setRectangle. Best regards. Christophe. == THE CODE == class MyFrame(QtGui.QFrame): def __init__(self, parent, titre, pixmapfile): QtGui.QFrame.__init__(self, parent, QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.Tool) rect = QtCore.QRect(QtGui.QCursor.pos(), pixmapfile.size()) self.setGeometry(rect) label = QtGui.QLabel(self) label.setPixmap(pixmapfile) label.show() self.timer = QtCore.QTimer() self.connect( self.timer, QtCore.SIGNAL(timeout()), self, QtCore.SLOT(hide()) ) def showEvent(self, evt): self.timer.start(1) # 10 seconds QtGui.QFrame.showEvent(self, evt) ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Changing the opacity of a frame when it doesn't have the focus
Hello, I would like to catch the events when my frame has the focus or losts it. I don't understand why the following code doesn't work. Indeed, I would like the frame to have a 0.5 opacity when the focus is out and 1.0 when it is in the frame. Every tip or clue is welcome. Christophe. == THE CODE == class MyFrame(QtGui.QFrame): def __init__(self, parent, titre, pixmapfile): QtGui.QFrame.__init__(self, parent, QtCore.Qt.Tool) self.setWindowTitle(titre) rect = QtCore.QRect(QtGui.QCursor.pos(), pixmapfile.size()) self.setGeometry(rect) self.setFixedSize(pixmapfile.size()) label = QtGui.QLabel(self) label.setPixmap(pixmapfile) label.show() self.timer = QtCore.QTimer() self.connect( self.timer, QtCore.SIGNAL(timeout()), self, QtCore.SLOT(hide())) def focusOutEvent(self, evt): print 'out' def focusInEvent(self, evt): print 'in' def showEvent(self, evt): self.timer.start(1) # 10 seconds QtGui.QFrame.showEvent(self, evt) ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Changing the opacity of a frame when it doesn't have the focus
Sorry for the indentation of the code but the problem is not there. My problem is that nothing is printed when the focus of the frame changes. Christophe. Hello, I would like to catch the events when my frame has the focus or losts it. I don't understand why the following code doesn't work. Indeed, I would like the frame to have a 0.5 opacity when the focus is out and 1.0 when it is in the frame. Every tip or clue is welcome. Christophe. == THE CODE == class MyFrame(QtGui.QFrame): def __init__(self, parent, titre, pixmapfile): QtGui.QFrame.__init__(self, parent, QtCore.Qt.Tool) self.setWindowTitle(titre) rect = QtCore.QRect(QtGui.QCursor.pos(), pixmapfile.size()) self.setGeometry(rect) self.setFixedSize(pixmapfile.size()) label = QtGui.QLabel(self) label.setPixmap(pixmapfile) label.show() self.timer = QtCore.QTimer() self.connect( self.timer, QtCore.SIGNAL(timeout()), self, QtCore.SLOT(hide())) def focusOutEvent(self, evt): print 'out' def focusInEvent(self, evt): print 'in' def showEvent(self, evt): self.timer.start(1) # 10 seconds QtGui.QFrame.showEvent(self, evt) ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Bug with eventFocus
Hello, the fllowing code doesn't work. Best regards. class MyFrame(QtGui.QFrame): def __init__(self, parent, titre, pixmapfile): QtGui.QFrame.__init__(self, parent, QtCore.Qt.Tool) self.setWindowTitle(titre) rect = QtCore.QRect(QtGui.QCursor.pos(), pixmapfile.size()) self.setGeometry(rect) self.setFixedSize(pixmapfile.size()) label = QtGui.QLabel(self) label.setPixmap(pixmapfile) label.show() def focusInEvent(self, event): print 'The focus IN event is not detected. Why ?' ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] How to catch a mouse event and a key event at the same time
Hello, I would like to know when the user uses at the same time the left button of the mouse and the key CTRL for example. Is-it possible ? Christophe. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] tooltips in menu: how?
V. Armando Solé is right. With this solution the tooltips come quickly in my computer. The corresponding PyQt code is : #!/usr/bin/env python # -*- coding: utf-8 -*- import sys from PyQt4 import QtCore, QtGui, uic class MainWindow(QtGui.QWidget): def __init__(self, parent=None): super(MainWindow, self).__init__(parent) self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.setAttribute(QtCore.Qt.WA_GroupLeader) self.menuI = QtGui.QPushButton(Menu) self.menuI.setToolTip(Click here...) self.menuI.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) mainLayout = QtGui.QHBoxLayout() mainLayout.addWidget(self.menuI) self.setLayout(mainLayout) self.resize(49,40) self.setWindowTitle(Qt menu) self.clicAct0 = QtGui.QAction(0, self) self.clicAct0.setToolTip(tooltip 0) self.connect(self.clicAct0, QtCore.SIGNAL(triggered()), self.clic) self.clicAct1 = QtGui.QAction(1, self) self.clicAct1.setToolTip(tooltip 1) self.connect(self.clicAct1, QtCore.SIGNAL(triggered()), self.clic) self.clicAct2 = QtGui.QAction(2, self) self.clicAct2.setToolTip(tooltip 2) self.connect(self.clicAct2, QtCore.SIGNAL(triggered()), self.clic) menu0 = QtGui.QMenu(self) menu0.addAction(self.clicAct0) menu0.addAction(self.clicAct1) menu0.addAction(self.clicAct2) self.connect(menu0, QtCore.SIGNAL(hovered(QAction *)), self._actionHovered) menu1 = QtGui.QMenu(self) menu1.setTitle(submenu) menu1.setToolTip(tooltip submenu) menu1_0 = QtGui.QAction(subentry,self) menu1_0.setToolTip(tooltip subentry) self.connect(menu1_0, QtCore.SIGNAL(triggered()), self.clic) menu1.addAction(menu1_0) menu0.addMenu(menu1) self.menuI.setMenu(menu0) def clic(self): print clic def _actionHovered(self, action): tip = action.toolTip() QtGui.QToolTip.showText(QtGui.QCursor.pos(), tip) def main(): app = QtGui.QApplication(sys.argv) locale = QtCore.QLocale.system().name() appTranslator = QtCore.QTranslator() app.setApplicationName(app.translate(main, qtmenu)) form = MainWindow() form.show() app.exec_() if __name__ == __main__: main() Andreas Pakulat wrote: On 17.04.09 19:57:29, V. Armando Solé wrote: Hi! I encounter the same problem as the original poster. The tooltips of QActions in a QMenu are not shown. Is there a solution? You can set the statustip on the actions, which makes the text show up in the statusbar (at least in KDE apps, maybe pure Qt needs some additional hookup there). But AFAIK Qt simply doesn't support Tooltips on menus at this point, possibly something they could add to 4.6. Andreas I get satisfactory results (if one does not mind to show ALWAYS a tooltip) with: qt.QObject.connect(menu, qt.SIGNAL(hovered(QAction *)), self._actionHovered) def _actionHovered(self, action): tip = action.toolTip() qt.QToolTip.showText(qt.QCursor.pos(), tip) Surely there are cleaner workarounds ... Armando ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Re: tooltips in menu: how?
This is normal. When the menu is activated ther is no reason to give a tooltip about it because we know wath is in. Christophe. Wolfgang Rohdewald a écrit : this code works here too - but not always. First place the mouse over the menu and wait until the tooltip Click here... appears now click on it and move the mouse to the menu entries. No tooltips. They only appear if the click here... was not visible when opening the menu. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Link between a QWebViev and a JavaScript program
Hello, I'm seeking for information about how to comunicate from PyQt with a JavaScript program. All kind of information is welcome. Christophe. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Link between a QWebViev and a JavaScript program
Simon Edwards a écrit : projetmbc wrote: I'm seeking for information about how to comunicate from PyQt with a JavaScript program. QWebFrame's evaluateJavaScript() might be a start. I also found a whitepaper of QT. I'll try to test that. Thanks for showing me the direction. Christophe. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Link between a QWebViev and a JavaScript program
Simon Edwards a écrit : projetmbc wrote: I'm seeking for information about how to comunicate from PyQt with a JavaScript program. QWebFrame's evaluateJavaScript() might be a start. Indeed I'm looking for a simple example rather than an abstract one. Christophe. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Re: tooltips in menu: how?
Wolfgang Rohdewald a écrit : let me restate what I observed: if the tip click here... appears, the tips tooltip 0 etc will never appear unless the program is restarted if the tip click here... does not appear, the tips tooltip 0 etc will appear this is inconsistent behaviour. You're right this a real problem. I've it on my computer too. This is a bug. Wolfgang Rohdewald a écrit : Even worse: 1. wait for the tooltip click here to appear 2. open the menu and click on any menu entry. 3. the tool tip click here will never appear again don't you observe this behaviour? What versions are you using? I do not have this problem. Christophe. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Link between a QWebViev and a JavaScript program
David Boddie a écrit : The porting of the C++ Qt examples to Python has fallen behind since Qt 4.3 so there aren't any simple WebKit examples included with PyQt. I'm not lucky... :-\ David Boddie a écrit : The recent Monster Evolution experiments on Qt Labs include a Python version of a program that integrates with WebKit's JavaScript engine: http://labs.trolltech.com/blogs/2009/04/07/monster-evolution-in-qt-episode-2-attack-of-the-squirrelfish/ QWebFrame's addToJavaScriptWindowObject() method lets you insert an instance of a QObject subclass into the page. You can expose methods to JavaScript, but you have to declare them as slots with the @pyqtSignature() decorator. The example code can be found here: http://labs.trolltech.com/gitweb?p=GraphicsDojo;a=blob;f=webmonster/webmonster.py I'll study it as soon as possible... Thanks. Christophe. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Link between a QWebViev and a JavaScript program
Marcell Mars a écrit : the simplest example of loading jquery.js (geti it from http://jqueryjs.googlecode.com/files/jquery-1.3.2.js and put it in the same directory with the snippet below) after loading html and then using jquery syntax to change the background color into red: run it in python interactive shell or better in ipython: from PyQt4.QtCore import * from PyQt4.QtGui import * from PyQt4.QtWebKit import * myWebKit = QWebView() myWebKit.show() myWebKit.setUrl(QUrl(http://www.google.com;)) myWebKit.page().mainFrame().evaluateJavaScript(open('jquery.js').read()) myWebKit.page().mainFrame().evaluateJavaScript($(document).ready(function() { $(body).css(background, #f00);});) Your example doesn't work for me. I've done the program given with tis message and the files which are ine the same folder. What's wrong ? Christophe. A simple test # -*- coding: utf-8 -*- #!/usr/bin/env python # Les lignes ci-dessus sont très importantes : #1°) La 1ère ligne indique le codage du fichier Python. #2°) La 2nde ligne est indispensable pour un bon fonctionnement sous Linux. # PRESENTATION : ce script montre comment créé un fichier au format HTML ou PDF. # AUTEUR : BAL Christophe # MAIL : projet...@club.fr # SITE : http://christophe_bal.club.fr/index.php # DATE DE CREATION : 24/06/2008 # DERNIERE MODIFICATION : 10/12/2008 # # TEST(S) EFFECTUE(S) : programme testé sous Windows XP avec succès. # On importe les bibliothèques que nous allons utiliser. import sys from PyQt4 import QtCore, QtGui from PyQt4 import QtWebKit # On importe notre boîte de dialogue. from JQueryTest import Ui_dial_Projet2 class dial_Projet2(QtGui.QDialog, Ui_dial_Projet2): def __init__(self): QtGui.QDialog.__init__(self) Ui_dial_Projet2.__init__(self) self.verticalLayout = QtGui.QVBoxLayout(self) self.verticalLayout.setObjectName(verticalLayout) self.webView = QtWebKit.QWebView(self) self.webView.setUrl(QtCore.QUrl(test.html)) self.webView.setObjectName(webView) self.verticalLayout.addWidget(self.webView) self.webView.page().mainFrame().evaluateJavaScript(open('jquery.js').read()) self.webView.page().mainFrame().evaluateJavaScript($(document).ready(function() { $(body).css(background, #ff0);});) if __name__ == __main__: import sys app = QtGui.QApplication(sys.argv) testFichier = dial_Projet2() testFichier.show() sys.exit(app.exec_()) ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Link between a QWebViev and a JavaScript program
I've forgot the gui file. Here is it. Christophe. : Marcell Mars a écrit : the simplest example of loading jquery.js (geti it from http://jqueryjs.googlecode.com/files/jquery-1.3.2.js and put it in the same directory with the snippet below) after loading html and then using jquery syntax to change the background color into red: run it in python interactive shell or better in ipython: from PyQt4.QtCore import * from PyQt4.QtGui import * from PyQt4.QtWebKit import * myWebKit = QWebView() myWebKit.show() myWebKit.setUrl(QUrl(http://www.google.com;)) myWebKit.page().mainFrame().evaluateJavaScript(open('jquery.js').read()) myWebKit.page().mainFrame().evaluateJavaScript($(document).ready(function() { $(body).css(background, #f00);});) Your example doesn't work for me. I've done the program given with tis message and the files which are ine the same folder. What's wrong ? Christophe. # -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'C:\Documents and Settings\Christophe\Mes documents\2,pyBaNaMa\Deb_PythonEtPyQT\CodesProjets\99-WebViev-JavaScript\JQueryTest.ui ' # # Created: Mon Apr 20 00:32:39 2009 # by: PyQt4 UI code generator 4.4.4 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_dial_Projet2(object): def setupUi(self, dial_Projet2): dial_Projet2.setObjectName(dial_Projet2) dial_Projet2.resize(805, 639) dial_Projet2.setAutoFillBackground(True) self.verticalLayout = QtGui.QVBoxLayout(dial_Projet2) self.verticalLayout.setObjectName(verticalLayout) self.webView = QtWebKit.QWebView(dial_Projet2) self.webView.setUrl(QtCore.QUrl(http://www.google.com;)) self.webView.setObjectName(webView) self.verticalLayout.addWidget(self.webView) self.retranslateUi(dial_Projet2) QtCore.QMetaObject.connectSlotsByName(dial_Projet2) def retranslateUi(self, dial_Projet2): dial_Projet2.setWindowTitle(QtGui.QApplication.translate(dial_Projet2, Projet n°2, None, QtGui.QApplication.UnicodeUTF8)) from PyQt4 import QtWebKit if __name__ == __main__: import sys app = QtGui.QApplication(sys.argv) dial_Projet2 = QtGui.QDialog() ui = Ui_dial_Projet2() ui.setupUi(dial_Projet2) dial_Projet2.show() sys.exit(app.exec_()) ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] How to survey the activity of the QSyntaxHighlighter ?
Hello, I would like to know if it is possible to know when the QSyntaxHighlighter does some chnages in the coloration of a text. Is-it possible or not ? C. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Problem with a simple JavaScript cionnection
Hello, I give a very simple HTML page with a very little Javascript. I would klike to do two things : 1) Read in a PyQt application the javascript variable nom. 2) Define a slot wich will tell to the PyQt application that the function affiche() has been called. Best regards and sorry for this question but JavaScript-PyQt is very hard I understand for me. Christophe CODE == html head script type=text/javascript nom = ''; function affiche(){ for(var i=0; idocument.images.length;i++){ document.images[i].onclick=function(){nameImage(this.alt)} } } function nameImage(text){ nom = text; test() } /script /head body onload=affiche() img src=im_1.jpg name=images1 width=256 height=192 border=1 alt=im_1 img src=im_2.jpg name=images2 width=609 height=457 border=1 alt=im_2 /body /html ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: Re: [PyQt] Link between a QWebViev and a JavaScript program
Marcell Mars a écrit : from PyQt4.QtCore import * from PyQt4.QtGui import * from PyQt4.QtWebKit import * myWebKit = QWebView() myWebKit.show() myWebKit.setUrl(QUrl(http://www.google.com;)) myWebKit.page().mainFrame().evaluateJavaScript(open('jquery.js').read()) myWebKit.page().mainFrame().evaluateJavaScript($(document).ready(function() { $(body).css(background, #f00);});) Indeed the line myWebKit.page().mainFrame().evaluateJavaScript($(document).ready(function() { $(body).css(background, #f00);});) must be changed to self.webView.page().mainFrame().evaluateJavaScript($(body).css(background, #f00);) With this modification, everything is ok. Thanks. Christophe. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Searching for a very small scprit using CLIPBOARD
Hello, here is an example for using the clipboard of Tkinter : from Tkinter import * root = Tk() root.clipboard_clear() root.clipboard_append('A text in the clipboard...') root.withdraw() I would like to do the same with PyQt. Is it possible ? Christophe. PS : if someone knows a Python script which is an universal ClipBoard (ie which works on Unix and Windows), it would be better. The purpose is just to send text. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Searching for a very small scprit using CLIPBOARD
I've already try that but I have the following message : QWidget: Must construct a QApplication before a QPaintDevice Christophe. Demetrius Cassidy a écrit : from PyQt4.QtGui import QApplication clipboard = QApplication.clipboard() clipboard.setText('mytext') see http://doc.trolltech.com/4.5/qapplication.html ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Searching for a very small scprit using CLIPBOARD
I've tried the following code but the application never stops because of app.exec_(), and when I close the application, the clipboard is empty. = #!/usr/bin/env python #coding=utf-8 import sys from PyQt4 import QtGui app = QtGui.QApplication(sys.argv) clipboard = app.clipboard() clipboard.setText('texte') app.exec_() = Darren Dale a écrit : Have you tried constructing a QApplication first? On Sat, Apr 25, 2009 at 8:24 PM, projetmbc projet...@club-internet.fr mailto:projet...@club-internet.fr wrote: I've already try that but I have the following message : QWidget: Must construct a QApplication before a QPaintDevice Christophe. Demetrius Cassidy a écrit : from PyQt4.QtGui import QApplication clipboard = QApplication.clipboard() clipboard.setText('mytext') see http://doc.trolltech.com/4.5/qapplication.html ___ PyQt mailing listPyQt@riverbankcomputing.com mailto:PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Searching for a very small scprit using CLIPBOARD
sys.exit(app.exec_()) doesn't work. If the clipboard is empty when the program exits, I will do without PyQt so as to have a universal clipboard. Thanks a lot because now I knows how to use clipboard in a real program.. Christophe. Demetrius Cassidy a écrit : The clipboard will empty when your program exits. Afaik this is normal behavior with Qt and clipboard access. I know if I use wxWindows the text in the clipboard stays even if I close my app, however I am not sure if it's possible to do this in Qt. And use sys.exit(app.exec_()) instead. projetmbc wrote: I've tried the following code but the application never stops because of app.exec_(), and when I close the application, the clipboard is empty. = #!/usr/bin/env python #coding=utf-8 import sys from PyQt4 import QtGui app = QtGui.QApplication(sys.argv) clipboard = app.clipboard() clipboard.setText('texte') app.exec_() = ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Searching for a very small scprit using CLIPBOARD
Thanks a lot, your solution works fine. :-) Here is the complete minimal code : #!/usr/bin/env python #coding=utf-8 import sys from PyQt4 import QtGui, QtCore app = QtGui.QApplication(sys.argv) clipboard = app.clipboard() clipboard.setText('The text that must be copied...') event = QtCore.QEvent(QtCore.QEvent.Clipboard) app.sendEvent(clipboard, event) Aron Bierbaum a écrit : We ran into a similar situation where we wanted to ensure that a QPixmap that is copied into the clipboard stays after the application exits. Although as far as I know this should happen automatically when your Qt application exists, we had to do this use the following code manually before exiting our application. # Send an event to the clipboard so that it copies the data over to the # clipboard instead of keeping a pointer to the data internally. This should # happen automatically on exit, but it appears that the mime type convertion # methods for Qt - windows formats get unregistered before this event gets # processed. This caused a bug where we couldn't paste data after closing # because there was not a conversion method. The magic function on Windows that # needs to be called to do this copy is OleFlushClipboard. from PyQt4 import QtGui, QtCore clipboard = QtGui.QApplication.clipboard() event = QtCore.QEvent(QtCore.QEvent.Clipboard) QtGui.QApplication.sendEvent(clipboard, event) The basic concept behind this is that by default copying something into the clipboard only copies a reference/pointer to the source application. Then when another application wants to paste the data from the clipboard it requests the data from the source application. Calling OleFlushClipboard [1] causes Windows to copy the real data into the clipboard instead of the reference. While this does cause a delay when copying images, it should not have any noticeable impact with strings. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Searching for a very small scprit using CLIPBOARD
Giovanni Bajo a écrit : On lun, 2009-04-27 at 18:42 +0200, projetmbc wrote: Thanks a lot, your solution works fine. :-) Here is the complete minimal code : #!/usr/bin/env python #coding=utf-8 import sys from PyQt4 import QtGui, QtCore app = QtGui.QApplication(sys.argv) clipboard = app.clipboard() clipboard.setText('The text that must be copied...') event = QtCore.QEvent(QtCore.QEvent.Clipboard) app.sendEvent(clipboard, event) It doesn't work for me on Linux. Should it? For the moment I do not test it on Linux. It seems that Linux distribution does not have necessarly a clipboard utility. I will try it on Linux and if I find a solution I'll put it here. Christophe. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] FetchMore Example
I really appreciate that kind of simple examples. This is the best way to learn how to use PyQt. Thanks a lot. Christophe Darryl Wallace a écrit : Hello Everyone, Since I was interested in the FetchMore example (included in Qt4.5) and extending it for myself, I just decided to port the FetchMore example to PyQt4 since I noticed it was not included in the ItemViews examples in the latest snapshot. Feel free to use it as you wish. Phil feel free to included it in your list of examples should it be deemed acceptable. The only thing that I have done differently is that I force the QStringList to be a Python list. I wrote it using PyQt4.4.2 in Linux (Ubuntu). See the attached file. Regards, Darryl ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Next Releases
Hello, I would like to know if the patch of Eric Software which allows to use pygments with QScintilla will be with this new release. Best regards. Christophe Phil Thompson a écrit : I plan to release new versions of SIP, PyQt3, PyQt4 and QScintilla at the end of the week based on the current snapshots. If there is something you think is missing or broken then now would be a good time to remind me. Phil ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Next Releases
That's very cool. I hope that there will be a simple example showing how to use it. Christophe. Phil Thompson a écrit : On Tue, 26 May 2009 11:48:52 +0200, projetmbc projet...@club-internet.fr wrote: Hello, I would like to know if the patch of Eric Software which allows to use pygments with QScintilla will be with this new release. Yes. Phil ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Next Releases
For your point of view but none for mine. Indeed I'd like examples which are very small. Why don't you give this kind of example ? Best regards. Christophe Detlev Offenbach a écrit : Hi, the simple example is eric. ;-) Detlev On Dienstag, 26. Mai 2009, projetmbc wrote: That's very cool. I hope that there will be a simple example showing how to use it. Christophe. Phil Thompson a écrit : On Tue, 26 May 2009 11:48:52 +0200, projetmbc projet...@club-internet.fr wrote: Hello, I would like to know if the patch of Eric Software which allows to use pygments with QScintilla will be with this new release. Yes. Phil ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Evolution of QWebView
Hello, I would like to know what is planed about JavaScript and PyQt. I know that for the moment it is possible to call a JS program from PyQt, but what about the use of a JS constant in a web page in a PyQt application. I also would like if the use of applet is, or will be, possible in a QWebView. Best regards. Christophe. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Question about QsciLexerCustom
Hello, I would like to use QsciLexerCustom so as to define my own lexer. The documentation says : All that is necessary to implement a new lexer is to define appropriate styles and to re-implement the styleText() classQsciLexerCustom.html#91d71c4bdff5140ae0b0cb34b4511f79 method. This sounds very abstract to me. How can I color a single word like STRANGE ? How can I define a block like a C++ comment ? Best regards. Christophe PS : I'm ready to do a simple but complete PyQt example that could help future users but for the moments I do not how to start. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Question about QsciLexerCustom
Phil Thompson a écrit : On Wed, 10 Jun 2009 15:12:03 +0200, projetmbc projet...@club-internet.fr wrote: Hello, I would like to use QsciLexerCustom so as to define my own lexer. The documentation says : All that is necessary to implement a new lexer is to define appropriate styles and to re-implement the styleText() classQsciLexerCustom.html#91d71c4bdff5140ae0b0cb34b4511f79 method. This sounds very abstract to me. How can I color a single word like STRANGE ? How can I define a block like a C++ comment ? You have to parse the text you are being asked to style (or find it in a data structure you have already created) to determine what style should be applied to each character (or group of characters). Apply the style by making a call to startStyling() followed by one or more calls to setStyling(). Phil Thanks I'll look at that. When I'll make a functionnal example I'll post it here. Christophe. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Question about QsciLexerCustom
Sorry but I do not see how to do. What is a minimal structure of the class ? class myLexer(Qsci.QsciLexerCustom): All kinds of clue is welcome. Christophe. Phil Thompson a écrit : On Wed, 10 Jun 2009 15:12:03 +0200, projetmbc projet...@club-internet.fr wrote: Hello, I would like to use QsciLexerCustom so as to define my own lexer. The documentation says : All that is necessary to implement a new lexer is to define appropriate styles and to re-implement the styleText() classQsciLexerCustom.html#91d71c4bdff5140ae0b0cb34b4511f79 method. This sounds very abstract to me. How can I color a single word like STRANGE ? How can I define a block like a C++ comment ? You have to parse the text you are being asked to style (or find it in a data structure you have already created) to determine what style should be applied to each character (or group of characters). Apply the style by making a call to startStyling() followed by one or more calls to setStyling(). Phil ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Probleme with the metho description of QSciScintlla
Hello, I'm always trying to make my own lexer but I don't have enough informtaion to start easily. I have to implement some methods but what have I to do with the method description. === My code === class monLexer(Qsci.QsciLexerCustom): # Obtenu patr tatons : http://www.riverbankcomputing.com/static/Docs/QScintilla2/classQsciLexerCustom.html def description(self, text): print 'oki' def setStyling(self, lenght, style_bits = 0): print '(lenght, style_bits)' print (lenght, style_bits) def startStyling(self, pos, style_bits = 0): print '(pos, style_bits)' print (pos, style_bits) def styleText(self, start, end): print '(start, end)' print (start, end) = Every kinds of help is welcome. Christophe. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Probleme with the metho description of QSciScintlla
Phil Thompson a écrit : On Mon, 15 Jun 2009 19:02:58 +0200, projetmbc projet...@club-internet.fr wrote: Hello, I'm always trying to make my own lexer but I don't have enough informtaion to start easily. I have to implement some methods but what have I to do with the method description. What part of... http://www.riverbankcomputing.com/static/Docs/QScintilla2/classQsciLexer.html#dd9c20adb43bc38d1a0ca3083ac3e6fa ...is causing you a problem? Phil Indeed I've typed the code given with this message. I have the folowing Error : QsciLexerCustom.description() is abstract and must be overridden. What's wrong ? Christophe. # -*- coding: utf-8 -*- #!/usr/bin/env python # PRESENTATION : ce script montre comment utiliser les focntionnalités de base du composant QSci (Scintilla). # AUTEUR : BAL Christophe # MAIL : projet...@club.fr # SITE : http://christophe_bal.club.fr/index.php # DATE DE CREATION : 28/08/2008 # # TEST(S) EFFECTUE(S) : programme testé sous Windows XP avec succès. # On importe les bibliothèques que nous allons utiliser. import sys from PyQt4 import QtCore, QtGui, Qsci from window_LecteurCodePython_HTML import Ui_window_LecteurCodePython_HTML class myLexer(Qsci.QsciLexerCustom): def setStyling(self, lenght, style_bits = 0): print '(lenght, style_bits)' print (lenght, style_bits) def startStyling(self, pos, style_bits = 0): print '(pos, style_bits)' print (pos, style_bits) def styleText(self, start, end): print '(start, end)' print (start, end) class window_LecteurCodePython_HTML(QtGui.QMainWindow, Ui_window_LecteurCodePython_HTML): def __init__(self): QtGui.QMainWindow.__init__(self) Ui_window_LecteurCodePython_HTML.__init__(self) self.setupUi(self) self.extensionsPython = ['py','pyw'] self.extensionsHTML = ['htm','html'] font = QtGui.QFont() font = QtGui.QFont() font.setFamily(Arial) font.setFixedPitch(True) font.setPointSize(10) fm = QtGui.QFontMetrics(font) self.textScintilla_Principal.setFont(font) self.textScintilla_Principal.setMarginsFont(font) self.textScintilla_Principal.setMarginLineNumbers(1,True) self.textScintilla_Principal.setMarginWidth(1, fm.width( 0 ) + 5) self.textScintilla_Principal.setBraceMatching(Qsci.QsciScintilla.SloppyBraceMatch) self.textScintilla_Principal.setFolding(Qsci.QsciScintilla.BoxedTreeFoldStyle) self.textScintilla_Principal.setWrapMode(Qsci.QsciScintilla.WrapMode(Qsci.QsciScintillaBase.SC_WRAP_WORD)) self.textScintilla_Principal.setWrapVisualFlags(Qsci.QsciScintilla.WrapVisualFlag(Qsci.QsciScintilla.WrapFlagByBorder), Qsci.QsciScintilla.WrapVisualFlag(Qsci.QsciScintilla.WrapFlagNone), 0) self.connect(self.actionOuvrir, QtCore.SIGNAL(triggered()),self.ouvrirFichier) self.textScintilla_Principal.setLexer(myLexer) f=open('test.txt') textFichier= f.read() self.textScintilla_Principal.setText(textFichier) def ouvrirFichier(self) : self.cheminFichier = QtGui.QFileDialog.getOpenFileName(self, self.tr(Choisir le fichier),QtCore.QDir.currentPath(),); if self.cheminFichier '': self.textScintilla_Principal.setMarginLineNumbers(1,True) nomFichier = str(QtCore.QFileInfo(self.cheminFichier).fileName()) separer = nomFichier.split('.') if len(separer) == 1 : print 'Fichier sans extension' else: extension = separer[len(separer) - 1] if extension in self.extensionsPython: self.textScintilla_Principal.setLexer(Qsci.QsciLexerPython()) elif extension in self.extensionsHTML: self.textScintilla_Principal.setLexer(Qsci.QsciLexerHTML()) else: print 'Seule la coloration des fichiers HTML et Python sont gérés par cette application Test.' self.textScintilla_Principal.setLexer(Qsci.QsciLexerCPP()) f=open(self.cheminFichier) textFichier= f.read() self.textScintilla_Principal.setText(textFichier) if __name__ == __main__: app = QtGui.QApplication(sys.argv) LecteurCodePython = window_LecteurCodePython_HTML() LecteurCodePython.show() sys.exit(app.exec_()) ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Probleme with the metho description of QSciScintlla
Indeed I've typed the code given with this message. I have the folowing Error : QsciLexerCustom.description() is abstract and must be overridden. What's wrong ? I don't think the error message can be clearer - you need to reimplement description() in your sub-class as described in the documentation. Phil I've tired to implement that : = def description(self, style): print '(style)' print (style) return '' = Then numbers from 0 to 30 has been catched by the method. What is the meaning of this numbers ? Sorry for beeing such a newbie. Christophe ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Probleme with the metho description of QSciScintlla
I've tired to implement that : = def description(self, style): print '(style)' print (style) return '' = Then numbers from 0 to 30 has been catched by the method. What is the meaning of this numbers ? Sorry for beeing such a newbie. Indeed, I've understood that this number are the default lexers. The following seems to work : === def description(self, style): if style == 7: return 'myLexer' return '' === Is-it what I'm supposed to do or not ? The problem is that I've no concrete example so as to start. Is there for example the C++ code of one of the default lexer ? Then the migration to Python must be easier. I hope. Christophe. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Using Unicode
Gabriel Hahmann a écrit : Hi, I'm new to the list and new to programming in python QT and I'm having a little problem dealing with accent characters. I have a little program that have the text sent to the user interface using something like this: QtGui.QPushButton(self.tr('Next ')) self.setWindowTitle(self.tr('Setup').arg(len(self.history)).arg(self.num_pages)) self.topTitle = QtGui.QLabel(self.tr('centerbWarning/center') self.set_status_text('Username', True) label_text = 'Warning' self.top_label = QtGui.QLabel(self.tr(label_text)) In fact this is some excerpt of parts of the code. What I want to do is translate every word of the text to Portuguese. I tried simply translating but then it gives me an error of outside ASCII range. Then I added coding: utf-8 at the top of the file. Changed self.tr to self.trUtf8 with no luck. I tried self.tr(unicode(Some text)) with no luck too. What I want to do is simply tranlate this program, I dont want it to be internationalized, I mean, changing it in a way that it can be tranlated again easily. The Portuguese characters have é, ç, ê, ô, etc. I tried with self.trUtf8 and putting the code in hex like this self.trUtf8(\00C9) without success. I've read a lot of pages telling how to print unicode characters but I couldnt print a single character right now. If anyone can help me I will really appreciate, just to give me some more things to try!! Thanks in advance. Gabriel. I'm French and I've lmett this problem with the accents. Here is a solution that I use. Instead of self.button.setText(self.tr(Créer les deux fichiers)) I use in my class dial_Projet2 self.button.setText(QtGui.QApplication.translate(dial_Projet2, Créer les deux fichiers, None, QtGui.QApplication.UnicodeUTF8)) Christophe. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Pressing enter in QLineEdit clicks QPushButton?
Mads Ipsen a écrit : If you change 'QDialog' to 'QWidget' the problem disappears. But I have no idea why. Anybody? Best regards, Mads In the first example proposed that did not work, you can see that the button has the focus even if the cursor is in the lineedit. I think that the problem comes from here. Christophe. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Using a QCompleter with a QLineEdit
Hello, can you give a LFE aka a little functiunal example ? C. Greg Smith a écrit : Hey Everyone, I’m trying to get a LineEdit I have in a tool I am writing to have the ability to auto complete the user’s entry based on what they have typed. From the sounds of it, QCompleter is exactly what I am after and they work on QLineEdit widgets. However I am having difficulty getting it to work, so I was wondering if I could share what I am trying to do and see if I am doing anything wrong or not doing something that I should be in order to get it to work. So here’s an abridged example of what I am doing. From PyQt4 import QtCore, QtGui, uic defaultList = [‘foo’, ‘bar’, ‘alpha’, ‘beta’, ‘ceti’, ‘delta’] completerList = QtCore.QStringList() for i in defaultList: completerList.append(QtCore.QString(i)) #defining my QDialog class MyPyQtTool(QtGui.QDialog): def __init__(self): QtGui.QDialog.__init__(self) self.ui = uic.loadUi (‘C:\\myUiFile.ui’) lineEditCompleter = QtGui.QCompleter(completerList) lineEditCompleter.setCompletionMode(QtGui.QCompleter.InlineCompletion) lineEditCompleter.setCaseSensitivity(QtCore.Qt.CaseInsensitive) self.ui.myLineEdit_widget.setCompleter(lineEditCompleter) #... defining other tool logic # I also have the list being modified in another method based off of user’s selection. def onMyComboBoxActivated(self) # code here where a string list is created from a mysql db query based on combo box selection. for i in dbQryList: completerList.append(QtCore.QString(i)) lineEditCompleter = QtGui.QCompleter(completerList) lineEditCompleter.setCompletionMode(QtGui.QCompleter.InlineCompletion) lineEditCompleter.setCaseSensitivity(QtCore.Qt.CaseInsensitive) self.ui.myLineEdit_widget.setCompleter(lineEditCompleter) app = QtGui.QApplication(sys.argv) dialog = MyPyQtTool() dialog.ui.show() app.exec_() --- This may not be the cleanest way of doing what I want but from the example shown in the class reference web page, this should be sound. However when I try to test it, I get no completion what so ever. No errors are thrown so I am not exactly sure what I am doing wrong. Is there another method that needs to be executed before it should work? Any help would be truly appreciated! Thanks, Greg ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Using a QCompleter with a QLineEdit
projetmbc a écrit : Try to do the following change : OLD lineEditCompleter = QtGui.QCompleter(completerList) NEW lineEditCompleter = QtGui.QCompleter(completerList) END Sorry, I've forgot to do the changes. Here there are. OLD lineEditCompleter = QtGui.QCompleter(completerList) NEW lineEditCompleter = QtGui.QCompleter(completerList, self) END ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Using a QCompleter with a QLineEdit
Greg Smith a écrit : Awesome! Merci beaucoup. That did the trick! Greg -Original Message- From: projetmbc [mailto:projet...@club-internet.fr] Sent: Thursday, June 25, 2009 3:56 AM To: projetmbc Cc: Greg Smith; PyQt Subject: Re: [PyQt] Using a QCompleter with a QLineEdit projetmbc a écrit : Try to do the following change : OLD lineEditCompleter = QtGui.QCompleter(completerList) NEW lineEditCompleter = QtGui.QCompleter(completerList) END Sorry, I've forgot to do the changes. Here there are. OLD lineEditCompleter = QtGui.QCompleter(completerList) NEW lineEditCompleter = QtGui.QCompleter(completerList, self) END === De rien... Christophe. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Probleme with the metho description of QSciScintlla
Phil Thompson a écrit : On Mon, 15 Jun 2009 19:02:58 +0200, projetmbc projet...@club-internet.fr wrote: Hello, I'm always trying to make my own lexer but I don't have enough informtaion to start easily. I have to implement some methods but what have I to do with the method description. What part of... http://www.riverbankcomputing.com/static/Docs/QScintilla2/classQsciLexer.html#dd9c20adb43bc38d1a0ca3083ac3e6fa ...is causing you a problem? Phil A lot of questions about the documentation... * Am I right if I define my own lexer by the following way ? = class myLexer(Qsci.QsciLexerCustom): # Struggle for a lexer. def description(self, style): . def styleText(self, start, end): . def setStyling(self, lenght): . def startStyling(self, pos): . class myApplication(QtGui.QMainWindow, Ui_window): def __init__(self): QtGui.QMainWindow.__init__(self) Ui_window_LecteurCodePython_HTML.__init__(self) self.setupUi(self) self.textScintilla_Principal.setLexer(myLexer()) . = * The method styleText works line by line. Is it right ? How can we read the characters of the line so as to analyse them ? What is the self.method to use ? * When a word is detected, is its highlighting made by doing something like ? = def styleText(self, start, end): . self.startStyling(posOfTheFisrtCharacterOfTheWord) self.setStyling(lenghtOfTheWord) . = * This near to be the last question is to know how to acess to the color and the font properties of a character. * Is there some signal to do or not ? Have we have acces to some signal to know that something has been highlighted ? Best regards. Christophe who feels like a galley slave... :-) ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Problem with QSciScintlla
Hello, why the following code doesn't print anything in the console ? Best regards. Christophe # -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'C:\Documents and Settings\Christophe\Mes documents\2,pyBaNaMa\DebuterAvecPythonEtPyQT\CodesProjets\04-Proj4_MiniEditHTML\05-TestColorSyntax(WebKit)\window_LecteurCodePython_HTML.ui ' # # Created: Thu Aug 28 12:37:43 2008 # by: PyQt4 UI code generator 4.4.3 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_window_LecteurCodePython_HTML(object): def setupUi(self, window_LecteurCodePython_HTML): window_LecteurCodePython_HTML.setObjectName(window_LecteurCodePython_HTML) window_LecteurCodePython_HTML.resize(516, 397) self.centralwidget = QtGui.QWidget(window_LecteurCodePython_HTML) self.centralwidget.setObjectName(centralwidget) self.verticalLayout = QtGui.QVBoxLayout(self.centralwidget) self.verticalLayout.setObjectName(verticalLayout) self.textScintilla_Principal = Qsci.QsciScintilla(self.centralwidget) self.textScintilla_Principal.setObjectName(textScintilla_Principal) self.verticalLayout.addWidget(self.textScintilla_Principal) window_LecteurCodePython_HTML.setCentralWidget(self.centralwidget) self.menubar = QtGui.QMenuBar(window_LecteurCodePython_HTML) self.menubar.setGeometry(QtCore.QRect(0, 0, 516, 21)) self.menubar.setObjectName(menubar) self.menuFichier = QtGui.QMenu(self.menubar) self.menuFichier.setObjectName(menuFichier) window_LecteurCodePython_HTML.setMenuBar(self.menubar) self.statusbar = QtGui.QStatusBar(window_LecteurCodePython_HTML) self.statusbar.setObjectName(statusbar) window_LecteurCodePython_HTML.setStatusBar(self.statusbar) self.actionOuvrir = QtGui.QAction(window_LecteurCodePython_HTML) self.actionOuvrir.setObjectName(actionOuvrir) self.actionEnregistrer = QtGui.QAction(window_LecteurCodePython_HTML) self.actionEnregistrer.setObjectName(actionEnregistrer) self.actionExporterHTML = QtGui.QAction(window_LecteurCodePython_HTML) self.actionExporterHTML.setObjectName(actionExporterHTML) self.menuFichier.addAction(self.actionOuvrir) self.menuFichier.addAction(self.actionEnregistrer) self.menuFichier.addSeparator() self.menuFichier.addAction(self.actionExporterHTML) self.menubar.addAction(self.menuFichier.menuAction()) self.retranslateUi(window_LecteurCodePython_HTML) QtCore.QMetaObject.connectSlotsByName(window_LecteurCodePython_HTML) def retranslateUi(self, window_LecteurCodePython_HTML): window_LecteurCodePython_HTML.setWindowTitle(QtGui.QApplication.translate(window_LecteurCodePython_HTML, MainWindow, None, QtGui.QApplication.UnicodeUTF8)) self.menuFichier.setTitle(QtGui.QApplication.translate(window_LecteurCodePython_HTML, Actions, None, QtGui.QApplication.UnicodeUTF8)) self.actionOuvrir.setText(QtGui.QApplication.translate(window_LecteurCodePython_HTML, Ouvrir, None, QtGui.QApplication.UnicodeUTF8)) self.actionOuvrir.setShortcut(QtGui.QApplication.translate(window_LecteurCodePython_HTML, Ctrl+O, None, QtGui.QApplication.UnicodeUTF8)) self.actionEnregistrer.setText(QtGui.QApplication.translate(window_LecteurCodePython_HTML, Rechercher, None, QtGui.QApplication.UnicodeUTF8)) self.actionEnregistrer.setShortcut(QtGui.QApplication.translate(window_LecteurCodePython_HTML, Ctrl+S, None, QtGui.QApplication.UnicodeUTF8)) self.actionExporterHTML.setText(QtGui.QApplication.translate(window_LecteurCodePython_HTML, Exporter, None, QtGui.QApplication.UnicodeUTF8)) self.actionExporterHTML.setShortcut(QtGui.QApplication.translate(window_LecteurCodePython_HTML, Ctrl+E, None, QtGui.QApplication.UnicodeUTF8)) from PyQt4 import Qsci if __name__ == __main__: import sys app = QtGui.QApplication(sys.argv) window_LecteurCodePython_HTML = QtGui.QMainWindow() ui = Ui_window_LecteurCodePython_HTML() ui.setupUi(window_LecteurCodePython_HTML) window_LecteurCodePython_HTML.show() sys.exit(app.exec_()) # -*- coding: utf-8 -*- #!/usr/bin/env python import sys from PyQt4 import QtCore, QtGui, Qsci from window_LecteurCodePython_HTML import Ui_window_LecteurCodePython_HTML class monLexer(Qsci.QsciLexerCustom): def description(self, style): return 'Style No ' + str(style) def styleText(self, start, end): print '(start, end)' print self [start, start+1] def setStyling(self, lenght, style_bits = 0): print '(lenght, style_bits)' print (lenght, style_bits) def startStyling(self, pos, style_bits = 0): print '(pos, style_bits)' print (pos, style_bits) class window_LecteurCodePython_HTML(QtGui.QMainWindow, Ui_window_LecteurCodePython_HTML):
[PyQt] QSyntaxHighlighter and folding
Hello, I would like to know if QSyntaxHighlighter can work with folding. I don't think so but... Best regards. Christophe PS : Indeed I've tried to use QSciScintilla and its custom lexer but with no simple examples to start it becomes to be very boring to try to find an hypothetical clue. I do not want to waste my time for the moment. The documentation is missing contrary to the PyQt API that is well done. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] QsciScintilla
H'ello, it is too hard to understand what it must be done sucha built with a custom lexer which could be recalled the harder lexer... :-) More seriously, I would like to know where I can do suggestions for a more easy use of it. There is a big incoherence to propose something so easy to use such as QSyntaxHighlighter and to propose a custom lexer with no example. I've already propose a simple lexer wich can be an instructive example for the C++ or Python newbies. This lexer would for example 1. ... put in red all line which begins with a # 2. ... put in blue only the word blue 3. ... make a folding with something starting with /* and ending with */ By doing this I'm sure that more people will use QScintilla because it would be easy to custom it. It seams that the users of Qscintilla are always the same and they don't seem to understand that the task for a newbie is very hard because all the examples are real ones and then there are a litlle bit complex to understand. Christophe. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] A first simple lexer for QSciScintilla ?
Hello, I'm trying to do a very simple lexer wich only detects a python single line comment : ID_DEFAULT = 0 ID_COMMENT = 1 class myLexer(Qsci.QsciLexerCustom): def description(self, style): if style == 0: print 'ID_DEFAULT' return 'ID_DEFAULT' if style == 1: print 'ID_COMMENT' return 'ID_COMMENT' return '' def styleText(self, start, end): if QsciStyle.style() == ID_COMMENT : if self.atLineEnd() : self.startStyling(start) self.setStyling(end,ID_DEFAULT) if QsciStyle.style() == ID_DEFAULT : if self.ch == '#' : self.startStyling(start) self.setStyling(end,ID_COMMENT) To do it, I've used a lexer written in C but I have problem. Can you help to find the mistakes I've made ? Best regards. Christophe. # -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'C:\Documents and Settings\Christophe\Mes documents\2,pyBaNaMa\DebuterAvecPythonEtPyQT\CodesProjets\04-Proj4_MiniEditHTML\05-TestColorSyntax(WebKit)\window_LecteurCodePython_HTML.ui ' # # Created: Thu Aug 28 12:37:43 2008 # by: PyQt4 UI code generator 4.4.3 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_window_LecteurCodePython_HTML(object): def setupUi(self, window_LecteurCodePython_HTML): window_LecteurCodePython_HTML.setObjectName(window_LecteurCodePython_HTML) window_LecteurCodePython_HTML.resize(516, 397) self.centralwidget = QtGui.QWidget(window_LecteurCodePython_HTML) self.centralwidget.setObjectName(centralwidget) self.verticalLayout = QtGui.QVBoxLayout(self.centralwidget) self.verticalLayout.setObjectName(verticalLayout) self.textScintilla_Principal = Qsci.QsciScintilla(self.centralwidget) self.textScintilla_Principal.setObjectName(textScintilla_Principal) self.verticalLayout.addWidget(self.textScintilla_Principal) window_LecteurCodePython_HTML.setCentralWidget(self.centralwidget) self.menubar = QtGui.QMenuBar(window_LecteurCodePython_HTML) self.menubar.setGeometry(QtCore.QRect(0, 0, 516, 21)) self.menubar.setObjectName(menubar) self.menuFichier = QtGui.QMenu(self.menubar) self.menuFichier.setObjectName(menuFichier) window_LecteurCodePython_HTML.setMenuBar(self.menubar) self.statusbar = QtGui.QStatusBar(window_LecteurCodePython_HTML) self.statusbar.setObjectName(statusbar) window_LecteurCodePython_HTML.setStatusBar(self.statusbar) self.actionOuvrir = QtGui.QAction(window_LecteurCodePython_HTML) self.actionOuvrir.setObjectName(actionOuvrir) self.actionEnregistrer = QtGui.QAction(window_LecteurCodePython_HTML) self.actionEnregistrer.setObjectName(actionEnregistrer) self.actionExporterHTML = QtGui.QAction(window_LecteurCodePython_HTML) self.actionExporterHTML.setObjectName(actionExporterHTML) self.menuFichier.addAction(self.actionOuvrir) self.menuFichier.addAction(self.actionEnregistrer) self.menuFichier.addSeparator() self.menuFichier.addAction(self.actionExporterHTML) self.menubar.addAction(self.menuFichier.menuAction()) self.retranslateUi(window_LecteurCodePython_HTML) QtCore.QMetaObject.connectSlotsByName(window_LecteurCodePython_HTML) def retranslateUi(self, window_LecteurCodePython_HTML): window_LecteurCodePython_HTML.setWindowTitle(QtGui.QApplication.translate(window_LecteurCodePython_HTML, MainWindow, None, QtGui.QApplication.UnicodeUTF8)) self.menuFichier.setTitle(QtGui.QApplication.translate(window_LecteurCodePython_HTML, Actions, None, QtGui.QApplication.UnicodeUTF8)) self.actionOuvrir.setText(QtGui.QApplication.translate(window_LecteurCodePython_HTML, Ouvrir, None, QtGui.QApplication.UnicodeUTF8)) self.actionOuvrir.setShortcut(QtGui.QApplication.translate(window_LecteurCodePython_HTML, Ctrl+O, None, QtGui.QApplication.UnicodeUTF8)) self.actionEnregistrer.setText(QtGui.QApplication.translate(window_LecteurCodePython_HTML, Rechercher, None, QtGui.QApplication.UnicodeUTF8)) self.actionEnregistrer.setShortcut(QtGui.QApplication.translate(window_LecteurCodePython_HTML, Ctrl+S, None, QtGui.QApplication.UnicodeUTF8)) self.actionExporterHTML.setText(QtGui.QApplication.translate(window_LecteurCodePython_HTML, Exporter, None, QtGui.QApplication.UnicodeUTF8)) self.actionExporterHTML.setShortcut(QtGui.QApplication.translate(window_LecteurCodePython_HTML, Ctrl+E, None, QtGui.QApplication.UnicodeUTF8)) from PyQt4 import Qsci if __name__ == __main__: import sys app = QtGui.QApplication(sys.argv) window_LecteurCodePython_HTML = QtGui.QMainWindow() ui =
[PyQt] Make a command prompt to see the execution of a Python script
Hello, I would like to know if someone has already made a console so as to see the execution step by step of a Python script launched via a process. Best regards. Christophe ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Problem with colors and QSciScintilla
Your example is great. Easy to understand. Thanks a lot ! :-) With this, I could start to study how to do more sophisticated things like folding. Christophe an happy man. :-D Baz Walter a écrit : I hope that someone can help me. Best regards. Christophe hello christophe here's a basic line-based custom lexer that should get you started: import sys from PyQt4 import QtCore, QtGui, Qsci class MainWindow(QtGui.QMainWindow): def __init__(self): QtGui.QMainWindow.__init__(self) self.setWindowTitle('Custom Lexer Example') self.setGeometry(QtCore.QRect(50,200,400,400)) self.editor = Qsci.QsciScintilla(self) self.editor.setUtf8(True) self.editor.setMarginWidth(2, 15) self.editor.setFolding(True) self.setCentralWidget(self.editor) self.lexer = CustomLexer(self.editor) self.editor.setLexer(self.lexer) self.editor.setText('\n# sample source\n\nfoo = 1\nbar = 2\n') class CustomLexer(Qsci.QsciLexerCustom): def __init__(self, parent): Qsci.QsciLexerCustom.__init__(self, parent) self._styles = { 0: 'Default', 1: 'Comment', 2: 'Key', 3: 'Assignment', 4: 'Value', } for key,value in self._styles.iteritems(): setattr(self, value, key) def description(self, style): return self._styles.get(style, '') def defaultColor(self, style): if style == self.Default: return QtGui.QColor('#00') elif style == self.Comment: return QtGui.QColor('#C0C0C0') elif style == self.Key: return QtGui.QColor('#CC') elif style == self.Assignment: return QtGui.QColor('#CC') elif style == self.Value: return QtGui.QColor('#00CC00') return Qsci.QsciLexerCustom.defaultColor(self, style) def styleText(self, start, end): editor = self.editor() if editor is None: return # scintilla works with encoded bytes, not decoded characters. # this matters if the source contains non-ascii characters and # a multi-byte encoding is used (e.g. utf-8) source = '' if end editor.length(): end = editor.length() if end start: if sys.hexversion = 0x0206: # faster when styling big files, but needs python 2.6 source = bytearray(end - start) editor.SendScintilla( editor.SCI_GETTEXTRANGE, start, end, source) else: source = unicode(editor.text() ).encode('utf-8')[start:end] if not source: return # the line index will also be needed to implement folding index = editor.SendScintilla(editor.SCI_LINEFROMPOSITION, start) if index 0: # the previous state may be needed for multi-line styling pos = editor.SendScintilla( editor.SCI_GETLINEENDPOSITION, index - 1) state = editor.SendScintilla(editor.SCI_GETSTYLEAT, pos) else: state = self.Default set_style = self.setStyling self.startStyling(start, 0x1f) # scintilla always asks to style whole lines for line in source.splitlines(True): length = len(line) if line.startswith('#'): state = self.Comment else: # the following will style lines like x = 0 pos = line.find('=') if pos 0: set_style(pos, self.Key) set_style(1, self.Assignment) length = length - pos - 1 state = self.Value else: state = self.Default set_style(length, state) # folding implementation goes here index += 1 if __name__ == __main__: app = QtGui.QApplication(sys.argv) app.connect(app, QtCore.SIGNAL('lastWindowClosed()'), QtCore.SLOT('quit()')) win = MainWindow() win.show() sys.exit(app.exec_()) ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Problem with colors and QSciScintilla
Baz Walter, I don't know if you are in the riverbanks'team but it could be very usefull to put your example in the official documentation. Regards. Christophe. projetmbc a écrit : Your example is great. Easy to understand. Thanks a lot ! :-) With this, I could start to study how to do more sophisticated things like folding. Christophe an happy man. :-D Baz Walter a écrit : I hope that someone can help me. Best regards. Christophe hello christophe here's a basic line-based custom lexer that should get you started: import sys from PyQt4 import QtCore, QtGui, Qsci class MainWindow(QtGui.QMainWindow): def __init__(self): QtGui.QMainWindow.__init__(self) self.setWindowTitle('Custom Lexer Example') self.setGeometry(QtCore.QRect(50,200,400,400)) self.editor = Qsci.QsciScintilla(self) self.editor.setUtf8(True) self.editor.setMarginWidth(2, 15) self.editor.setFolding(True) self.setCentralWidget(self.editor) self.lexer = CustomLexer(self.editor) self.editor.setLexer(self.lexer) self.editor.setText('\n# sample source\n\nfoo = 1\nbar = 2\n') class CustomLexer(Qsci.QsciLexerCustom): def __init__(self, parent): Qsci.QsciLexerCustom.__init__(self, parent) self._styles = { 0: 'Default', 1: 'Comment', 2: 'Key', 3: 'Assignment', 4: 'Value', } for key,value in self._styles.iteritems(): setattr(self, value, key) def description(self, style): return self._styles.get(style, '') def defaultColor(self, style): if style == self.Default: return QtGui.QColor('#00') elif style == self.Comment: return QtGui.QColor('#C0C0C0') elif style == self.Key: return QtGui.QColor('#CC') elif style == self.Assignment: return QtGui.QColor('#CC') elif style == self.Value: return QtGui.QColor('#00CC00') return Qsci.QsciLexerCustom.defaultColor(self, style) def styleText(self, start, end): editor = self.editor() if editor is None: return # scintilla works with encoded bytes, not decoded characters. # this matters if the source contains non-ascii characters and # a multi-byte encoding is used (e.g. utf-8) source = '' if end editor.length(): end = editor.length() if end start: if sys.hexversion = 0x0206: # faster when styling big files, but needs python 2.6 source = bytearray(end - start) editor.SendScintilla( editor.SCI_GETTEXTRANGE, start, end, source) else: source = unicode(editor.text() ).encode('utf-8')[start:end] if not source: return # the line index will also be needed to implement folding index = editor.SendScintilla(editor.SCI_LINEFROMPOSITION, start) if index 0: # the previous state may be needed for multi-line styling pos = editor.SendScintilla( editor.SCI_GETLINEENDPOSITION, index - 1) state = editor.SendScintilla(editor.SCI_GETSTYLEAT, pos) else: state = self.Default set_style = self.setStyling self.startStyling(start, 0x1f) # scintilla always asks to style whole lines for line in source.splitlines(True): length = len(line) if line.startswith('#'): state = self.Comment else: # the following will style lines like x = 0 pos = line.find('=') if pos 0: set_style(pos, self.Key) set_style(1, self.Assignment) length = length - pos - 1 state = self.Value else: state = self.Default set_style(length, state) # folding implementation goes here index += 1 if __name__ == __main__: app = QtGui.QApplication(sys.argv) app.connect(app, QtCore.SIGNAL('lastWindowClosed()'), QtCore.SLOT('quit()')) win = MainWindow() win.show() sys.exit(app.exec_()) ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Is there a logical link bewtween C++ methods and Python methods for QScintilla ?
Hello, I've seen some C++ lexers using styler.SetLevel(nbLine,nbLevel) so as to do folding. Is there an equivalent of it ? Best regards. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Problem to make the use of folder with QScintilla (even with traditional lexer)
Hello, normally, self.editor.setFolding(Qsci.QsciScintilla.BoxedTreeFoldStyle) asks to the QScintilla widget to reduce or expand foldings by using the mouse. This doesn't work in the joined code even if foldings are marked by a vertical line. What's the problem with the way I define options of the editor ? Here is a piece of code : = class MainWindow(QtGui.QMainWindow): def __init__(self): QtGui.QMainWindow.__init__(self) self.setWindowTitle('Custom Lexer Example') self.setGeometry(QtCore.QRect(50,200,400,400)) self.editor = Qsci.QsciScintilla(self) self.editor.setUtf8(True) self.editor.setFolding(Qsci.QsciScintilla.BoxedTreeFoldStyle) self.setCentralWidget(self.editor) self.lexer = CustomLexer(self.editor) self.editor.setLexer(self.lexer) self.editor.setText('\n# sample source\n\nfoo = 1\nbar = 2\n') class CustomLexer(Qsci.QsciLexerCustom): .. = Best regards. Christophe. #!/usr/bin/env python #coding=utf-8 import sys from PyQt4 import QtCore, QtGui, Qsci # Code given by Baz WALTER on the PyQt list class MainWindow(QtGui.QMainWindow): def __init__(self): QtGui.QMainWindow.__init__(self) self.setWindowTitle('Custom Lexer Example') self.setGeometry(QtCore.QRect(50,200,400,400)) self.editor = Qsci.QsciScintilla(self) self.editor.setUtf8(True) self.editor.setFolding(Qsci.QsciScintilla.BoxedTreeFoldStyle) self.setCentralWidget(self.editor) self.lexer = CustomLexer(self.editor) self.editor.setLexer(self.lexer) self.editor.setText('\n# sample source\n\nfoo = 1\nbar = 2\n') class CustomLexer(Qsci.QsciLexerCustom): def __init__(self, parent): Qsci.QsciLexerCustom.__init__(self, parent) self._styles = { 0: 'Default', 1: 'Comment', 2: 'Key', 3: 'Assignment', 4: 'Value', } for key,value in self._styles.iteritems(): setattr(self, value, key) def description(self, style): return self._styles.get(style, '') def defaultColor(self, style): if style == self.Default: return QtGui.QColor('#00') elif style == self.Comment: return QtGui.QColor('#C0C0C0') elif style == self.Key: return QtGui.QColor('#CC') elif style == self.Assignment: return QtGui.QColor('#CC') elif style == self.Value: return QtGui.QColor('#00CC00') return Qsci.QsciLexerCustom.defaultColor(self, style) def styleText(self, start, end): editor = self.editor() if editor is None: return # scintilla works with encoded bytes, not decoded characters. # this matters if the source contains non-ascii characters and # a multi-byte encoding is used (e.g. utf-8) source = '' if end editor.length(): end = editor.length() if end start: if sys.hexversion = 0x0206: # faster when styling big files, but needs python 2.6 source = bytearray(end - start) editor.SendScintilla( editor.SCI_GETTEXTRANGE, start, end, source) else: source = unicode(editor.text() ).encode('utf-8')[start:end] if not source: return # the line index will also be needed to implement folding index = editor.SendScintilla(editor.SCI_LINEFROMPOSITION, start) if index 0: # the previous state may be needed for multi-line styling pos = editor.SendScintilla(editor.SCI_GETLINEENDPOSITION, index - 1) state = editor.SendScintilla(editor.SCI_GETSTYLEAT, pos) else: state = self.Default set_style = self.setStyling self.startStyling(start, 0x1f) # scintilla always asks to style whole lines for line in source.splitlines(True): length = len(line) levelFolder = editor.SendScintilla(editor.SCI_GETFOLDLEVEL, index) if line.startswith('+ '): state = self.Comment editor.SendScintilla(editor.SCI_SETFOLDLEVEL, index, levelFolder+10) else: # the following will style lines like x = 0 pos = line.find('=') if pos 0: set_style(pos, self.Key) set_style(1, self.Assignment) length = length - pos - 1 state = self.Value else: state = self.Default set_style(length, state) # folding implementation goes here # PB PB PB PB PB PB PB
Re: [PyQt] Problem with folding and QSciScintilla
Hello Baz Walter gives me somethiong to start with QScintilla but I don't uderstand why the joined code doesn't make possible to reduce or expand the folders. Maybe I've forgotten to send something. Christophe #!/usr/bin/env python #coding=utf-8 import sys from PyQt4 import QtCore, QtGui, Qsci # Code given by Baz WALTER on the PyQt list class MainWindow(QtGui.QMainWindow): def __init__(self): QtGui.QMainWindow.__init__(self) self.setWindowTitle('Custom Lexer Example') self.setGeometry(QtCore.QRect(50,200,400,400)) self.editor = Qsci.QsciScintilla(self) self.editor.setUtf8(True) self.editor.setFolding(Qsci.QsciScintilla.BoxedTreeFoldStyle) self.setCentralWidget(self.editor) self.lexer = CustomLexer(self.editor) self.editor.setLexer(self.lexer) self.editor.setText('\n# sample source\n\nfoo = 1\nbar = 2\n') class CustomLexer(Qsci.QsciLexerCustom): def __init__(self, parent): Qsci.QsciLexerCustom.__init__(self, parent) self._styles = { 0: 'Default', 1: 'Comment', 2: 'Key', 3: 'Assignment', 4: 'Value', } for key,value in self._styles.iteritems(): setattr(self, value, key) def description(self, style): return self._styles.get(style, '') def defaultColor(self, style): if style == self.Default: return QtGui.QColor('#00') elif style == self.Comment: return QtGui.QColor('#C0C0C0') elif style == self.Key: return QtGui.QColor('#CC') elif style == self.Assignment: return QtGui.QColor('#CC') elif style == self.Value: return QtGui.QColor('#00CC00') return Qsci.QsciLexerCustom.defaultColor(self, style) def styleText(self, start, end): editor = self.editor() if editor is None: return # scintilla works with encoded bytes, not decoded characters. # this matters if the source contains non-ascii characters and # a multi-byte encoding is used (e.g. utf-8) source = '' if end editor.length(): end = editor.length() if end start: if sys.hexversion = 0x0206: # faster when styling big files, but needs python 2.6 source = bytearray(end - start) editor.SendScintilla( editor.SCI_GETTEXTRANGE, start, end, source) else: source = unicode(editor.text() ).encode('utf-8')[start:end] if not source: return # the line index will also be needed to implement folding index = editor.SendScintilla(editor.SCI_LINEFROMPOSITION, start) if index 0: # the previous state may be needed for multi-line styling pos = editor.SendScintilla(editor.SCI_GETLINEENDPOSITION, index - 1) state = editor.SendScintilla(editor.SCI_GETSTYLEAT, pos) else: state = self.Default set_style = self.setStyling self.startStyling(start, 0x1f) # scintilla always asks to style whole lines for line in source.splitlines(True): length = len(line) if line.startswith('+ '): state = self.Comment else: # the following will style lines like x = 0 pos = line.find('=') if pos 0: set_style(pos, self.Key) set_style(1, self.Assignment) length = length - pos - 1 state = self.Value else: state = self.Default set_style(length, state) # folding implementation goes here levelFolder = editor.SendScintilla(editor.SCI_GETFOLDLEVEL, index-1) if line.startswith('+ '): editor.SendScintilla(editor.SCI_SETFOLDLEVEL, index, levelFolder + 1) index += 1 if __name__ == __main__: app = QtGui.QApplication(sys.argv) app.connect(app, QtCore.SIGNAL('lastWindowClosed()'), QtCore.SLOT('quit()')) win = MainWindow() win.show() sys.exit(app.exec_()) ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Problem with folding and QSciScintilla
projetmbc a écrit : Maybe I've forgotten to send something. Christophe Maybe I've forgotten to send something **to QScintilla**. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Problem with folding and QSciScintilla
Baz Walter a écrit : hello christophe i expanded my earlier example to include folding. this is a complete config files lexer based on the lexer for properties files in src/LexOthers.cpp. Thanks for this. Santa Claus exists... ;-) I'll look at and study your code to see how to do my simple lexer. Did you allow me to use your code in a future free tutorial on the use of QScintilla ? I'll cite your name. Thanks. Christophe PS : indeed there is a big difference between QSyntaxHighlighter and QScintilla. QSyntaxHighlighter works on the whole text whereas QScintilla works on a line somewhere in the text. That's why I met problems when trying to work with multline feature. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Re: [Matplotlib-users] Strange issue when using Matplotlib with PyQt4
Lukas Hetzenecker a écrit : I tried to embed a Matplotlib FigureCanvas into a QTabWidget. But at the first start of my script - the main.py in the attatched example - the widget in the Tab is incorrectly sized. If I embed the FigureCanvas in a QTabWidget the widget is to big, but if I put it in a QWidget it is shown correctly. I'm not sure that is a pure MatPlotLib issue. Have you try with a big standard widget instead of the FigureCanvas ? Christophe ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Setting font for QScintilla
Baz Walter a écrit : projetmbc wrote: I still have a little problem because I only want to have the comments in bold font in my example. Indeed all is in bold font. I don't understand why. the problem is this line: if style == self.Comment or self.Comment_End: i think you meant: if style == self.Comment or style == self.Comment_End: regards baz walter I feel a little bit ashamed :-[ . The next time I'll be more carefull. Christophe. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Problem with folding and QSciScintilla
Baz Walter a écrit : projetmbc wrote: Baz Walter a écrit : hello christophe i expanded my earlier example to include folding. this is a complete config files lexer based on the lexer for properties files in src/LexOthers.cpp. Thanks for this. Santa Claus exists... ;-) I'll look at and study your code to see how to do my simple lexer. Did you allow me to use your code in a future free tutorial on the use of QScintilla ? I'll cite your name. your welcome. feel free to use it as you wish regards baz walter Finally I've done a very simple lexer that find multi-lines /*...*/ wich can be folded and single line //... comment of C++ kind. I hope that will help people and that there is no bug. Thanks for all the informations. The next step would be to highlight some specific words but the harder has been done. Christophe. import sys from PyQt4.QtCore import SIGNAL, SLOT, QString from PyQt4.QtGui import QApplication, QMainWindow, QColor, QFont from PyQt4.Qsci import QsciScintilla, QsciLexerCustom # The most important and hard part of this code was given by Baz WALTER on the PyQt list. if sys.hexversion 0x020600F0: print('python 2.6 or greater is required by this program') sys.exit(1) _sample = /* This example uses this multi-line coment which can be extanded or retracted. The end must be the following line. */ A text outside a MultiLinesComment is not retactable. /* Another test. */ class MainWindow(QMainWindow): def __init__(self): QMainWindow.__init__(self) self.setWindowTitle('Custom Lexer For Config Files') self.setGeometry(50, 200, 400, 400) self.editor = QsciScintilla(self) self.editor.setUtf8(True) # + OR - TO FOLD OR UNFOLD self.editor.setFolding(QsciScintilla.BoxedTreeFoldStyle) # LINES' NUMBER IN THE MARGIN self.editor.setMarginLineNumbers(1,True) self.editor.setMarginWidth(1, QString(---)) # OK for 3 digits. This was found by direct tests... self.setCentralWidget(self.editor) self.lexer = ConfigLexer(self.editor) self.editor.setLexer(self.lexer) self.editor.setText(_sample) class ConfigLexer(QsciLexerCustom): def __init__(self, parent): QsciLexerCustom.__init__(self, parent) self._styles = { 0: 'Default', 1: 'MultiLinesComment_Start', 2: 'MultiLinesComment', 3: 'MultiLinesComment_End', 4: 'SingleLineComment' } for key,value in self._styles.iteritems(): setattr(self, value, key) self._foldcompact = True self.__comment = [self.MultiLinesComment, self.MultiLinesComment_End, self.MultiLinesComment_Start, self.SingleLineComment] def foldCompact(self): return self._foldcompact def setFoldCompact(self, enable): self._foldcompact = bool(enable) def language(self): return 'Config Files' def description(self, style): return self._styles.get(style, '') def defaultColor(self, style): if style == self.Default: return QColor('#00') elif style in self.__comment: return QColor('#A0A0A0') return QsciLexerCustom.defaultColor(self, style) def defaultFont(self, style): if style in self.__comment: if sys.platform in ('win32', 'cygwin'): return QFont('Comic Sans MS', 9, QFont.Bold) return QFont('Bitstream Vera Serif', 9, QFont.Bold) return QsciLexerCustom.defaultFont(self, style) def defaultPaper(self, style): # Here we change the color of the background. # We want to colorize all the background of the line. # This is done by using the following method defaultEolFill() . if style in self.__comment: return QColor('#FFEECC') return QsciLexerCustom.defaultPaper(self, style) def defaultEolFill(self, style): # This allowed to colorize all the background of a line. if style in self.__comment: return True return QsciLexerCustom.defaultEolFill(self, style) def styleText(self, start, end): editor = self.editor() if editor is None: return SCI = editor.SendScintilla GETFOLDLEVEL = QsciScintilla.SCI_GETFOLDLEVEL SETFOLDLEVEL = QsciScintilla.SCI_SETFOLDLEVEL HEADERFLAG = QsciScintilla.SC_FOLDLEVELHEADERFLAG LEVELBASE = QsciScintilla.SC_FOLDLEVELBASE NUMBERMASK = QsciScintilla.SC_FOLDLEVELNUMBERMASK WHITEFLAG = QsciScintilla.SC_FOLDLEVELWHITEFLAG set_style = self.setStyling source = '' if end editor.length(): end = editor.length() if end start: source = bytearray(end - start) SCI(QsciScintilla.SCI_GETTEXTRANGE, start, end, source) if not source: return
[PyQt] Request-QSciScintilla
Hello, in some language like HTML there are PhP codes and/or JavaScript code embeded. It could be usefull to have a way to tell to Scintilla to use some specific Lexer for specific lines. With this kind of feature, it could be easy to make custom lexers that call general ones for some part of the text. I hope that my request is clear enough. Best regards. Christophe. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Problem with folding and QSciScintilla
Baz Walter a écrit : projetmbc wrote: Baz Walter a écrit : hello christophe i expanded my earlier example to include folding. this is a complete config files lexer based on the lexer for properties files in src/LexOthers.cpp. Thanks for this. Santa Claus exists... ;-) I'll look at and study your code to see how to do my simple lexer. Did you allow me to use your code in a future free tutorial on the use of QScintilla ? I'll cite your name. your welcome. feel free to use it as you wish regards baz walter Here is another simple lexer to higlight some sepcifc words and lines. It's time to sleep. Christophe. import sys from PyQt4.QtCore import SIGNAL, SLOT, QString from PyQt4.QtGui import QApplication, QMainWindow, QColor, QFont from PyQt4.Qsci import QsciScintilla, QsciLexerCustom # The most important and hard part of this code was given by Baz WALTER on the PyQt list. if sys.hexversion 0x020600F0: print('python 2.6 or greater is required by this program') sys.exit(1) _sample = This example shows how to highlight some specific lines or words. + A first level title bold and red + A secund level title bold and blue with a yellow background Some text with green in green but also bold and underlined. The digits are gray with an orange backround. You don't believe it, look at that : 1 , 2 , ... , 123456789... It's very uggly but it shows how to do more pretty highlighters. class MainWindow(QMainWindow): def __init__(self): QMainWindow.__init__(self) self.setWindowTitle('Custom Lexer For Config Files') self.setGeometry(50, 200, 400, 400) self.editor = QsciScintilla(self) self.editor.setUtf8(True) # LINES' NUMBER IN THE MARGIN self.editor.setMarginLineNumbers(1,True) self.editor.setMarginWidth(1, QString(---)) # OK for 3 digits. This was found by direct tests... # WRAPING self.editor.setWrapMode(True) self.setCentralWidget(self.editor) self.lexer = ConfigLexer(self.editor) self.editor.setLexer(self.lexer) self.editor.setText(_sample) class ConfigLexer(QsciLexerCustom): def __init__(self, parent): QsciLexerCustom.__init__(self, parent) self._styles = { 0: 'Default', 1: 'FirstLevelTitle', 2: 'SecundLevelTitle', 3: 'Green', 4: 'Digits' } for key,value in self._styles.iteritems(): setattr(self, value, key) def language(self): return 'Config Files' def description(self, style): return self._styles.get(style, '') def defaultColor(self, style): if style == self.Default: return QColor('#00') elif style == self.FirstLevelTitle: return QColor('#FF') elif style == self.SecundLevelTitle: return QColor('#FF') elif style == self.Green: return QColor('#00FF00') elif style == self.Digits: return QColor('#AA') return QsciLexerCustom.defaultColor(self, style) def defaultFont(self, style): font = QsciLexerCustom.defaultFont(self, style) if style == self.FirstLevelTitle or style == self.SecundLevelTitle: font.setBold(True) elif style == self.Green: font.setBold(True) font.setUnderline(True) return font def defaultPaper(self, style): # Here we change the color of the background. # We want to colorize all the background of the line. # This is done by using the following method defaultEolFill() . if style == self.SecundLevelTitle: return QColor('#99') elif style == self.Digits: return QColor('#FFCC66') return QsciLexerCustom.defaultPaper(self, style) def defaultEolFill(self, style): # This allowed to colorize all the background of a line. if style == self.SecundLevelTitle: return True return QsciLexerCustom.defaultEolFill(self, style) def styleText(self, start, end): editor = self.editor() if editor is None: return SCI = editor.SendScintilla set_style = self.setStyling source = '' if end editor.length(): end = editor.length() if end start: source = bytearray(end - start) SCI(QsciScintilla.SCI_GETTEXTRANGE, start, end, source) if not source: return self.startStyling(start, 0x1f) index = SCI(QsciScintilla.SCI_LINEFROMPOSITION, start) for line in source.splitlines(True): # Try to uncomment the following line to see in the console # how Scintiallla works. You have to think in terms of isolated # lines rather than globally on the whole text. #print line length = len(line) if line.startswith('+'): newState
[PyQt] How to install pyQt on a Mac ?
Hello, I've bought a Mac and this is my first one. So I do not how to install pyQt on a Mac. Is there an easy way to do that ? Best regards. Christophe. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Building OSX universal Sip and PyQt packages
Cezary Krzyżanowski a écrit : It would be even nicer if binary distributions of PyQt and Sip would be available on the website, so compound with the UB build of Qt for Mac a developer would have instantly a toolchain for building and shipping UB apps. Yes it would be very great because compiling is not easy for all users. On Ubuntu, the use of Synaptic is easy even for noobies. By giving a binary distribution, this will make the use of pyQt application easy on Windows, Ubuntu and Mac. Christophe. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Tutorial about the use of JavaScript
Hello, I'm looking for a tutorial about the use of JavaScript inside a pyQt application. Every kind of clue is welcome. Christophe. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Problem with a very simple JavaScript
Hello, I have joined a file simpleHtmlPageColorViaJS.html which use a very simple script and jQuery : http://jqueryjs.googlecode.com/files/jquery-1.3.2.js . I would like to do something similar via pyQt by adding some JS code to simpleHtmlPage.html. I have used the following code jqueryFromPyqt.py without success. I don't see why. Any clue is welcome. Christophe # -*- coding: utf-8 -*- #!/usr/bin/env python # Sources # http://www.mail-archive.com/pyqt@riverbankcomputing.com/msg17247.html # jQuery J. Chhaffer K. Swedberg Ed. : PEARSON import sys from PyQt4.QtCore import * from PyQt4.QtGui import * from PyQt4.QtWebKit import * app = QApplication(sys.argv) myWebKit = QWebView() myWebKit.show() myWebKit.setUrl(QUrl(simpleHtmlPage.html)) myWebKit.page().mainFrame().evaluateJavaScript(open('jquery-1.3.2.js').read()) # There is ROUGE in the HTML source. myWebKit.page().mainFrame().evaluateJavaScript($(document).ready(function(){$(.red).css(color, #ff);});) sys.exit(app.exec_()) We want to have a RED WORD colored by jQuery. A whole paragraph colored in red by jQuery. # -*- coding: utf-8 -*- #!/usr/bin/env python # Sources #http://www.mail-archive.com/pyqt@riverbankcomputing.com/msg17247.html #jQuery J. Chhaffer K. Swedberg Ed. : PEARSON import sys from PyQt4.QtCore import * from PyQt4.QtGui import * from PyQt4.QtWebKit import * app = QApplication(sys.argv) myWebKit = QWebView() myWebKit.show() myWebKit.setUrl(QUrl(simpleHtmlPage.html)) myWebKit.page().mainFrame().evaluateJavaScript(open('jquery-1.3.2.js').read()) # There is span class=rougeBROUGE/B in the HTML source. myWebKit.page().mainFrame().evaluateJavaScript($(document).ready(function(){$(.red).css(color, #ff);});) sys.exit(app.exec_()) We want to have a RED WORD colored by pyQt using jQuery. A whole paragraph colored in red by pyQt using jQuery. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Laucnh a JavaScript after and not before the loading of a page in QWebView
Hello, in the following code the JavaScript is launched before the loading of the HTML page. Is there a way to call a JavaScript only when the whole page is loaded in the QWebView ? Best regards. Christophe. == # -*- coding: utf-8 -*- #!/usr/bin/env python # Source # http://www.slideshare.net/tewson/using-qtwebkit-in-pyqt-as-a-n00b import sys from PyQt4.QtCore import * from PyQt4.QtGui import * from PyQt4.QtWebKit import * app = QApplication(sys.argv) myWebKit = QWebView() myWebKit.show() myWebKit.setUrl(QUrl(http://www.google.fr/;)) myWebKit.page().mainFrame().evaluateJavaScript(alert('Hello, World !');) sys.exit(app.exec_()) # -*- coding: utf-8 -*- #!/usr/bin/env python # Source #http://www.slideshare.net/tewson/using-qtwebkit-in-pyqt-as-a-n00b import sys from PyQt4.QtCore import * from PyQt4.QtGui import * from PyQt4.QtWebKit import * app = QApplication(sys.argv) myWebKit = QWebView() myWebKit.show() myWebKit.setUrl(QUrl(http://www.google.fr/;)) myWebKit.page().mainFrame().evaluateJavaScript(alert('Hello, World !');) sys.exit(app.exec_())___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] JavaScript in WebView-Looking for C++ examples
Hello, I'm looking of examples showing how to use JavaScript programs (like for example jQuery) in a WebView. Every kinds of clues are welcome. Best regards. Christopĥe ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] 64 bits and Snow Leopard make me crazy
Hello, I've downloaded qt-sdk-mac-opensource-2010.02.dmg . I've installed it. Then I've downloaded PyQt-mac-gpl-4.7 and sip-4.10. I've compiled sip using the following commands : python3.1 configure.py make sudo make install No problem. Then I decide, because I'm a crazy man :-) to compile pyqt using the following commands : python3.1 configure.py make sudo make install The make gives me the following boring error : /Library/Frameworks/QtCore.framework/Headers/qglobal.h:288:2: error: #error You are building a 64-bit application, but using a 32-bit version of Qt. Check your build configuration. sipQtCorecmodule.cpp: In function ‘PyObject* PyInit_QtCore()’: sipQtCorecmodule.cpp:9854: warning: missing initializer for member ‘PyModuleDef_Base::m_init’ sipQtCorecmodule.cpp:9854: warning: missing initializer for member ‘PyModuleDef_Base::m_index’ sipQtCorecmodule.cpp:9854: warning: missing initializer for member ‘PyModuleDef_Base::m_copy’ make[1]: *** [sipQtCorecmodule.o] Error 1 make: *** [all] Error 2 What can I do ? Must I use another framework like wxPython ? Best regards. Christophe. === The whole message given by make g++ -c -pipe -fno-strict-aliasing -O2 -arch i386 -fPIC -Wall -W -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Qt4.6/mkspecs/macx-g++ -I. -I/Library/Frameworks/QtCore.framework/Versions/4/Headers -I/usr/include/QtCore -I/Library/Frameworks/QtGui.framework/Versions/4/Headers -I/usr/include/QtGui -I/usr/include -I/Library/Frameworks/Python.framework/Versions/3.1/include/python3.1 -I../../QtCore -I. -I. -F/Library/Frameworks -o qpycore_chimera.o qpycore_chimera.cpp g++ -c -pipe -fno-strict-aliasing -O2 -arch i386 -fPIC -Wall -W -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Qt4.6/mkspecs/macx-g++ -I. -I/Library/Frameworks/QtCore.framework/Versions/4/Headers -I/usr/include/QtCore -I/Library/Frameworks/QtGui.framework/Versions/4/Headers -I/usr/include/QtGui -I/usr/include -I/Library/Frameworks/Python.framework/Versions/3.1/include/python3.1 -I../../QtCore -I. -I. -F/Library/Frameworks -o qpycore_chimera_signature.o qpycore_chimera_signature.cpp g++ -c -pipe -fno-strict-aliasing -O2 -arch i386 -fPIC -Wall -W -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Qt4.6/mkspecs/macx-g++ -I. -I/Library/Frameworks/QtCore.framework/Versions/4/Headers -I/usr/include/QtCore -I/Library/Frameworks/QtGui.framework/Versions/4/Headers -I/usr/include/QtGui -I/usr/include -I/Library/Frameworks/Python.framework/Versions/3.1/include/python3.1 -I../../QtCore -I. -I. -F/Library/Frameworks -o qpycore_chimera_storage.o qpycore_chimera_storage.cpp g++ -c -pipe -fno-strict-aliasing -O2 -arch i386 -fPIC -Wall -W -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Qt4.6/mkspecs/macx-g++ -I. -I/Library/Frameworks/QtCore.framework/Versions/4/Headers -I/usr/include/QtCore -I/Library/Frameworks/QtGui.framework/Versions/4/Headers -I/usr/include/QtGui -I/usr/include -I/Library/Frameworks/Python.framework/Versions/3.1/include/python3.1 -I../../QtCore -I. -I. -F/Library/Frameworks -o qpycore_init.o qpycore_init.cpp g++ -c -pipe -fno-strict-aliasing -O2 -arch i386 -fPIC -Wall -W -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Qt4.6/mkspecs/macx-g++ -I. -I/Library/Frameworks/QtCore.framework/Versions/4/Headers -I/usr/include/QtCore -I/Library/Frameworks/QtGui.framework/Versions/4/Headers -I/usr/include/QtGui -I/usr/include -I/Library/Frameworks/Python.framework/Versions/3.1/include/python3.1 -I../../QtCore -I. -I. -F/Library/Frameworks -o qpycore_misc.o qpycore_misc.cpp g++ -c -pipe -fno-strict-aliasing -O2 -arch i386 -fPIC -Wall -W -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Qt4.6/mkspecs/macx-g++ -I. -I/Library/Frameworks/QtCore.framework/Versions/4/Headers -I/usr/include/QtCore -I/Library/Frameworks/QtGui.framework/Versions/4/Headers -I/usr/include/QtGui -I/usr/include -I/Library/Frameworks/Python.framework/Versions/3.1/include/python3.1 -I../../QtCore -I. -I. -F/Library/Frameworks -o qpycore_post_init.o qpycore_post_init.cpp g++ -c -pipe -fno-strict-aliasing -O2 -arch i386 -fPIC -Wall -W -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Qt4.6/mkspecs/macx-g++ -I. -I/Library/Frameworks/QtCore.framework/Versions/4/Headers -I/usr/include/QtCore -I/Library/Frameworks/QtGui.framework/Versions/4/Headers -I/usr/include/QtGui -I/usr/include -I/Library/Frameworks/Python.framework/Versions/3.1/include/python3.1 -I../../QtCore -I. -I. -F/Library/Frameworks -o qpycore_pyqtboundsignal.o qpycore_pyqtboundsignal.cpp g++ -c -pipe -fno-strict-aliasing -O2 -arch i386 -fPIC