Python Forum
[PyQt] [Solved]Change text color of one line in TextBrowser
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyQt] [Solved]Change text color of one line in TextBrowser
#1
Hello,

I'm trying to make a GUI for my Chatbot/Voice Assistant and I'm trying to get the user input to be a different colour than the A.I's response.
Right now if I type in "Hello" it populates on the text browser in green (as show in the screenshot attached), but I want it to be yellow.

How do I get it to be a different colour?

Thanks in advance.

Snippet:
#----------------------------------------------------------------------------------------------------
#                                       Button Actions
#----------------------------------------------------------------------------------------------------
        #------------------------------------------
                        #Submit Button
        #------------------------------------------
        #When the Submit button is clicked -> submitClicked Function
        SubmitButton = self.SubmitButton
        SubmitButton.clicked.connect(self.SubmitClicked)
        #------------------------------------------

    #Submit Function
    def SubmitClicked(self):
        #Take UserInput & append it to ConvoTextBrowser
        userInput = self.UserInputLineEdit.text()
        ConvoHistory = self.ConvoTextBrowser.append(userInput)
Full Code:
#!/usr/bin/env python3

import sys
from PyQt5 import QtCore, QtWidgets, QtGui
from PyQt5.QtSql import QSqlDatabase, QSqlTableModel
from PyQt5.QtWidgets import (QApplication, QWidget, QPushButton, QMainWindow, 
                                QLabel, QLineEdit, QTableWidget, QTableWidgetItem, 
                                QGridLayout, QVBoxLayout, QSizePolicy, QSpacerItem, 
                                QMessageBox,QSpinBox, QComboBox, QTableView,QStyledItemDelegate)
from PyQt5.QtCore import Qt, QMetaObject, QCoreApplication
from PyQt5.QtGui import QFont

