I know "ip" works but when I go to click the button I see nothing(the user is supposed to see nothing so this is great!) however, I don't know how I can verify the buttons ability. The goal is to eventually have specified information from the button sent to a label widget(which the user will get to see)
import tkinter as tk
import subprocess
ip = subprocess.run("ipconfig /all",universal_newlines=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
#Setup for the window
window =tk.Tk()
window.title("Title_Name")
window.geometry("300x500")
x = window.winfo_x()
y = window.winfo_y()
sh = window.winfo_screenheight()
sw = window.winfo_screenwidth()
x_cord = int((sw/2)-550)
y_cord = int((sh/2)-300)
wh = 350
ww = 500
window.geometry("{}x{} {} {}".format(ww, wh ,x_cord, y_cord))
#widgets
button = tk.Button(window, text= "submit",
command = ip)
#widget placement
button.grid(row=0, column=0, padx=5)
CodePudding user response:
Just quickly change command to a different function to test the command!
import tkinter as tk
import subprocess
ip = subprocess.run("ipconfig /all",universal_newlines=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
#Setup for the window
window =tk.Tk()
window.title("Title_Name")
window.geometry("300x500")
x = window.winfo_x()
y = window.winfo_y()
sh = window.winfo_screenheight()
sw = window.winfo_screenwidth()
x_cord = int((sw/2)-550)
y_cord = int((sh/2)-300)
wh = 350
ww = 500
window.geometry("{}x{} {} {}".format(ww, wh ,x_cord, y_cord))
def ButtonTest():
print('The button is working!')
#widgets
button = tk.Button(window, text= "submit",
command = ButtonTest)
#widget placement
button.grid(row=0, column=0, padx=5)
tk.mainloop()
When you run this code and press the button it will print the output, so you can rest assured that assuming the ip function is working it will run!