ManlyGG
ManlyGG

Reputation: 1

How to make Tkinter run a command using a button and label out my output in Terminal

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()

Upvotes: 0

Views: 682

Answers (1)

Minecrafster Tanner
Minecrafster Tanner

Reputation: 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()

Upvotes: -1

Related Questions