Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Spanish
  4. Text en Qt importado con "from"
QtWS25 Last Chance

Text en Qt importado con "from"

Scheduled Pinned Locked Moved Unsolved Spanish
text en qt
10 Posts 4 Posters 1.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Raulh
    wrote on 1 Jan 2024, 21:11 last edited by
    #1

    Hola, adjunto dos file .py. No encuentro la sintaxis para optener y escribir sobre los text de los widgest desde un programa q importa con from una panatlla qt ya traducida a python.
    En el ejemplo es al presionar el boton 'Generar File', ejecutandose la def 'Control de datos'.

    Programa de conbversion Gcode a Lua per Dobot

    File Conv_Gcode_a_Lua

    Raul

    File de Texto original 852303

    File de destino point.Json

    prj.json

    src0.lua

    global.lua

    fileCRCCode.json

    import sys
    import time
    from PyQt5.QtCore import Qt

    from Scn_Cnv_Dobot import *

    class Aplicacion:

    def Calculo_puntos():
    	Punto += 1
    
    	Punto_X = linea.find("X",primer_caracter_g)
    	Punto_Y = linea.find("Y",primer_caracter_g)
    	Punto_Z = linea.find("Z",primer_caracter_g)
    		
    	if Punto_X !=-1:
    		Punto_X_Es = linea.find(" ",Punto_X)
    		if Punto_X_Es == -1:
    			Punto_X_Val = linea[Punto_X+1:len(linea)]
    			Punto_X_Val = Punto_X_Val.strip()
    		else:
    			Punto_X_Val = linea[Punto_X+1:Punto_X_Es]
    			Punto_X_Val = Punto_X_Val.strip()
    		if Punto_Y !=-1:
    			Punto_Y_Es = linea.find(" ",Punto_Y)
    		if Punto_Y_Es == -1:
    			Punto_Y_Val = linea[Punto_Y+1:len(linea)]
    			Punto_Y_Val = Punto_Y_Val.strip()
    		else:
    			Punto_Y_Val = linea[Punto_Y+1:Punto_Y_Es]
    			Punto_Y_Val = Punto_Y_Val.strip()
    		
    	if Punto_Z !=-1:
    		Punto_Z_Es = linea.find(" ",Punto_Z)
    		if Punto_Z_Es == -1:
    			Punto_Z_Val = linea[Punto_Z+1:len(linea)]
    			Punto_Z_Val = Punto_Z_Val.strip()
    		else:
    			Punto_Z_Val = linea[Punto_Z+1:Punto_Z_Es]
    			Punto_Z_Val = Punto_Z_Val.strip()
    			
    	Pto_Save_1 = "\"name:\""+"\"P\"" +str(Punto)+"\"tool\""+":1"+"\"user\""+":1,"
    	Pto_Save_2 = "\"joint\":[-20.0277,-11.1383,88.9708,30.2226,-91.7566,-261.5641]},{\"id\":1699604796888,\"alias\":\"\",\n"
    	Pto_Save_3 = "\"armOrientation\":[1,1,1,-1],\"coordinate\":["
    	Pto_Save_4 = str(Punto_X_Val)+","+str(Punto_Y_Val)+","+str(Punto_Z_Val)+","+str(A_Euler)+","+str(E_Euler)+","+str(R_Euler)+"]\n"
    	Pto_Save_5 = "\n"
    		
    	archivo_point.write(Pto_Save_1)
    	archivo_point.write(Pto_Save_2)
    	archivo_point.write(Pto_Save_3)
    	archivo_point.write(Pto_Save_4)
    
    def Crear_Cartela():
    	print ("")
    def Copiar_File():
    	print ('')
    
    def Init():
    	os.path.getsize("852303.txt")
    	Uscita = 3
    	On =1 
    	Off = 0
    	A_Euler = 20.101
    	E_Euler = 22.202
    	R_Euler = 33.303
    	Punto = 0
    	P_save = 10
    	Punto_X_Val = 0
    	Punto_Y_Val = 0
    	Punto_Z_Val = 0
    	#
    

    def Control_Datos():
    print ("Contro d Ver Mod 7")
    #Cpo_Sorg = (Campo_Sorgente[text()])
    #Cpo_Info = (Campo_Info[SetText()],"Texto")
    # Cambio color a Info_Progetto
    # Cambio texto a una Label
    print ("Control Datos ejecutada")

    def Generacion_Files():

    	Init()
    	#Control_Datos()
    
    	archivo_gcode = open ("852303.txt","r")
    	archivo_src0 = open ("src0.lua","w")
    	archivo_point = open ("point.json","w")
    	archivo_point.write("[{\"id\":\"base\",\"alias\":\"\",\"armOrientation\":[1,1,-1,-1],\"coordinate\":[0,0,0,0,0,0],\n");
    	archivo_point.write("\"name\":\"InitialPose\",\"tool\":0,\"user\":0,\"joint\":[0,0,0,0,0,0]},{\"id\":1699604731023,\"alias\":\"\",\n");
    	archivo_point.write("\"armOrientation\":[1,1,1,-1],\"coordinate\":[-555.0739,2.8527,746.882,-175.0788,-17.2875,-29.1041],\n");
    	#  ===============================================
    	archivo_global = open ("global.lua","w")
    	archivo_global.close
    	archivo_prj = open ("prj.json","w")
    	Prj_Save = "{"+"\"cpus\""+":[\"src0.lua\"],\"global\":\"global.lua\",\"teach_point\":\"point.json\"}"
    	archivo_prj.write(Prj_Save)
    	archivo_prj.close
    
    	archivo_fileCRCCode = open ("fileCRCCode.json","w")
    	CRCCode_Save ="{\"fileName\":[\"scratch.xml\",\"global.lua\",\"point.json\",\"prj.json\",\"src0.lua\"],\"crcCode\":[2064672904,0,3216453487,668367846,1563868684]}"
    	archivo_fileCRCCode.write(CRCCode_Save)
    	archivo_fileCRCCode.close 
    	#=================================================
    
    	total_lineas = len(archivo_gcode.readline())
    	archivo_src0.write("--- \n");
    	archivo_src0.write(" \n")
    	archivo_src0.write("local Option 1={CP=1, SpeedL=40, AccL=10} "+"---\n");
    	archivo_src0.write("local Option 2={CP=100, SpeedL=15, AccL=10} "+"---\n");
    	archivo_src0.write(" \n")
    
    
    
    
    	for i in range (0,55):
    		linea = archivo_gcode.readline()
    		lg = len(linea)
    		print("linea Nro",i," Long: ",lg,"  ",linea)
    
    		primer_caracter_g = linea.find("G")
    		primer_caracter_m = linea.find("M")
    		primer_caracter_f = linea.find("F")
    		primer_caracter_Paren = linea.find("(")
    
    		if primer_caracter_Paren != -1:
    			archivo_src0.write("---"+" "+linea);
    		else:
    			if primer_caracter_g != -1:
    	
    				gcodigo = linea[primer_caracter_g:7]
    				gcodigo = gcodigo.strip()
    
    				if gcodigo == "G0":
    					#===========================
    					Calculo_puntos()
    					archivo_src0.write("  MovJ("+"P"+str(Punto)+",Option1"+")"+"\n");
    					#============================
    
    				if gcodigo == "G1":
    					#===========================
    					Calculo_puntos()
    					archivo_src0.write("  MovL("+"P"+str(Punto)+",Option2"+")"+"\n")
    					#============================
    
    				if gcodigo == "G2":
    					#===========================
    					Calculo_puntos()
    					archivo_src0.write("  MovL("+"P"+str(Punto)+",Option2"+")"+"\n")
    					#============================
    
    				if gcodigo == "G4":
    					primer_caracter_p = linea.find("P")
    					Punto_P_Val = linea[primer_caracter_p+1:len(linea)]
    					Punto_P_Val = Punto_P_Val.strip()
    					archivo_src0.write("  WAIT("+str(Punto_P_Val)+")"+"\n");	
    
    				if gcodigo == "G90":
    					archivo_src0.write("--- "+str(i)+" "+gcodigo+"  90"+"\n");
    				if gcodigo == "G71":
    					archivo_src0.write("--- "+str(i)+" "+gcodigo+"  71"+"\n");
    
    			else:
    				if primer_caracter_m != -1:
    					mcodigo = linea[primer_caracter_m:8]
    					mcodigo = mcodigo.strip()
    					if mcodigo =="M3":
    						archivo_src0.write( "  DO("+str(Uscita)+","+str(On)+")"+"\n");
    					if mcodigo =="M5":
    						archivo_src0.write( "  DO("+str(Uscita)+","+str(Off)+")"+"\n");
    		
    				if primer_caracter_f != -1:
    					fcodigo = linea[primer_caracter_f:9]
    					fcodigo = fcodigo.strip()
    					archivo_src0.write(str(i)+" "+fcodigo+"\n");
    				
    
    	##
    	archivo_gcode.close
    	archivo_src0.close
    	archivo_point.close
    	print ("Fin generacion")
    

    def Uscita(self):
    quit()

    class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
    def init(self, *args, **kwargs):
    QtWidgets.QMainWindow.init(self, *args, **kwargs)
    self.setupUi(self)
    self.Tasto_Uscita.clicked.connect(Uscita)
    self.Tasto_Generar_File.clicked.connect(Control_Datos)

    #self.Tasto_Nuevo_Pro.clicked(Nuovo_Proggetto)
    

    if name == "main":
    app = QtWidgets.QApplication([])
    window = MainWindow()
    window.show()
    app.exec_()

    Pantalla:

    -- coding: utf-8 --

    Form implementation generated from reading ui file 'Scn_Cnv_Dobot.ui'

    Created by: PyQt5 UI code generator 5.15.7

    WARNING: Any manual changes made to this file will be lost when pyuic5 is

    run again. Do not edit this file unless you know what you are doing.

    from PyQt5 import QtCore, QtGui, QtWidgets

    class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
    MainWindow.setObjectName("MainWindow")
    MainWindow.resize(842, 464)
    MainWindow.setMinimumSize(QtCore.QSize(0, 464))
    MainWindow.setStyleSheet("background-color: rgb(221, 255, 205);")
    self.centralwidget = QtWidgets.QWidget(MainWindow)
    self.centralwidget.setObjectName("centralwidget")
    self.Titulo_Principal = QtWidgets.QLabel(self.centralwidget)
    self.Titulo_Principal.setGeometry(QtCore.QRect(10, 0, 321, 31))
    self.Titulo_Principal.setStyleSheet("font: 87 12pt "Arial Black";\n"
    "background-color: rgb(8, 202, 255);")
    self.Titulo_Principal.setObjectName("Titulo_Principal")
    self.Grafica_MgM = QtWidgets.QGraphicsView(self.centralwidget)
    self.Grafica_MgM.setGeometry(QtCore.QRect(610, 20, 211, 141))
    self.Grafica_MgM.setObjectName("Grafica_MgM")
    self.Titolo_Sorgente = QtWidgets.QLabel(self.centralwidget)
    self.Titolo_Sorgente.setGeometry(QtCore.QRect(20, 50, 121, 21))
    self.Titolo_Sorgente.setStyleSheet("font: 87 11pt "Arial Black";\n"
    "background-color: rgb(255, 255, 127);")
    self.Titolo_Sorgente.setObjectName("Titolo_Sorgente")
    self.Info_Codigo = QtWidgets.QLineEdit(self.centralwidget)
    self.Info_Codigo.setGeometry(QtCore.QRect(770, 170, 51, 20))
    self.Info_Codigo.setObjectName("Info_Codigo")
    self.Info_Variabile = QtWidgets.QLineEdit(self.centralwidget)
    self.Info_Variabile.setGeometry(QtCore.QRect(770, 200, 51, 20))
    self.Info_Variabile.setObjectName("Info_Variabile")
    self.Info_Global = QtWidgets.QLineEdit(self.centralwidget)
    self.Info_Global.setGeometry(QtCore.QRect(770, 230, 51, 20))
    self.Info_Global.setObjectName("Info_Global")
    self.Info_Proggeto = QtWidgets.QLineEdit(self.centralwidget)
    self.Info_Proggeto.setGeometry(QtCore.QRect(770, 260, 51, 20))
    self.Info_Proggeto.setObjectName("Info_Proggeto")
    self.Titolo_Codigo = QtWidgets.QLabel(self.centralwidget)
    self.Titolo_Codigo.setGeometry(QtCore.QRect(680, 170, 71, 21))
    self.Titolo_Codigo.setStyleSheet("font: 87 8pt "Arial Black";\n"
    "background-color: rgb(255, 255, 127);")
    self.Titolo_Codigo.setObjectName("Titolo_Codigo")
    self.Titolo_Variabile = QtWidgets.QLabel(self.centralwidget)
    self.Titolo_Variabile.setGeometry(QtCore.QRect(670, 200, 81, 21))
    self.Titolo_Variabile.setStyleSheet("font: 87 8pt "Arial Black";\n"
    "background-color: rgb(255, 255, 127);")
    self.Titolo_Variabile.setObjectName("Titolo_Variabile")
    self.Titolo_Global = QtWidgets.QLabel(self.centralwidget)
    self.Titolo_Global.setGeometry(QtCore.QRect(670, 230, 81, 21))
    self.Titolo_Global.setStyleSheet("font: 87 8pt "Arial Black";\n"
    "background-color: rgb(255, 255, 127);")
    self.Titolo_Global.setObjectName("Titolo_Global")
    self.Titolo_File_Proggeto = QtWidgets.QLabel(self.centralwidget)
    self.Titolo_File_Proggeto.setGeometry(QtCore.QRect(670, 260, 81, 21))
    self.Titolo_File_Proggeto.setStyleSheet("font: 87 8pt "Arial Black";\n"
    "background-color: rgb(255, 255, 127);")
    self.Titolo_File_Proggeto.setObjectName("Titolo_File_Proggeto")
    self.Titolo_Proggeto = QtWidgets.QLabel(self.centralwidget)
    self.Titolo_Proggeto.setGeometry(QtCore.QRect(231, 107, 90, 21))
    self.Titolo_Proggeto.setStyleSheet("font: 87 11pt "Arial Black";\n"
    "background-color: rgb(255, 255, 127);")
    self.Titolo_Proggeto.setObjectName("Titolo_Proggeto")
    self.Titolo_Versioni = QtWidgets.QLabel(self.centralwidget)
    self.Titolo_Versioni.setGeometry(QtCore.QRect(740, 410, 91, 21))
    self.Titolo_Versioni.setStyleSheet("font: 87 7pt "Arial Black";")
    self.Titolo_Versioni.setObjectName("Titolo_Versioni")
    self.Titolo_Cartela = QtWidgets.QLabel(self.centralwidget)
    self.Titolo_Cartela.setGeometry(QtCore.QRect(360, 178, 81, 21))
    self.Titolo_Cartela.setStyleSheet("font: 87 11pt "Arial Black";\n"
    "background-color: rgb(255, 255, 127);")
    self.Titolo_Cartela.setObjectName("Titolo_Cartela")
    self.Titolo_Info = QtWidgets.QLabel(self.centralwidget)
    self.Titolo_Info.setGeometry(QtCore.QRect(10, 250, 51, 21))
    self.Titolo_Info.setStyleSheet("font: 87 11pt "Arial Black";\n"
    "background-color: rgb(255, 255, 127);")
    self.Titolo_Info.setObjectName("Titolo_Info")
    self.dateEdit = QtWidgets.QDateEdit(self.centralwidget)
    self.dateEdit.setGeometry(QtCore.QRect(690, 0, 110, 22))
    self.dateEdit.setObjectName("dateEdit")
    self.Tasto_Nuovo_Pro = QtWidgets.QPushButton(self.centralwidget)
    self.Tasto_Nuovo_Pro.setGeometry(QtCore.QRect(390, 10, 181, 31))
    self.Tasto_Nuovo_Pro.setStyleSheet("font: 87 12pt "Arial Black";\n"
    "background-color: rgb(170, 170, 127);")
    self.Tasto_Nuovo_Pro.setObjectName("Tasto_Nuovo_Pro")
    self.Tasto_Generar_File = QtWidgets.QPushButton(self.centralwidget)
    self.Tasto_Generar_File.setGeometry(QtCore.QRect(400, 50, 161, 51))
    self.Tasto_Generar_File.setStyleSheet("font: 87 12pt "Arial Black";\n"
    "background-color: rgb(85, 255, 0);")
    self.Tasto_Generar_File.setObjectName("Tasto_Generar_File")
    self.Tasto_Uscita = QtWidgets.QPushButton(self.centralwidget)
    self.Tasto_Uscita.setGeometry(QtCore.QRect(670, 360, 151, 23))
    self.Tasto_Uscita.setStyleSheet("font: 87 14pt "Arial Black";\n"
    "background-color: rgb(255, 85, 255);")
    self.Tasto_Uscita.setObjectName("Tasto_Uscita")
    self.label_12 = QtWidgets.QLabel(self.centralwidget)
    self.label_12.setGeometry(QtCore.QRect(10, 380, 591, 41))
    self.label_12.setStyleSheet("background-color: rgb(255, 244, 158);\n"
    "font: 87 10pt "Arial Black";")
    self.label_12.setObjectName("label_12")
    self.Titolo_Instruzioni = QtWidgets.QLabel(self.centralwidget)
    self.Titolo_Instruzioni.setGeometry(QtCore.QRect(10, 360, 121, 21))
    self.Titolo_Instruzioni.setStyleSheet("font: 87 11pt "Arial Black";\n"
    "background-color: rgb(255, 255, 127);")
    self.Titolo_Instruzioni.setObjectName("Titolo_Instruzioni")
    self.Titolo_Proggeto_3 = QtWidgets.QLabel(self.centralwidget)
    self.Titolo_Proggeto_3.setGeometry(QtCore.QRect(350, 270, 171, 21))
    self.Titolo_Proggeto_3.setStyleSheet("font: 87 11pt "Arial Black";\n"
    "background-color: rgb(255, 255, 127);")
    self.Titolo_Proggeto_3.setObjectName("Titolo_Proggeto_3")
    self.Titolo_Proggeto_4 = QtWidgets.QLabel(self.centralwidget)
    self.Titolo_Proggeto_4.setGeometry(QtCore.QRect(353, 307, 161, 21))
    self.Titolo_Proggeto_4.setStyleSheet("font: 87 11pt "Arial Black";\n"
    "background-color: rgb(255, 255, 127);")
    self.Titolo_Proggeto_4.setObjectName("Titolo_Proggeto_4")
    self.Campo_Sorgente = QtWidgets.QLineEdit(self.centralwidget)
    self.Campo_Sorgente.setGeometry(QtCore.QRect(20, 70, 191, 31))
    font = QtGui.QFont()
    font.setFamily("Arial Black")
    font.setPointSize(11)
    font.setBold(False)
    font.setItalic(False)
    font.setWeight(10)
    self.Campo_Sorgente.setFont(font)
    self.Campo_Sorgente.setStyleSheet("font: 87 11pt "Arial Black";\n"
    "background-color: rgb(231, 225, 255);")
    self.Campo_Sorgente.setText("")
    self.Campo_Sorgente.setObjectName("Campo_Sorgente")
    self.Campo_Progetto = QtWidgets.QLineEdit(self.centralwidget)
    self.Campo_Progetto.setGeometry(QtCore.QRect(220, 150, 191, 31))
    font = QtGui.QFont()
    font.setFamily("Arial Black")
    font.setPointSize(11)
    font.setBold(False)
    font.setItalic(False)
    font.setWeight(10)
    self.Campo_Progetto.setFont(font)
    self.Campo_Progetto.setStyleSheet("font: 87 11pt "Arial Black";\n"
    "background-color: rgb(175, 255, 250);")
    self.Campo_Progetto.setText("")
    self.Campo_Progetto.setObjectName("Campo_Progetto")
    self.Campo_Cartella = QtWidgets.QLineEdit(self.centralwidget)
    self.Campo_Cartella.setGeometry(QtCore.QRect(360, 200, 191, 31))
    font = QtGui.QFont()
    font.setFamily("Arial Black")
    font.setPointSize(11)
    font.setBold(False)
    font.setItalic(False)
    font.setWeight(10)
    self.Campo_Cartella.setFont(font)
    self.Campo_Cartella.setStyleSheet("background-color: rgb(255, 210, 157);\n"
    "font: 87 11pt "Arial Black";")
    self.Campo_Cartella.setText("")
    self.Campo_Cartella.setObjectName("Campo_Cartella")
    self.Campo_Vel_Trasl = QtWidgets.QLineEdit(self.centralwidget)
    self.Campo_Vel_Trasl.setGeometry(QtCore.QRect(520, 260, 101, 31))
    font = QtGui.QFont()
    font.setFamily("Arial Black")
    font.setPointSize(11)
    font.setBold(False)
    font.setItalic(False)
    font.setWeight(10)
    self.Campo_Vel_Trasl.setFont(font)
    self.Campo_Vel_Trasl.setStyleSheet("font: 87 11pt "Arial Black";\n"
    "background-color: rgb(231, 225, 255);")
    self.Campo_Vel_Trasl.setText("")
    self.Campo_Vel_Trasl.setObjectName("Campo_Vel_Trasl")
    self.Campo_Vel_Taglio = QtWidgets.QLineEdit(self.centralwidget)
    self.Campo_Vel_Taglio.setGeometry(QtCore.QRect(521, 300, 100, 31))
    font = QtGui.QFont()
    font.setFamily("Arial Black")
    font.setPointSize(11)
    font.setBold(False)
    font.setItalic(False)
    font.setWeight(10)
    self.Campo_Vel_Taglio.setFont(font)
    self.Campo_Vel_Taglio.setStyleSheet("font: 87 11pt "Arial Black";\n"
    "background-color: rgb(231, 225, 255);")
    self.Campo_Vel_Taglio.setText("")
    self.Campo_Vel_Taglio.setObjectName("Campo_Vel_Taglio")
    self.Campo_Info = QtWidgets.QLineEdit(self.centralwidget)
    self.Campo_Info.setGeometry(QtCore.QRect(10, 270, 331, 81))
    font = QtGui.QFont()
    font.setFamily("Arial Black")
    font.setPointSize(11)
    font.setBold(False)
    font.setItalic(False)
    font.setWeight(10)
    self.Campo_Info.setFont(font)
    self.Campo_Info.setStyleSheet("font: 87 11pt "Arial Black";\n"
    "background-color: rgb(239, 255, 164);")
    self.Campo_Info.setText("")
    self.Campo_Info.setObjectName("Campo_Info")
    self.label = QtWidgets.QLabel(self.centralwidget)
    self.label.setGeometry(QtCore.QRect(480, 140, 47, 13))
    self.label.setObjectName("label")
    MainWindow.setCentralWidget(self.centralwidget)
    self.menubar = QtWidgets.QMenuBar(MainWindow)
    self.menubar.setGeometry(QtCore.QRect(0, 0, 842, 21))
    self.menubar.setObjectName("menubar")
    MainWindow.setMenuBar(self.menubar)
    self.statusbar = QtWidgets.QStatusBar(MainWindow)
    self.statusbar.setObjectName("statusbar")
    MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
    
    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
        self.Titulo_Principal.setText(_translate("MainWindow", "  Conversor Gcode a Lua per DOBOT"))
        self.Titolo_Sorgente.setText(_translate("MainWindow", "File Sorgente"))
        self.Titolo_Codigo.setText(_translate("MainWindow", "File Codigo"))
        self.Titolo_Variabile.setText(_translate("MainWindow", "File Variables"))
        self.Titolo_Global.setText(_translate("MainWindow", "File Golbal"))
        self.Titolo_File_Proggeto.setText(_translate("MainWindow", "File Progetto"))
        self.Titolo_Proggeto.setText(_translate("MainWindow", "Proggeto"))
        self.Titolo_Versioni.setText(_translate("MainWindow", "Version RM  1-1"))
        self.Titolo_Cartela.setText(_translate("MainWindow", "Cartella"))
        self.Titolo_Info.setText(_translate("MainWindow", "Info"))
        self.Tasto_Nuovo_Pro.setText(_translate("MainWindow", "Nuovo Proggetto"))
        self.Tasto_Generar_File.setText(_translate("MainWindow", "Generar Files"))
        self.Tasto_Uscita.setText(_translate("MainWindow", "Uscita "))
        self.label_12.setText(_translate("MainWindow", "Per questa versione i Circolare bisgogna disegnarli con \'piccole\' trati lineare."))
        self.Titolo_Instruzioni.setText(_translate("MainWindow", " Instrazione"))
        self.Titolo_Proggeto_3.setText(_translate("MainWindow", "Velocita Traslato %"))
        self.Titolo_Proggeto_4.setText(_translate("MainWindow", "Velocita Taglio %"))
        self.label.setText(_translate("MainWindow", "TextLabel"))
    

    if name == "main":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    MainWindow = QtWidgets.QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    MainWindow.show()
    sys.exit(app.exec_())

    C jsulmJ 2 Replies Last reply 2 Jan 2024, 01:32
    0
    • R Raulh
      1 Jan 2024, 21:11

      Hola, adjunto dos file .py. No encuentro la sintaxis para optener y escribir sobre los text de los widgest desde un programa q importa con from una panatlla qt ya traducida a python.
      En el ejemplo es al presionar el boton 'Generar File', ejecutandose la def 'Control de datos'.

      Programa de conbversion Gcode a Lua per Dobot

      File Conv_Gcode_a_Lua

      Raul

      File de Texto original 852303

      File de destino point.Json

      prj.json

      src0.lua

      global.lua

      fileCRCCode.json

      import sys
      import time
      from PyQt5.QtCore import Qt

      from Scn_Cnv_Dobot import *

      class Aplicacion:

      def Calculo_puntos():
      	Punto += 1
      
      	Punto_X = linea.find("X",primer_caracter_g)
      	Punto_Y = linea.find("Y",primer_caracter_g)
      	Punto_Z = linea.find("Z",primer_caracter_g)
      		
      	if Punto_X !=-1:
      		Punto_X_Es = linea.find(" ",Punto_X)
      		if Punto_X_Es == -1:
      			Punto_X_Val = linea[Punto_X+1:len(linea)]
      			Punto_X_Val = Punto_X_Val.strip()
      		else:
      			Punto_X_Val = linea[Punto_X+1:Punto_X_Es]
      			Punto_X_Val = Punto_X_Val.strip()
      		if Punto_Y !=-1:
      			Punto_Y_Es = linea.find(" ",Punto_Y)
      		if Punto_Y_Es == -1:
      			Punto_Y_Val = linea[Punto_Y+1:len(linea)]
      			Punto_Y_Val = Punto_Y_Val.strip()
      		else:
      			Punto_Y_Val = linea[Punto_Y+1:Punto_Y_Es]
      			Punto_Y_Val = Punto_Y_Val.strip()
      		
      	if Punto_Z !=-1:
      		Punto_Z_Es = linea.find(" ",Punto_Z)
      		if Punto_Z_Es == -1:
      			Punto_Z_Val = linea[Punto_Z+1:len(linea)]
      			Punto_Z_Val = Punto_Z_Val.strip()
      		else:
      			Punto_Z_Val = linea[Punto_Z+1:Punto_Z_Es]
      			Punto_Z_Val = Punto_Z_Val.strip()
      			
      	Pto_Save_1 = "\"name:\""+"\"P\"" +str(Punto)+"\"tool\""+":1"+"\"user\""+":1,"
      	Pto_Save_2 = "\"joint\":[-20.0277,-11.1383,88.9708,30.2226,-91.7566,-261.5641]},{\"id\":1699604796888,\"alias\":\"\",\n"
      	Pto_Save_3 = "\"armOrientation\":[1,1,1,-1],\"coordinate\":["
      	Pto_Save_4 = str(Punto_X_Val)+","+str(Punto_Y_Val)+","+str(Punto_Z_Val)+","+str(A_Euler)+","+str(E_Euler)+","+str(R_Euler)+"]\n"
      	Pto_Save_5 = "\n"
      		
      	archivo_point.write(Pto_Save_1)
      	archivo_point.write(Pto_Save_2)
      	archivo_point.write(Pto_Save_3)
      	archivo_point.write(Pto_Save_4)
      
      def Crear_Cartela():
      	print ("")
      def Copiar_File():
      	print ('')
      
      def Init():
      	os.path.getsize("852303.txt")
      	Uscita = 3
      	On =1 
      	Off = 0
      	A_Euler = 20.101
      	E_Euler = 22.202
      	R_Euler = 33.303
      	Punto = 0
      	P_save = 10
      	Punto_X_Val = 0
      	Punto_Y_Val = 0
      	Punto_Z_Val = 0
      	#
      

      def Control_Datos():
      print ("Contro d Ver Mod 7")
      #Cpo_Sorg = (Campo_Sorgente[text()])
      #Cpo_Info = (Campo_Info[SetText()],"Texto")
      # Cambio color a Info_Progetto
      # Cambio texto a una Label
      print ("Control Datos ejecutada")

      def Generacion_Files():

      	Init()
      	#Control_Datos()
      
      	archivo_gcode = open ("852303.txt","r")
      	archivo_src0 = open ("src0.lua","w")
      	archivo_point = open ("point.json","w")
      	archivo_point.write("[{\"id\":\"base\",\"alias\":\"\",\"armOrientation\":[1,1,-1,-1],\"coordinate\":[0,0,0,0,0,0],\n");
      	archivo_point.write("\"name\":\"InitialPose\",\"tool\":0,\"user\":0,\"joint\":[0,0,0,0,0,0]},{\"id\":1699604731023,\"alias\":\"\",\n");
      	archivo_point.write("\"armOrientation\":[1,1,1,-1],\"coordinate\":[-555.0739,2.8527,746.882,-175.0788,-17.2875,-29.1041],\n");
      	#  ===============================================
      	archivo_global = open ("global.lua","w")
      	archivo_global.close
      	archivo_prj = open ("prj.json","w")
      	Prj_Save = "{"+"\"cpus\""+":[\"src0.lua\"],\"global\":\"global.lua\",\"teach_point\":\"point.json\"}"
      	archivo_prj.write(Prj_Save)
      	archivo_prj.close
      
      	archivo_fileCRCCode = open ("fileCRCCode.json","w")
      	CRCCode_Save ="{\"fileName\":[\"scratch.xml\",\"global.lua\",\"point.json\",\"prj.json\",\"src0.lua\"],\"crcCode\":[2064672904,0,3216453487,668367846,1563868684]}"
      	archivo_fileCRCCode.write(CRCCode_Save)
      	archivo_fileCRCCode.close 
      	#=================================================
      
      	total_lineas = len(archivo_gcode.readline())
      	archivo_src0.write("--- \n");
      	archivo_src0.write(" \n")
      	archivo_src0.write("local Option 1={CP=1, SpeedL=40, AccL=10} "+"---\n");
      	archivo_src0.write("local Option 2={CP=100, SpeedL=15, AccL=10} "+"---\n");
      	archivo_src0.write(" \n")
      
      
      
      
      	for i in range (0,55):
      		linea = archivo_gcode.readline()
      		lg = len(linea)
      		print("linea Nro",i," Long: ",lg,"  ",linea)
      
      		primer_caracter_g = linea.find("G")
      		primer_caracter_m = linea.find("M")
      		primer_caracter_f = linea.find("F")
      		primer_caracter_Paren = linea.find("(")
      
      		if primer_caracter_Paren != -1:
      			archivo_src0.write("---"+" "+linea);
      		else:
      			if primer_caracter_g != -1:
      	
      				gcodigo = linea[primer_caracter_g:7]
      				gcodigo = gcodigo.strip()
      
      				if gcodigo == "G0":
      					#===========================
      					Calculo_puntos()
      					archivo_src0.write("  MovJ("+"P"+str(Punto)+",Option1"+")"+"\n");
      					#============================
      
      				if gcodigo == "G1":
      					#===========================
      					Calculo_puntos()
      					archivo_src0.write("  MovL("+"P"+str(Punto)+",Option2"+")"+"\n")
      					#============================
      
      				if gcodigo == "G2":
      					#===========================
      					Calculo_puntos()
      					archivo_src0.write("  MovL("+"P"+str(Punto)+",Option2"+")"+"\n")
      					#============================
      
      				if gcodigo == "G4":
      					primer_caracter_p = linea.find("P")
      					Punto_P_Val = linea[primer_caracter_p+1:len(linea)]
      					Punto_P_Val = Punto_P_Val.strip()
      					archivo_src0.write("  WAIT("+str(Punto_P_Val)+")"+"\n");	
      
      				if gcodigo == "G90":
      					archivo_src0.write("--- "+str(i)+" "+gcodigo+"  90"+"\n");
      				if gcodigo == "G71":
      					archivo_src0.write("--- "+str(i)+" "+gcodigo+"  71"+"\n");
      
      			else:
      				if primer_caracter_m != -1:
      					mcodigo = linea[primer_caracter_m:8]
      					mcodigo = mcodigo.strip()
      					if mcodigo =="M3":
      						archivo_src0.write( "  DO("+str(Uscita)+","+str(On)+")"+"\n");
      					if mcodigo =="M5":
      						archivo_src0.write( "  DO("+str(Uscita)+","+str(Off)+")"+"\n");
      		
      				if primer_caracter_f != -1:
      					fcodigo = linea[primer_caracter_f:9]
      					fcodigo = fcodigo.strip()
      					archivo_src0.write(str(i)+" "+fcodigo+"\n");
      				
      
      	##
      	archivo_gcode.close
      	archivo_src0.close
      	archivo_point.close
      	print ("Fin generacion")
      

      def Uscita(self):
      quit()

      class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
      def init(self, *args, **kwargs):
      QtWidgets.QMainWindow.init(self, *args, **kwargs)
      self.setupUi(self)
      self.Tasto_Uscita.clicked.connect(Uscita)
      self.Tasto_Generar_File.clicked.connect(Control_Datos)

      #self.Tasto_Nuevo_Pro.clicked(Nuovo_Proggetto)
      

      if name == "main":
      app = QtWidgets.QApplication([])
      window = MainWindow()
      window.show()
      app.exec_()

      Pantalla:

      -- coding: utf-8 --

      Form implementation generated from reading ui file 'Scn_Cnv_Dobot.ui'

      Created by: PyQt5 UI code generator 5.15.7

      WARNING: Any manual changes made to this file will be lost when pyuic5 is

      run again. Do not edit this file unless you know what you are doing.

      from PyQt5 import QtCore, QtGui, QtWidgets

      class Ui_MainWindow(object):
      def setupUi(self, MainWindow):
      MainWindow.setObjectName("MainWindow")
      MainWindow.resize(842, 464)
      MainWindow.setMinimumSize(QtCore.QSize(0, 464))
      MainWindow.setStyleSheet("background-color: rgb(221, 255, 205);")
      self.centralwidget = QtWidgets.QWidget(MainWindow)
      self.centralwidget.setObjectName("centralwidget")
      self.Titulo_Principal = QtWidgets.QLabel(self.centralwidget)
      self.Titulo_Principal.setGeometry(QtCore.QRect(10, 0, 321, 31))
      self.Titulo_Principal.setStyleSheet("font: 87 12pt "Arial Black";\n"
      "background-color: rgb(8, 202, 255);")
      self.Titulo_Principal.setObjectName("Titulo_Principal")
      self.Grafica_MgM = QtWidgets.QGraphicsView(self.centralwidget)
      self.Grafica_MgM.setGeometry(QtCore.QRect(610, 20, 211, 141))
      self.Grafica_MgM.setObjectName("Grafica_MgM")
      self.Titolo_Sorgente = QtWidgets.QLabel(self.centralwidget)
      self.Titolo_Sorgente.setGeometry(QtCore.QRect(20, 50, 121, 21))
      self.Titolo_Sorgente.setStyleSheet("font: 87 11pt "Arial Black";\n"
      "background-color: rgb(255, 255, 127);")
      self.Titolo_Sorgente.setObjectName("Titolo_Sorgente")
      self.Info_Codigo = QtWidgets.QLineEdit(self.centralwidget)
      self.Info_Codigo.setGeometry(QtCore.QRect(770, 170, 51, 20))
      self.Info_Codigo.setObjectName("Info_Codigo")
      self.Info_Variabile = QtWidgets.QLineEdit(self.centralwidget)
      self.Info_Variabile.setGeometry(QtCore.QRect(770, 200, 51, 20))
      self.Info_Variabile.setObjectName("Info_Variabile")
      self.Info_Global = QtWidgets.QLineEdit(self.centralwidget)
      self.Info_Global.setGeometry(QtCore.QRect(770, 230, 51, 20))
      self.Info_Global.setObjectName("Info_Global")
      self.Info_Proggeto = QtWidgets.QLineEdit(self.centralwidget)
      self.Info_Proggeto.setGeometry(QtCore.QRect(770, 260, 51, 20))
      self.Info_Proggeto.setObjectName("Info_Proggeto")
      self.Titolo_Codigo = QtWidgets.QLabel(self.centralwidget)
      self.Titolo_Codigo.setGeometry(QtCore.QRect(680, 170, 71, 21))
      self.Titolo_Codigo.setStyleSheet("font: 87 8pt "Arial Black";\n"
      "background-color: rgb(255, 255, 127);")
      self.Titolo_Codigo.setObjectName("Titolo_Codigo")
      self.Titolo_Variabile = QtWidgets.QLabel(self.centralwidget)
      self.Titolo_Variabile.setGeometry(QtCore.QRect(670, 200, 81, 21))
      self.Titolo_Variabile.setStyleSheet("font: 87 8pt "Arial Black";\n"
      "background-color: rgb(255, 255, 127);")
      self.Titolo_Variabile.setObjectName("Titolo_Variabile")
      self.Titolo_Global = QtWidgets.QLabel(self.centralwidget)
      self.Titolo_Global.setGeometry(QtCore.QRect(670, 230, 81, 21))
      self.Titolo_Global.setStyleSheet("font: 87 8pt "Arial Black";\n"
      "background-color: rgb(255, 255, 127);")
      self.Titolo_Global.setObjectName("Titolo_Global")
      self.Titolo_File_Proggeto = QtWidgets.QLabel(self.centralwidget)
      self.Titolo_File_Proggeto.setGeometry(QtCore.QRect(670, 260, 81, 21))
      self.Titolo_File_Proggeto.setStyleSheet("font: 87 8pt "Arial Black";\n"
      "background-color: rgb(255, 255, 127);")
      self.Titolo_File_Proggeto.setObjectName("Titolo_File_Proggeto")
      self.Titolo_Proggeto = QtWidgets.QLabel(self.centralwidget)
      self.Titolo_Proggeto.setGeometry(QtCore.QRect(231, 107, 90, 21))
      self.Titolo_Proggeto.setStyleSheet("font: 87 11pt "Arial Black";\n"
      "background-color: rgb(255, 255, 127);")
      self.Titolo_Proggeto.setObjectName("Titolo_Proggeto")
      self.Titolo_Versioni = QtWidgets.QLabel(self.centralwidget)
      self.Titolo_Versioni.setGeometry(QtCore.QRect(740, 410, 91, 21))
      self.Titolo_Versioni.setStyleSheet("font: 87 7pt "Arial Black";")
      self.Titolo_Versioni.setObjectName("Titolo_Versioni")
      self.Titolo_Cartela = QtWidgets.QLabel(self.centralwidget)
      self.Titolo_Cartela.setGeometry(QtCore.QRect(360, 178, 81, 21))
      self.Titolo_Cartela.setStyleSheet("font: 87 11pt "Arial Black";\n"
      "background-color: rgb(255, 255, 127);")
      self.Titolo_Cartela.setObjectName("Titolo_Cartela")
      self.Titolo_Info = QtWidgets.QLabel(self.centralwidget)
      self.Titolo_Info.setGeometry(QtCore.QRect(10, 250, 51, 21))
      self.Titolo_Info.setStyleSheet("font: 87 11pt "Arial Black";\n"
      "background-color: rgb(255, 255, 127);")
      self.Titolo_Info.setObjectName("Titolo_Info")
      self.dateEdit = QtWidgets.QDateEdit(self.centralwidget)
      self.dateEdit.setGeometry(QtCore.QRect(690, 0, 110, 22))
      self.dateEdit.setObjectName("dateEdit")
      self.Tasto_Nuovo_Pro = QtWidgets.QPushButton(self.centralwidget)
      self.Tasto_Nuovo_Pro.setGeometry(QtCore.QRect(390, 10, 181, 31))
      self.Tasto_Nuovo_Pro.setStyleSheet("font: 87 12pt "Arial Black";\n"
      "background-color: rgb(170, 170, 127);")
      self.Tasto_Nuovo_Pro.setObjectName("Tasto_Nuovo_Pro")
      self.Tasto_Generar_File = QtWidgets.QPushButton(self.centralwidget)
      self.Tasto_Generar_File.setGeometry(QtCore.QRect(400, 50, 161, 51))
      self.Tasto_Generar_File.setStyleSheet("font: 87 12pt "Arial Black";\n"
      "background-color: rgb(85, 255, 0);")
      self.Tasto_Generar_File.setObjectName("Tasto_Generar_File")
      self.Tasto_Uscita = QtWidgets.QPushButton(self.centralwidget)
      self.Tasto_Uscita.setGeometry(QtCore.QRect(670, 360, 151, 23))
      self.Tasto_Uscita.setStyleSheet("font: 87 14pt "Arial Black";\n"
      "background-color: rgb(255, 85, 255);")
      self.Tasto_Uscita.setObjectName("Tasto_Uscita")
      self.label_12 = QtWidgets.QLabel(self.centralwidget)
      self.label_12.setGeometry(QtCore.QRect(10, 380, 591, 41))
      self.label_12.setStyleSheet("background-color: rgb(255, 244, 158);\n"
      "font: 87 10pt "Arial Black";")
      self.label_12.setObjectName("label_12")
      self.Titolo_Instruzioni = QtWidgets.QLabel(self.centralwidget)
      self.Titolo_Instruzioni.setGeometry(QtCore.QRect(10, 360, 121, 21))
      self.Titolo_Instruzioni.setStyleSheet("font: 87 11pt "Arial Black";\n"
      "background-color: rgb(255, 255, 127);")
      self.Titolo_Instruzioni.setObjectName("Titolo_Instruzioni")
      self.Titolo_Proggeto_3 = QtWidgets.QLabel(self.centralwidget)
      self.Titolo_Proggeto_3.setGeometry(QtCore.QRect(350, 270, 171, 21))
      self.Titolo_Proggeto_3.setStyleSheet("font: 87 11pt "Arial Black";\n"
      "background-color: rgb(255, 255, 127);")
      self.Titolo_Proggeto_3.setObjectName("Titolo_Proggeto_3")
      self.Titolo_Proggeto_4 = QtWidgets.QLabel(self.centralwidget)
      self.Titolo_Proggeto_4.setGeometry(QtCore.QRect(353, 307, 161, 21))
      self.Titolo_Proggeto_4.setStyleSheet("font: 87 11pt "Arial Black";\n"
      "background-color: rgb(255, 255, 127);")
      self.Titolo_Proggeto_4.setObjectName("Titolo_Proggeto_4")
      self.Campo_Sorgente = QtWidgets.QLineEdit(self.centralwidget)
      self.Campo_Sorgente.setGeometry(QtCore.QRect(20, 70, 191, 31))
      font = QtGui.QFont()
      font.setFamily("Arial Black")
      font.setPointSize(11)
      font.setBold(False)
      font.setItalic(False)
      font.setWeight(10)
      self.Campo_Sorgente.setFont(font)
      self.Campo_Sorgente.setStyleSheet("font: 87 11pt "Arial Black";\n"
      "background-color: rgb(231, 225, 255);")
      self.Campo_Sorgente.setText("")
      self.Campo_Sorgente.setObjectName("Campo_Sorgente")
      self.Campo_Progetto = QtWidgets.QLineEdit(self.centralwidget)
      self.Campo_Progetto.setGeometry(QtCore.QRect(220, 150, 191, 31))
      font = QtGui.QFont()
      font.setFamily("Arial Black")
      font.setPointSize(11)
      font.setBold(False)
      font.setItalic(False)
      font.setWeight(10)
      self.Campo_Progetto.setFont(font)
      self.Campo_Progetto.setStyleSheet("font: 87 11pt "Arial Black";\n"
      "background-color: rgb(175, 255, 250);")
      self.Campo_Progetto.setText("")
      self.Campo_Progetto.setObjectName("Campo_Progetto")
      self.Campo_Cartella = QtWidgets.QLineEdit(self.centralwidget)
      self.Campo_Cartella.setGeometry(QtCore.QRect(360, 200, 191, 31))
      font = QtGui.QFont()
      font.setFamily("Arial Black")
      font.setPointSize(11)
      font.setBold(False)
      font.setItalic(False)
      font.setWeight(10)
      self.Campo_Cartella.setFont(font)
      self.Campo_Cartella.setStyleSheet("background-color: rgb(255, 210, 157);\n"
      "font: 87 11pt "Arial Black";")
      self.Campo_Cartella.setText("")
      self.Campo_Cartella.setObjectName("Campo_Cartella")
      self.Campo_Vel_Trasl = QtWidgets.QLineEdit(self.centralwidget)
      self.Campo_Vel_Trasl.setGeometry(QtCore.QRect(520, 260, 101, 31))
      font = QtGui.QFont()
      font.setFamily("Arial Black")
      font.setPointSize(11)
      font.setBold(False)
      font.setItalic(False)
      font.setWeight(10)
      self.Campo_Vel_Trasl.setFont(font)
      self.Campo_Vel_Trasl.setStyleSheet("font: 87 11pt "Arial Black";\n"
      "background-color: rgb(231, 225, 255);")
      self.Campo_Vel_Trasl.setText("")
      self.Campo_Vel_Trasl.setObjectName("Campo_Vel_Trasl")
      self.Campo_Vel_Taglio = QtWidgets.QLineEdit(self.centralwidget)
      self.Campo_Vel_Taglio.setGeometry(QtCore.QRect(521, 300, 100, 31))
      font = QtGui.QFont()
      font.setFamily("Arial Black")
      font.setPointSize(11)
      font.setBold(False)
      font.setItalic(False)
      font.setWeight(10)
      self.Campo_Vel_Taglio.setFont(font)
      self.Campo_Vel_Taglio.setStyleSheet("font: 87 11pt "Arial Black";\n"
      "background-color: rgb(231, 225, 255);")
      self.Campo_Vel_Taglio.setText("")
      self.Campo_Vel_Taglio.setObjectName("Campo_Vel_Taglio")
      self.Campo_Info = QtWidgets.QLineEdit(self.centralwidget)
      self.Campo_Info.setGeometry(QtCore.QRect(10, 270, 331, 81))
      font = QtGui.QFont()
      font.setFamily("Arial Black")
      font.setPointSize(11)
      font.setBold(False)
      font.setItalic(False)
      font.setWeight(10)
      self.Campo_Info.setFont(font)
      self.Campo_Info.setStyleSheet("font: 87 11pt "Arial Black";\n"
      "background-color: rgb(239, 255, 164);")
      self.Campo_Info.setText("")
      self.Campo_Info.setObjectName("Campo_Info")
      self.label = QtWidgets.QLabel(self.centralwidget)
      self.label.setGeometry(QtCore.QRect(480, 140, 47, 13))
      self.label.setObjectName("label")
      MainWindow.setCentralWidget(self.centralwidget)
      self.menubar = QtWidgets.QMenuBar(MainWindow)
      self.menubar.setGeometry(QtCore.QRect(0, 0, 842, 21))
      self.menubar.setObjectName("menubar")
      MainWindow.setMenuBar(self.menubar)
      self.statusbar = QtWidgets.QStatusBar(MainWindow)
      self.statusbar.setObjectName("statusbar")
      MainWindow.setStatusBar(self.statusbar)

          self.retranslateUi(MainWindow)
          QtCore.QMetaObject.connectSlotsByName(MainWindow)
      
      def retranslateUi(self, MainWindow):
          _translate = QtCore.QCoreApplication.translate
          MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
          self.Titulo_Principal.setText(_translate("MainWindow", "  Conversor Gcode a Lua per DOBOT"))
          self.Titolo_Sorgente.setText(_translate("MainWindow", "File Sorgente"))
          self.Titolo_Codigo.setText(_translate("MainWindow", "File Codigo"))
          self.Titolo_Variabile.setText(_translate("MainWindow", "File Variables"))
          self.Titolo_Global.setText(_translate("MainWindow", "File Golbal"))
          self.Titolo_File_Proggeto.setText(_translate("MainWindow", "File Progetto"))
          self.Titolo_Proggeto.setText(_translate("MainWindow", "Proggeto"))
          self.Titolo_Versioni.setText(_translate("MainWindow", "Version RM  1-1"))
          self.Titolo_Cartela.setText(_translate("MainWindow", "Cartella"))
          self.Titolo_Info.setText(_translate("MainWindow", "Info"))
          self.Tasto_Nuovo_Pro.setText(_translate("MainWindow", "Nuovo Proggetto"))
          self.Tasto_Generar_File.setText(_translate("MainWindow", "Generar Files"))
          self.Tasto_Uscita.setText(_translate("MainWindow", "Uscita "))
          self.label_12.setText(_translate("MainWindow", "Per questa versione i Circolare bisgogna disegnarli con \'piccole\' trati lineare."))
          self.Titolo_Instruzioni.setText(_translate("MainWindow", " Instrazione"))
          self.Titolo_Proggeto_3.setText(_translate("MainWindow", "Velocita Traslato %"))
          self.Titolo_Proggeto_4.setText(_translate("MainWindow", "Velocita Taglio %"))
          self.label.setText(_translate("MainWindow", "TextLabel"))
      

      if name == "main":
      import sys
      app = QtWidgets.QApplication(sys.argv)
      MainWindow = QtWidgets.QMainWindow()
      ui = Ui_MainWindow()
      ui.setupUi(MainWindow)
      MainWindow.show()
      sys.exit(app.exec_())

      C Offline
      C Offline
      ChrisW67
      wrote on 2 Jan 2024, 01:32 last edited by ChrisW67 1 Feb 2024, 03:11
      #2

      @Raulh No hablo español. Trabajando desde una versión de Google Translate. Perdona cualquier mala traducción.

      Welcome to the forum.

      Bienvenido al foro.

      I think you are asking how to access the text edits in the Designer UI. Here is a simple example:

      Creo que estás preguntando cómo acceder a las ediciones de texto en la interfaz de usuario del Diseñador. Aquí hay un ejemplo simple:

      main.py

      from PyQt5 import Qt, QtWidgets
      from ui_mainwindow import Ui_MainWindow
      
      
      class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
          def __init__(self, *args, **kwargs):
              QtWidgets.QMainWindow.__init__(self, *args, **kwargs)
              self.setupUi(self)
              self.pbQuit.clicked.connect(self.close)
              self.pbAdd.clicked.connect(self.addClicked)
      
          def addClicked(self):
              self.lineEdit.setText(self.lineEdit.text() + "Text! ")
              self.plainTextEdit.setPlainText(self.plainTextEdit.toPlainText() + "Text!\n")
      
      if __name__ == "__main__":
          app = QtWidgets.QApplication([])
          window = MainWindow()
          window.show()
          app.exec_()
      

      ui_mainwindow.ui

      <?xml version="1.0" encoding="UTF-8"?>
      <ui version="4.0">
       <class>MainWindow</class>
       <widget class="QMainWindow" name="MainWindow">
        <property name="geometry">
         <rect>
          <x>0</x>
          <y>0</y>
          <width>800</width>
          <height>600</height>
         </rect>
        </property>
        <property name="windowTitle">
         <string>MainWindow</string>
        </property>
        <widget class="QWidget" name="centralwidget">
         <layout class="QVBoxLayout" name="verticalLayout">
          <item>
           <widget class="QLineEdit" name="lineEdit"/>
          </item>
          <item>
           <widget class="QPlainTextEdit" name="plainTextEdit"/>
          </item>
          <item>
           <layout class="QHBoxLayout" name="horizontalLayout">
            <item>
             <widget class="QPushButton" name="pbAdd">
              <property name="text">
               <string>Agregar</string>
              </property>
             </widget>
            </item>
            <item>
             <widget class="QPushButton" name="pbQuit">
              <property name="text">
               <string>Abandonar</string>
              </property>
             </widget>
            </item>
           </layout>
          </item>
         </layout>
        </widget>
        <widget class="QMenuBar" name="menubar">
         <property name="geometry">
          <rect>
           <x>0</x>
           <y>0</y>
           <width>800</width>
           <height>30</height>
          </rect>
         </property>
        </widget>
        <widget class="QStatusBar" name="statusbar"/>
       </widget>
       <resources/>
       <connections/>
      </ui>
      

      Please use code tags when posting code. You can:

      • select some text and use the </> tool in the editor, or
      • type three backticks (```) on a line before and after each block.

      Utilice etiquetas de código al publicar código. Puede:

      • seleccione algo de texto y use la herramienta </> en el editor, o
      • escriba tres comillas invertidas (```) en una línea antes y después de cada bloque.
      1 Reply Last reply
      0
      • R Raulh
        1 Jan 2024, 21:11

        Hola, adjunto dos file .py. No encuentro la sintaxis para optener y escribir sobre los text de los widgest desde un programa q importa con from una panatlla qt ya traducida a python.
        En el ejemplo es al presionar el boton 'Generar File', ejecutandose la def 'Control de datos'.

        Programa de conbversion Gcode a Lua per Dobot

        File Conv_Gcode_a_Lua

        Raul

        File de Texto original 852303

        File de destino point.Json

        prj.json

        src0.lua

        global.lua

        fileCRCCode.json

        import sys
        import time
        from PyQt5.QtCore import Qt

        from Scn_Cnv_Dobot import *

        class Aplicacion:

        def Calculo_puntos():
        	Punto += 1
        
        	Punto_X = linea.find("X",primer_caracter_g)
        	Punto_Y = linea.find("Y",primer_caracter_g)
        	Punto_Z = linea.find("Z",primer_caracter_g)
        		
        	if Punto_X !=-1:
        		Punto_X_Es = linea.find(" ",Punto_X)
        		if Punto_X_Es == -1:
        			Punto_X_Val = linea[Punto_X+1:len(linea)]
        			Punto_X_Val = Punto_X_Val.strip()
        		else:
        			Punto_X_Val = linea[Punto_X+1:Punto_X_Es]
        			Punto_X_Val = Punto_X_Val.strip()
        		if Punto_Y !=-1:
        			Punto_Y_Es = linea.find(" ",Punto_Y)
        		if Punto_Y_Es == -1:
        			Punto_Y_Val = linea[Punto_Y+1:len(linea)]
        			Punto_Y_Val = Punto_Y_Val.strip()
        		else:
        			Punto_Y_Val = linea[Punto_Y+1:Punto_Y_Es]
        			Punto_Y_Val = Punto_Y_Val.strip()
        		
        	if Punto_Z !=-1:
        		Punto_Z_Es = linea.find(" ",Punto_Z)
        		if Punto_Z_Es == -1:
        			Punto_Z_Val = linea[Punto_Z+1:len(linea)]
        			Punto_Z_Val = Punto_Z_Val.strip()
        		else:
        			Punto_Z_Val = linea[Punto_Z+1:Punto_Z_Es]
        			Punto_Z_Val = Punto_Z_Val.strip()
        			
        	Pto_Save_1 = "\"name:\""+"\"P\"" +str(Punto)+"\"tool\""+":1"+"\"user\""+":1,"
        	Pto_Save_2 = "\"joint\":[-20.0277,-11.1383,88.9708,30.2226,-91.7566,-261.5641]},{\"id\":1699604796888,\"alias\":\"\",\n"
        	Pto_Save_3 = "\"armOrientation\":[1,1,1,-1],\"coordinate\":["
        	Pto_Save_4 = str(Punto_X_Val)+","+str(Punto_Y_Val)+","+str(Punto_Z_Val)+","+str(A_Euler)+","+str(E_Euler)+","+str(R_Euler)+"]\n"
        	Pto_Save_5 = "\n"
        		
        	archivo_point.write(Pto_Save_1)
        	archivo_point.write(Pto_Save_2)
        	archivo_point.write(Pto_Save_3)
        	archivo_point.write(Pto_Save_4)
        
        def Crear_Cartela():
        	print ("")
        def Copiar_File():
        	print ('')
        
        def Init():
        	os.path.getsize("852303.txt")
        	Uscita = 3
        	On =1 
        	Off = 0
        	A_Euler = 20.101
        	E_Euler = 22.202
        	R_Euler = 33.303
        	Punto = 0
        	P_save = 10
        	Punto_X_Val = 0
        	Punto_Y_Val = 0
        	Punto_Z_Val = 0
        	#
        

        def Control_Datos():
        print ("Contro d Ver Mod 7")
        #Cpo_Sorg = (Campo_Sorgente[text()])
        #Cpo_Info = (Campo_Info[SetText()],"Texto")
        # Cambio color a Info_Progetto
        # Cambio texto a una Label
        print ("Control Datos ejecutada")

        def Generacion_Files():

        	Init()
        	#Control_Datos()
        
        	archivo_gcode = open ("852303.txt","r")
        	archivo_src0 = open ("src0.lua","w")
        	archivo_point = open ("point.json","w")
        	archivo_point.write("[{\"id\":\"base\",\"alias\":\"\",\"armOrientation\":[1,1,-1,-1],\"coordinate\":[0,0,0,0,0,0],\n");
        	archivo_point.write("\"name\":\"InitialPose\",\"tool\":0,\"user\":0,\"joint\":[0,0,0,0,0,0]},{\"id\":1699604731023,\"alias\":\"\",\n");
        	archivo_point.write("\"armOrientation\":[1,1,1,-1],\"coordinate\":[-555.0739,2.8527,746.882,-175.0788,-17.2875,-29.1041],\n");
        	#  ===============================================
        	archivo_global = open ("global.lua","w")
        	archivo_global.close
        	archivo_prj = open ("prj.json","w")
        	Prj_Save = "{"+"\"cpus\""+":[\"src0.lua\"],\"global\":\"global.lua\",\"teach_point\":\"point.json\"}"
        	archivo_prj.write(Prj_Save)
        	archivo_prj.close
        
        	archivo_fileCRCCode = open ("fileCRCCode.json","w")
        	CRCCode_Save ="{\"fileName\":[\"scratch.xml\",\"global.lua\",\"point.json\",\"prj.json\",\"src0.lua\"],\"crcCode\":[2064672904,0,3216453487,668367846,1563868684]}"
        	archivo_fileCRCCode.write(CRCCode_Save)
        	archivo_fileCRCCode.close 
        	#=================================================
        
        	total_lineas = len(archivo_gcode.readline())
        	archivo_src0.write("--- \n");
        	archivo_src0.write(" \n")
        	archivo_src0.write("local Option 1={CP=1, SpeedL=40, AccL=10} "+"---\n");
        	archivo_src0.write("local Option 2={CP=100, SpeedL=15, AccL=10} "+"---\n");
        	archivo_src0.write(" \n")
        
        
        
        
        	for i in range (0,55):
        		linea = archivo_gcode.readline()
        		lg = len(linea)
        		print("linea Nro",i," Long: ",lg,"  ",linea)
        
        		primer_caracter_g = linea.find("G")
        		primer_caracter_m = linea.find("M")
        		primer_caracter_f = linea.find("F")
        		primer_caracter_Paren = linea.find("(")
        
        		if primer_caracter_Paren != -1:
        			archivo_src0.write("---"+" "+linea);
        		else:
        			if primer_caracter_g != -1:
        	
        				gcodigo = linea[primer_caracter_g:7]
        				gcodigo = gcodigo.strip()
        
        				if gcodigo == "G0":
        					#===========================
        					Calculo_puntos()
        					archivo_src0.write("  MovJ("+"P"+str(Punto)+",Option1"+")"+"\n");
        					#============================
        
        				if gcodigo == "G1":
        					#===========================
        					Calculo_puntos()
        					archivo_src0.write("  MovL("+"P"+str(Punto)+",Option2"+")"+"\n")
        					#============================
        
        				if gcodigo == "G2":
        					#===========================
        					Calculo_puntos()
        					archivo_src0.write("  MovL("+"P"+str(Punto)+",Option2"+")"+"\n")
        					#============================
        
        				if gcodigo == "G4":
        					primer_caracter_p = linea.find("P")
        					Punto_P_Val = linea[primer_caracter_p+1:len(linea)]
        					Punto_P_Val = Punto_P_Val.strip()
        					archivo_src0.write("  WAIT("+str(Punto_P_Val)+")"+"\n");	
        
        				if gcodigo == "G90":
        					archivo_src0.write("--- "+str(i)+" "+gcodigo+"  90"+"\n");
        				if gcodigo == "G71":
        					archivo_src0.write("--- "+str(i)+" "+gcodigo+"  71"+"\n");
        
        			else:
        				if primer_caracter_m != -1:
        					mcodigo = linea[primer_caracter_m:8]
        					mcodigo = mcodigo.strip()
        					if mcodigo =="M3":
        						archivo_src0.write( "  DO("+str(Uscita)+","+str(On)+")"+"\n");
        					if mcodigo =="M5":
        						archivo_src0.write( "  DO("+str(Uscita)+","+str(Off)+")"+"\n");
        		
        				if primer_caracter_f != -1:
        					fcodigo = linea[primer_caracter_f:9]
        					fcodigo = fcodigo.strip()
        					archivo_src0.write(str(i)+" "+fcodigo+"\n");
        				
        
        	##
        	archivo_gcode.close
        	archivo_src0.close
        	archivo_point.close
        	print ("Fin generacion")
        

        def Uscita(self):
        quit()

        class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
        def init(self, *args, **kwargs):
        QtWidgets.QMainWindow.init(self, *args, **kwargs)
        self.setupUi(self)
        self.Tasto_Uscita.clicked.connect(Uscita)
        self.Tasto_Generar_File.clicked.connect(Control_Datos)

        #self.Tasto_Nuevo_Pro.clicked(Nuovo_Proggetto)
        

        if name == "main":
        app = QtWidgets.QApplication([])
        window = MainWindow()
        window.show()
        app.exec_()

        Pantalla:

        -- coding: utf-8 --

        Form implementation generated from reading ui file 'Scn_Cnv_Dobot.ui'

        Created by: PyQt5 UI code generator 5.15.7

        WARNING: Any manual changes made to this file will be lost when pyuic5 is

        run again. Do not edit this file unless you know what you are doing.

        from PyQt5 import QtCore, QtGui, QtWidgets

        class Ui_MainWindow(object):
        def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(842, 464)
        MainWindow.setMinimumSize(QtCore.QSize(0, 464))
        MainWindow.setStyleSheet("background-color: rgb(221, 255, 205);")
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.Titulo_Principal = QtWidgets.QLabel(self.centralwidget)
        self.Titulo_Principal.setGeometry(QtCore.QRect(10, 0, 321, 31))
        self.Titulo_Principal.setStyleSheet("font: 87 12pt "Arial Black";\n"
        "background-color: rgb(8, 202, 255);")
        self.Titulo_Principal.setObjectName("Titulo_Principal")
        self.Grafica_MgM = QtWidgets.QGraphicsView(self.centralwidget)
        self.Grafica_MgM.setGeometry(QtCore.QRect(610, 20, 211, 141))
        self.Grafica_MgM.setObjectName("Grafica_MgM")
        self.Titolo_Sorgente = QtWidgets.QLabel(self.centralwidget)
        self.Titolo_Sorgente.setGeometry(QtCore.QRect(20, 50, 121, 21))
        self.Titolo_Sorgente.setStyleSheet("font: 87 11pt "Arial Black";\n"
        "background-color: rgb(255, 255, 127);")
        self.Titolo_Sorgente.setObjectName("Titolo_Sorgente")
        self.Info_Codigo = QtWidgets.QLineEdit(self.centralwidget)
        self.Info_Codigo.setGeometry(QtCore.QRect(770, 170, 51, 20))
        self.Info_Codigo.setObjectName("Info_Codigo")
        self.Info_Variabile = QtWidgets.QLineEdit(self.centralwidget)
        self.Info_Variabile.setGeometry(QtCore.QRect(770, 200, 51, 20))
        self.Info_Variabile.setObjectName("Info_Variabile")
        self.Info_Global = QtWidgets.QLineEdit(self.centralwidget)
        self.Info_Global.setGeometry(QtCore.QRect(770, 230, 51, 20))
        self.Info_Global.setObjectName("Info_Global")
        self.Info_Proggeto = QtWidgets.QLineEdit(self.centralwidget)
        self.Info_Proggeto.setGeometry(QtCore.QRect(770, 260, 51, 20))
        self.Info_Proggeto.setObjectName("Info_Proggeto")
        self.Titolo_Codigo = QtWidgets.QLabel(self.centralwidget)
        self.Titolo_Codigo.setGeometry(QtCore.QRect(680, 170, 71, 21))
        self.Titolo_Codigo.setStyleSheet("font: 87 8pt "Arial Black";\n"
        "background-color: rgb(255, 255, 127);")
        self.Titolo_Codigo.setObjectName("Titolo_Codigo")
        self.Titolo_Variabile = QtWidgets.QLabel(self.centralwidget)
        self.Titolo_Variabile.setGeometry(QtCore.QRect(670, 200, 81, 21))
        self.Titolo_Variabile.setStyleSheet("font: 87 8pt "Arial Black";\n"
        "background-color: rgb(255, 255, 127);")
        self.Titolo_Variabile.setObjectName("Titolo_Variabile")
        self.Titolo_Global = QtWidgets.QLabel(self.centralwidget)
        self.Titolo_Global.setGeometry(QtCore.QRect(670, 230, 81, 21))
        self.Titolo_Global.setStyleSheet("font: 87 8pt "Arial Black";\n"
        "background-color: rgb(255, 255, 127);")
        self.Titolo_Global.setObjectName("Titolo_Global")
        self.Titolo_File_Proggeto = QtWidgets.QLabel(self.centralwidget)
        self.Titolo_File_Proggeto.setGeometry(QtCore.QRect(670, 260, 81, 21))
        self.Titolo_File_Proggeto.setStyleSheet("font: 87 8pt "Arial Black";\n"
        "background-color: rgb(255, 255, 127);")
        self.Titolo_File_Proggeto.setObjectName("Titolo_File_Proggeto")
        self.Titolo_Proggeto = QtWidgets.QLabel(self.centralwidget)
        self.Titolo_Proggeto.setGeometry(QtCore.QRect(231, 107, 90, 21))
        self.Titolo_Proggeto.setStyleSheet("font: 87 11pt "Arial Black";\n"
        "background-color: rgb(255, 255, 127);")
        self.Titolo_Proggeto.setObjectName("Titolo_Proggeto")
        self.Titolo_Versioni = QtWidgets.QLabel(self.centralwidget)
        self.Titolo_Versioni.setGeometry(QtCore.QRect(740, 410, 91, 21))
        self.Titolo_Versioni.setStyleSheet("font: 87 7pt "Arial Black";")
        self.Titolo_Versioni.setObjectName("Titolo_Versioni")
        self.Titolo_Cartela = QtWidgets.QLabel(self.centralwidget)
        self.Titolo_Cartela.setGeometry(QtCore.QRect(360, 178, 81, 21))
        self.Titolo_Cartela.setStyleSheet("font: 87 11pt "Arial Black";\n"
        "background-color: rgb(255, 255, 127);")
        self.Titolo_Cartela.setObjectName("Titolo_Cartela")
        self.Titolo_Info = QtWidgets.QLabel(self.centralwidget)
        self.Titolo_Info.setGeometry(QtCore.QRect(10, 250, 51, 21))
        self.Titolo_Info.setStyleSheet("font: 87 11pt "Arial Black";\n"
        "background-color: rgb(255, 255, 127);")
        self.Titolo_Info.setObjectName("Titolo_Info")
        self.dateEdit = QtWidgets.QDateEdit(self.centralwidget)
        self.dateEdit.setGeometry(QtCore.QRect(690, 0, 110, 22))
        self.dateEdit.setObjectName("dateEdit")
        self.Tasto_Nuovo_Pro = QtWidgets.QPushButton(self.centralwidget)
        self.Tasto_Nuovo_Pro.setGeometry(QtCore.QRect(390, 10, 181, 31))
        self.Tasto_Nuovo_Pro.setStyleSheet("font: 87 12pt "Arial Black";\n"
        "background-color: rgb(170, 170, 127);")
        self.Tasto_Nuovo_Pro.setObjectName("Tasto_Nuovo_Pro")
        self.Tasto_Generar_File = QtWidgets.QPushButton(self.centralwidget)
        self.Tasto_Generar_File.setGeometry(QtCore.QRect(400, 50, 161, 51))
        self.Tasto_Generar_File.setStyleSheet("font: 87 12pt "Arial Black";\n"
        "background-color: rgb(85, 255, 0);")
        self.Tasto_Generar_File.setObjectName("Tasto_Generar_File")
        self.Tasto_Uscita = QtWidgets.QPushButton(self.centralwidget)
        self.Tasto_Uscita.setGeometry(QtCore.QRect(670, 360, 151, 23))
        self.Tasto_Uscita.setStyleSheet("font: 87 14pt "Arial Black";\n"
        "background-color: rgb(255, 85, 255);")
        self.Tasto_Uscita.setObjectName("Tasto_Uscita")
        self.label_12 = QtWidgets.QLabel(self.centralwidget)
        self.label_12.setGeometry(QtCore.QRect(10, 380, 591, 41))
        self.label_12.setStyleSheet("background-color: rgb(255, 244, 158);\n"
        "font: 87 10pt "Arial Black";")
        self.label_12.setObjectName("label_12")
        self.Titolo_Instruzioni = QtWidgets.QLabel(self.centralwidget)
        self.Titolo_Instruzioni.setGeometry(QtCore.QRect(10, 360, 121, 21))
        self.Titolo_Instruzioni.setStyleSheet("font: 87 11pt "Arial Black";\n"
        "background-color: rgb(255, 255, 127);")
        self.Titolo_Instruzioni.setObjectName("Titolo_Instruzioni")
        self.Titolo_Proggeto_3 = QtWidgets.QLabel(self.centralwidget)
        self.Titolo_Proggeto_3.setGeometry(QtCore.QRect(350, 270, 171, 21))
        self.Titolo_Proggeto_3.setStyleSheet("font: 87 11pt "Arial Black";\n"
        "background-color: rgb(255, 255, 127);")
        self.Titolo_Proggeto_3.setObjectName("Titolo_Proggeto_3")
        self.Titolo_Proggeto_4 = QtWidgets.QLabel(self.centralwidget)
        self.Titolo_Proggeto_4.setGeometry(QtCore.QRect(353, 307, 161, 21))
        self.Titolo_Proggeto_4.setStyleSheet("font: 87 11pt "Arial Black";\n"
        "background-color: rgb(255, 255, 127);")
        self.Titolo_Proggeto_4.setObjectName("Titolo_Proggeto_4")
        self.Campo_Sorgente = QtWidgets.QLineEdit(self.centralwidget)
        self.Campo_Sorgente.setGeometry(QtCore.QRect(20, 70, 191, 31))
        font = QtGui.QFont()
        font.setFamily("Arial Black")
        font.setPointSize(11)
        font.setBold(False)
        font.setItalic(False)
        font.setWeight(10)
        self.Campo_Sorgente.setFont(font)
        self.Campo_Sorgente.setStyleSheet("font: 87 11pt "Arial Black";\n"
        "background-color: rgb(231, 225, 255);")
        self.Campo_Sorgente.setText("")
        self.Campo_Sorgente.setObjectName("Campo_Sorgente")
        self.Campo_Progetto = QtWidgets.QLineEdit(self.centralwidget)
        self.Campo_Progetto.setGeometry(QtCore.QRect(220, 150, 191, 31))
        font = QtGui.QFont()
        font.setFamily("Arial Black")
        font.setPointSize(11)
        font.setBold(False)
        font.setItalic(False)
        font.setWeight(10)
        self.Campo_Progetto.setFont(font)
        self.Campo_Progetto.setStyleSheet("font: 87 11pt "Arial Black";\n"
        "background-color: rgb(175, 255, 250);")
        self.Campo_Progetto.setText("")
        self.Campo_Progetto.setObjectName("Campo_Progetto")
        self.Campo_Cartella = QtWidgets.QLineEdit(self.centralwidget)
        self.Campo_Cartella.setGeometry(QtCore.QRect(360, 200, 191, 31))
        font = QtGui.QFont()
        font.setFamily("Arial Black")
        font.setPointSize(11)
        font.setBold(False)
        font.setItalic(False)
        font.setWeight(10)
        self.Campo_Cartella.setFont(font)
        self.Campo_Cartella.setStyleSheet("background-color: rgb(255, 210, 157);\n"
        "font: 87 11pt "Arial Black";")
        self.Campo_Cartella.setText("")
        self.Campo_Cartella.setObjectName("Campo_Cartella")
        self.Campo_Vel_Trasl = QtWidgets.QLineEdit(self.centralwidget)
        self.Campo_Vel_Trasl.setGeometry(QtCore.QRect(520, 260, 101, 31))
        font = QtGui.QFont()
        font.setFamily("Arial Black")
        font.setPointSize(11)
        font.setBold(False)
        font.setItalic(False)
        font.setWeight(10)
        self.Campo_Vel_Trasl.setFont(font)
        self.Campo_Vel_Trasl.setStyleSheet("font: 87 11pt "Arial Black";\n"
        "background-color: rgb(231, 225, 255);")
        self.Campo_Vel_Trasl.setText("")
        self.Campo_Vel_Trasl.setObjectName("Campo_Vel_Trasl")
        self.Campo_Vel_Taglio = QtWidgets.QLineEdit(self.centralwidget)
        self.Campo_Vel_Taglio.setGeometry(QtCore.QRect(521, 300, 100, 31))
        font = QtGui.QFont()
        font.setFamily("Arial Black")
        font.setPointSize(11)
        font.setBold(False)
        font.setItalic(False)
        font.setWeight(10)
        self.Campo_Vel_Taglio.setFont(font)
        self.Campo_Vel_Taglio.setStyleSheet("font: 87 11pt "Arial Black";\n"
        "background-color: rgb(231, 225, 255);")
        self.Campo_Vel_Taglio.setText("")
        self.Campo_Vel_Taglio.setObjectName("Campo_Vel_Taglio")
        self.Campo_Info = QtWidgets.QLineEdit(self.centralwidget)
        self.Campo_Info.setGeometry(QtCore.QRect(10, 270, 331, 81))
        font = QtGui.QFont()
        font.setFamily("Arial Black")
        font.setPointSize(11)
        font.setBold(False)
        font.setItalic(False)
        font.setWeight(10)
        self.Campo_Info.setFont(font)
        self.Campo_Info.setStyleSheet("font: 87 11pt "Arial Black";\n"
        "background-color: rgb(239, 255, 164);")
        self.Campo_Info.setText("")
        self.Campo_Info.setObjectName("Campo_Info")
        self.label = QtWidgets.QLabel(self.centralwidget)
        self.label.setGeometry(QtCore.QRect(480, 140, 47, 13))
        self.label.setObjectName("label")
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 842, 21))
        self.menubar.setObjectName("menubar")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

            self.retranslateUi(MainWindow)
            QtCore.QMetaObject.connectSlotsByName(MainWindow)
        
        def retranslateUi(self, MainWindow):
            _translate = QtCore.QCoreApplication.translate
            MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
            self.Titulo_Principal.setText(_translate("MainWindow", "  Conversor Gcode a Lua per DOBOT"))
            self.Titolo_Sorgente.setText(_translate("MainWindow", "File Sorgente"))
            self.Titolo_Codigo.setText(_translate("MainWindow", "File Codigo"))
            self.Titolo_Variabile.setText(_translate("MainWindow", "File Variables"))
            self.Titolo_Global.setText(_translate("MainWindow", "File Golbal"))
            self.Titolo_File_Proggeto.setText(_translate("MainWindow", "File Progetto"))
            self.Titolo_Proggeto.setText(_translate("MainWindow", "Proggeto"))
            self.Titolo_Versioni.setText(_translate("MainWindow", "Version RM  1-1"))
            self.Titolo_Cartela.setText(_translate("MainWindow", "Cartella"))
            self.Titolo_Info.setText(_translate("MainWindow", "Info"))
            self.Tasto_Nuovo_Pro.setText(_translate("MainWindow", "Nuovo Proggetto"))
            self.Tasto_Generar_File.setText(_translate("MainWindow", "Generar Files"))
            self.Tasto_Uscita.setText(_translate("MainWindow", "Uscita "))
            self.label_12.setText(_translate("MainWindow", "Per questa versione i Circolare bisgogna disegnarli con \'piccole\' trati lineare."))
            self.Titolo_Instruzioni.setText(_translate("MainWindow", " Instrazione"))
            self.Titolo_Proggeto_3.setText(_translate("MainWindow", "Velocita Traslato %"))
            self.Titolo_Proggeto_4.setText(_translate("MainWindow", "Velocita Taglio %"))
            self.label.setText(_translate("MainWindow", "TextLabel"))
        

        if name == "main":
        import sys
        app = QtWidgets.QApplication(sys.argv)
        MainWindow = QtWidgets.QMainWindow()
        ui = Ui_MainWindow()
        ui.setupUi(MainWindow)
        MainWindow.show()
        sys.exit(app.exec_())

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on 2 Jan 2024, 06:26 last edited by
        #3

        @Raulh Please post Spanish in https://forum.qt.io/category/31/spanish
        This is English subforum.

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        1
        • SGaistS SGaist moved this topic from General and Desktop on 2 Jan 2024, 20:14
        • R Offline
          R Offline
          Raulh
          wrote on 3 Jan 2024, 16:31 last edited by
          #4

          Hola,
          Se entinede bien Tu Espanol.
          Entendistes BIEN. Necesito 'leer', 'modificar', propiedades de algunos objetos. Ejemplo, leer 'text', escrubir 'text', cambiar colore de fondo, ect.
          En el ejemplo Cargan el .UI, Yo cargo el .Py de la pantalla Qt. O sea .UI convertido en .PY.
          El objetivo es, desde un Programa Python, 'gestionar' una pantalla IMPORTADA con from xxx 'convertida' a Python.
          Lo cargare en la opcion en espanol. Gracias.

          1 Reply Last reply
          0
          • R Offline
            R Offline
            Raulh
            wrote on 4 Jan 2024, 14:31 last edited by
            #5

            Hello jsum, try that syntax. It does not work. Remember that I 'incorporate' with from xxx a python file, which is the 'translated' Qt.
            On the other hand, the syntax for a 'click' event of a button DOES work, which makes me think that what I am sending is a syntax error.

            class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
            def init(self, *args, **kwargs):
            QtWidgets.QMainWindow.init(self, *args, **kwargs)
            self.setupUi(self)
            self.Tasto_Uscita.clicked.connect(Uscita)
            self.Tasto_Generar_File.clicked.connect(Data_Control)

            #self.Tasto_Nuevo_Pro.clicked(Nuovo_Proggetto)

            if name == "main":
            app = QtWidgets.QApplication([])
            window = MainWindow()
            window.show()
            app.exec_()

            JonBJ 1 Reply Last reply 4 Jan 2024, 16:08
            0
            • R Raulh
              4 Jan 2024, 14:31

              Hello jsum, try that syntax. It does not work. Remember that I 'incorporate' with from xxx a python file, which is the 'translated' Qt.
              On the other hand, the syntax for a 'click' event of a button DOES work, which makes me think that what I am sending is a syntax error.

              class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
              def init(self, *args, **kwargs):
              QtWidgets.QMainWindow.init(self, *args, **kwargs)
              self.setupUi(self)
              self.Tasto_Uscita.clicked.connect(Uscita)
              self.Tasto_Generar_File.clicked.connect(Data_Control)

              #self.Tasto_Nuevo_Pro.clicked(Nuovo_Proggetto)

              if name == "main":
              app = QtWidgets.QApplication([])
              window = MainWindow()
              window.show()
              app.exec_()

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on 4 Jan 2024, 16:08 last edited by JonB 1 Apr 2024, 16:10
              #6

              @Raulh said in Text en Qt importado con "from":

              self.Tasto_Uscita.clicked.connect(Uscita)
              self.Tasto_Generar_File.clicked.connect(Data_Control)

              What is this? What are Uscita & Data_Control and how is this supposed to work?

              @ChrisW67 said in Text en Qt importado con "from":

              Please use code tags when posting code. You can:

              select some text and use the </> tool in the editor, or
              type three backticks (```) on a line before and after each block.

              Utilice etiquetas de código al publicar código. Puede:

              seleccione algo de texto y use la herramienta </> en el editor, o
              escriba tres comillas invertidas (```) en una línea antes y después de cada bloque.

              1 Reply Last reply
              0
              • R Offline
                R Offline
                Raulh
                wrote on 4 Jan 2024, 20:05 last edited by
                #7

                </

                Programa de conbversion Gcode a Lua per Dobot

                File Conv_Gcode_a_Lua

                Raul

                File de Texto original 852303

                File de destino point.Json

                prj.json

                src0.lua

                global.lua

                fileCRCCode.json

                import sys
                import time
                from PyQt5.QtCore import Qt

                from Scn_Cnv_Dobot import *

                class Aplicacion:

                def Calculo_puntos():
                	Punto += 1
                
                	Punto_X = linea.find("X",primer_caracter_g)
                	Punto_Y = linea.find("Y",primer_caracter_g)
                	Punto_Z = linea.find("Z",primer_caracter_g)
                		
                	if Punto_X !=-1:
                		Punto_X_Es = linea.find(" ",Punto_X)
                		if Punto_X_Es == -1:
                			Punto_X_Val = linea[Punto_X+1:len(linea)]
                			Punto_X_Val = Punto_X_Val.strip()
                		else:
                			Punto_X_Val = linea[Punto_X+1:Punto_X_Es]
                			Punto_X_Val = Punto_X_Val.strip()
                		if Punto_Y !=-1:
                			Punto_Y_Es = linea.find(" ",Punto_Y)
                		if Punto_Y_Es == -1:
                			Punto_Y_Val = linea[Punto_Y+1:len(linea)]
                			Punto_Y_Val = Punto_Y_Val.strip()
                		else:
                			Punto_Y_Val = linea[Punto_Y+1:Punto_Y_Es]
                			Punto_Y_Val = Punto_Y_Val.strip()
                		
                	if Punto_Z !=-1:
                		Punto_Z_Es = linea.find(" ",Punto_Z)
                		if Punto_Z_Es == -1:
                			Punto_Z_Val = linea[Punto_Z+1:len(linea)]
                			Punto_Z_Val = Punto_Z_Val.strip()
                		else:
                			Punto_Z_Val = linea[Punto_Z+1:Punto_Z_Es]
                			Punto_Z_Val = Punto_Z_Val.strip()
                			
                	Pto_Save_1 = "\"name:\""+"\"P\"" +str(Punto)+"\"tool\""+":1"+"\"user\""+":1,"
                	Pto_Save_2 = "\"joint\":[-20.0277,-11.1383,88.9708,30.2226,-91.7566,-261.5641]},{\"id\":1699604796888,\"alias\":\"\",\n"
                	Pto_Save_3 = "\"armOrientation\":[1,1,1,-1],\"coordinate\":["
                	Pto_Save_4 = str(Punto_X_Val)+","+str(Punto_Y_Val)+","+str(Punto_Z_Val)+","+str(A_Euler)+","+str(E_Euler)+","+str(R_Euler)+"]\n"
                	Pto_Save_5 = "\n"
                		
                	archivo_point.write(Pto_Save_1)
                	archivo_point.write(Pto_Save_2)
                	archivo_point.write(Pto_Save_3)
                	archivo_point.write(Pto_Save_4)
                
                def Crear_Cartela():
                	print ("")
                def Copiar_File():
                	print ('')
                
                def Init():
                	os.path.getsize("852303.txt")
                	Uscita = 3
                	On =1 
                	Off = 0
                	A_Euler = 20.101
                	E_Euler = 22.202
                	R_Euler = 33.303
                	Punto = 0
                	P_save = 10
                	Punto_X_Val = 0
                	Punto_Y_Val = 0
                	Punto_Z_Val = 0
                	#
                

                def Control_Datos():
                print ("Contro d Ver Mod 7")

                self.Campo_Sorgente.setText(self.Campo_Sorgente.text()+"Hola| ")
                self.Campo_Info.setCampo_Info(selfCampo_Info.toPlainText() + "Hola 2! \n")
                
                #Cpo_Sorg = (Campo_Sorgente[text()])
                #Campo_Info.SetText("Hola")
                # Cambio color a Info_Progetto
                # Cambio texto a una Label
                print ("Control Datos ejecutada")
                

                def Generacion_Files():

                	Init()
                	#Control_Datos()
                
                	archivo_gcode = open ("852303.txt","r")
                	archivo_src0 = open ("src0.lua","w")
                	archivo_point = open ("point.json","w")
                	archivo_point.write("[{\"id\":\"base\",\"alias\":\"\",\"armOrientation\":[1,1,-1,-1],\"coordinate\":[0,0,0,0,0,0],\n");
                	archivo_point.write("\"name\":\"InitialPose\",\"tool\":0,\"user\":0,\"joint\":[0,0,0,0,0,0]},{\"id\":1699604731023,\"alias\":\"\",\n");
                	archivo_point.write("\"armOrientation\":[1,1,1,-1],\"coordinate\":[-555.0739,2.8527,746.882,-175.0788,-17.2875,-29.1041],\n");
                	#  ===============================================
                	archivo_global = open ("global.lua","w")
                	archivo_global.close
                	archivo_prj = open ("prj.json","w")
                	Prj_Save = "{"+"\"cpus\""+":[\"src0.lua\"],\"global\":\"global.lua\",\"teach_point\":\"point.json\"}"
                	archivo_prj.write(Prj_Save)
                	archivo_prj.close
                
                	archivo_fileCRCCode = open ("fileCRCCode.json","w")
                	CRCCode_Save ="{\"fileName\":[\"scratch.xml\",\"global.lua\",\"point.json\",\"prj.json\",\"src0.lua\"],\"crcCode\":[2064672904,0,3216453487,668367846,1563868684]}"
                	archivo_fileCRCCode.write(CRCCode_Save)
                	archivo_fileCRCCode.close 
                	#=================================================
                
                	total_lineas = len(archivo_gcode.readline())
                	archivo_src0.write("--- \n");
                	archivo_src0.write(" \n")
                	archivo_src0.write("local Option 1={CP=1, SpeedL=40, AccL=10} "+"---\n");
                	archivo_src0.write("local Option 2={CP=100, SpeedL=15, AccL=10} "+"---\n");
                	archivo_src0.write(" \n")
                

                Firs part of program

                1 Reply Last reply
                0
                • R Offline
                  R Offline
                  Raulh
                  wrote on 4 Jan 2024, 20:06 last edited by
                  #8
                  	for i in range (0,55):
                  		linea = archivo_gcode.readline()
                  		lg = len(linea)
                  		print("linea Nro",i," Long: ",lg,"  ",linea)
                  
                  		primer_caracter_g = linea.find("G")
                  		primer_caracter_m = linea.find("M")
                  		primer_caracter_f = linea.find("F")
                  		primer_caracter_Paren = linea.find("(")
                  
                  		if primer_caracter_Paren != -1:
                  			archivo_src0.write("---"+" "+linea);
                  		else:
                  			if primer_caracter_g != -1:
                  	
                  				gcodigo = linea[primer_caracter_g:7]
                  				gcodigo = gcodigo.strip()
                  
                  				if gcodigo == "G0":
                  					#===========================
                  					Calculo_puntos()
                  					archivo_src0.write("  MovJ("+"P"+str(Punto)+",Option1"+")"+"\n");
                  					#============================
                  
                  				if gcodigo == "G1":
                  					#===========================
                  					Calculo_puntos()
                  					archivo_src0.write("  MovL("+"P"+str(Punto)+",Option2"+")"+"\n")
                  					#============================
                  
                  				if gcodigo == "G2":
                  					#===========================
                  					Calculo_puntos()
                  					archivo_src0.write("  MovL("+"P"+str(Punto)+",Option2"+")"+"\n")
                  					#============================
                  
                  				if gcodigo == "G4":
                  					primer_caracter_p = linea.find("P")
                  					Punto_P_Val = linea[primer_caracter_p+1:len(linea)]
                  					Punto_P_Val = Punto_P_Val.strip()
                  					archivo_src0.write("  WAIT("+str(Punto_P_Val)+")"+"\n");	
                  
                  				if gcodigo == "G90":
                  					archivo_src0.write("--- "+str(i)+" "+gcodigo+"  90"+"\n");
                  				if gcodigo == "G71":
                  					archivo_src0.write("--- "+str(i)+" "+gcodigo+"  71"+"\n");
                  
                  			else:
                  				if primer_caracter_m != -1:
                  					mcodigo = linea[primer_caracter_m:8]
                  					mcodigo = mcodigo.strip()
                  					if mcodigo =="M3":
                  						archivo_src0.write( "  DO("+str(Uscita)+","+str(On)+")"+"\n");
                  					if mcodigo =="M5":
                  						archivo_src0.write( "  DO("+str(Uscita)+","+str(Off)+")"+"\n");
                  		
                  				if primer_caracter_f != -1:
                  					fcodigo = linea[primer_caracter_f:9]
                  					fcodigo = fcodigo.strip()
                  					archivo_src0.write(str(i)+" "+fcodigo+"\n");
                  				
                  
                  	##
                  	archivo_gcode.close
                  	archivo_src0.close
                  	archivo_point.close
                  	print ("Fin generacion")
                  

                  def Uscita(self):
                  quit()

                  class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
                  def init(self, *args, **kwargs):
                  QtWidgets.QMainWindow.init(self, *args, **kwargs)
                  self.setupUi(self)
                  self.Tasto_Uscita.clicked.connect(Uscita)
                  self.Tasto_Generar_File.clicked.connect(Control_Datos)

                  #self.Tasto_Nuevo_Pro.clicked(Nuovo_Proggetto)
                  

                  if name == "main":
                  app = QtWidgets.QApplication([])
                  window = MainWindow()
                  window.show()
                  app.exec_()

                  1 Reply Last reply
                  0
                  • R Offline
                    R Offline
                    Raulh
                    wrote on 4 Jan 2024, 20:14 last edited by
                    #9

                    Cos'è questo? Cosa sono Uscitae Data_Controlcome dovrebbe funzionare
                    Son dos botones q llaman a dos funciones.

                    Scn_Cnv_Dodot.py == Sceen Qt 'convertido' a Python
                    Conv_Gcode_a_Lua.py == Program di control di Screen
                    This program, send in two parts.

                    1 Reply Last reply
                    0
                    • R Offline
                      R Offline
                      Raulh
                      wrote on 27 Jan 2024, 20:36 last edited by
                      #10

                      Hello Chrish, I have to access (read, modify) the .text property of a QlineEdit, of a Row generated with Qt, .ui extension, 'translated' to .py.

                      In the .py program with which I 'work' it has to 'import' the .py and it does, it just DOES NOT 'access', unknown field,

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved