Re: [PyQt] QT save state example

2013-10-07 Thread David Cortesi
> I'm trying to understand how does save state works using QT... > ... I only found C++ examples which I cant read, Being able to mentally translate the C++ code in the Qt doc into Python is a very useful skill! It really isn't too hard. Turn :: into dot and add "self." everywhere. The first thin

[PyQt] PyQt4 - QChar - unicode char?

2013-10-05 Thread David Cortesi
# python 2.7 from future import unicode_literals uu = u'\u2019' # no problem here but... qcCurlyApostrophe = QChar(uu) Traceback (most recent call last): File "", line 1, in UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in position 0: ordinal not in range(128) qcCurlyApost

[PyQt] Trying to upgrade Qt4 in Linux

2013-09-30 Thread David Cortesi
In a Linux system my PyQt4 app fails because it relies on a feature that dates to Qt 4.7. This Linux system has 4.6 installed. Also the PyQt4 was at 4.6.x. So I did the following: Downloaded the Linux source of SIP, configure, make, make-install Downloaded the Linux source of PyQt4, configure, m

Re: [PyQt] is there some good PyQt source code for learning?

2013-09-08 Thread David Cortesi
The original request was, > I can write some small and urgly GUI using PyQt, > but I want to write some bigger and beautiful > So, is there some good PyQt source code for learning? I think Genban Tade was looking for design help, not code help. Making the UI after you design it on paper, is a me

Re: [PyQt] Scroll QTableView beyond last column/row

2013-08-28 Thread David Cortesi
How about defining some "extra" rows and columns? Then, in your data() method, if the column (or row) index is beyond the "real" data, you return a string of blanks for the display role, and a 50% gray brush for the Background role. ___ PyQt mailing lis

Re: [PyQt] Easy Segfault using (or misusing) QTextStream

2013-08-15 Thread David Cortesi
I had the problem that this sequence crashed Python: from PyQt4.QtCore import (Qt, QString, QTextStream) > ts = QTextStream(QString()) > ts << u'x' > > Segmentation fault > Phil properly reminded me that, > You need to keep a reference to the QString. > And I thought, oh crap,

[PyQt] Easy Segfault using (or misusing) QTextStream

2013-08-11 Thread David Cortesi
I was experimenting to see if I could make an in-memory QTextStream and discovered instead an easy way to make Python 2.7.3 segfault: [08:23] python Python 2.7.3 (v2.7.3:70274d53c1dd, Apr 9 2012, 20:52:43) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" o

Re: [PyQt] qtablewidget multi cell editing

2013-05-29 Thread David Cortesi
> From: Christopher Evans > > anyone know a way to select multiple cells and edit them, a la excel and > other packages? Do i need to write custom code, or is this supported? > You need to set the Selection Mode. In the Qt Assistant page for QTableWidget, click "List of all members, including in

Re: [PyQt] General questions on parsing large QStrings

2013-05-13 Thread David Cortesi
> > Which is why you wouldn't do it, even in C++. You would use QTextDocument, > QSyntaxHighlighter etc. > Sorry, that was a stupid example, as a I realized not long after hitting "send." My fault. ___ PyQt mailing listPyQt@riverbankcomputing.com htt

Re: [PyQt] General questions on parsing large QStrings

2013-05-12 Thread David Cortesi
Thanks to you and Mathias for the prompt replies. > docstring = unicode( myEditor.toPlainText() ) > In PyQt5 toPlainText() will return a str object for Python3 and a unicode > object for Python2. > And, as Mathias says, it is a copy?... That is not IMO a good design choice. At least if toPla

[PyQt] General questions on parsing large QStrings

2013-05-12 Thread David Cortesi
For an app to be built with PyQt5/Qt5, I will have a QPlainTextEdit in which the document may be quite sizable, 500K characters or more. I will want at times to inspect the document character by character, or possibly apply Python relib REs to it. I am somewhat at sea regarding the relationship b

Re: [PyQt] PyQt Digest, Vol 105, Issue 26

2013-04-17 Thread David Cortesi
> > From: Phil Thompson > > * How to handle co-installing qt4 & qt5 variants of pyqt? > > Given that currently pyqt4 uses PyQt4 name-space regardless if it's > > compiled against qt4 or qt5. > > A good question that doesn't have a good answer. > > The Qt4 and Qt5 variants of PyQt4 are incompatible

[PyQt] Does this crash look like a known bug?

