[PyQt] QPrinter and matplotlib

2012-01-18 Thread Nils Wagner

Hi all,

I added a printer button to the navigation toolbar in 
matplotlib.
However the quality of the print-out is poor using 
QPrinter.
Moreover the frame including the navigation toolbar is 
printed.

How can I omit that ?

How can I improve the quality of the hardcopy ? If I save 
the figure before, the print-out is o.k.

I have attached the program.
Can anybody offer any solutions to this ?

Thanks in advance.

 Nils

import sys
import numpy as np
from PyQt4.QtCore import *
from PyQt4.QtGui import *
#from xlwt import *
from pylab import plot, show

from matplotlib.figure import Figure
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT as NavigationToolbar2


class ViewWidget(QMainWindow):
 def __init__(self):
 QMainWindow.__init__(self)

 # create a simple main widget to keep the figure
 self.mainWidget = QWidget()
 self.setCentralWidget(self.mainWidget)

 layout = QVBoxLayout()
 self.mainWidget.setLayout(layout)

 # create a figure
 self.figure_canvas = FigureCanvas(Figure())
 layout.addWidget(self.figure_canvas, 10)

 # and the axes for the figure
 self.axes = self.figure_canvas.figure.add_subplot(111)
 x = np.linspace(0.,2*np.pi,100)
 self.axes.plot(x,np.sin(x),label='sin(x) ')
 self.axes.plot(x,np.cos(x),label='cos(x) ')
 self.axes.figure.set_facecolor('white') 
 self.axes.grid('on')
 self.axes.legend()
 # add a navigation toolbar
 self.navigation_toolbar = NavigationToolbar2(self.figure_canvas, self)
 layout.addWidget(self.navigation_toolbar, 0)

 self.print_button = QPushButton()
 self.print_button.setIcon(QIcon(Fileprint.png))
 self.print_button.setToolTip(Print the figure)
 self.navigation_toolbar.addWidget(self.print_button)
 self.connect(self.print_button, SIGNAL('clicked()'), self.goPrinter)

 self.quit_button = QPushButton(Quit)
 self.navigation_toolbar.addWidget(self.quit_button)
 self.connect(self.quit_button, SIGNAL('clicked()'), self.close)
 
 def goPrinter(self):
 printer = QPrinter()
 anotherWidget= QPrintDialog(printer,self)
 if(anotherWidget.exec_() != QDialog.Accepted):
 return
 p = QPixmap.grabWidget(self)
 printLabel = QLabel()
 printLabel.setPixmap(p)
 painter = QPainter(printer)
 printLabel.render(painter)
 painter.end()

 show()

if __name__==__main__:
 app=QApplication(sys.argv)
 mw=ViewWidget()
 mw.show()
 sys.exit(app.exec_())
attachment: Fileprint.png___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] QWebkit: saving/caching user input

2012-01-18 Thread Andreas Pakulat
On 17.01.12 18:24:50, James Polk wrote:
 okay, Back at the front,...
 
 Let's say we use QWebKit to read an HTML file containing a javascript 
 textField...like so:
 
 htmlbody
 p
     form name=thisForm
     tr
     tdName:/td tdinput type=text name=name id=nameId 
 value=John/td
     /tr
     /form
 /body/html
 
 When displayed,..the user types Mary into the field, replacing John.
 Then using a method I, uh...derived...from a related web example...
 We want to capture the HTML being displayed and save it out to file
 
 But,..we need the resulting file to contain the new user input text 
 Mary...not John...
 so that on subsequent reloads, the HTML textField will display Mary,etc...
 
 Here's the snippet to cache...
 
     def DoIt(self):
     print Saving...
 
     data = self.webview.page().mainFrame().toHtml()
     thisFile = test.html
     open(QtCore.QString(thisFile), 'w').write(data)
 
     print Done!
 
 However, it saves out John instead of Mary
 
 Can anybody offer any solutions to this ?

File a bugreport with Nokia that they DOM-API is broken.

 And/or offer any other suggestions or workarounds to accomplish same ?

You could try evaluateJavaScript(document.innerHTML) or
evaluateJavaScript(document.body.innerHTML) (the latter will not
include the headers and the body-attributes though) to get the HTML
of the page via JS which apparently always works.

