I have a Tkinter (3.8) program. When testing it in IDLE I select "Show report" from the menu and it automatically uses the IDLE Shell to output the data. I can then print the data from the Shell. However, when I open the program from a desktop shortcut and I select "Show report" it does not open any Shell to output the data and consequently I cannot print the formatted data. The code for the Run_Report which is called from the menu item "Show report" is shown below. What should I add to it to open the IDLE Shell window to display the data?
def Run_Report():
sPrinciple=e_SelectInv.get()
Sql=("SELECT Principle as Investment, RptDate as Report_Date, printf('%,.2f',RptVal) as Report_Value, printf('%.2f',ExchRate) as Exchange_Rate, printf('%,d',RptVal*ExchRate) as Total_Value FROM MyInv WHERE Principle = ?" +
"order by Id Asc")
conn = sqlite3.connect(r'/home/bushbug/Databases/TrackMyInv')
curs = conn.cursor()
curs.execute(Sql,(sPrinciple,))
col_names = [cn[0] for cn in curs.description]
rows = curs.fetchall()
x = PrettyTable(col_names)
x.align[col_names[0]] = "l"
x.align[col_names[1]] = "r"
x.align[col_names[2]] = "r"
x.align[col_names[3]] = "r"
x.align[col_names[4]] = "r"
x.padding_width = 1
for row in rows:
x.add_row(row)
print (x)
tabstring = x.get_string()
output=open("export.txt","w")
output.write("Population Data"+"n")
output.write(tabstring)
output.close()
Help will be greatly appreciated.