[PyQt] QTextEdit 80 chars wide

2011-01-27 Thread Mads Ipsen

Hi,

Suppose I have a QTextEdit set up with a monospace font. How do I make 
the text edit field exactly 80 chars wide? E.g. similar to a command 
prompt window.


Best regards,

Mads

--
+--+
| Mads Ipsen, Scientific developer |
+---+--+
| QuantumWise A/S   | phone:  +45-29716388 |
| Lersø Parkallé 107| www: www.quantumwise.com |
| DK-2100 Copenhagen Ø, Denmark | email:  mads.ip...@gmail.com |
+---+--+


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


Re: [PyQt] Custom Widget

2011-01-27 Thread Phil Thompson
On Thu, 27 Jan 2011 04:03:48 +0100, Hans-Peter Jansen h...@urpla.net
wrote:
 On Wednesday 26 January 2011, 14:35:35 ferde...@gmail.com wrote:
 Thanks again Pete

 I think i will do my own custom widget from scratch following a book
 i have and then use the link you gave me to integrate it to the
 designer.
 
 As I told you, it is simpler to convert the Qt code.
 
 @Phil: for some reason, the richTextPainter.end() is needed in the PyQt 
 version to avoid a SIGSEGV crash during paint event:
 
 QPaintDevice: Cannot destroy paint device that is being painted
 
 (gdb) bt
 #0  0x08339d10 in ?? ()
 #1  0xb647c3f8 in ~QPainter (this=0x1) at painting/qpainter.cpp:1491
 #2  0xb6fdfe80 in release_QPainter (sipCppV=0x82514d8) at
 sipQtGuiQPainter.cpp:5371
 #3  0xb6fdfedc in dealloc_QPainter (sipSelf=0xb4ae4454) at
 sipQtGuiQPainter.cpp:5382
 #4  0xb7fc4f5f in forgetObject (sw=0xb4ae4454) at siplib.c:10004
 #5  0xb7fc4ff1 in sipSimpleWrapper_dealloc (self=0xb4ae4454) at
 siplib.c:9233
 #6  0xb7eba68d in subtype_dealloc (self=0xb4ae4454) at
 Objects/typeobject.c:1018
 #7  0xb7e8c24a in frame_dealloc (f=0x8301c4c) at
Objects/frameobject.c:417
 #8  0xb7ef8bec in PyEval_EvalCodeEx (co=0xb7c32260, globals=0xb7c7602c,
 locals=0x0, args=0xb7c42418, argcount=2, 
 kws=0x0, kwcount=0, defs=0x0, defcount=0, closure=0x0) at
 Python/ceval.c:2953
 #9  0xb7e8da29 in function_call (func=0xb5f37994, arg=0xb7c4240c,
kw=0x0)
 at Objects/funcobject.c:524
 #10 0xb7e68c1c in PyObject_Call (func=0xb5f37994, arg=0xb7c4240c,
kw=0x0)
 at Objects/abstract.c:2487
 #11 0xb7e769fe in instancemethod_call (func=0xb5f37994, arg=0xb7c4240c,
 kw=0x0) at Objects/classobject.c:2579
 #12 0xb7e68c1c in PyObject_Call (func=0xb7c26694, arg=0xb5f5b02c,
kw=0x0)
 at Objects/abstract.c:2487
 #13 0xb7ef177f in PyEval_CallObjectWithKeywords (func=0xb7c26694,
 arg=0xb5f5b02c, kw=0x0) at Python/ceval.c:3548
 #14 0xb7fc6b03 in sip_api_call_method (isErr=0x0, method=0xb7c26694,
 fmt=0xb721cf4c D) at siplib.c:1721
 #15 0xb6e3b5f9 in sipVH_QtGui_3 (sipGILState=PyGILState_UNLOCKED,
 sipMethod=0xb7c26694, a0=0xbfffdaa4)
 at sipQtGuicmodule.cpp:7343
 #16 0xb7199dc9 in sipQPushButton::paintEvent (this=0x81f0718,
 a0=0xbfffdaa4) at sipQtGuiQPushButton.cpp:420

