Re: [PyQt] Fwd: threading and qt warnings

2007-09-07 Thread Darren Dale
On Friday 07 September 2007 04:09:02 am Phil Thompson wrote:
 On Thursday 06 September 2007, Darren Dale wrote:
  Hello,
 
  I am writing some code to allow a pyqt4 program to be run with ipython in
  a separate thread. Using python-2.5.1, qt-4.3.1 and pyqt-4.3, I get the
  following warning messages at each timeout:
 
  QSocketNotifier: Can only be used with threads started with QThread
  QApplication::exec: Must be called from the main thread
 
  A short standalone script that reproduces this behavior is attached. If I
  comment out the raw_input statement on line 21, and uncomment lines 22
  and 23, then I do not get the warnings.
 
  I reported the issue at Trolltech, and they suggested that I was somehow
  calling exec_ at every timeout, but I think I am only calling it once.
  They also suggested that I could silence the warnings, and pointed me to
  http://doc.trolltech.com/4.3/qtglobal.html#qWarning, but I was not able
  to silence the warnings by defining a python global QT_NO_WARNING_OUTPUT,
  or an environment variable QT_FATAL_WARNINGS. Is it possible to silence
  these warnings with PyQt4?
 
  If anyone was willing to have a look at the attached script and comment,
  I would really appreciate it.
 
  Thank you,
  Darren

 Try current snapshots.

I just installed the most recent snapshots of qt-4.3.2, sip, and PyQt4 (using 
custom gentoo ebuilds). I am very happy to report that they solved the issue 
I reported. Thank you very much!

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


[PyQt] Re: How to set some attributes to the Application Window

2007-09-07 Thread Gustavo A. Díaz
Non help about this? :(

2007/9/5, Gustavo A. Díaz [EMAIL PROTECTED]:

 Hi !

 I was searching a lot and playing around with setFlags to my mainWindow to
 make possible two things:

 - I want to disable my app to be placed on the taskbar/kicker/whatever
 when i execute it, cause i do not use minimize function (like an applet
 style)
 - I want this window to be always on bottom of all the rest of the
 windows/apps (again, like an applet Style)

 What did I've tested?

 - To disable the window from being in the task bar, I've tested 2 flags:

 *One is the QtCore.Qt.Dialog, which does not do what i want, indeed
 does nothing... my app still is available to minimize by the user.
 *Second, I've tested this time with
 QtCore.Qt.X11BypassWindowManagerHint which do what i want, the app.
 disappear from the taskbar but the window stay always on top. So this
 conflict with the first thing i want that is to put the app always on bottom
 of all windows/apps.

 - To place the app always on bottom: I don't know how to do this.

 The code, just in case:
 http://opencoffee.lnxteam.org/trac/browser/trunk/opencoffee-client/MainApp.py

 I will be thankful if someone could guide me here.

 Cheers.


 --
 Gustavo A. Díaz
 GDNet Projects
 www.gdnet.com.ar




-- 
Gustavo A. Díaz
GDNet Projects
www.gdnet.com.ar
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] deleting QTreeWidgetItem

2007-09-07 Thread Michael Towers

Phil Thompson wrote:

On Friday 07 September 2007, Michael Towers wrote:
  

Hi all,

Could someone confirm (or otherwise!) my understanding of the way PyQt4
deals with management of Qt objects? If I want to delete a
QTreeWidgetItem and all its children from a tree (and release all
connected storage), is it enough to do the following?

 p = item.parent()
 p.removeChild(item)
item = None

(assuming item is the only python reference to the QTreeWidgetItem).



Correct.

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

  

Thanks, Phil. I'm really enjoying PyQt4!

Best wishes,
mt

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


[PyQt] Catching Qt exceptions in PyQt

2007-09-07 Thread Dirk Wagener

Hi

I have a piece of code that produces this error:

Qt has caught an exception thrown from an event handler. Throwing 
exceptions from an event handler is not supported in Qt.
You must reimplement QApplication::notify() and catch all exceptions 
there. 


I implemented my own app class as follows:

class Application (QtGui.QApplication):
   def __init__(self, argv):
   QtGui.QApplication.__init__(self, argv)

   def notify(self, obj, evt):
   try:
   # Call base class notify.
   return QtGui.QApplication.notify(self, obj, evt)
   except Exception:
   print Unexpected error:, 
string.join(traceback.format_exception(*sys.exc_info()))

   return False

My code still produces exactly the same error, so it seems that the 
exception is still not caught!

What am I doing wrong here?

Kind regards
Dirk Wagener
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] a CustomEvent in KTMLPart crashes eventFilter

2007-09-07 Thread Jean-Michel Vourgère
Hi.

I've been digging into a bug for a few days, now. After upgrading from Debian 
Sarge to Etch, our python application crashes (SEGV) if we install an event 
filter.
Attached is a minimal example of the problem.

The application doesn't crash when commenting out the installEventFilter, 
despite the fact it does nothing.

Does any one has a cue?
I suspect a problem in KHTML sending a signal to a deleted object.
It could also be that the void *data of the QCustomEvent causes problems in 
sip that can't possibly convert its type...
Or maybe I'm just doing something wrong that will look obvious to an expert ^^