2013-02-13 Thread David Cortesi
The following is the top bit of an apple crash report. Latest mac binary PyQt4, plus Qt 4.8.4. Only happens in the version bundled by pyinstaller - never running from source in the IDE. The crash follows cmd-q quit after a normal work session. The main window closeEvent does a number of settings w

Re: [PyQt] Version strings in Qt 4.8 PyQt 4.9

2013-02-06 Thread David Cortesi
>> Everything seems to work correctly except this small thing: it used to >> be that I could get version strings from Qt.PYQT_VERSION_STR and >> Qt.qVersion() but now those attributes of Qt are undefined. >> >> Does this indicate that I've done something wrong in the installation? > Works fine for

[PyQt] Version strings in Qt 4.8 PyQt 4.9

2013-02-05 Thread David Cortesi
I had been running fine (Mac OS 10.6, PyQt 4.6 and Qt 4.6 I think). Today, in order to hopefully fix a QWebKit problem, I installed Qt 4.8.4 for Mac OS, followed immediately by installing the latest stable SIP and PyQt4 from source. (From source because I'm still on the mac default python 2.6 and t

[PyQt] QTerminate and Python libs?

2013-01-09 Thread David Cortesi
The doc for QThread.terminate() says its use "is discouraged". I have a thread that calls urllib2 to read an http page. I am having a problem where this thread gets hung somewhere in the urllib2 -- remains to be determined whether in urllib2.urlopen() or in a read() on the resulting object. Anywa

Re: [PyQt] Strange error loop...

2012-12-20 Thread David Cortesi
Sorry, googling some of the messages shows they come from the OSX Core Graphics. So it's an issue between Qt and OSX. Sorry for the noise. On Thu, Dec 20, 2012 at 4:00 AM, wrote: > CGErrorBreakpoint ___ PyQt mailing listPyQt@riverbankcomputing.com h

[PyQt] Strange error loop in QWebView, probably

2012-12-19 Thread David Cortesi
Hello, I'm working on a little browser app using a QWebView. Today it went into a loop throwing hundreds of messages like the following. Revisiting the same URL did not reproduce it. Do these look familiar to anyone? What component might be in trouble here? The first messages were: Wed Dec 19 08

Re: [PyQt] Shortening multiple widget initializations to one line

2012-12-10 Thread David Cortesi
On Mon, Dec 10, 2012 at 4:00 AM, wrote: > is there any other method I can follow to shorten the > tortuous list of repetitive commands for initializing multiple widgets? If you don't mind referring to the objects by index number rather than individual names, you can do this: self.myListOfE

Re: [PyQt] dense about qvariant and dict

2012-12-08 Thread David Cortesi
qv.toPyObject() gives the same as qv.toMap, a python dict in which the keys have been changed to QStrings (these keys were all python strings originally, don't know what it would do with numeric keys) and the values to QVariants. This is ok in the sense that no data is lost, but adds some code in

[PyQt] dense about qvariant and dict

2012-12-07 Thread David Cortesi
OK, I implement QListView.itemData() returning a python dict, which then arrives at QListView.setItemData() as a QVariant of length 1. The problem is, how to cast that qv back to a dict? I have read http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qvariant.html and noted especially the

Re: [PyQt] A quick question about Return in a text edit (Evan Driscoll)

2012-12-04 Thread David Cortesi
This type of question is better addressed to the Qt fora, see qt-project.org/forums. That said... You definitely can monitor all keystrokes using keyPressEvent. You will likely find other reasons for doing so besides shift-enter, for example you might trap ^f to implement find. A whole lot of stu

Re: [PyQt] QMap, QHash?

2012-11-16 Thread David Cortesi
On Fri, Nov 16, 2012 at 2:20 PM, Phil Thompson wrote: > On Fri, 16 Nov 2012 10:34:12 -0800, David Cortesi > wrote: >> Working on implementing a List model using QAbstractListModel and >> would like to implement (set)itemData which returns a QMap. > Have you tried... >

[PyQt] QMap, QHash?

2012-11-16 Thread David Cortesi
Working on implementing a List model using QAbstractListModel and would like to implement (set)itemData which returns a QMap. QMap seems to be Qt's version of a dict, a list of key:value pairs. (QHash is apparently similar.) The point of itemData/setItemData is to return or set the data for every

[PyQt] QImage.constBits, constScanLine?

2012-11-05 Thread David Cortesi
In the Digia docs (http://doc.qt.digia.com/qt/qimage.html) QImage is said to have both a .bits() method and a .constBits() one, the latter differing in that it does not perform a "deep" copy of the image data. This might be useful if one wants to sample or process the contents of large images. Sim

Re: [PyQt] Not getting it re sip.voidptr

2012-11-04 Thread David Cortesi
>> When I try assignment, >> vptr[1] = 0x00 >> I get the message, >> TypeError: 'int' does not have the buffer interface > I can't reproduce this - can you send a short, complete test that > demonstrates the problem. Here you go: Ubuntu 12.10, PyQt4 4.9.3-4 $ python Python 2.7.3 (default

[PyQt] Not getting it re sip.voidptr

2012-11-03 Thread David Cortesi
Following up on a stackoverflow answer re manipulating a QImage, I access the contents of an image by: vptr = myQi.bytes() vptr.setsize(myQi.byteCount()) Per the Riverbank docs, > A sip.voidptr may also be given a size... If it has a size then it is > also able to support Python’s buffer

Re: [PyQt] QValidator.validate encore

2012-09-29 Thread David Cortesi
> > The API is different for different versions of the QString API. > Phil > Sorry, I'm using Python 2.7 and PyQt4 (4.8.3). Looking around the Riverbank docs starting at the top level I find this link: http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/python_v3.html#qvalidator which s

[PyQt] QValidator.validate encore

2012-09-28 Thread David Cortesi
I have set up a QValidator whose validate method consists of: def validate(self, qs, pos) : return (QValidator.Acceptable, qs, pos) and this still gets TypeError: invalid result type from findRepValidator.validate() Very puzzling. ___ PyQt

[PyQt] QValidator - forget it

2012-09-28 Thread David Cortesi
Sorry, should have checked the docs on the riverbank first. QValidator.validate has to return a triple (State, string, pos). Apparently because the string and pos input args are mutable (non-"const") in the C++, and this how argument altering is done? Anyway, excuse the noise on the channel. DC

[PyQt] Correct return type from QValidator.validate()?

2012-09-28 Thread David Cortesi
Hello, I am trying to set up a QValidator on a QLineEdit. The Assistant says that the validate() member should return something from the Enum QValidator::State. My validator's validate() member currently has only the one statement, return QValidator.Acceptable Whenever an edit is made in the L

[PyQt] QImage in BI24 format

2012-09-18 Thread David Cortesi
> > I have a C-library creating an image supposedly in in BI24 format (video > application) > > Now I'd like to display the image. > > I tried to set the pixel format to QImage.Format_RGB888 > > and I can see the image. > However the red and blue colors are inversed. > I don't know if this will he

[PyQt] unicode(QChar) produces unexpected result?

2012-08-09 Thread David Cortesi
To get a python string copy of the contents of a QString object, I have been using unicode(some_qstring) . >>> qs = QString(u'BAZ') >>> len(unicode(qs)) 3 So I was surprised when I did the analogous thing to get a python string copy of the contents of a QChar. >>> qc = QChar(u'Z') >>> len(unicod

[PyQt] Qt5 roadmap?

2012-06-16 Thread David Cortesi
Folks, Per the Qt Project roadmap (http://qt-project.org/wiki/Qt_5.0) Qt 5 is supposed to be in beta now (the alpha is available at http://qt-project.org/prereleases), with final release "by the end of June". I look in vain for a pyqt roadmap at riverbank.co.uk, although I do see roadmaps for sip

Re: [PyQt] PyQt Digest, Vol 95, Issue 9

2012-06-12 Thread David Cortesi
On Tue, Jun 12, 2012 at 4:00 AM, wrote: > > 1. QTabWidget tab width change (Ganesh Kumar) > > I have try with pyqt, with QTabWidget I want increase tab width my > application. How to achieve tab width. please guide me. > > -Ganesh > The idea is that the tab bar will resize the tabs in an approp

Re: [PyQt] TableView - activated signal

2012-02-21 Thread David Cortesi
> > * But if you navigate around in the cell using arrow keys and then press > space, the cell is opened, but no signal is triggered. >* If you then write something in the cell and press TAB to leave the > cell - no signal is triggered. These actions relate to editing the cell contents. Sugg

[PyQt] QStringList does not inherit QList methods?

2012-01-18 Thread David Cortesi
Per both the Qt Assistant and the PyQt4 class reference, QStringList inherits all methods of QList, but the following code produces the error message, AttributeError: 'QStringList' object has no attribute 'at'. If I convert the .at(0) to simple [0] indexing, the error moves on to say "no attribute

[PyQt] PyQt (Qt) widgets ignore Mac Keyboard Viewer input

2011-11-25 Thread David Cortesi
I wrote previously about (Py)Qt widgets ignoring generated keystrokes from third-party apps like Typinator, but now I have verified that they also ignore input from the official Mac OS built-in keystroke generator, the Apple Keyboard Viewer. To test this, - open System Preferences - select t

[PyQt] Qt keystroke input and OS X keystroke apps

2011-11-19 Thread David Cortesi
I've posted this at the Qt developer forum with no response, (http://developer.qt.nokia.com/forums/viewthread/11749/), hopefully someone here has a thought: my PyQt4 app under OS X 10.6 does not respond properly to keystroke input generated by the popular apps PopChar and Typinator. (PopChar is an

[PyQt] Strange problem with QPixmap

2011-10-06 Thread David Cortesi
I've a working program that loads grayscale PNG images with QPixmap. The call is the simplest possible, pxmap = QPixmap(pngPathString) This worked great, but recently I got a set of png images that look fine in Mac OS Preview, in Photoshop, etc. but when loaded with the above, the colors are

[PyQt] How specify a null QFlags item?

2011-09-22 Thread David Cortesi
To a function I want to pass a parameter to be used with QTextDocument.find, either QTextDocument.FindCaseSensitively or zero. When I literally pass QTextDocument.FindCaseSensitively the function receives an object of type PyQt4.QtGui FindFlags. When I pass zero, it gets, no surprise, an int 0. I

[PyQt] make error in PyQt-mac-gpl-4.8.5/designer

2011-09-08 Thread David Cortesi
I had previously installed PyQt4 (4.7.2) without difficulty but trying to update to 4.8.5 a make error occurs, specifically while making the subdirectory "designer" - the error is around a bunch of missing names at ld time. Any suggestions appreciated.. Here is an edited display of the error: ld:

[PyQt] segv crashes on mac os around signal statements

2011-09-08 Thread David Cortesi
I am experimenting with trying to implement a custom signal and having a lot of trouble with the syntax of connect, etc, and while making various changes I am getting frequent SEGV crashes in the QtCore plugin. Below is the abbreviated head of a crash report. Does anybody want to know about these?

[PyQt] SEGV in QTextStream.atEnd on Mac OS

2011-08-29 Thread David Cortesi
The following code will reliably produce a crash on my Mac OS 10.6.8 (snow leopard) system. Python 2.6.1. from __future__ import division from __future__ import print_function from __future__ import unicode_literals from future_builtins import * from PyQt4.QtCore import (QFile, QTextStream, QStri

Re: [PyQt] Please tell me if I have this straight...

2011-08-06 Thread David Cortesi
OK, David Boddie helped clear up my confusion (as did rereading chapter 1 of "Rapid GUI Programming") -- to get from a QString to something I can work on in Python it is only necessary to apply unicode(). Doh! (Facepalm). BLEEP represents any transformation that the user requires, which is not in

[PyQt] Please tell me if I have this straight...

2011-08-05 Thread David Cortesi
I present a document to a user in a QPlainTextEdit widget. The widget nicely handles most editing functions, but there is a unique operation I want to provide. When the user selects Edit > BLEEP, the app is supposed to BLEEP the document. BLEEPing is not something Qt does, I have to implement BLEE

[PyQt] combining python regex with QPlainTextEdit?

2011-07-27 Thread David Cortesi
This is a high-level design question. I'm looking at writing a PyQt-based replacement for an old app written in Perl/TCL. It is basically a specialized text editor and QPlainTextEdit would be a nifty basis with one exception: regex find/replace. The old app fully exposed Perl regex syntax in its F

Re: [PyQt] make failure on mac os x

2011-05-01 Thread David Cortesi
On Sun, May 1, 2011 at 12:40 AM, Sateesh Kumar wrote: > I faced the same error while installing PyQt on Mac. Following the steps > mentioned here : > https://bugs.launchpad.net/bzr-mac-installers/+bug/529987/comments/9 > helped me to do a successful install of PyQt Mac. This does eliminate the e

[PyQt] make failure on mac os x

2011-04-27 Thread David Cortesi
I'm trying to install on Mac OS X 10.6.7 with the default python 2.6. I installed SIP, its make and make-install seemed to run correctly. I installed Qt 4.7.2 and ran its demos. I downloaded PyQt-mac-gpl-4.8.3 and ran its make, which did a whole bunch of compiles with no obvious errors. It got righ