Probably related to the (random) order that locals are being garbage
collected. As you aren't calling begin() a better solution would be to del
the painter rather than call end().

 Do you want me to prepare that code for inclusion into examples? 

If you want to.

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


Re: [PyQt] Typedefs and SIP

2011-01-27 Thread Phil Thompson
On Wed, 26 Jan 2011 10:18:55 -0800, Nate Reid gnat...@hotmail.com wrote:
 If I'm using a typedef with a MappedType, and a container that's a
 MappedType,  it seems like I have to use a #define to tell SIP that the
 specific typedef is the same as the MappedType.
 E.g.
 
 I've wrapped std::string with MappedType, so it's type is
 sipType_std_string
 
 and I've also wrapped std::set in a MappedType where templateTYPE
 std::setTYPE is defined.
 
 If I do a typedef in my C++ code as:
 // C++ file...
 namespace foo {
 typedef std::string NameType
 }
 
 And also in my SIP file, create an equivalent typedef
 // SIP module file
 namespace foo {
 typedef std::string NameType;
 typedef std::setfoo::NameType SetOfNames; // Aside, it'd be great
if
 SIP knew that NameType was already a member of foo, and I didn't
have
 to explicitly qualify it!
 };
 
 SIP will come back with a compile error like this when using NameType in
 my MappedType for std::set
 python/util/set.sip(73): error: identifier sipType_foo_NameType is
 undefined
   foo::NameType *copy = reinterpret_castfoo::NameType
   *(sipConvertToType(item, sipType_foo_NameType,
   sipTransferObj, SIP_NOT_NONE, state, sipIsErr))
 
 I was able to get rid of the compile error by adding a #define to my
 %ModuleHeaderCode section of the SIP file like this
 %ModuleHeaderCode
 ...
 #define sipType_foo_NameType sipType_std_string
 
 It seems to me that this is fragile.  If I change the namespace of where
 NameType lives, I'd have to manually change all of the #defines,
typedefs
 in the SIP files, etc.  Also, requiring this 'hint' to SIP seems
erroneous
 to me.  Shouldn't the typedef be sufficient for creating a new sipType
in
 the API file?
 Or, am I doing something wrong? :)
 Thanks,
 -Nate

typedef shouldn't create a new sipType because you are creating an alias
to an existing type, not creating a new one. If you move the typedef to a
different namespace then you are changing its name and should expect to
have to make corresponding changes in the rest of your source.

Automatically generating the #defines seems to be a reasonable suggestion.

Phil


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


[PyQt] PyQwt and SIP-4.12.1

2011-01-27 Thread Gerard Vermeulen
Hi,

The following works with sip-4.12 (python compiled in my home directory):

Python 2.6.6 (r266:84292, Jan  8 2011, 16:35:06)
[GCC 4.4.4] on linux2
Type help, copyright, credits or license for more information.
 import PyQt4.Qwt5 as qwt
 import sip
 sip.SIP_VERSION_STR
'4.12'
 qwt.QwtText(Qt.QString(wow))
PyQt4.Qwt5.Qwt.QwtText object at 0x216cb90


but not with sip-4.12.1 (python in Gentoo system):
Python 2.6.6 (r266:84292, Dec 30 2010, 09:16:49)
[GCC 4.4.4] on linux2
Type help, copyright, credits or license for more information.
 import PyQt4.Qwt5 as qwt
 import sip
 sip.SIP_VERSION_STR
'4.12.1'
 qwt.QwtText(Qt.QString(wow))
Traceback (most recent call last):
  File stdin, line 1, in module
TypeError: QwtText(): arguments did not match any overloaded call:
  overload 1: argument 1 has unexpected type 'QString'
  overload 2: argument 1 has unexpected type 'QString'



The relevant part of the sip file for QwtText is attached.

Best regards -- Gerard

// The SIP interface specification for:
//  QwtText.
//
// Copyright (C) 2001-2010 Gerard Vermeulen
// Copyright (C) 2000 Mark Colclough
//
// This file is part of PyQwt.
//
// PyQwt is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// PyQwt is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with PyQwt; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
//
// In addition, as a special exception, Gerard Vermeulen gives permission
// to link PyQwt dynamically with non-free versions of Qt and PyQt,
// and to distribute PyQwt in this form, provided that equally powerful
// versions of Qt and PyQt have been released under the terms of the GNU
// General Public License.
//
// If PyQwt is dynamically linked with non-free versions of Qt and PyQt,
// PyQwt becomes a free plug-in for a non-free program.


