简体   繁体   中英

Get grtexstr ready for Python Qt4

I try to use a python qt program to insert tex equations into xmgrace. It is called grtexstr , but the problem (i assume) is that it is not compatible with Qt4. I did some changes when loading qt:

#from qt import *
from PyQt4.QtGui import *
from PyQt4.QtCore import *

but I still get a error message

File "./grtexstr.py", line 68, in __init__
    QWidget.__init__(self,parent,name,fl)
TypeError: QDialog(QWidget parent=None, Qt.WindowFlags flags=0): argument 2 has unexpected type 'NoneType'

when I try to run it. Google brought me to a suggestion to use

fl=Qt.WindowFlags(0)

in

class latexWindow(QDialog):
    def __init__(self,parent = None,name = None,fl = 0):
        QWidget.__init__(self,parent,name,fl)

This does not help either. Is there a python Qt expert out there you can help?

I put the file here for an easy access.

Edit

It seems the problem exists with the type of name, which shouldn't be None.

To answer your question, QWidget.__init__() only takes two parameters in Qt4+, parent and f (window flags). I'm not familiar with earlier version of Qt, but I'm guessing they've changed the signature to not need a name.

So instead you should call (though see comment below about QWidget vs QDialog ):

QWidget.__init__(self,parent,fl)

Is name what you want shown in the window title bar? You can set that separately with:

if name:
    self.setWindowTitle(str(name))

Also, why are you calling QWidget.__init__() instead of QDialog.__init__() , given you are subclassing QDialog

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM