PyQt5 installation problem
2013-05-15 12:23:35 GMT
<div><div dir="ltr">Hi!<div>When I'm trying to install PyQt5 I get an error: Error: PyQt5 requires Qt v5.0 or later.</div> <div><br></div> <div>My Qt5.0.2 installation is in my $HOME/dev/Qt5.0.2 - how can I tell the configure script to search for it there?</div> <div><br></div> </div></div>
Re: Paste entire column into QTableView from Excel
2013-05-14 20:21:31 GMT
On Mon 13 May 2013 15:12:41 -0400, Mark Mordeca wrote: > I am having an issue pasting into a QTableView from Excel when the user has > copied by selecting an entire column in Excel, essentially putting every > single row in the selected column, for the entire excel sheet, on the > clipboard. The following is my paste code for QTableView: [...] > This all works fine when a user has selected just a bunch of cells in Excel > and copied those. It breaks down when they select an entire column because > pasteString then becomes upwards of 1048576 characters long (this value is > found by printing pasteString.size() when highlighting a completely empty > Excel column by selecting its header and copying). It completely kills the > program. Does it crash or just become unresponsive? Is there a limit on the amount of data that can be stored in the clipboard on Windows? Maybe that could be a factor. Can you paste the whole column into another application successfully? > Is there any way to get the copied column from the clipboard more > efficiently than tab delimited text or something? Or should I just throw up > an error when the size of the string on the clipboard is some arbitrarily > large length? Any help would be appreciated. You need to check what sort of MIME data is contained in the clipboard. The QClipboard documentation should have example code for this. David
resizing layouts
2013-05-14 15:15:18 GMT
Hi all, If have a quick question regarding qt layouts. My application has 4 areas, defined by a 2x2 QGridLayout. Each area can have single widgets and also sub layouts. Now I want the user to be able to interactivly change the size of each of the 4 areas by a handle. Basically what a QSplitter does, but QSplitter seems only to work on widgets, not on complete layouts. Anyone has an idea to solve this? Thanks, Andre
Paste entire column into QTableView from Excel
2013-05-13 19:12:41 GMT
Greetings,
I am having an issue pasting into a QTableView from Excel when the user has copied by selecting an entire column in Excel, essentially putting every single row in the selected column, for the entire excel sheet, on the clipboard. The following is my paste code for QTableView:
def paste(self):
model=self.model()
pasteString=QtGui.QApplication.clipboard().text()
rows=pasteString.split('\n')
numRows=len(rows)
numCols=rows[0].count('\t')+1
selectionRanges=self.selectionModel().selection()
#make sure we only have one selection range and not non-contiguous selections
if len(selectionRanges)==1:
topLeftIndex=selectionRanges[0].topLeft()
selColumn=topLeftIndex.column()
selRow=topLeftIndex.row()
if selColumn+numCols>model.columnCount():
#the number of columns we have to paste, starting at the selected cell, go beyond how many columns exist.
#insert the amount of columns we need to accomodate the paste
model.insertColumns(model.columnCount(), numCols-(model.columnCount()-selColumn))
if selRow+numRows>model.rowCount():
#the number of rows we have to paste, starting at the selected cell, go beyond how many rows exist.
#insert the amount of rows we need to accomodate the paste
model.insertRows(model.rowCount(), numRows-(model.rowCount()-selRow))
#block signals so that the "dataChanged" signal from setData doesn't update the view for every cell we set
model.blockSignals(True)
for row in xrange(numRows):
columns=rows[row].split('\t')
[model.setData(model.createIndex(selRow+row, selColumn+col), QVariant(columns[col])) for col in xrange(len(columns))]
#unblock the signal and emit dataChangesd ourselves to update all the view at once
model.blockSignals(False)
model.dataChanged.emit(topLeftIndex, model.createIndex(selRow+numRows, selColumn+numCols))
This all works fine when a user has selected just a bunch of cells in Excel and copied those. It breaks down when they select an entire column because pasteString then becomes upwards of 1048576 characters long (this value is found by printing pasteString.size() when highlighting a completely empty Excel column by selecting its header and copying). It completely kills the program.
Is there any way to get the copied column from the clipboard more efficiently than tab delimited text or something? Or should I just throw up an error when the size of the string on the clipboard is some arbitrarily large length? Any help would be appreciated.
Thanks,
Mark
<div><div class="WordSection1">
<p class="MsoNormal"><span>Greetings,</span></p>
<p class="MsoNormal"><span>I am having an issue pasting into a QTableView from Excel when the user has copied by selecting an entire column in Excel, essentially putting every single row in the selected column, for the entire excel sheet, on the clipboard. The following is my paste code for QTableView:</span></p>
<p class="MsoNormal"><span> def paste(self):</span></p>
<p class="MsoNormal"><span> model=self.model()</span></p>
<p class="MsoNormal"><span> pasteString=QtGui.QApplication.clipboard().text()</span></p>
<p class="MsoNormal"><span> </span></p>
<p class="MsoNormal"><span> rows=pasteString.split('\n')</span></p>
<p class="MsoNormal"><span> numRows=len(rows)</span></p>
<p class="MsoNormal"><span> numCols=rows[0].count('\t')+1</span></p>
<p class="MsoNormal"><span> </span></p>
<p class="MsoNormal"><span> selectionRanges=self.selectionModel().selection()</span></p>
<p class="MsoNormal"><span> </span></p>
<p class="MsoNormal"><span> #make sure we only have one selection range and not non-contiguous selections</span></p>
<p class="MsoNormal"><span> if len(selectionRanges)==1:</span></p>
<p class="MsoNormal"><span> topLeftIndex=selectionRanges[0].topLeft()</span></p>
<p class="MsoNormal"><span> selColumn=topLeftIndex.column()</span></p>
<p class="MsoNormal"><span> selRow=topLeftIndex.row()</span></p>
<p class="MsoNormal"><span> if selColumn+numCols>model.columnCount():</span></p>
<p class="MsoNormal"><span> #the number of columns we have to paste, starting at the selected cell, go beyond how many columns exist.</span></p>
<p class="MsoNormal">
<span> #insert the amount of columns we need to accomodate the paste</span></p>
<p class="MsoNormal"><span> model.insertColumns(model.columnCount(), numCols-(model.columnCount()-selColumn))</span></p>
<p class="MsoNormal"><span> </span></p>
<p class="MsoNormal"><span> if selRow+numRows>model.rowCount():</span></p>
<p class="MsoNormal"><span> #the number of rows we have to paste, starting at the selected cell, go beyond how many rows exist.</span></p>
<p class="MsoNormal">
<span> #insert the amount of rows we need to accomodate the paste</span></p>
<p class="MsoNormal"><span> model.insertRows(model.rowCount(), numRows-(model.rowCount()-selRow))</span></p>
<p class="MsoNormal"><span> </span></p>
<p class="MsoNormal"><span> #block signals so that the "dataChanged" signal from setData doesn't update the view for every cell we set</span></p>
<p class="MsoNormal"><span> model.blockSignals(True) </span></p>
<p class="MsoNormal"><span> </span></p>
<p class="MsoNormal"><span> for row in xrange(numRows):</span></p>
<p class="MsoNormal"><span> columns=rows[row].split('\t')</span></p>
<p class="MsoNormal"><span> </span></p>
<p class="MsoNormal"><span> [model.setData(model.createIndex(selRow+row, selColumn+col), QVariant(columns[col])) for col in xrange(len(columns))]</span></p>
<p class="MsoNormal"><span> </span></p>
<p class="MsoNormal"><span> #unblock the signal and emit dataChangesd ourselves to update all the view at once</span></p>
<p class="MsoNormal"><span> model.blockSignals(False)</span></p>
<p class="MsoNormal"><span> model.dataChanged.emit(topLeftIndex, model.createIndex(selRow+numRows, selColumn+numCols))</span></p>
<p class="MsoNormal"><span>This all works fine when a user has selected just a bunch of cells in Excel and copied those. It breaks down when they select an entire column because </span><span>pasteString</span><span> then becomes upwards of 1048576 characters long (this value is found by printing pasteString.size() when highlighting a completely empty Excel column by selecting its header and copying). It completely kills the program.</span></p>
<p class="MsoNormal"><span>Is there any way to get the copied column from the clipboard more efficiently than tab delimited text or something? Or should I just throw up an error when the size of the string on the clipboard is some arbitrarily large length? Any help would be appreciated.</span></p>
<p class="MsoNormal"><span>Thanks,</span></p>
<p class="MsoNormal"><span>Mark</span></p>
<p class="MsoNormal"> </p>
</div></div>
PyQt5 Snapshot, build problems and their solutions, Windows, mingw
2013-05-12 20:42:23 GMT
Hi,
I've compiled the latest PyQt5 snaphot, on 32bit python 3.3.1 (compiled with mingw, using a self-made
build script based on scons), Windows7, Qt 5.1alpha.
I've used this configuration step:
D:\_cpp_projects_\Python\Python-3.3.1\.build_release\python.exe configure.py --no-docstrings
--confirm-license -u --spec=win32-g++ --verbose --trace
--sip="D:\_cpp_projects_\Python\Python-3.3.1\sip.exe"
LFLAGS+="-LD:\_cpp_projects_\Python\Python-3.3.1\.build_debug
-LD:\_cpp_projects_\Python\Python-3.3.1\.build_release" DEFINES+=_DEBUG
(It's necessary to include the release version of the python lib even in debug build for the designer
plugins.)
I've run into a number of problems:
(1)
PyQt's configure.py autoamtically assumes certain MS-compilers on the win32 platform, in
TargetConfiguration.__init__():262 and following:
# The default qmake spec.
if sys.platform == 'win32':
if self.py_version >= 0x030300:
#self.qmake_spec = 'win32-msvc2010'
---- self.qmake_spec = 'win32-g++'
elif self.py_version >= 0x020600:
self.qmake_spec = 'win32-msvc2008'
elif self.py_version >= 0x020400:
self.qmake_spec = 'win32-msvc.net'
else:
self.qmake_spec = 'win32-msvc'
else:
# Use the Qt default. (We may update it for MacOS/X later.)
self.qmake_spec = ''
I had to make the marked change to get around that for my mingw-based python. It would be nice
if there was an option to influence that.
[Motivation: I must embedd the python interpreter, and I want to get away from MS Visual Studio,
because it is becoming slower with each version. Hence I'll have to compile python myself using
mingw, which is non-standard.]
(2)
All makefiles attempt to build all DLLs without referring to the python DLL. Adding
"-lpython33_d" to each Makefile.Debug and "-lpython33" to Makefile.Release solves this.
I tried adding LFLAGS_DEBUG+="-lpython33_d" as parameter to the configure script, but it had
no effect on the makefiles.
(3)
The final debugging versions of the DLLs get the wrong names. They all miss the trailing "_d".
This way they can't be imported, unless manually renamed arcordingly.
Best Regards,
Mathias Born
General questions on parsing large QStrings
2013-05-12 20:19:55 GMT
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.
a const QString such as returned by QPlainTextEdit.toPlainText()
the best way to do intensive examination of big strings.
Is there a copy involved in, e.g.
how well do PyQtx calls integrate with Cython or PyPy?
Dave Cortesi
<div><div dir="ltr"> <div> <div> <div> <div> <div> <div> <div> <div> <div> <div>For an app to be built with PyQt5/Qt5, I will have a<br> </div>QPlainTextEdit in which the document may be quite<br>sizable, 500K characters or more.<br><br>I will want at times to inspect the document character<br> by character, or possibly apply Python relib REs to it.<br><br> </div>I am somewhat at sea regarding the relationship between<br>a const QString such as returned by QPlainTextEdit.toPlainText()<br> </div>and a Python3 unicode string, and -- just in general -- about<br> the best way to do intensive examination of big strings.<br>Is there a copy involved in, e.g.<br><br> </div> docstring = unicode( myEditor.toPlainText() )<br><br> </div>I note that the PyQt4 QString reference omits the <br> </div>QString.begin() or .constBegin() etc methods that return an<br> </div>"STL-style iterator" so that's out. Is there some internal magic<br> </div>to integrate the QString type into Python's "for" mechanism<br> </div>so that "for c in myEditor.toPlainText()" might be more<br> </div> <div>efficient than making a Python3 string and iterating on it?<br><br> </div> <div> <div>Also in regard to making intensive loops faster, <br> how well do PyQtx calls integrate with Cython or PyPy?<br><br> </div> <div>Thanks for any insights,<br><br>Dave Cortesi<br> </div> <div><br></div> </div> </div></div>
Re: Designer Customer Widget
2013-05-10 23:27:42 GMT
On Wed, 08 May 2013 15:20:26 -0500, Stephen Funkhouser wrote: [...] > Is it possible to get Qt Designer to save custom properties of the > inherited QTreeWidgetItems objects? I guess it's more of a Qt Designer question than a PyQt question but you would need to find out if a C++ custom widget suffers from the same problem to be sure. It's been a long time since I looked at Designer. It may be that it only only saves certain properties out to .ui files, but there may also be a problem with how it examines custom properties and how those are registered using PyQt. The only vague recollection I have, apart from realising that Qt relies on information that is usually provided by plugins at compile time, is the thought that custom property types seemed difficult to do with PyQt. Custom properties themselves should be OK - I think. It might be a long shot, but have you looked at the PyQt examples to see if any do something similar to what you are doing? David
status of PyPy support
2013-05-10 09:47:14 GMT
Hello, what is the status of PyPy support for PyQt? The PyPy compatibility wiki page (https://bitbucket.org/pypy/compatibility/wiki/Home#!gui-library-bindings) just says 'Unknown' ? Sincerely, Gour -- -- Not by merely abstaining from work can one achieve freedom from reaction, nor by renunciation alone can one attain perfection. http://www.atmarama.net | Hlapicina (Croatia) | GPG: 52B5C810
PyQt5 and QtMultimediaWidgets
2013-05-10 01:11:30 GMT
Hi, I was able to build the PyQt5 development snapshot against Qt5.0.2 on Linux and started playing around with it. I attempted to port one of the examples from the Qt5.0.2 c++ source, /examples/multimediawidgets/videographicsitem, but it seems that some Qt libraries/classes were skipped when I built PyQt5? In the example I attempted I need the QGraphicsVideoItem class from the QtMultimediaWidgets namespace. Any ideas? Will this one be added later? Cheers Christoffer
Designer Customer Widget
2013-05-08 20:20:26 GMT
I'm working on creating a custom widget inherited from QTreeWidget. The purpose of this is I'm using the Designer for another programming language which doesn't have any of it's own developer tools. I'm creating custom widgets to mimic each of this programming language's widgets. The language has a tree control that I can mimic using QTreeWidget, but I need to add a lot of custom properties to the Tree columns. I'm trying to do this by inheriting from QTreeWidgetItems to create custom items that have unique properties. I'm also overriding the default TreeWidget Editor by creating a Menu Entry, and a Menu Factory that calls a custom dialog to edit the custom widget. In this custom dialog I'm adding a header using setHeaderItem(); which, displays properly in Qt Designer. The problem though, is that it the text property of the columns isn't being saved to the .ui file. Designer does add column tags to the .ui file, but the text is just the column numbers and not my text added through the QExtensionFactory call to the dialog. Is it possible to get Qt Designer to save custom properties of the inherited QTreeWidgetItems objects? Stephen
RSS Feed