Andreas

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] Installation Path Problems Python 2.7 and 3.2

2012-01-18 Thread Robert Ford

Hello,

Windows Vista SP2 32 bit
Python 2.7.2
Python 3.2.2
eric4-4.4.20
eric5-5.18
PyQt-Py2.7-x86-gpl-4.9-1.exe
PyQt-Py3.2-x86-gpl-4.9-1.exe

PYQT INSTALL MAY SET WRONG PATHS?

I am trying to install eric4 and eric 5 into respectively Python 2.7 and 
Python 3.2.

This uses the appropriate PyQt windows binaries above
.
The eric mailing list have told me this is a PyQt issue.

ERIC4:

PROBLEM
PyQt modules import correctly as per eric manual test.

I have eric4 download folder extracted to C:\Python27.

When I run install it starts and confirms PyQt4 is found, but then states
Sorry, please install QtHelp. DLL load failure

In the same PyQt folder there are definitely QtHelp.pyd and a QtHelp4.dll
files.

Eric 4 installation apparently cannot find them though.

SOLVED
In the Registry the default path for PyQt4 was found to be set for Python32.
I cleaned this out and reinstalled and eric4 now installed.


ERIC5
I again looked in the Registry and the default path is wrongly set to 
Python27 ??

I cleaned this out and reinstalled.
This did not work though, although I am in the Python32 folder it still 
thinks it is Python27 and  I get the following error message:


c:\Users\Robertcd c:\python32\eric5-5.1.8

c:\Python32\eric5-5 .1 .8install
Checking dependencies
Sorry. you must have Python 3.1.0 or higher.
Press enter to continue...
An internal error occurred. Please report all the output of the program.
including the following traceback. to eric5b...@ericide.python-projects.org.

Traceback (most recent call last):
File C:\Python32\eric5-5.1.8\install.py. line 1039. in nodule
main(sys .argv)
File C:\Python32\eric5-5.1.8\install.py. line 971. in main
doDependancyChecks()
File C:\Python32\eric5-5.1.8\install.py. line 709. in doDependancyChecks
exit (5)
File C:\Python32\eric5-5.1.8\install.py. line 48. in exit
input('Press enter to continue.. _')
File string, line 0
 ^
SyntaxError: unexpected EOF while parsing

c:\Python32\eric5-5 .1.8

Robert


___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] [Eric] Installation Path Problems Python 2.7 and 3.2

2012-01-18 Thread Detlev Offenbach
Am Mittwoch, 18. Januar 2012, 17:29:39 schrieb Robert Ford:
 Hello,
 
 Windows Vista SP2 32 bit
 Python 2.7.2
 Python 3.2.2
 eric4-4.4.20
 eric5-5.18
 PyQt-Py2.7-x86-gpl-4.9-1.exe
 PyQt-Py3.2-x86-gpl-4.9-1.exe
 
 PYQT INSTALL MAY SET WRONG PATHS?
 
 I am trying to install eric4 and eric 5 into respectively Python 2.7 and
 Python 3.2.
 This uses the appropriate PyQt windows binaries above
 .
 The eric mailing list have told me this is a PyQt issue.
 
 ERIC4:
 
 PROBLEM
 PyQt modules import correctly as per eric manual test.
 
 I have eric4 download folder extracted to C:\Python27.
 
 When I run install it starts and confirms PyQt4 is found, but then states
 Sorry, please install QtHelp. DLL load failure
 
 In the same PyQt folder there are definitely QtHelp.pyd and a QtHelp4.dll
 files.
 
 Eric 4 installation apparently cannot find them though.
 
 SOLVED
 In the Registry the default path for PyQt4 was found to be set for Python32.
 I cleaned this out and reinstalled and eric4 now installed.
 
 
 ERIC5
 I again looked in the Registry and the default path is wrongly set to
 Python27 ??
 I cleaned this out and reinstalled.
 This did not work though, although I am in the Python32 folder it still
 thinks it is Python27 and  I get the following error message:
 
 c:\Users\Robertcd c:\python32\eric5-5.1.8
 
 c:\Python32\eric5-5 .1 .8install

You better use this command

c:\python32\python install.py

