0

I have this script:


Multiply = Tk()
Multiply.geometry('500x700+700+200')
Multiply.title('SuperTrend Backtesting')

def TimesTable():
    result11= print('Profit gained from the ST strategy by investing $100k : ',total_investment_ret)

    result1 = Label(Multiply, text=result11, justify='center').grid(row=5, column=6)
   
    return result1



 


button1=Button(Multiply, text='Run and close the window', command=TimesTable).grid(row=1,column=6)
label1=Label(Multiply,text='                                         ').grid(row=2,column=6)        
QUIT=Button(Multiply,text='Quit', fg='Red', command=Multiply.destroy).grid(row=3,column=6)
label1=Label(Multiply,text='                                         ').grid(row=4,column=6)        
result1=Label(Multiply, justify='center').grid(row=5, column=6)
label1=Label(Multiply,text='                                         ').grid(row=6,column=6)        

Multiply.mainloop()

And for some reason I don't know, it doesn't do what it should do (print the terminal)

What do I have to do to print the terminal in the TK UI?

  • Which operating system? On Windows, GUI applications are disconnected from the terminal. They don't have a stdout. You'd need to write to file, and then look at the file. – Tim Roberts Nov 14 '22 at 18:28
  • @Tim Roberts there is a very similar tkinter .py that doesnt write a file ... what is he doing different? https://python-forum.io/thread-33804.html – user20503383 Nov 14 '22 at 19:08
  • It depends how you are calling the app. Are you running it from a command line? From inside a GUI? By double-clicking the file? In Windows, there are two Python interpreters: `python` is a command-line app that retains a link to stdout, and `pythonw` is a GUI app that does not retain that connection. If I run your script as `python x.py`, it prints to the terminal. If I run `pythonw x.py`, it does not. – Tim Roberts Nov 14 '22 at 19:10
  • And do be sure to look at the duplicate link above. You need to separate your `result11 = print...` into two statements: one that creates `result11`, and one that `print`s it. – Tim Roberts Nov 14 '22 at 19:13

0 Answers0