0

So I am making a project that outputs responses from Google Sheets that asks me and gives me video ideas. I just need help figuring out how to make Tkinter output the whole response into a window.

Here is the main code for the project I am working on:

import pygsheets
import random
import tkinter
import numpy as np

gc = pygsheets.authorize()

sh = gc.open('Give Me Video Ideas (Responses)')
wks = sh.sheet1

for row in wks:
    print(list(row))

And here is the Tkinter code I have so far:

import sys
import os
from tkinter import *

window=Tk()

window.title("Give me Video Ideas")
window.geometry('550x200')

def run():
    os.system('python anothergithub.py')

btn = Button(window, text="Click Me", bg="black", fg="white",command=run)
btn.grid(column=0, row=0)

window.mainloop()
acw1668
  • 40,144
  • 5
  • 22
  • 34
  • do u want to print the excel into the new window? – Delrius Euphoria Jul 15 '20 at 17:55
  • You could use the `subprocess` module to run the other script and redirect its output into a file, then after the it finishes, display the contents of the file in your tkinter GUI. It would also be possible to redirect the output into a `subprocess.PIPE` and display the output in real-time, but that would be fairly complicated. – martineau Jul 15 '20 at 17:55
  • How exactly do you want to output it? Printing to the console? Or saving to a file? Or displaying in the tkinter GUI? – dwb Jul 15 '20 at 20:13
  • I wanted to output this to the Tkinter GUI. So when the command runs and it shows all responses, it also outputs that to the Tkinter GUI once the command is run – ManlyGG Jul 16 '20 at 18:08

1 Answers1

-1

This is if you have variables in you deal line run(string)

import sys
import os
from tkinter import *

window=Tk()

window.title("Give me Video Ideas")
window.geometry('550x200')

def run():
    os.system('python anothergithub.py')

btn = Button(window, text="Click Me", bg="black", fg="white",command=lambda: run("Hey"))
btn.grid(column=0, row=0)

window.mainloop()
Barbaros Özhan
  • 59,113
  • 10
  • 31
  • 55
  • 1
    This solution does not address OP issue. Also `run()` does not expect any argument, so `run("Hey")` will raise exception. – acw1668 Dec 28 '22 at 04:07