I am trying to make a simple GUI console using PyQt5. On trying to print the text using QTextBrowser - setText, it loses alignment and looks bad. but the text is aligned in my python console
I am using the setText function to display my data frame. On changing the justify parameter of df.to_string(), i am able to see the changed alignment in the python console, but this is not reflected in my Qt console.
Code :
import sys
from GUI_4 import Ui_MainWindow
from PyQt5 import QtCore, QtGui, QtWidgets
import New_Read_Map_File
def window():
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QWidget()
label = QtWidgets.QTextBrowser(MainWindow)
label.setStyleSheet('color: blue')
MainWindow.setGeometry(600,150,800,800)
label.setGeometry(10,10,780,780)
GetData()
label.setText(DisplayData)
MainWindow.show()
sys.exit(app.exec_())
def GetData():
global DisplayData
New_Read_Map_File.read_MapFile_main()
DisplayData = (New_Read_Map_File.df.to_string(col_space = 14,justify = "justify"))
print(DisplayData)
window()
Expected Alignment
Observed Qt GUI