Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > logging and PyQt4

Reply
Thread Tools

logging and PyQt4

 
 
Adrian Casey
Guest
Posts: n/a
 
      03-14-2011
I have a multi-threaded PyQt4 application which has both a GUI and command-
line interface. I am using Qt4's threading because from what I have read,
it is more efficient than the native python threading module. Also, given
most users will probably use the GUI, it seemed to make sense.

I want a flexible, threadsafe logging facility for my application so I was
thinking of using python's logging module. I need a logger that can log to
the GUI or a terminal depending on how the application is invoked.

So, my question is -:

Is it wise to use python's logging module in conjunction with Qt4 threads?
If not, what are my options apart from writing my own logging module?

If it is OK, then I would like to know how to subclass the logging class so
that instead of sending output to stdout (as in StreamHandler), it emits Qt4
signals instead.

Any help would be appreciated.

Thank you.
Adrian Casey.
 
Reply With Quote
 
 
 
 
Vinay Sajip
Guest
Posts: n/a
 
      03-15-2011
On Mar 14, 7:40*am, Adrian Casey <m...@agcasey.com> wrote:
> I have a multi-threaded PyQt4 application which has both a GUI and command-
> line interface. *I am using Qt4's threading because from what I have read,
> it is more efficient than the native python threading module. *Also, given
> most users will probably use the GUI, it seemed to make sense. *
>
> I want a flexible, threadsafeloggingfacility for my application so I was
> thinking of using python'sloggingmodule. *I need a logger that can log to
> the GUI or a terminal depending on how the application is invoked.
>
> So, my question is -:
>
> Is it wise to use python'sloggingmodule in conjunction with Qt4 threads? *
> If not, what are my options apart from writing my ownloggingmodule?
>
> If it is OK, then I would like to know how to subclass theloggingclass so
> that instead of sending output to stdout (as in StreamHandler), it emits Qt4
> signals instead.
>
> Any help would be appreciated.
>
> Thank you.
> Adrian Casey.


Logging certainly works well with PyQt4 in multi-threaded
applications, though of course it's based on Python's threading API
rather than Qt's. To direct logging output to a GUI, it would be
appropriate to develop a Qt/PyQt-aware handler class (derived from
logging.Handler) to do the Qt interfacing.

Regards,

Vinay Sajip
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PyQt4.__file__ gives PyQt4/__init__.py as value wgw Python 1 08-15-2009 09:58 PM
QPicture and Qpainter PyQt4 luca72 Python 1 09-17-2007 08:41 AM
pyqt4 signal/slot using PyObject* and shortcut Pradnyesh Sawant Python 0 04-27-2007 05:59 AM
Hey! A VERY c00l feature of X and mplayer(could bind to PyQt4) Marco Python 0 03-04-2007 01:48 PM
Drag and Drop with PyQt4 Harshad Python 2 08-26-2006 11:42 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57