(gdb) bt
#0  0xb781a1fd in sipQLayoutItem::sizeHint () from 
/usr/lib/python2.4/site-packages/qt.so
#1  0xb7307264 in sip_api_convert_from_void_ptr () from 
/usr/lib/python2.4/site-packages/sip.so
#2  0xb7307470 in sip_api_convert_from_void_ptr () from 
/usr/lib/python2.4/site-packages/sip.so
#3  0x0808b9f3 in PyType_GenericAlloc ()
#4  0x08089495 in PyTuple_Size ()
#5  0xb72ffbc8 in sip_api_free () from /usr/lib/python2.4/site-packages/sip.so
#6  0xb75ce7f2 in sipVH_qt_177 () from /usr/lib/python2.4/site-packages/qt.so
#7  0xb787cb70 in sipQObject::eventFilter () from 
/usr/lib/python2.4/site-packages/qt.so
#8  0xb6db4a18 in QApplication::internalNotify (this=0x82ade78, 
receiver=0x82eb258, e=0xbfc20594) at kernel/qapplication.cpp:2568
#9  0xb6db6a43 in QApplication::notify (this=0x82ade78, receiver=0x82eb258, 
e=0xbfc20594) at kernel/qapplication.cpp:2358
#10 0xb647ae0e in KApplication::notify (this=0x82ade78, receiver=0x82eb258, 
event=0xbfc20594) at 
/tmp/buildd/kdelibs-3.5.5a.dfsg.1/./kdecore/kapplication.cpp:550
#11 0xb65fa0cf in sipKApplication::notify () from 
/usr/lib/python2.4/site-packages/kdecore.so
#12 0x082ade78 in ?? ()
#13 0x082eb258 in ?? ()
#14 0xbfc20594 in ?? ()
#15 0x in ?? ()

Last events received:
...
DEBUG:root:Event: kdeui.KPopupMenu object at 0xb7ae21ec , qt.QResizeEvent 
object at 0xb7ae222c
DEBUG:root:Event: kdeui.KPopupMenu object at 0xb7ae21ec , qt.QMoveEvent 
object at 0xb7ae222c
DEBUG:root:Event: kdeui.KPopupMenu object at 0xb7ae21ec , qt.QResizeEvent 
object at 0xb7ae222c
DEBUG:root:Event: qt.QWidget object at 0xb7ae21ec , qt.QPaintEvent object at 
0xb7ae222c
DEBUG:root:Event: __main__.HTMLPart object at 0xb7ae216c , qt.QCustomEvent 
object at 0xb7ae21ec
Program received signal SIGSEGV, Segmentation fault.

Versions of Debian Etch:
python  2.4.4-2
kdelibs 4:3.5.5a.dfsg.1-8
python-sip4 4.4.5-4
python-qt3  3.16-1.2
python-kde3 3.15.2+20060422-3

-- Jean-Michel Vourgère
Dental-on-Line - 23 rue du Départ - 75014 Paris
+33 1 43 27 84 88


kaboum.py
Description: application/python
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Catching Qt exceptions in PyQt

2007-09-07 Thread Claudio A. Quezada R.
Hello, i´ve got the very same trouble several of times, and i tried to
reimplement notify, but the same exception was thrown over and over
again.

I changed the code (finding where was the error) and exception didn´t
appear again. It´s seems easier debug and change the code than
reimplement QApplication notify, at least for me. Probably silly
errors (like setItem to a QTableWidget that isn´t enabled, or setText
on a QTableWidgetItem that don´t exists) are common.

Anyway, if anyone get QApplication notify works, post it at the list.

Cheers,

Claudio

2007/9/7, Allen Bierbaum [EMAIL PROTECTED]:
 I don't know what you are doing wrong or what causes this, but I do
 know that we see it all the time when trying to debug and it makes the
 entire process very painful.  If you find any type of solution that
 works so you can see the exception that is being thrown, please let me
 know so we can use it.

 -Allen

 On 9/7/07, Dirk Wagener [EMAIL PROTECTED] wrote:
  Hi
 
  I have a piece of code that produces this error:
 
  Qt has caught an exception thrown from an event handler. Throwing
  exceptions from an event handler is not supported in Qt.
  You must reimplement QApplication::notify() and catch all exceptions
  there. 
 
  I implemented my own app class as follows:
 
  class Application (QtGui.QApplication):
  def __init__(self, argv):
  QtGui.QApplication.__init__(self, argv)
 
  def notify(self, obj, evt):
  try:
  # Call base class notify.
  return QtGui.QApplication.notify(self, obj, evt)
  except Exception:
  print Unexpected error:,
  string.join(traceback.format_exception(*sys.exc_info()))
  return False
 
  My code still produces exactly the same error, so it seems that the
  exception is still not caught!
  What am I doing wrong here?
 
  Kind regards
  Dirk Wagener
  ___
  PyQt mailing listPyQt@riverbankcomputing.com
  http://www.riverbankcomputing.com/mailman/listinfo/pyqt
 
 ___
 PyQt mailing listPyQt@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt



-- 
Claudio Quezada Romegialli
Ingeniero Ambiental
(02)7321665 - 81466049

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


[PyQt] deleting QTreeWidgetItem

2007-09-07 Thread Michael Towers

Hi all,

Could someone confirm (or otherwise!) my understanding of the way PyQt4 
deals with management of Qt objects? If I want to delete a 
QTreeWidgetItem and all its children from a tree (and release all 
connected storage), is it enough to do the following?


p = item.parent()
p.removeChild(item)
item = None

(assuming item is the only python reference to the QTreeWidgetItem).

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


Re: [PyQt] Catching Qt exceptions in PyQt

2007-09-07 Thread Allen Bierbaum
I don't know what you are doing wrong or what causes this, but I do
know that we see it all the time when trying to debug and it makes the
entire process very painful.  If you find any type of solution that
works so you can see the exception that is being thrown, please let me
know so we can use it.

-Allen

On 9/7/07, Dirk Wagener [EMAIL PROTECTED] wrote:
 Hi

 I have a piece of code that produces this error:

 Qt has caught an exception thrown from an event handler. Throwing
 exceptions from an event handler is not supported in Qt.
 You must reimplement QApplication::notify() and catch all exceptions
 there. 

 I implemented my own app class as follows:

 class Application (QtGui.QApplication):
 def __init__(self, argv):
 QtGui.QApplication.__init__(self, argv)

 def notify(self, obj, evt):
 try:
 # Call base class notify.
 return QtGui.QApplication.notify(self, obj, evt)
 except Exception:
 print Unexpected error:,
 string.join(traceback.format_exception(*sys.exc_info()))
 return False

 My code still produces exactly the same error, so it seems that the
 exception is still not caught!
 What am I doing wrong here?

 Kind regards
 Dirk Wagener
 ___
 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] Fwd: threading and qt warnings

2007-09-07 Thread Phil Thompson
On Thursday 06 September 2007, Darren Dale wrote:
 Hello,

 I am writing some code to allow a pyqt4 program to be run with ipython in a
 separate thread. Using python-2.5.1, qt-4.3.1 and pyqt-4.3, I get the
 following warning messages at each timeout:

 QSocketNotifier: Can only be used with threads started with QThread
 QApplication::exec: Must be called from the main thread

 A short standalone script that reproduces this behavior is attached. If I
 comment out the raw_input statement on line 21, and uncomment lines 22 and
 23, then I do not get the warnings.

 I reported the issue at Trolltech, and they suggested that I was somehow
 calling exec_ at every timeout, but I think I am only calling it once. They
 also suggested that I could silence the warnings, and pointed me to
 http://doc.trolltech.com/4.3/qtglobal.html#qWarning, but I was not able to
 silence the warnings by defining a python global QT_NO_WARNING_OUTPUT, or
 an environment variable QT_FATAL_WARNINGS. Is it possible to silence these
 warnings with PyQt4?

 If anyone was willing to have a look at the attached script and comment, I
 would really appreciate it.

 Thank you,
 Darren

Try current snapshots.

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


Re: [PyQt] a CustomEvent in KTMLPart crashes eventFilter

2007-09-07 Thread Jim Bublitz
One additional comment (that just occurred to me)  - your version will work if 
you don't try to display a page (begin - write - end) before starting the 
event loop in KApplication.

That's probably what's causing the crash.

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


[PyQt] Adding properties to a custom widget

2007-09-07 Thread skawaii

I've looked around and tried things for a couple of days now, but haven't
been able to figure this out quite yet.

I've created a custom widget in Qt Designer. It's working great and I'd like
to be able to use this widget in future GUI's that I make (obviously). When
in the Edit Custom Widgets dialog (Tools  Custom), I tried to add some
properties that I'd like visible in Designer for future use. For example, a
property called precision that is an int. Fantastic.

I added my widget to a new dialog as a test. Compiled the ui file to python,
which has the following line -
self.fValuator2.setProperty(precision,QVariant(3)).

However, when I run this test dialog (i.e. python test_dialog.py), I get the
following error -
QWidget::setProperty( display_precision, value ) failed: property invalid,
read-only or does not exist.

So, it seems the adding the property in Designer does not equate to the
property being created in my widget class. And this is where I hit a dead
end. How do i create this property in my widget class? I looked at the 
http://doc.trolltech.com/3.3/properties.html Qt docs  on properties;
however, I can't seem to figure out where the Q_PROPERTY macro is in PyQt
3.3.6 (upgrading to version 4.3 isn't an option for me, unfortunately). I've
also found some material 
http://www.diotavelli.net/PyQtWiki/Using_Python_Custom_Widgets_in_Qt_Designer
here , but it's again for PyQt 4.3 and doesn't seem that it'll work for me.

Any suggestions out there? Thanks in advance.
-- 
View this message in context: 
http://www.nabble.com/Adding-properties-to-a-custom-widget-tf4403448.html#a12562213
Sent from the PyQt mailing list archive at Nabble.com.

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