If you install via double click onto the install script you might pick the 
wrong interpreter version dpending on your PATH settings.

 Checking dependencies
 Sorry. you must have Python 3.1.0 or higher.
 Press enter to continue...
 An internal error occurred. Please report all the output of the program.
 including the following traceback. to eric5b...@ericide.python-projects.org.
 
 Traceback (most recent call last):
 File C:\Python32\eric5-5.1.8\install.py. line 1039. in nodule
 main(sys .argv)
 File C:\Python32\eric5-5.1.8\install.py. line 971. in main
 doDependancyChecks()
 File C:\Python32\eric5-5.1.8\install.py. line 709. in doDependancyChecks
 exit (5)
 File C:\Python32\eric5-5.1.8\install.py. line 48. in exit
 input('Press enter to continue.. _')
 File string, line 0
   ^
 SyntaxError: unexpected EOF while parsing
 
 c:\Python32\eric5-5 .1.8
 
 Robert
 
 
 ___
 Eric mailing list
 e...@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/eric
-- 
Detlev Offenbach
det...@die-offenbachs.de
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Installation Path Problems Python 2.7 and 3.2

2012-01-18 Thread Phil Thompson
On Wed, 18 Jan 2012 17:29:39 -, Robert Ford for...@ntlworld.com
wrote:
 Hello,
 
 Windows Vista SP2 32 bit
 Python 2.7.2
 Python 3.2.2
 eric4-4.4.20
 eric5-5.18
 PyQt-Py2.7-x86-gpl-4.9-1.exe
 PyQt-Py3.2-x86-gpl-4.9-1.exe
 
 PYQT INSTALL MAY SET WRONG PATHS?
 
 I am trying to install eric4 and eric 5 into respectively Python 2.7 and

 Python 3.2.
 This uses the appropriate PyQt windows binaries above
 .
 The eric mailing list have told me this is a PyQt issue.
 
 ERIC4:
 
 PROBLEM
 PyQt modules import correctly as per eric manual test.
 
 I have eric4 download folder extracted to C:\Python27.
 
 When I run install it starts and confirms PyQt4 is found, but then
states
 Sorry, please install QtHelp. DLL load failure
 
 In the same PyQt folder there are definitely QtHelp.pyd and a
QtHelp4.dll
 files.
 
 Eric 4 installation apparently cannot find them though.
 
 SOLVED
 In the Registry the default path for PyQt4 was found to be set for
 Python32.
 I cleaned this out and reinstalled and eric4 now installed.
 
 
 ERIC5
 I again looked in the Registry and the default path is wrongly set to 
 Python27 ??
 I cleaned this out and reinstalled.
 This did not work though, although I am in the Python32 folder it still 
 thinks it is Python27 and  I get the following error message:
 
 c:\Users\Robertcd c:\python32\eric5-5.1.8
 
 c:\Python32\eric5-5 .1 .8install
 Checking dependencies
 Sorry. you must have Python 3.1.0 or higher.
 Press enter to continue...
 An internal error occurred. Please report all the output of the program.
 including the following traceback. to
 eric5b...@ericide.python-projects.org.
 
 Traceback (most recent call last):
 File C:\Python32\eric5-5.1.8\install.py. line 1039. in nodule
 main(sys .argv)
 File C:\Python32\eric5-5.1.8\install.py. line 971. in main
 doDependancyChecks()
 File C:\Python32\eric5-5.1.8\install.py. line 709. in
doDependancyChecks
 exit (5)
 File C:\Python32\eric5-5.1.8\install.py. line 48. in exit
 input('Press enter to continue.. _')
 File string, line 0
   ^
 SyntaxError: unexpected EOF while parsing
 
 c:\Python32\eric5-5 .1.8

Each installer will add what it needs to the PATH. Obviously one will
appear in the PATH before the other.

Probably the best thing to do is to remove both from PATH in the registry
and create appropriate .bat files containing the PATH needed for that
particular case.

