I was working on a GUI app that I was hoping to use to run a python script inside of it(don't know if it's even possible) I was hoping to get a script to run in the GUI by importing it but I don't if this can work so I looked for another way and the only working thing I got too was copying my script and paste it in a function called script
and then assign the start button with the command to run this function but this runs the script in the terminal when I press the start button and that is not what I want.
I want my script to run inside the Frame I created, in other means print the text that is outputting in the terminal to the frame but I don't seem to get anywhere or find a solution
GUI:
import tkinter as tk
from tkinter import Button, Canvas, Image, PhotoImage, filedialog, Text
import os
from tkinter.constants import COMMAND, DISABLED
root = tk.Tk()
canvas = tk.Canvas(root, height = 750, width = 800, bg = "#110a60")
canvas.pack()
root.resizable(False, False)
frame = tk.Frame(root, bg = "black")
frame.place(relheight = 0.8, relwidth = 0.8, relx = 0.1, rely = 0.1)
start_button = Button(root, text = 'Start Program', padx = 10, pady = 5, fg = "#FFFF00", bg = "#012456", state = DISABLED)
start_button.place(x = 350, y = 680)
exit_button = Button(root, text = 'Exit', padx = 20, pady = 5, fg = "#FFFF00", bg = "#012456", command = exit)
exit_button.place(x = 368, y = 714.5 )
root.mainloop()
I have tried doing this:
import tkinter as tk
from tkinter import Button, Canvas, Image, PhotoImage, filedialog, Text
import os
from tkinter.constants import COMMAND, DISABLED
def script():
#type my script here and use it as a command but it gets printed in my terminal, not in the canvas
root = tk.Tk()
canvas = tk.Canvas(root, height = 750, width = 800, bg = "#110a60")
canvas.pack()
root.resizable(False, False)
frame = tk.Frame(root, bg = "black")
frame.place(relheight = 0.8, relwidth = 0.8, relx = 0.1, rely = 0.1)
start_button = Button(root, text = 'Start Program', padx = 10, pady = 5, fg = "#FFFF00", bg = "#012456", command = script)
start_button.place(x = 350, y = 680)
exit_button = Button(root, text = 'Exit', padx = 20, pady = 5, fg = "#FFFF00", bg = "#012456", command = exit)
exit_button.place(x = 368, y = 714.5 )
root.mainloop()
But this only runs the script in the terminal, I want it to run inside the frame I made in other means I want the text outputting from the script to be printed inside the frame and every user input to be made inside the frame
Brief explanation:
I need the text that gets printed to my terminal to be printed inside the frame I made in my GUI
Thank you in advance.