I am trying to print table via PrettyTable
library in python in my ScrolledText
tkinter widget.
here is the function snippet:
global Scrolledtext1
Scrolledtext1 = ScrolledText(top, state="disable")
def display_output(self,output_message):
myTable = PrettyTable()
for list_item in output_message:
myTable.add_row(list_item)
print(myTable)
Scrolledtext1.config(state="normal") # changing text box's state so that we can edit it
Scrolledtext1.delete("1.0", "end") # deletes previous contents
Scrolledtext1.insert(1.0,myTable) # showing output message
Scrolledtext1.config(state="disable") # disabling text box's state so that user cannot change it's content
I am inserting myTable in second last line in above code (in insert method).
this is printing table correctly in console
via print statement but it is not printing correctly in ScrolledText
.
This is screenshot of this table which is inserted in ScrolledText
in tkinter:
GUI output image
console output image
Please suggest me something so that i can print table correctly in ScrolledText
.