简体   繁体   English

为Python Qt4准备好grtexstr

[英]Get grtexstr ready for Python Qt4

I try to use a python qt program to insert tex equations into xmgrace. 我尝试使用python qt程序将tex方程插入xmgrace。 It is called grtexstr , but the problem (i assume) is that it is not compatible with Qt4. 它称为grtexstr ,但问题(我认为)是它与Qt4不兼容。 I did some changes when loading qt: 加载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 Google给我一个使用建议

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? 是否有Python Qt专家可以协助您?

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. 似乎名称类型存在问题,该名称不应为None。

To answer your question, QWidget.__init__() only takes two parameters in Qt4+, parent and f (window flags). 为了回答您的问题, QWidget.__init__()在Qt4 +中仅采用两个参数, parentf (窗口标志)。 I'm not familiar with earlier version of Qt, but I'm guessing they've changed the signature to not need a name. 我对Qt的早期版本不熟悉,但是我猜他们已经将签名更改为不需要名称。

So instead you should call (though see comment below about QWidget vs QDialog ): 因此,您应该致电(尽管请参阅下面有关QWidget vs QDialog评论):

QWidget.__init__(self,parent,fl)

Is name what you want shown in the window title bar? name您在窗口的标题栏显示想要什么? 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 同样,为什么要调用QWidget.__init__()而不是QDialog.__init__() ,因为您要QDialog子类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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