Reputation: 37
I'm trying to make a basic gui menu option that will run my stated exe (hurl), but it won't. Here is my code:
from tkinter import *
import os
root = Tk()
root.geometry('350x150')
root.title("hurler")
photo = PhotoImage(file = "Logo_Image.png")
root.iconphoto(False, photo)
entry_text = Label(text = "Number of posts you wish to automate (between 1-12) * ")
entry_text.place(x = 15, y = 10)
num = StringVar()
time_entry = Entry(textvariable = num, width = "10")
time_entry.place(x = 15, y = 40)
def action():
if num == '1':
os.system(".\hurl\hurl.exe")
register = Button(root,text = "Make", width = "10", height = "2", command = action, bg = "lightblue")
register.place(x = 15, y = 70)
root.mainloop()
I'm not the most experienced at this, so any feedback helps.
How do I get option 1 to run this exe? Thanks.
Upvotes: 0
Views: 67
Reputation: 6156
so these are the improvements, should work now:
from tkinter import *
import os
root = Tk()
root.geometry('350x150')
root.title("hurler")
# photo = PhotoImage(file = "Logo_Image.png")
# root.iconphoto(False, photo)
entry_text = Label(text = "Number of posts you wish to automate (between 1-12) * ")
entry_text.place(x = 15, y = 10)
num = StringVar()
time_entry = Entry(textvariable = num, width = "10")
time_entry.place(x = 15, y = 40)
def action():
global num
num = num.get()
if num == '1':
os.startfile('https://www.google.com')
num = StringVar()
register = Button(root,text = "Make", width = "10", height = "2", command = action, bg = "lightblue")
register.place(x = 15, y = 70)
root.mainloop()
the changes were made here:
def action():
global num
num = num.get()
if num == '1':
os.startfile('https://www.google.com')
num = StringVar()
also should work with the os.system thingy
Upvotes: 1