Phil
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[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 'removeFirst'.

from PyQt4.QtCore import(Qt,QString,QStringList,QRegExp)
def trySplit(us,ur):
qs = QString(us)
qr = QRegExp(ur)
ql = qs.split(qr)
if unicode(ql.at(0)) == u'': # -- no attribute 'at'
ql.removeFirst()   # -- nor any attribute 'removeFirst' etc.
if unicode(ql.at(ql.size()-1)) == u'':
ql.removeLast()
print('sans leading/trailing nulls, split gives ',ql.count(), items)
for q in ql:
print(u''+unicode(q)+u'')

It also doesn't seem to have a .size() method, only .count()

OK, so what am I doing wrong?

Thanks,

Dave Cortesi
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] QStringList does not inherit QList methods?

2012-01-18 Thread Phil Thompson
On Wed, 18 Jan 2012 12:44:57 -0800, David Cortesi davecort...@gmail.com
wrote:
 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 'removeFirst'.
 
 from PyQt4.QtCore import(Qt,QString,QStringList,QRegExp)
 def trySplit(us,ur):
 qs = QString(us)
 qr = QRegExp(ur)
 ql = qs.split(qr)
 if unicode(ql.at(0)) == u'': # -- no attribute 'at'
 ql.removeFirst()   # -- nor any attribute 'removeFirst' etc.
 if unicode(ql.at(ql.size()-1)) == u'':
 ql.removeLast()
 print('sans leading/trailing nulls, split gives ',ql.count(),
items)
 for q in ql:
 print(u''+unicode(q)+u'')
 
 It also doesn't seem to have a .size() method, only .count()
 
 OK, so what am I doing wrong?

Only a subset of the QList methods are implemented. Use the corresponding
Python operators instead.

Phil
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Building PyQT windows 7 64 bit QT 4.8.0

2012-01-18 Thread Phil Thompson
On Wed, 18 Jan 2012 21:14:01 +, calin.hanchev...@gmail.com wrote:
 Hi,
 
 I am trying to build PyQt-win-gpl-4.9 on Windows 7 professional 64 bit.
I  
 have QT 4.8.0 and Python2.7 and 3.2
 I have downloaded and built sip-4.13.1.
 
 With both versions of python I get the following error:
 Generating the C++ source for the QtNetwork module...
 sip: __or__() unsupported function return type - provide %MethodCode and
a
 
 C++ signature
 Error: Unable to create the C++ code.
 
 I downloaded and extracted the files in the installer, and compared the
 sip  
 files for QTNetwork. The files in the source are the same with the ones
in
 
 PyQt-Py2.7-x64-gpl-4.9-1.exe
 
 Any help is appreciated.

Any chance you have earlier versions installed as well?

Phil
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Building PyQT windows 7 64 bit QT 4.8.0

2012-01-18 Thread Teodor Calin Hanchevici
Hi Phil,

I do have QGIS installed, and it comes with PyQT as well, however the
distribution is clean (the interpreter is not in the path and it is
installed in QGIS directory. I have renamed sip.exe from QGIS and tried
again

Creating the Makefile for the QtMultimedia module...
Generating the C++ source for the QtNetwork module...
C:\Python27\sip -w -o -x VendorID -t WS_WIN -x PyQt_OpenSSL -x
PyQt_NoPrintRangeBug -t Qt_4_8_0 -x Py_v3 -g -a QtNetwork.api -c
C:\home\3rdparty\sources\PyQt-win-gpl-4.9\QtNetwork -b
QtNetwork\QtNetwork.sbf -I C:\home\3rdparty\sources\PyQt-win-gpl-4.9\sip
C:\home\3rdparty\sources\PyQt-win-gpl-4.9/sip/QtNetwork/QtNetworkmod.sip
sip: __or__() unsupported function return type - provide %MethodCode and a
C++ signature
Error: Unable to create the C++ code.

The version of sip is correct:
C:\home\3rdparty\sources\PyQt-win-gpl-4.9C:\Python27\sip.exe -V
4.13.1

Teodor

On Wed, Jan 18, 2012 at 5:03 PM, Phil Thompson
p...@riverbankcomputing.comwrote:

 On Wed, 18 Jan 2012 21:14:01 +, calin.hanchev...@gmail.com wrote:
  Hi,
 
  I am trying to build PyQt-win-gpl-4.9 on Windows 7 professional 64 bit.
 I
  have QT 4.8.0 and Python2.7 and 3.2
  I have downloaded and built sip-4.13.1.
 
  With both versions of python I get the following error:
  Generating the C++ source for the QtNetwork module...
  sip: __or__() unsupported function return type - provide %MethodCode and
 a
 
  C++ signature
  Error: Unable to create the C++ code.
 
  I downloaded and extracted the files in the installer, and compared the
  sip
  files for QTNetwork. The files in the source are the same with the ones
 in
 
  PyQt-Py2.7-x64-gpl-4.9-1.exe
 
  Any help is appreciated.

 Any chance you have earlier versions installed as well?

 Phil

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] [Eric] Installation Path Problems Python 2.7 and 3.2

