Home > other >  Pyqt want to pass parameters in lineEdit controls but failed
Pyqt want to pass parameters in lineEdit controls but failed

Time:09-30

Want to achieve the parameter display function in lineEdit
Change in other files used in the function is an error, error below


Yysqt print_text function in the following


Found missing this one line of code with this line of code is not an error, but still can't realize to pass parameters to the function of the lineEdit, o great god teach



CodePudding user response:

Add the last line of code, is the key for binding, but the key changes the text value after the signal once, not changed? I wonder can custom groove function as long as the changes in the parameters on the text?

CodePudding user response:

Yysqt code in
 # - * - coding: utf-8 - * - 

# Form implementation generated from reading the UI file 'untitled. UI'
#
# Created by: PyQt5 UI code generator 5.13.0
#
# WARNING! All changes made in this file will be lost!
The from Settings import Settings
The import yys
The from PyQt5 import QtCore QtGui, QtWidgets
The import threading


The class Ui_YYS (object) :
Def setupUi (self, YYS) :
YYS. SetObjectName (" YYS ")
YYS. Resize (533, 297)
Self. Centralwidget=QtWidgets. QWidget (YYS)
Self. Centralwidget. SetObjectName (" centralwidget ")
The self. The pushButton=QtWidgets. QPushButton (self. Centralwidget)
The self. The pushButton. SetGeometry (QtCore QRect (190, 110, 114, 51))
The self. The pushButton. SetObjectName (" pushButton ")
Self. PushButton. Pressed. Connect (self. Click_success)

# the self. The pushButton. Pressed. Connect (self. Print_text)
Self. TextBrowser=QtWidgets. QTextBrowser (self centralwidget)
Self. TextBrowser. SetGeometry (QtCore QRect (11, 11, 508, 90))
Self. TextBrowser. SetObjectName (" textBrowser ")
The self. The label=QtWidgets. QLabel (self centralwidget)
Self. Label. SetGeometry (QtCore QRect (101, 220, 291, 20))
Self. Label. SetObjectName (" label ")
The self. The lineEdit=QtWidgets. QLineEdit (self centralwidget)
The self. The lineEdit. SetGeometry (QtCore QRect (10, 180, 501, 31))
The self. The lineEdit. SetObjectName (" lineEdit ")
YYS. SetCentralWidget (self. Centralwidget)
The self. The menubar=QtWidgets. QMenuBar (YYS)
The self. The menubar. SetGeometry (QtCore QRect (0, 0, 533, 26))
The self. The menubar. SetObjectName (" menubar ")
YYS. SetMenuBar (self. Menubar)
The self. The statusbar=QtWidgets. QStatusBar (YYS)
The self. The statusbar. SetObjectName (" statusbar ")
The self. The lineEdit. The textChanged. Connect (self. Print_text)
YYS. SetStatusBar (self. The statusbar)
Self. RetranslateUi (YYS)
QtCore. QMetaObject. ConnectSlotsByName (YYS)

Def retranslateUi (self, YYS) :
_translate=QtCore. QCoreApplication. Translate
YYS. SetWindowTitle (_translate (" YYS ", "Onmyoji script"))
The self. The pushButton. SetText (_translate (" YYS ", "click start"))
Self. TextBrowser. SetHtml (_translate (" YYS ", "& lt; ! DOCTYPE HTML PUBLIC \ "- 4.0//////W3C DTD HTML EN " \ "http://www.w3.org/TR/REC-html40/strict.dtd" & gt;
\ n""& lt; html> <meta name=\ "qrichtext " content=\ \ "1"/& gt; <style type=\ \ "text/CSS" & gt;
\ n""P, li {white - space: the pre - wrap; } \ n
""& lt;/style> \ n""& lt; P style=\ "margin - top: 0 px; Margin - bottom: 0 px; Margin - left: 0 px; Margin - right: 0 px; Qt - block text-indent: 0; The text text-indent: 0 px; \ "& gt; Instructions!!!!!!


\ n""& lt; P style=\ "margin - top: 0 px; Margin - bottom: 0 px; Margin - left: 0 px; Margin - right: 0 px; Qt - block text-indent: 0; The text text-indent: 0 px; \ "& gt; 1: using open Onmyoji lightning simulator and set the simulator resolution for & lt;/p>
\ n""& lt; P style=\ "margin - top: 0 px; Margin - bottom: 0 px; Margin - left: 0 px; Margin - right: 0 px; Qt - block text-indent: 0; The text text-indent: 0 px; \ "& gt; * * * tablet edition 960 x540 & lt;/p>
\ n""& lt; P style=\ "margin - top: 0 px; Margin - bottom: 0 px; Margin - left: 0 px; Margin - right: 0 px; Qt - block text-indent: 0; The text text-indent: 0 px; \ "& gt; 2: the game window put the upper left corner of the screen, and don't keep out the game window & lt;/p>
\ n""& lt; P style=\ "margin - top: 0 px; Margin - bottom: 0 px; Margin - left: 0 px; Margin - right: 0 px; Qt - block text-indent: 0; The text text-indent: 0 px; \ "& gt; 3: do this and then click start & lt;/p>
\ n""& lt; P style=\ "- qt - com.lowagie.text.paragraph - type: the empty; Margin - top: 0 px; Margin - bottom: 0 px; Margin - left: 0 px; Margin - right: 0 px; Qt - block text-indent: 0; The text text-indent: 0 px; \ "& gt;


\ n""& lt; P style=\ "margin - top: 0 px; Margin - bottom: 0 px; Margin - left: 0 px; Margin - right: 0 px; Qt - block text-indent: 0; The text text-indent: 0 px; \ "& gt; Author: * * * * * * BingYiii contact qq: 981725514 * * * * & lt;/p> " ))
Self. The label. The setText (_translate (" YYS ", "author: BingYIII contact: qq981725514"))


Def click_success (self) :
Text=self. PushButton. Text ()
If the text=="click start" :
The self. The pushButton. SetText (click "stop")
Settings. Set_run (1)
T=threading. Thread (target=yys. Yys_run)
T.s tart ()
If the text=="click stop" :
The self. The pushButton. SetText (click on the "start")
Settings. Set_run (0)

Def print_text (self, STR) :
# text=Settings. Get_text ()
# print (text)

The self. The lineEdit. SetText (STR (STR))



  • Related