python - QtiPlot 和 Python : global name 'QLocale' is not defined

标签 python qt pyqt pyqt4 mencoder

我正在开发一个 Python 脚本,它将在名为 QtiPlot 的应用程序中运行。我搜索了 Qtiplot 的 Python API 文档,它使用 PyQt 4。我将我的脚本编码如下:

#! /usr/bin/env python

# A python script to be used in QtiPlot to convert .dat files into .jpg graphs and these ones into .avi movie

import os
import re
import glob
from PyQt4 import uic
from PyQt4 import *

def chooseInputFolder():
    input_folder = QtGui.QFileDialog.getExistingDirectory(qti.app, "Choose Working Folder")
    ui.inputFolderLine.setText(input_folder)
    return input_folder

def chooseOutputFile():
    output_file = QtGui.QFileDialog.getSaveFileName(qti.app, "Choose Output File")
    ui.outputFileLine.setText(output_file)
    return output_file

def createVideoFromJPG():
    input_folder_name = ui.inputFolderLine.text()
    output_file_name = ui.outputFileLine.text()
    dirList = os.listdir(input_folder_name)
    for fname in dirList:
        t = newTable()
        t.importASCII(input_folder_name+fname,sep="\t",ignoreLines=0,renameCols=False,stripSpaces=True,simplifySpace=False,importComments=False,comment="#",readOnly=False,importAs=Table.Overwrite,locale=QLocale(),endLine=0,maxRows=-1)
#       g = plot(t, 2, 0)
#       cmd = 'mencoder "mf://*.jpg" -mf fps=25 -o %s -ovc lavc -lavcopts vcodec=mpeg4' % output_file
#       os.system(cmd)

ui = uic.loadUi("/home/kurumin/Scripts/python/dat2vid.ui")
ui.connect(ui.inputFolderButton, QtCore.SIGNAL("clicked()"),chooseInputFolder)
ui.connect(ui.outputFileButton, QtCore.SIGNAL("clicked()"),chooseOutputFile)
ui.connect(ui.createVideo, QtCore.SIGNAL("clicked()"),createVideoFromJPG)
ui.show()

这是输出:

Traceback (most recent call last):

File "<>", line 27, in createVideoFromJPG

NameError
: 
global name 'QLocale' is not defined

我尝试定义 QLocale,但在文档中找不到任何真正有用的内容。

最佳答案

locale=QLocale() 替换为文件 line 27 中的 locale=QtGui.QLocale(),因为 from PyQt4 import * 你必须提供模块名称..

关于python - QtiPlot 和 Python : global name 'QLocale' is not defined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12700293/

相关文章:

python - 尝试使用 CSV 文件从 URL 下载数据

c++ - 将字符串从一个 .cpp 文件传输到另一个

python - 将两个变量添加到 QComboBox

python - 在嵌入式 Python 解释器中启用代码完成

python - NumPy - 这可以向量化吗?

python - 如何将包含 ' : ' 的列表转换为 python 中的字典

python - turtle 随机运动,从墙上弹起

qt - qDebug() 如何打印枚举值?

qt - 在 ListView 之间传递焦点

python - 在 sys.exit() 之外的 pyqt 应用程序上调用 exec_()