#----------------------------------------------------------------------------------------------------
#                                      Main Display
#----------------------------------------------------------------------------------------------------
class Ui_MainDisplay(QMainWindow):
    def __init__(self, parent = None):
        super(Ui_MainDisplay, self).__init__(parent)
        self.setObjectName("MainDisplay")
        self.setFixedSize(800, 665)
        self.setStyleSheet("background-color: rgb(0, 0, 0);")
        self.centralwidget = QtWidgets.QWidget(self)
        self.centralwidget.setObjectName("centralwidget")
        self.MainFrame = QtWidgets.QFrame(self.centralwidget)
        self.MainFrame.setGeometry(QtCore.QRect(10, 70, 781, 521))
        self.MainFrame.setStyleSheet("")
        self.MainFrame.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.MainFrame.setFrameShadow(QtWidgets.QFrame.Raised)
        self.MainFrame.setObjectName("MainFrame")
        self.ConvoTextBrowser = QtWidgets.QTextBrowser(self.MainFrame)
        self.ConvoTextBrowser.setGeometry(QtCore.QRect(10, 20, 271, 481))
        font = QtGui.QFont()
        font.setFamily("Robo Sapien")
        font.setPointSize(10)
        self.ConvoTextBrowser.setFont(font)
        self.ConvoTextBrowser.setStyleSheet("color: rgb(0, 255, 0);")
        self.ConvoTextBrowser.setObjectName("ConvoTextBrowser")
        self.TextBrowser = QtWidgets.QTextBrowser(self.MainFrame)
        self.TextBrowser.setGeometry(QtCore.QRect(0, 10, 781, 501))
        self.TextBrowser.setStyleSheet("color: rgb(0, 170, 0);")
        self.TextBrowser.setObjectName("TextBrowser")
        self.calendarWidget = QtWidgets.QCalendarWidget(self.MainFrame)
        self.calendarWidget.setGeometry(QtCore.QRect(290, 20, 312, 183))
        self.calendarWidget.setStyleSheet("color: rgb(120, 120, 120);\n"
"selection-color: rgb(255, 149, 0);\n"
"selection-background-color: rgb(100, 100, 100);")
        self.calendarWidget.setObjectName("calendarWidget")
        self.CalendarTextBrowser = QtWidgets.QTextBrowser(self.MainFrame)
        self.CalendarTextBrowser.setGeometry(QtCore.QRect(295, 211, 311, 221))
        font = QtGui.QFont()
        font.setFamily("Runlion")
        font.setPointSize(10)
        self.CalendarTextBrowser.setFont(font)
        self.CalendarTextBrowser.setStyleSheet("color: rgb(255, 170, 0);")
        self.CalendarTextBrowser.setObjectName("CalendarTextBrowser")
        self.TODOTextBrowser = QtWidgets.QTextBrowser(self.MainFrame)
        self.TODOTextBrowser.setGeometry(QtCore.QRect(620, 210, 151, 291))
        font = QtGui.QFont()
        font.setFamily("Runlion")
        font.setPointSize(10)
        self.TODOTextBrowser.setFont(font)
        self.TODOTextBrowser.setStyleSheet("color: rgb(170, 0, 0);\n"
"color: rgb(0, 85, 255);")
        self.TODOTextBrowser.setObjectName("TODOTextBrowser")
        self.NewsTextBrowser = QtWidgets.QTextBrowser(self.MainFrame)
        self.NewsTextBrowser.setGeometry(QtCore.QRect(295, 440, 311, 61))
        font = QtGui.QFont()
        font.setFamily("Android Insomnia")
        self.NewsTextBrowser.setFont(font)
        self.NewsTextBrowser.setStyleSheet("color: rgb(255, 170, 0);")
        self.NewsTextBrowser.setObjectName("NewsTextBrowser")
        self.DateTimeTextBrowser = QtWidgets.QTextBrowser(self.MainFrame)
        self.DateTimeTextBrowser.setGeometry(QtCore.QRect(630, 20, 131, 41))
        font = QtGui.QFont()
        font.setFamily("Roblox Font")
        font.setPointSize(10)
        self.DateTimeTextBrowser.setFont(font)
        self.DateTimeTextBrowser.setStyleSheet("color: rgb(0, 170, 0);")
        self.DateTimeTextBrowser.setObjectName("DateTimeTextBrowser")
        self.BootStatusTextBrowser = QtWidgets.QTextBrowser(self.MainFrame)
        self.BootStatusTextBrowser.setGeometry(QtCore.QRect(610, 70, 171, 131))
        font = QtGui.QFont()
        font.setFamily("Robo Sapien")
        font.setItalic(True)
        self.BootStatusTextBrowser.setFont(font)
        self.BootStatusTextBrowser.setStyleSheet("color: rgb(0, 170, 0);")
        self.BootStatusTextBrowser.setObjectName("BootStatusTextBrowser")
        self.TextBrowser.raise_()
        self.ConvoTextBrowser.raise_()
        self.calendarWidget.raise_()
        self.CalendarTextBrowser.raise_()
        self.TODOTextBrowser.raise_()
        self.NewsTextBrowser.raise_()
        self.DateTimeTextBrowser.raise_()
        self.BootStatusTextBrowser.raise_()
        self.InputFrame = QtWidgets.QFrame(self.centralwidget)
        self.InputFrame.setGeometry(QtCore.QRect(110, 590, 581, 51))
        self.InputFrame.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.InputFrame.setFrameShadow(QtWidgets.QFrame.Raised)
        self.InputFrame.setObjectName("InputFrame")
        self.verticalLayout = QtWidgets.QVBoxLayout(self.InputFrame)
        self.verticalLayout.setObjectName("verticalLayout")
        self.UserInputLineEdit = QtWidgets.QLineEdit(self.InputFrame)
        font = QtGui.QFont()
        font.setFamily("Android Insomnia")
        font.setPointSize(10)
        self.UserInputLineEdit.setFont(font)
        self.UserInputLineEdit.setStyleSheet("color: rgb(255, 170, 0);\n"
"")
        self.UserInputLineEdit.setObjectName("UserInputLineEdit")
        self.verticalLayout.addWidget(self.UserInputLineEdit)
        self.HeaderFrame = QtWidgets.QFrame(self.centralwidget)
        self.HeaderFrame.setGeometry(QtCore.QRect(9, 10, 781, 61))
        self.HeaderFrame.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.HeaderFrame.setFrameShadow(QtWidgets.QFrame.Raised)
        self.HeaderFrame.setObjectName("HeaderFrame")
        self.TitleLabel = QtWidgets.QLabel(self.HeaderFrame)
        self.TitleLabel.setGeometry(QtCore.QRect(0, 0, 781, 41))
        font = QtGui.QFont()
        font.setFamily("Android Insomnia")
        font.setPointSize(25)
        font.setBold(False)
        font.setWeight(50)
        self.TitleLabel.setFont(font)
        self.TitleLabel.setStyleSheet("color: rgb(0, 255, 0);")
        self.TitleLabel.setAlignment(QtCore.Qt.AlignCenter)
        self.TitleLabel.setObjectName("TitleLabel")
        self.SystemStatusLabel = QtWidgets.QLabel(self.HeaderFrame)
        self.SystemStatusLabel.setGeometry(QtCore.QRect(6, 36, 771, 20))
        font = QtGui.QFont()
        font.setFamily("Android Insomnia")
        font.setPointSize(10)
        self.SystemStatusLabel.setFont(font)
        self.SystemStatusLabel.setStyleSheet("color: rgb(0, 230, 0);")
        self.SystemStatusLabel.setAlignment(QtCore.Qt.AlignCenter)
        self.SystemStatusLabel.setObjectName("SystemStatusLabel")
        self.WeatherTextBrowser = QtWidgets.QTextBrowser(self.HeaderFrame)
        self.WeatherTextBrowser.setGeometry(QtCore.QRect(620, 0, 161, 61))
        font = QtGui.QFont()
        font.setFamily("Android Insomnia")
        font.setPointSize(10)
        self.WeatherTextBrowser.setFont(font)
        self.WeatherTextBrowser.setStyleSheet("color: rgb(255, 170, 0);")
        self.WeatherTextBrowser.setObjectName("WeatherTextBrowser")
        self.graphicsView = QtWidgets.QGraphicsView(self.HeaderFrame)
        self.graphicsView.setGeometry(QtCore.QRect(560, 0, 61, 61))
        self.graphicsView.setObjectName("graphicsView")
        self.SubmitButton = QtWidgets.QPushButton(self.centralwidget)
        self.SubmitButton.setGeometry(QtCore.QRect(700, 600, 91, 41))
        font = QtGui.QFont()
        font.setFamily("Lethal Injector")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.SubmitButton.setFont(font)
        self.SubmitButton.setStyleSheet("background-color: rgb(170, 170, 0);\n"
"background-color: rgb(200, 133, 0);")
        self.SubmitButton.setObjectName("SubmitButton")
        self.OnOffButton = QtWidgets.QPushButton(self.centralwidget)
        self.OnOffButton.setGeometry(QtCore.QRect(10, 600, 91, 41))
        font = QtGui.QFont()
        font.setFamily("Lethal Injector")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.OnOffButton.setFont(font)
        self.OnOffButton.setStyleSheet("background-color: rgb(170, 0, 0);")
        self.OnOffButton.setObjectName("OnOffButton")
        self.setCentralWidget(self.centralwidget)
        self.statusbar = QtWidgets.QStatusBar(self)
        self.statusbar.setObjectName("statusbar")
        self.setStatusBar(self.statusbar)

        self.retranslateUi(self)
        QtCore.QMetaObject.connectSlotsByName(self)
