Python Forum
recording textbox data into a variable
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
recording textbox data into a variable
#5
That works with PySide6

import sys
from PySide6.QtWidgets import QMainWindow, QApplication, QWidget, QLineEdit
from PySide6.QtCore import Slot
 
 
 
class MyMainWindow(QMainWindow):
     
    def __init__(self):
        super().__init__()
        self.setWindowTitle("Qt window")
        self.setMinimumSize(800,600)
 
        # widget of central area
        centralArea = QWidget()
        centralArea.setStyleSheet("background: #5A5E6B")
        self.setCentralWidget(centralArea) 
 
        # textbox implementation
        textBox1 = QLineEdit("", centralArea)
        textBox1.setStyleSheet('background: lightgrey;'
                               'color: red;')
        textBox1.setGeometry(200, 90, 270, 30)
        textBox1.textEdited.connect(self.getTextInTextBox)              # signal = "textEdited"
                                                                        # my own slot = "getTextInTextBox"
 
    # slots definition
    @Slot(str)
    def getTextInTextBox(self, text):          
        print(f"Text in the textbox is '{text}'")
        return text
 
 
if __name__ == "__main__":
     
    app = QApplication(sys.argv)    
 
    MyWindow = MyMainWindow()
    MyWindow.show()
    implementedText = MyWindow.getTextInTextBox("")
 
    sys.exit(app.exec())
Reply


Messages In This Thread
RE: recording textbox data into a variable - by Axel_Erfurt - Feb-19-2024, 09:30 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Tkinter Textbox only showing one character Xylianth 1 2,222 Jan-29-2021, 02:59 AM
Last Post: Xylianth
  [Tkinter] Redirecting stdout to TextBox in realtime Gilush 2 9,971 Jun-06-2020, 11:05 AM
Last Post: deanhystad
  tkinter how to unselect text in textbox Battant 0 2,302 Feb-17-2020, 02:00 PM
Last Post: Battant
  [Tkinter] cannot type in textbox msteffes 2 3,060 Jul-28-2018, 04:20 AM
Last Post: msteffes
  GUI insert textbox value into a Class dimvord 0 2,289 Jul-04-2018, 06:49 PM
Last Post: dimvord

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020