I'm a newbie programming in Python
and my idea is that by clicking on the button that calls "Botonawg" a file pdf
is opened. I would like this to work both in windows
and systems UNIX
.
I use GNU-Linux ARCh
.
I made this code but it gives me the following error:
NameError: name 'QtCore' is not defined.
Code:
import sys
import webbrowser #para abrir archivos
from PyQt5.QtWidgets import QApplication, QMainWindow
from PyQt5 import uic
"""from PyQt5.QtCore import Qt"""
"""#Clase heredada de QMainWindow (Constructor de ventanas)"""
class Ventana(QMainWindow):
#Método constructor de la clase
def __init__(self):
#Iniciar el objeto QMainWindow
QMainWindow.__init__(self)
#Cargar la configuración del archivo .ui en el objeto
uic.loadUi("MiProyecto.ui", self)
self.setWindowTitle("Ktronix")
#Abrir tabla AWG
"""
def openFile(file):
if sys.platform == 'linux2':
subprocess.call(["xdg-open", file])
else:
os.startfilefile)
"""
QtCore.QObject.connect(self.uiself.Botonawg, QtCore.SIGNAL ('clicked()'), webbrowser.open_new(r'/home/ronal/ktronic/awg.pdf'))
I would appreciate your help.