#----------------------------------------------------------------------------------------------------

#----------------------------------------------------------------------------------------------------
#                                       Button Actions
#----------------------------------------------------------------------------------------------------
        #------------------------------------------
                        #Submit Button
        #------------------------------------------
        #When the Submit button is clicked -> submitClicked Function
        SubmitButton = self.SubmitButton
        SubmitButton.clicked.connect(self.SubmitClicked)
        #------------------------------------------

    #Submit Function
    def SubmitClicked(self):
        #Take UserInput & append it to ConvoTextBrowser
        userInput = self.UserInputLineEdit.text()
        ConvoHistory = self.ConvoTextBrowser.append(userInput)


#----------------------------------------------------------------------------------------------------
#                                      Retranslate Ui
#----------------------------------------------------------------------------------------------------
    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        self.setWindowTitle(_translate("MainWindow", "MainWindow"))
        
        self.ConvoTextBrowser.setHtml(_translate("MainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'Robo Sapien\'; font-size:10pt; font-weight:400; font-style:normal;\">\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Hello Commander. How may I be of service?</p>\n"
"<p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p>\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">What is 1 + 1?</p>\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">1 + 1 = 2</p>\n"
"<p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p>\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Thanks.</p>\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">No problem.</p></body></html>"))
        
        self.CalendarTextBrowser.setHtml(_translate("MainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'Runlion\'; font-size:10pt; font-weight:400; font-style:normal;\">\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">August 21 2022</p>\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">-Dentist appointment @ 2:00pm</p>\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">-Doctor\'s Appointment @ 3:00pm</p></body></html>"))
        
        self.TODOTextBrowser.setHtml(_translate("MainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'Runlion\'; font-size:10pt; font-weight:400; font-style:normal;\">\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-weight:600; font-style:italic;\">Todo:</span></p>\n"
"<p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-weight:600; font-style:italic;\"><br /></p>\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-weight:600; font-style:italic;\">-Fix Anycubic Mega X PRinter</span></p>\n"
"<p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-weight:600; font-style:italic;\"><br /></p>\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-weight:600; font-style:italic;\">-Work on B.A.X.T.E.R</span></p></body></html>"))
        
        self.NewsTextBrowser.setHtml(_translate("MainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'Android Insomnia\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:10pt;\">Todays\' News</span></p>\n"
"<p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;\"><br /></p>\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:10pt;\">- News Headline 1</span></p></body></html>"))
        
        self.DateTimeTextBrowser.setHtml(_translate("MainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'Roblox Font\'; font-size:10pt; font-weight:400; font-style:normal;\">\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Date: 08/21/22</p>\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Time: 07:15:20pm</p></body></html>"))
        
        self.BootStatusTextBrowser.setHtml(_translate("MainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'Robo Sapien\'; font-size:8.25pt; font-weight:400; font-style:italic;\">\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\">Starting Systems...</span></p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\">Systems Started...</span></p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\">Connecting to Databases...</span></p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\">Databases - online</span></p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\">Checking Connections...</span></p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\">Defense Arm - Online</span></p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\">V.L.A.D 001 - Online</span></p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\">V.L.A.D 002 - Online</span></p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\">Neural Network - Online</span></p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\">Establishing Link...</span></p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\">Secure Link Established...</span></p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\">---</span></p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\">All Systems  Running</span></p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\">---</span></p></body></html>"))
        
        self.TitleLabel.setText(_translate("MainWindow", "B.A.X.T.E.R"))
        self.SystemStatusLabel.setText(_translate("MainWindow", "Systems Online"))
        
        self.WeatherTextBrowser.setHtml(_translate("MainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'Android Insomnia\'; font-size:10pt; font-weight:400; font-style:normal;\">\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">ThunderStorms</p>\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">22.9 Celcius</p>\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Feels Like: 23.4</p></body></html>"))
        
        self.SubmitButton.setText(_translate("MainWindow", "Submit"))
        self.OnOffButton.setText(_translate("MainWindow", "Mic Offline"))
#----------------------------------------------------------------------------------------------------


#----------------------------------------------------------------------------------------------------
#                                       Run this Program
#----------------------------------------------------------------------------------------------------
def main():
    app = QApplication(sys.argv)
    win = Ui_MainDisplay()
    win.show()
    sys.exit(app.exec_())

if __name__ == "__main__":
    main()
#----------------------------------------------------------------------------------------------------

Attached Files

Thumbnail(s)
   
Reply
#2
You can use html

    #Submit Function
    def SubmitClicked(self):
        #Take UserInput & append it to ConvoTextBrowser
        userInput = self.UserInputLineEdit.text()
        ConvoHistory = self.ConvoTextBrowser.append(f"<p style='color:yellow'>{userInput}</p>")
Reply
#3
Thanks. That worked!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Can't change the colour of Tk button text Pilover 6 14,734 Nov-15-2022, 10:11 PM
Last Post: woooee
  [WxPython] [SOLVED] How to change button label? Winfried 3 2,088 May-31-2022, 06:37 PM
Last Post: Winfried
  Tkinter - How can I change the default Notebook border color? TurboC 5 14,755 May-23-2022, 03:44 PM
Last Post: bigmac
  [PyGUI] [Solved]Help storing in user input from line edit Extra 2 1,730 May-12-2022, 07:46 PM
Last Post: Extra
Question [Tkinter] Change Treeview column color? water 3 9,594 Mar-04-2022, 11:20 AM
Last Post: Larz60+
  Can't get tkinter button to change color based on changes in data dford 4 3,418 Feb-13-2022, 01:57 PM
Last Post: dford
  tkinter change the text of the checkbox zazas321 1 3,828 Sep-17-2021, 06:19 AM
Last Post: zazas321
  Line numbers in Text widget rfresh737 3 5,404 Apr-15-2021, 12:30 PM
Last Post: rfresh737
  How to dynamically change radiobutton text kenwatts275 2 3,341 Mar-05-2021, 02:25 AM
Last Post: deanhystad
  [PyGTK] How to center text on multi-line buttons? Lomax 3 4,229 Jan-23-2021, 03:23 PM
Last Post: Lomax

Forum Jump:

User Panel Messages

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