2012-01-18 Thread Robert Ford

Hello,

YOU ADVISED:
You better use this command

c:\python32\python install.py

If you install via double click onto the install script you might pick the
wrong interpreter version depending on your PATH settings

ME:
I ran your suggested command from inside the eric5-5.1.8 folder and eric5 is 
now running.

Thank you very much. I have learned something new and important.

The eric4 manual on page 119 implies that you just run install.py from the 
unzipped folder.
You do need to change the directory of the windows shell command to be in 
that folder in order to find install.py. Perhaps the manual could be 
clarified as run is such a vague word where precision is necessary?


Robert



- Original Message - 
From: Detlev Offenbach det...@die-offenbachs.de

To: e...@riverbankcomputing.com
Cc: Robert Ford for...@ntlworld.com; pyqt@riverbankcomputing.com; 
eric5-b...@eric-ide.python-projects.org

Sent: Wednesday, January 18, 2012 6:08 PM
Subject: Re: [Eric] Installation Path Problems Python 2.7 and 3.2



Am Mittwoch, 18. Januar 2012, 17:29:39 schrieb Robert Ford:

Hello,

Windows Vista SP2 32 bit
Python 2.7.2
Python 3.2.2
eric4-4.4.20
eric5-5.18
PyQt-Py2.7-x86-gpl-4.9-1.exe
PyQt-Py3.2-x86-gpl-4.9-1.exe

PYQT INSTALL MAY SET WRONG PATHS?

I am trying to install eric4 and eric 5 into respectively Python 2.7 and
Python 3.2.
This uses the appropriate PyQt windows binaries above
.
The eric mailing list have told me this is a PyQt issue.

ERIC4:

PROBLEM
PyQt modules import correctly as per eric manual test.

I have eric4 download folder extracted to C:\Python27.

When I run install it starts and confirms PyQt4 is found, but then 
states

Sorry, please install QtHelp. DLL load failure

In the same PyQt folder there are definitely QtHelp.pyd and a QtHelp4.dll
files.

Eric 4 installation apparently cannot find them though.

SOLVED
In the Registry the default path for PyQt4 was found to be set for 
Python32.

I cleaned this out and reinstalled and eric4 now installed.


ERIC5
I again looked in the Registry and the default path is wrongly set to
Python27 ??
I cleaned this out and reinstalled.
This did not work though, although I am in the Python32 folder it still
thinks it is Python27 and  I get the following error message:

c:\Users\Robertcd c:\python32\eric5-5.1.8

c:\Python32\eric5-5 .1 .8install


You better use this command

c:\python32\python install.py

If you install via double click onto the install script you might pick the
wrong interpreter version dpending on your PATH settings.


Checking dependencies
Sorry. you must have Python 3.1.0 or higher.
Press enter to continue...
An internal error occurred. Please report all the output of the program.
including the following traceback. to 
eric5b...@ericide.python-projects.org.


Traceback (most recent call last):
File C:\Python32\eric5-5.1.8\install.py. line 1039. in nodule
main(sys .argv)
File C:\Python32\eric5-5.1.8\install.py. line 971. in main
doDependancyChecks()
File C:\Python32\eric5-5.1.8\install.py. line 709. in 
doDependancyChecks

exit (5)
File C:\Python32\eric5-5.1.8\install.py. line 48. in exit
input('Press enter to continue.. _')
File string, line 0
  ^
SyntaxError: unexpected EOF while parsing

c:\Python32\eric5-5 .1.8

Robert


___
Eric mailing list
e...@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/eric

--
Detlev Offenbach
det...@die-offenbachs.de 


___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt