Re: [PyQt] Delaying splash screen

2011-09-09 Thread Hans-Peter Jansen
Am Thursday 08 September 2011 00:32:17 schrieb Muhammad Bashir Al-Noimi:
 On 07/09/2011 11:27 م, Hans-Peter Jansen wrote:
 On Wednesday 07 September 2011, 14:04:02 ad...@mbnoimi.net wrote:

 Hi guys,

  I wrote a tiny class for delaying splash screen in C++ but when I
 tired to re-write it in python it didn't work!

  I got AttributeError TeSplashScreen object has no attribut QFrate
 although TeSplashScreen inherited from QFrame

  Could you please help me, I'm still a newbie in PyQt and Python.

  tesplashscreen.py

 from PyQt4.QtCore import *
 from PyQt4.QtGui import *

 Hmm, that * imports are easily avoided.
  Thanks a lot Pete, You mean I don't need to use both import lines?

Well, do it sanely with (the proposed standard of):

from PyQt4 import QtCore, QtGui

You will learn something about the structure of Qt, that is also helpful 
in understanding the basic concepts.

 import sys
 class TeSplashScreen(QFrame):
 
 Splash doc
 

 app = QApplication(sys.argv)
 sPixmap = QPixmap(10,  10)
 sMessage = QString()
 messages = [nothing]
 sAlignment = 0
 sColor = QColor()

 def __init__(self,  pixmap):

 You need to call the base class c'tor here, e.g.:

   super(QFrame, self).__init__()

 Most of your code below has issues with missing self. references,
 which will result in access to undefined variables and instances,
 that are prematurely garbarge collected.
  I did as you mentioned exactly.
  I got new issue because I don't know how can I use QStringList
 class, I read in some article that it's unavailable in PyQt

Huch

Python 2.6.2 (r262:71600, May 25 2011, 11:48:28) 
[GCC 4.3.2 [gcc-4_3-branch revision 141291]] on linux2
Type help, copyright, credits or license for more information.
 from PyQt4 import QtCore
 sl = QtCore.QStringList()
 map(sl.append, (a, b, c, d, e))
[None, None, None, None, None]
 print sl.join(..)
a..b..c..d..e

 so I 
 tried to use python lists instead but I got an exception at for loop

 TypeError object of type int has no len()

You seem to supply an int as second argument to showSplash.

  here's the modified class:

 from PyQt4.QtCore import *
 from PyQt4.QtGui import *
 import sys
 class TeSplashScreen(QFrame):
 
 Splash doc
 

 app = QApplication(sys.argv)
 sPixmap = QPixmap(10,  10)
 sMessage = QString()
 #messages = [nothing]
 sAlignment = 0
 sColor = QColor()

 def __init__(self,  pixmap):
 super(QFrame,  self).__init__()
 self.sPixmap =  pixmap

 self.setWindowFlags(Qt.FramelessWindowHint|Qt.WindowStaysOnTopHint)
 self.setAttribute(Qt.WA_TranslucentBackground)
 self.setFixedSize(self.sPixmap.size())

 def clearMessage(self):
 self.sMessage.clear()
 self.repaint()

 def showMessage(self,  theMessage, theAlignment, theColor):
 self.sMessage  = theMessage
 self.sAlignment = theAlignment
 self.sColor  = theColor
 self.repaint()

 def paintEvent(self, pe):
 aTextRect = QRect(self.rect())
 aTextRect.setRect(aTextRect.x()+5, aTextRect.y()+5,
 aTextRect.width()-10, aTextRect.height()-10) aPainter =
 QPainter(self)
 aPainter.drawPixmap(self.rect(), self.sPixmap)
 aPainter.setPen(self.sColor)
 aPainter.drawText(aTextRect, self.sAlignment, self.sMessage)

 def showSplash(self,  delay, messages, alignment, color):
 delay = 0
 #self.messages = messages
 alignment = 0
 color = QColor(color)
 class SleeperThread(QThread):
 msecs = 0
 QThread.msleep(msecs)
 aSplashScreen = TeSplashScreen(self.sPixmap)
 aSplashScreen.show
 for i in range(len(messages)):
 aSplashScreen.showMessage(messages[i], alignment, color)
 SleeperThread.msleep(delay)

Don't expect this to work correctly. Does it? If you want to delay the 
messages, do it with QTimer triggered updates.

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

Re: [PyQt] segv crashes on mac os around signal statements

2011-09-09 Thread Hans-Peter Jansen
Am Friday 09 September 2011 00:27:22 schrieb David Cortesi:
 I am experimenting with trying to implement a custom signal and
 having a lot of trouble with the syntax of connect, etc, and while
 making various changes I am getting frequent SEGV crashes in the
 QtCore plugin. Below is the abbreviated head of a crash report.

 Does anybody want to know about these? I don't see any way to submit
 them at riverbank.

You did already ;) but you will need to provide a minimum runnable 
example to get further help.

Pete

 Path:
 /System/Library/Frameworks/Python.framework/Versions/2.6/Resources/Py
thon.app/Contents/MacOS/Python Version: 2.6 (2.6)
 Build Info:  python-440200~2
 Code Type:   X86-64 (Native)
 PlugIn Path:  
 /Library/Frameworks/QtCore.framework/Versions/4/QtCore PlugIn
 Identifier: QtCore
 PlugIn Version:4.7.2 (compatibility 4.7.0)

 Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
 Exception Codes: KERN_INVALID_ADDRESS at 0x0001148cc000
 Crashed Thread:  0  Dispatch queue: com.apple.main-thread
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] override className() in QMetaClass

2011-09-09 Thread Daniel Goertzen
Thank you Rafeal, I forgot about that usage of metaclasses.  It certainly
cleans things up for me.  One thing of note is that the metaclass of QWidget
is not 'type', but 'pyqtWrapperType'.  So the invocation should be...

pyqtWrapperType(name, (gui.QWidget,),{'spam':spam, 'yam': yam})

... or more generically

gui.QWidget.__class__(name, (gui.QWidget,),{'spam':spam, 'yam': yam})


Thanks again,
Dan.

2011/9/9 Rafael Durán Castañeda rafadurancastan...@gmail.com

 **
 I think you can do something like this:

  import PyQt4.QtGui as gui
  def factory(name):
 ... def spam(): pass
 ... def yam(): pass
 ... return type(name, (gui.QWidget,),{'spam':spam, 'yam': yam})
 ...
  MyClass = factory('MyClass')
  MyClass.__mro__
 (class '__main__.MyClass', class 'PyQt4.QtGui.QWidget', class
 'PyQt4.QtCore.QObject', type 'sip.wrapper', class
 'PyQt4.QtGui.QPaintDevice', type 'sip.simplewrapper', type 'object')


 On 08/09/11 23:33, Daniel Goertzen wrote:

 Does pyqt provide a way to override the class name when deriving a QObject
 based class?

  An example of why this is wanted:

  def my_widget_class_factory(...):
class temp(QWidget):
   ...(dynamically generate class attributes and methods)
return temp

  All classes generated by the above function will come back with
 className() as temp.  This causes headaches for Designer.

  I know I can add a metaclass to mangle the class name, but I was
 wondering there was an easier way (ie, does QObject's metaclass provided a
 way to rename the class?)

  Thanks,
 Dan.


 ___
 PyQt mailing list
 PyQt@riverbankcomputing.comhttp://www.riverbankcomputing.com/mailman/listinfo/pyqt



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




-- 
*Daniel Goertzen
Senior Software Engineer
*--
*Network Integrity Systems
*We Bring Security To Light™

1937 Tate Blvd. SE
Hickory, North Carolina 28602

Phone: 828.610.4596
Fax: 828.322.5294

http://www.networkintegritysystems.com/

Visit our Blog at:
http://sipreasy.blogspot.com/
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Embedding MPlayer in a QWidget // painting problems

2011-09-09 Thread Timothy W. Grove
Thanks, I'm giving VLC a try and it seems to be working okay. Probably a 
question for the VLC forums (I'll copy a post there in a minute...), but 
I don't understand why I can't get autocropping to work. I'm using 
self.Instance = vlc.Instance(--no-audio, --play-and-pause, 
--autocrop)  within my program, and I've tried using the same 
arguments on the command line but no joy. Should I be adding any other 
arguments to include this filter? I'm using the precompiled version of 
vlc.py which came with the Qt bindings; under Windows 7, PyQt4 and 
Python 3.2.


MPlayer was also working well embedded into a QWidget, only the 
background was destroyed in resizing when paused or stopped as described 
in my earlier posting below. I attempted also to take screenshots using 
QPixmap.grabWindow() and .grabWidget() but these only return an empty 
image. I'd still like to understand this behaviour if anyone has any 
ideas. Thanks.


Best regards,
Timothy Grove

On 04/09/2011 13:45, Jo Jürgens wrote:
If you can use VLC instead of Mplayer, there are Python/Qt bindings 
for it that seem to work fine


http://wiki.videolan.org/Python_bindings

On Sun, Aug 28, 2011 at 4:27 PM, Timothy W. Grove tim_gr...@sil.org 
mailto:tim_gr...@sil.org wrote:


I've been successful in embedding the MPlayer video player into a
QWidget thanks to the PyMPlayer application
(http://code.google.com/p/python-mplayer/). Resizing the QWidget
resizes a movie just fine while the movie is playing, but once a
movie is paused or stopped, no resizing of the displayed frame
occurrs and even worse, if the window size is decreased so that it
covers the movie, that area of the movie frame is erased. I'm
wondering if someone could suggest what issues 'might' be involved
here? Thanks for any ideas!

Best regards,
Tim
___
PyQt mailing list PyQt@riverbankcomputing.com
mailto:PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


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

[PyQt] Icon size and label position in QPushButton?

2011-09-09 Thread Maxwell, Thomas P. (GSFC-606.2)[SCIENCE APPLICATIONS INTL CORP]
I am creating a button with an icon:

icon = QIcon ( iconFile )
button = QPushButton(  icon, label, parent )

The icon as saved in the file is rather large, but is always scaled down to
a tiny size when displayed in the button.   Is there any way to get the
QPushButton to display the icon at full size?Also, is there any way to
get the QPushButton to display the label below the icon (instead of to the
right)?

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


Re: [PyQt] Icon size and label position in QPushButton?

2011-09-09 Thread Vincent Vande Vyvre


  
  
Le 09/09/11 16:05, Maxwell, Thomas P. (GSFC-606.2)[SCIENCE
APPLICATIONS INTL CORP] a crit:

  I am creating a button with an icon:

icon = QIcon ( iconFile )
button = QPushButton(  icon, label, parent )

The icon as saved in the file is rather large, but is always scaled down to
a tiny size when displayed in the button.   Is there any way to get the
QPushButton to display the icon at full size?Also, is there any way to
get the QPushButton to display the label below the icon (instead of to the
right)?

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



For the icon you can fix his size

button.setIconSize(32, 32)

... if the button's size is minimum 32 x 32

For the position of text, consider to use QToolButton instead of
QPushButton

button.setToolButtonStyle(style)

See here for style:


http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qt.html#ToolButtonStyle-enum

Regards
-- 
  Vincent V.V.
  Oqapy . Qarte+7 . PaQager
  


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

Re: [PyQt] Embedding MPlayer in a QWidget // painting problems

2011-09-09 Thread emmanuel_mayssat

Just out of curiosity, why don't you use phonon?
I currently using mplayer and saw that phonon can now display rtsp streams 
(which I use)
Is there a reason not to use phonon and go with mplayer/vlc?
Regards,
--
Emmanuel

On 14:55 Fri 09 Sep , Timothy W. Grove wrote:
 Thanks, I'm giving VLC a try and it seems to be working okay. Probably a  
 question for the VLC forums (I'll copy a post there in a minute...), but  
 I don't understand why I can't get autocropping to work. I'm using  
 self.Instance = vlc.Instance(--no-audio, --play-and-pause,  
 --autocrop)  within my program, and I've tried using the same  
 arguments on the command line but no joy. Should I be adding any other  
 arguments to include this filter? I'm using the precompiled version of  
 vlc.py which came with the Qt bindings; under Windows 7, PyQt4 and  
 Python 3.2.

 MPlayer was also working well embedded into a QWidget, only the  
 background was destroyed in resizing when paused or stopped as described  
 in my earlier posting below. I attempted also to take screenshots using  
 QPixmap.grabWindow() and .grabWidget() but these only return an empty  
 image. I'd still like to understand this behaviour if anyone has any  
 ideas. Thanks.

 Best regards,
 Timothy Grove

 On 04/09/2011 13:45, Jo Jürgens wrote:
 If you can use VLC instead of Mplayer, there are Python/Qt bindings  
 for it that seem to work fine

 http://wiki.videolan.org/Python_bindings

 On Sun, Aug 28, 2011 at 4:27 PM, Timothy W. Grove tim_gr...@sil.org  
 mailto:tim_gr...@sil.org wrote:

 I've been successful in embedding the MPlayer video player into a
 QWidget thanks to the PyMPlayer application
 (http://code.google.com/p/python-mplayer/). Resizing the QWidget
 resizes a movie just fine while the movie is playing, but once a
 movie is paused or stopped, no resizing of the displayed frame
 occurrs and even worse, if the window size is decreased so that it
 covers the movie, that area of the movie frame is erased. I'm
 wondering if someone could suggest what issues 'might' be involved
 here? Thanks for any ideas!

 Best regards,
 Tim
 ___
 PyQt mailing list PyQt@riverbankcomputing.com
 mailto:PyQt@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt



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

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


[PyQt] [SIP] Python crash with QString

2011-09-09 Thread Jens Thoms Toerring
Hi,

   I've got a SIP wrapper for a C++ library and have some issue
with running under Win32 after compiling with Visual Studio 10.
Within the library I have a number of functions that return
QString objects or (mostly const) references. Under Linux every-
thing works fine, e.g. if I do in a Python script

  print yaba.Version.text( )

I get the version string (which is a QString returned by the
wrapped library) output to the screen. Under Windows Python
crashes after outputting the string with an access violation
(C005). The crash seems to happen whenever I use a QString
object (or reference) returned by the library wrapped with SIP,
e.g. also

  print yaba.Version.text( ).length( )

crashes. The same happens with all other methods of the
QString class I tried.

I can avoid the crash in this case by assigning the QString
object to another Python variable first, i.e. with

   dummy = yaba.Version.text( )
   print dummy

it seems to work.

To confirm that this is a problem with QString I then wrote
an extremely simple library, containing just a single class
with a single (static) method that returns a QString, plus an
equally simple SIP wrapper for it. Again, everything works
fine under Linux but crashes under Windows the first time the
QString (or PyQt4.QtCore.QString) object is used. And with
this much simplified library even the trick of copying
the QString to a local variable first doesn't work anymore.
The error is again an access violation and as far as I can
tell it seems to be an attempt to write to address 0x0.

The SIP version I'm using under Windows is 4.12.2 (under
Linux it's 4.10.1). The Windows version is 7 Professional
32-bit and the compiler Visual Studio 10. Has anyone an idea
what could be behind this? Since I have nearly no experience
with Windows and, after having struggled for two weeks to get
the whole stuff to built, I'm not too keen on spending what's
probably's going to be another month to learn how to obtain a
debug built under this environment, thus I can at the moment
only report my observations and no more details...

To check for possible memory problems with the simple library
(though I can't see where any could come from) I also run the
Linux version under valgrind and just got the usual complaints
about stuff from what looks like somewhere deep in the inter-
nals Python, but nothing that would let me suspect that there's
anything broken in the library.

I append the relevant code of the simple library and SIP wrap-
per below (with qs_lib.hpp and qs_lib.cpp being the code for
the library to be SIP-wrapped, qs_sip.sip the SIP wrapper and
qs.py the script that crashes Python) in the hope that it is
of any help.
   Best regards, Jens

- qs_lib.hpp --

#ifndef QS_HPP_
#define QS_HPP_

#if ! defined _MSC_VER  // this isn't MS Visual Studio
#define DLL_STUFF
#else
#if defined BUILDING_LIB
#define DLL_STUFF __declspec( dllexport )
#else
#define DLL_STUFF __declspec( dllimport )
#endif
#endif

#include QString

class DLL_STUFF QS {
  public:
static QString text( );
};

#endif

- qs_lib.cpp --

#include qs_lib.hpp

QString
QS::text( ) {
return QString( Hello world );
}

- qs_sip.sip --

%Module qs_sip 0

%Import QtCore/QtCoremod.sip
%Import QtGui/QtGuimod.sip

class QS
{
%TypeHeaderCode
#include qs_lib.hpp
%End
  public:
static QString text( );
};

- qs.py --

import qs_sip as qs
print qs.QS.text( )

-- 
  \   Jens Thoms Toerring    j...@toerring.de
   \___  http://toerring.de
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] [SIP] Python crash with QString

2011-09-09 Thread Demetrius Cassidy
Well, my educated guess is it's because PyQt4 is being compiled with VS2010,
but the Python binaries are all compiled under VS2008. I've had issues
before trying to use sip/PyQt4 compiled with VS2010, with Python compiled
with 2008, in that strings would end up being blank or having odd crashes
going from C++ to Python.

To keep it short, I do not recommend you mix dlls created with VS2010 with
Python built under VS2008, it has tended to cause issues at least for me.

On Fri, Sep 9, 2011 at 9:20 PM, Jens Thoms Toerring j...@toerring.de wrote:

 Hi Demetrius,

 On Fri, Sep 09, 2011 at 09:04:28PM +, Demetrius Cassidy wrote:
  Is Python also compiled with VS2010?

 Honestly, I can't tell - I got that installation and was told
 to use it as it is. My guess is that the Python version (2.7)
 was simply a binary download, gotten from somewhere I have no
 ideas about. Is there a way to find out about that? And would
 that make a lot of a difference? All I can tell at the moment
 is that a lot of other stuff that to me looks much nore complex
 to me seems to work. Please keep in mind that my experience with
 Windows is basically non-existent, so I need quite a bit of
 handholding and probably will have to ask really stupid ques-
 tions...
  Thanks and best regards, Jens
 --
   \   Jens Thoms Toerring    j...@toerring.de
   \___  http://toerring.de

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