class QwtText
{
%TypeHeaderCode
#include qwt_text.h
%End // %TypeHeaderCode

public:
enum TextFormat {
AutoText,
PlainText,
RichText,
MathMLText,
TeXText,
OtherFormat
}; // enum TextFormat

enum PaintAttribute {
PaintUsingTextFont,
PaintUsingTextColor,
PaintBackground
}; // enum PaintAttribute

enum LayoutAttribute {
MinimumLayout
}; // enum LayoutAttribute

QwtText();
QwtText(const QString);
QwtText(const QString, QwtText::TextFormat);
QwtText(const QwtText);
~QwtText();
// Not Pythonic: QwtText operator=(const QwtText);
int operator==(const QwtText) const;
int operator!=(const QwtText) const;
void setText(const QString, QwtText::TextFormat = QwtText::AutoText);
QString text() const;
bool isNull() const;
bool isEmpty() const;
void setFont(const QFont);
QFont font() const;
QFont usedFont(const QFont) const;
void setRenderFlags(int);
int renderFlags() const;
void setColor(const QColor);
QColor color() const;
QColor usedColor(const QColor) const;
void setBackgroundPen(const QPen);
QPen backgroundPen() const;
void setBackgroundBrush(const QBrush);
QBrush backgroundBrush() const;
void setPaintAttribute(QwtText::PaintAttribute, bool = true);
bool testPaintAttribute(QwtText::PaintAttribute) const;
void setLayoutAttribute(QwtText::LayoutAttribute, bool = true);
bool testLayoutAttribute(QwtText::LayoutAttribute) const;
int heightForWidth(int, const QFont = QFont()) const;
QSize textSize(const QFont = QFont()) const;
void draw(QPainter*, const QRect) const;
static const QwtTextEngine* textEngine(const QString, QwtText::TextFormat 
= QwtText::AutoText);
static const QwtTextEngine* textEngine(QwtText::TextFormat);
static void setTextEngine(QwtText::TextFormat, QwtTextEngine*);
}; // class QwtText


// Local Variables:
// mode: C++
// c-file-style: stroustrup
// indent-tabs-mode: nil
// End:
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] QWebView, Google Maps issue on Windows.

2011-01-27 Thread Thomas Mansencal
Apparently it's not the fact of PyQt, I just did a quick example in C++ and
it's the same. I opened a ticket on Qt tracker :
http://bugreports.qt.nokia.com/browse/QTBUG-16970

Here is the C++ snippet :

#include QtGui/QApplication
#include QtWebKit

int main(int argc, char *argv[])
{
QApplication a(argc, argv);

QWebView *webview = new QWebView();
webview-load(QUrl(
http://code.google.com/intl/fr-FR/apis/maps/documentation/javascript/examples/map-simple.html
));
webview-show();
return a.exec();
}

By the way when I wrote this : I was previously using 4.7.3 and had no
particular issue I meant 4.6.3.

Cheers,

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

[PyQt] memory leak on a Mac

2011-01-27 Thread Danny Shevitz
Howdy,

I have an app that works just fine on the one click windows distro. 

I just tried to run the same app on a Mac for the first time. I am nobody's
Mac expert, but I did manage to get the latest PyQt4, Sip, QScintilla working.

When I run my app on the Mac, I get the following:

macshev:elm3 shev$ python elm3.py
2011-01-27 09:02:06.705 Python[16663:613] *** _NSAutoreleaseNoPool(): Object
0xae0e30 of class NSCFNumber autoreleased with no pool in place - just leaking
Stack: (0x97805f4f 0x97712432 0x97714c3a 0x22c36b7 0x232ecca 0x232f126 0x1e60363
0x1e65287 0x1023d6 0x4f49a6 0x497caa 0x53a916 0x53da4b 0x53eb8b 0x53ed42
0x562c4b 0x563a53 0x574248)

The app still runs, but evidently I am leaking memory. My app is pure PyQt, no
C is involved. I can't even begin to guess how to diagnose this problem.
Does anyone have any ideas? 

MacOs 10.5.8
Python 2.6.2
sip 4.12.1
PyQt 4.8.3
QScintilla 2.4.6

thanks,
Danny


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


Re: [PyQt] memory leak on a Mac

2011-01-27 Thread Arne Schmitz
Am 27.01.2011 um 18:12 schrieb Danny Shevitz:

 Any PyQt application generates the same message. If I run something from the
 samples directory, I get the same memory leak, so it is nothing in my code.


I don't have those problems. How did you install PyQt? I use MacPorts (using 
Python 2.7). 

Regards,

Arne

-- 
Dipl.-Inform. Arne Schmitz  Phone   +49 (0)241 80-21817
Computer Graphics Group Mobile  +49 (0)151 29145947
RWTH Aachen University  Fax +49 (0)241 80-22899
Ahornstrasse 55, 52074 Aachen, Germany  http://www.rwth-graphics.de

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


Re: [PyQt] memory leak on a Mac

2011-01-27 Thread Danny Shevitz
Arne Schmitz arne.schmitz at gmx.net writes:

 
 Am 27.01.2011 um 18:12 schrieb Danny Shevitz:
 
  Any PyQt application generates the same message. If I run something from the
  samples directory, I get the same memory leak, so it is nothing in my code.
 
 I don't have those problems. How did you install PyQt? I use MacPorts (using
Python 2.7). 
 
 Regards,
 
 Arne
 
I got the gzipped tarball, unpacked it. cd'ed to the directory. Then I 
ran:
python configure.py
make
make install.

I had to do this for sip as well.

D




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


[PyQt] Previous PyQt Releases

2011-01-27 Thread Thomas Mansencal
Hi,

Is there a way to access previous PyQt releases somewhere ? I'm searching
for that release : PyQt-Py2.6-gpl-4.7.3-2.exe but for python 2.7 ( if it
exists at all ).

Thanks,

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

[PyQt] QProgressBar : CPU usage on Snow Leopard 10.6.6

2011-01-27 Thread Capa/Aurelien
Dear all,

I am writing an application (music player) using a progress bar in order to
display the timeline of a song.
My problem is that the QProgressBar object is a bit burning my CPU :

   - 1% of usage to display an empty progress bar.
   - 6% to display a progress bar with a value.

Here is my configuration :

   - Mac book pro Intel Core 2 Duo 2.4GHz, 4Go RAM.
   - Qt-4.7.1 library (32 and 64bits), it's the open-source dmg version.
   - SIP-4.12 (32 and 64bits)
   - PyQt-mac-gpl-4.8.2 (32 and 64bits)
   - Python-2.7 standalone (32 and 64bits)

Here is the source code of an empty application with the same behavior :


#!/usr/bin/env python


import sys

from PyQt4 import QtGui, QtCore


class
MainWindow(QtGui.QMainWindow):

def __init__(self):

QtGui.QMainWindow.__init__(self)



pb = QtGui.QProgressBar(self)

pb.setRange(0, 100)

pb.setValue(34)


app = QtGui.QApplication(sys.argv)

main = MainWindow()

main.show()

sys.exit(app.exec_())


Is it the normal CPU usage for a QProgressBar, or how can I fix it?

Regards,

-- 
Aurélien
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] Capture drop in a QTableWidget

2011-01-27 Thread starglider develop
Hi,
I'm new to PyQt and I have a problem, search de google, PyQt docs, Mr.
Summerfield's  book, but
was unable to find a way of sort it.

I have a QListWidget and  a QTableWidget all have the drag and drop enable,
I use this example:
http://zetcode.com/tutorials/pyqt4/dragdrop/

it works fine because the text in the ListWidget goes to the TableWidget and
I can further process it,
but I need to pick the text immediately after it is drooped in the
WidgetList without the need of click in the cell.

Tried:
SIGNAL(itemChanged(QTableWidgetItem*))
SIGNAL(currentItemChanged(QTableWidgetItem *,QTableWidgetItem *))

without result.

If any one can help I really appreciate.

Thank you in advance for your cooperation.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt