[PyQt] determining pyqt version
I am doing that with: import PyQt4.pyqtconfig PYQTVERSION = PyQt4.pyqtconfig.Configuration().pyqt_version_str but now that I tried to deploy it I see that this imports sipconfig which is part of the ubuntu package python-sip4-dev I do not want to depend on -dev packages on target machines, is there any other way to find out the current version? -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] determining pyqt version
On Sat, 18 Jul 2009 11:59:23 +0200, Wolfgang Rohdewald wolfg...@rohdewald.de wrote: I am doing that with: import PyQt4.pyqtconfig PYQTVERSION = PyQt4.pyqtconfig.Configuration().pyqt_version_str but now that I tried to deploy it I see that this imports sipconfig which is part of the ubuntu package python-sip4-dev I do not want to depend on -dev packages on target machines, is there any other way to find out the current version? PyQt4.QtCore.PYQT_VERSION_STR PyQt4.QtCore.PYQT_VERSION Phil ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] determining pyqt version
On Saturday 18 July 2009, Phil Thompson wrote: On Sat, 18 Jul 2009 11:59:23 +0200, Wolfgang Rohdewald wolfg...@rohdewald.de wrote: is there any other way to find out the current version? PyQt4.QtCore.PYQT_VERSION_STR PyQt4.QtCore.PYQT_VERSION thank you! -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] QTabWidget subclassing woes
Hi, I tried to subclass QTabWidget in order to do some processing before a tab is displayed or left. The problem is, that my setCurrentIndex methods are not called, if switching tabs via keyboard (cursor left/right on linux). Interestingly, my keyPressEvent handlers are called. Out of desperation, I also intercepted QTabBar, but beside key presses, the expected calls to setCurrentIndex are missing. I've added some shortcuts (Alt+Left/Right) to switch tabs programmatically, but I would like to catch all set* calls. Do I do something stupid, or do I need to handle the key presses myself (which would make the whole thing less robust and less portable)? TIA, Pete tabwidget.py Description: application/python ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] opening Dock widget as a tab
I am creating a dock widget dynamically at runtime. problem i am facing is 1 i have to open a dock widget containing two tree widgets as a tab dynamically at runtime 2also the tabs of dock widget should be placed above the dock widget and not below the widget . please help me out as i have no one here to answer my question and on my own to complete the project. Thanking you in advance. here is my code.. def createdockProject(self): self.dockUser = QtGui.QDockWidget(self.obj) self.dockUser.setFeatures(QtGui.QDockWidget.DockWidgetClosable|QtGui.QDockWidget.DockWidgetMovable) #self.dockUser.setObjectName(dockUser_%s%(self.title)) self.dockWidgetContents = QtGui.QWidget(self.dockUser) self.dockWidgetContents.setObjectName(dockWidgetContents) self.gridLayout = QtGui.QGridLayout(self.dockWidgetContents) #self.gridLayout.setObjectName(gridLayout) self.tree = QtGui.QTreeWidget(self.dockWidgetContents) self.tree.setAlternatingRowColors(True) self.tree.setHeaderLabel() self.tree.setHeaderHidden(True) self.tree.setObjectName(tree1) self.gridLayout.addWidget(self.tree,0,1,1,2) self.tree1 = QtGui.QTreeWidget(self.dockWidgetContents) self.tree1.setAlternatingRowColors(True) self.tree1.setHeaderLabel() self.tree1.setHeaderHidden(True) self.gridLayout.addWidget(self.tree1,0,0,1,1) self.dockUser.setWidget(self.dockWidgetContents) self.obj.addDockWidget(QtCore.Qt.BottomDockWidgetArea,self.dockUser,QtCore.Qt.Horizontal) self.firstDockWidget.setWidget(self.dockUser) -- View this message in context: http://www.nabble.com/opening-Dock-widget-as-a-tab-tp24546676p24546676.html Sent from the PyQt mailing list archive at Nabble.com. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] QTabWidget subclassing woes
On 18.07.09 12:18:37, Hans-Peter Jansen wrote: Hi, I tried to subclass QTabWidget in order to do some processing before a tab is displayed or left. The problem is, that my setCurrentIndex methods are not called, if switching tabs via keyboard (cursor left/right on linux). Thats because the C++ setCurrentIndex method is not virtual and hence cannot be overriden so easily. Your only options are handling all events yourself (also check wether QTabWidget has any event filters set) or do your processing based on the currentChanged() signal instead (i.e. post-processing). Andreas -- Your analyst has you mixed up with another patient. Don't believe a thing he tells you. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] [i18n] Can't understand contexts
Hi, I develop my application using PyQt4. First I've decided to put all messages those are subject to be translated into a separate file, let's call it msg.py like: ADD_ACTION = QCoreApplication.translate('here goes context', 'Add', '', 1) # ... and etc. and init QApplication and setup translators in main source file before import-ing msg.py. Is it possible to put something as context argument so translations will actually work for all classes or is there any way to disable context chack? P.S. Even when I put class name for class that exists in main source file and is already declared into context arg, e. g. QtInterface or AddAction anything doesn't get translated. Thanks! -- Написано в почтовом клиенте браузера Opera: http://www.opera.com/mail/ ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] [i18n] Can't understand contexts
On 18.07.09 18:28:39, Anonymous wrote: Hi, I develop my application using PyQt4. First I've decided to put all messages those are subject to be translated into a separate file, let's call it msg.py like: ADD_ACTION = QCoreApplication.translate('here goes context', 'Add', '', 1) # ... and etc. and init QApplication and setup translators in main source file before import-ing msg.py. Is it possible to put something as context argument so translations will actually work for all classes or is there any way to disable context chack? Context is just a string that allows you to differentiate between the same string being used in different places of your application. Sometimes these differing places need different translations in some languages, hence the translator needs a context. For proper translation appearing in the GUI there shouldn't be anything you need to do. lupdate should extract the messages including the custom context into the .ts file and there it'll appear for the translator to use. P.S. Even when I put class name for class that exists in main source file and is already declared into context arg, e. g. QtInterface or AddAction anything doesn't get translated. Hmm, strange, works fine here with the attached three files (C++ though). Can you post a minimal example? (To run the example put all three files into a directory, then do qmake; make; lrelease testtrans.pro) Andreas -- You will live a long, healthy, happy life and make bags of money. ?xml version=1.0 encoding=utf-8? !DOCTYPE TS TS version=2.0 context nameMyContext/name message location filename=main.cpp line=10/ sourceSampleText/source translation Sample Text XX/translation /message /context /TS #include QtGui int main(int argc, char** argv) { QApplication app(argc, argv); QTranslator tr; tr.load(foo.qm); QApplication::installTranslator(tr); QPushButton* button = new QPushButton(); button-setText(QApplication::translate(MyContext, SampleText, , QCoreApplication::UnicodeUTF8)); button-show(); return app.exec(); } ## # Automatically generated by qmake (2.01a) Sat Jul 18 16:06:31 2009 ## TEMPLATE = app TARGET = DEPENDPATH += . INCLUDEPATH += . # Input SOURCES += main.cpp TRANSLATIONS += foo.ts ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Problem with folding and QSciScintilla
projetmbc wrote: 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. 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. ==8== import sys from PyQt4.QtCore import SIGNAL, SLOT from PyQt4.QtGui import QApplication, QMainWindow, QColor, QFont from PyQt4.Qsci import QsciScintilla, QsciLexerCustom if sys.hexversion 0x020600F0: print('python 2.6 or greater is required by this program') sys.exit(1) _sample = # Sample config file this is a junk line [FirstItem] Width=100 Height=200 Colour=orange Info=this is some multiline text [SecondItem] Width=200 Height=300 Colour=green Info= this is some multiline text 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) self.editor.setMarginWidth(2, 15) self.editor.setFolding(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: 'Comment', 2: 'Section', 3: 'Key', 4: 'Assignment', 5: 'Value', } for key,value in self._styles.iteritems(): setattr(self, value, key) self._foldcompact = True 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 == self.Comment: return QColor('#A0A0A0') elif style == self.Section: return QColor('#CC6600') elif style == self.Key: return QColor('#CC') elif style == self.Assignment: return QColor('#CC') elif style == self.Value: return QColor('#00CC00') return QsciLexerCustom.defaultColor(self, style) def defaultPaper(self, style): if style == self.Section: return QColor('#FFEECC') return QsciLexerCustom.defaultPaper(self, style) def defaultEolFill(self, style): if style == self.Section: return True return QsciLexerCustom.defaultEolFill(self, style) def defaultFont(self, style): if style == self.Comment: if sys.platform in ('win32', 'cygwin'): return QFont('Comic Sans MS', 9) return QFont('Bitstream Vera Serif', 9) return QsciLexerCustom.defaultFont(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 compact = self.foldCompact() index = SCI(QsciScintilla.SCI_LINEFROMPOSITION, start) if index 0: pos = SCI(QsciScintilla.SCI_GETLINEENDPOSITION, index - 1) state = SCI(QsciScintilla.SCI_GETSTYLEAT, pos) else: state = self.Default self.startStyling(start, 0x1f) for line in source.splitlines(True): length = len(line) if length == 1: whitespace = compact state = self.Default else: whitespace = False firstchar = chr(line[0]) if firstchar in '#;': state = self.Comment elif firstchar == '[': state = self.Section elif firstchar in ' \t': if state == self.Value or state == self.Assignment: state = self.Value
Re: [PyQt] Small paid development task
Hi Jason I'm looking at this as we speak (checking out Qt from git), although I can't promise anything. Arve On Tue, Jul 14, 2009 at 10:58 PM, Jason H scorp...@yahoo.com wrote: I mentioned last week that I was looking to get some of the Kinetic project's bindings into PyQt. Unfortunately, it is going slow, and my time has had me working things where I am more productive. I am now offering anyone up to $200US via paypal to get these patched into the latest PyQt 4.5.2 snapshot. I am hoping this code will be done in a way (quality, style, license) that it can be used by Phil in the PyQt 4.6 release. I just need to test these features sooner than later, and the next Qt release is 6-9 months off. In order to get these classes, you'll have to get Qt/master or Qt/master-stable out of the git repo. Part of deleivery, aside from sip files is to then provide instructions on how to drop it into a PyQt 4.5.2 installation. Classes I need immediately for my test: ($100) * QAbstractAnimation * QAnimationGroup * QEasingCurve * QParallelAnimationGroup * QPropertyAnimation * QSequentialAnimationGroup * QVariantAnimation Not so immediate, but would like to have them eventually: ($100) * QGraphicsWidget * QAbstractState * QAbstractTransition * QActionState * QEventTransition * QFinalState * QHistoryState * QKeyEventTransition * QMouseEventTransition * QSignalEvent * QSignalTransition * QState * QStateAction * QStateFinishedEvent * QStateFinishedTransition * QStateInvokeMethodAction * QtStateMachine * QTransition I figure it's a cool opportunity to get paid for something that has to be done anyway. Thanks ___ 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] 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
Re: [PyQt] Problem with folding and QSciScintilla
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 ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Function-pointer typedef
Hi Phil In my attempt to wrap the new Qt animation classes, as requested by Jason H, I find that I'm not able declare a function-pointer typedef within a class. According to the SIP syntax specification it seems perfectly possible, however. Can you please tell me why the following declaration from QEasingCurve doesn't work: class EasingCurve { [...] public: typedef qreal (*EasingFunction)(qreal progress); [...] }; Thanks, Arve ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Function-pointer typedef
On Sat, 18 Jul 2009 22:42:31 +0200, Arve Knudsen arve.knud...@gmail.com wrote: Hi Phil In my attempt to wrap the new Qt animation classes, as requested by Jason H, I find that I'm not able declare a function-pointer typedef within a class. According to the SIP syntax specification it seems perfectly possible, however. Can you please tell me why the following declaration from QEasingCurve doesn't work: class EasingCurve { [...] public: typedef qreal (*EasingFunction)(qreal progress); [...] }; It's a bug - just remove the name of the argument. Phil ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Function-pointer typedef
On Sat, Jul 18, 2009 at 10:59 PM, Phil Thompson p...@riverbankcomputing.com wrote: On Sat, 18 Jul 2009 22:42:31 +0200, Arve Knudsen arve.knud...@gmail.com wrote: Hi Phil In my attempt to wrap the new Qt animation classes, as requested by Jason H, I find that I'm not able declare a function-pointer typedef within a class. According to the SIP syntax specification it seems perfectly possible, however. Can you please tell me why the following declaration from QEasingCurve doesn't work: class EasingCurve { [...] public: typedef qreal (*EasingFunction)(qreal progress); [...] }; It's a bug - just remove the name of the argument. Thanks, you're right. Looks like I'll have to wrap the function-pointer by hand though, am I right (sip says I have to provide %Metod code)? I'm guessing you should fix sip's error message to say %MethodCode instead of %Method code. Arve ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Function-pointer typedef
On Sat, 18 Jul 2009 23:06:47 +0200, Arve Knudsen arve.knud...@gmail.com wrote: On Sat, Jul 18, 2009 at 10:59 PM, Phil Thompson p...@riverbankcomputing.com wrote: On Sat, 18 Jul 2009 22:42:31 +0200, Arve Knudsen arve.knud...@gmail.com wrote: Hi Phil In my attempt to wrap the new Qt animation classes, as requested by Jason H, I find that I'm not able declare a function-pointer typedef within a class. According to the SIP syntax specification it seems perfectly possible, however. Can you please tell me why the following declaration from QEasingCurve doesn't work: class EasingCurve { [...] public: typedef qreal (*EasingFunction)(qreal progress); [...] }; It's a bug - just remove the name of the argument. Thanks, you're right. Looks like I'll have to wrap the function-pointer by hand though, am I right Yes, and depending on the context, it may prove to be difficult. (sip says I have to provide %Metod code)? I'm guessing you should fix sip's error message to say %MethodCode instead of %Method code. Yes - thanks. Phil ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Strange issue when using Matplotlib with PyQt4
Hello, 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. Sorry, but this is my first try of Matplotlib and I don't know what I could have done wrong - maybe this is just because it's nearly 3 o'clock in the night and I'm to tired to find this mistake. ;-) Thanks for help, Lukas PyQt4_MPL.tar.bz2 Description: application/bzip-compressed-tar ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt