[PyKDE] Porting Tux

Dennis Schaaf dennis.schaaf at gmail.com
Tue Nov 2 16:46:26 GMT 2004


Hi,

Just for experimentation purposes, I'm porting the tux (
http://webcvs.kde.org/cgi-bin/cvsweb.cgi/qt-copy/examples/tux/tux.cpp?rev=1.2)
program over to python.

The problem I have when doing this though is that QWidget will not
take the last argument I give it. In the original project, the first
argument is the object itself, then secon is the name (a char) and
lastly an integer (int)

In my code I have the same thing:
class MoveMe(QWidget):
	def __init__(self, name, args):
		apply(QWidget.__init__, (self, name, args))

but I get 
"apply(QWidget.__init__, (self, name, args))
TypeError: argument 1 of QWidget() has an invalid type"

whenever i try to execute it.

do you guys know how to call this function properly, so that I can
still pass the right arguments along?

yours
 Dennis

PS here is the whole program 
import sys
from kdecore import KApplication, KCmdLineArgs, KAboutData
from dcopexport import DCOPExObj
from qt import *

class MoveMe(QWidget):
	#def __init__(self, name="unnamed", *args):
	def __init__(self, name, args):
		apply(QWidget.__init__, (self, name, args))
		
def main ():
	KCmdLineArgs.init (sys.argv, aboutData)

	#KCmdLineArgs.addCmdLineOptions ([("+files", "File to open")])
	
	app   = KApplication ()
	
	filename = QString("tux.png")
	
	if not QFile.exists(filename):
		print "file doesn't exist"
	
	image = QImage(filename)
	
	pixmap = QPixmap()
	
	pixmap.convertFromImage(image)
	
	if not pixmap.mask():
		if image.hasAlphaBuffer():
			bitmap = image.createAlphaMask()
			pixmap.setMask(bitmap)
		else:
			bitmap = image.createHeuristicMask()
			pixmap.setMask(bitmap)
			
	arguments = Qt.WStyle_Customize | Qt.WStyle_NoBorder
	Instance = MoveMe('t',arguments)
	Instance.setBackgroundPixmap( pixmap)
	Instance.setFixedSize(pixmap.size())
	if pixmap.mask():
		Instance.setMask(pixmap.mask())
	Instance.show()
	app.setMainWidget(Instance)
	app.exec_loop()
	



description = "The Python Version of the famous Tux"
version     = "0.1"
aboutData   = KAboutData ("pytux", "pytux",\
    version, description, KAboutData.License_GPL,\
    "(C) 2004 Dennis Schaaf")

aboutData.addAuthor ("Dennis Schaaf", "surfing through websites and
puttin it all together :-D", "email at somedomain")
#aboutData.addAuthor ("author2", "they did something else",
"another at email.address")

main()




More information about the PyQt mailing list