gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 06:20:29 29 4
gpt4 key购买 nike

我正在开发一个 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/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com