calling a python script on button click using python and tkinter
I have a python script which has the functionality of sending an email to a user. I executed this script and it is working fine. In another python script I have only a button, so when I click on this button I want the other python script which sends a email to be executed.I have written the following code:
#!/usr/bin/python
import sys
import os
import Tkinter
import tkMessageBox
top=Tkinter.Tk()
def helloCallBack():
os.system('SendEmail.py')
B=Tkinter.Button(top,text="hello",command= helloCallBack)
B.pack()
top.mainloop()
I get the following error when I click on the button:
sh: 1:SendEmail.py:not found.
Could you let me know what is the reason for this error and how it can be resolved.Thanks.
python-2.7 tkinter
add a comment |
I have a python script which has the functionality of sending an email to a user. I executed this script and it is working fine. In another python script I have only a button, so when I click on this button I want the other python script which sends a email to be executed.I have written the following code:
#!/usr/bin/python
import sys
import os
import Tkinter
import tkMessageBox
top=Tkinter.Tk()
def helloCallBack():
os.system('SendEmail.py')
B=Tkinter.Button(top,text="hello",command= helloCallBack)
B.pack()
top.mainloop()
I get the following error when I click on the button:
sh: 1:SendEmail.py:not found.
Could you let me know what is the reason for this error and how it can be resolved.Thanks.
python-2.7 tkinter
If you go to a command prompt and typeSendEmail.py
, what happens? Do you get the same error?
– Bryan Oakley
Nov 10 '14 at 20:44
no it works fine.I executed the same python file separately and then it worked fine.I used python SendEmail.py and it worked.
– Valla
Nov 10 '14 at 20:53
1
Do you notice what you just wrote? You said "I used python SendEmail.py". That's not what I asked, and that's not what you're doing in the script. At a prompt, type literallySendMail.py
notpython SendMail.py
. I suspect you'll get the same error. If it doesn't work from the command line, it's not going to work fromos.system()
.
– Bryan Oakley
Nov 10 '14 at 20:55
add a comment |
I have a python script which has the functionality of sending an email to a user. I executed this script and it is working fine. In another python script I have only a button, so when I click on this button I want the other python script which sends a email to be executed.I have written the following code:
#!/usr/bin/python
import sys
import os
import Tkinter
import tkMessageBox
top=Tkinter.Tk()
def helloCallBack():
os.system('SendEmail.py')
B=Tkinter.Button(top,text="hello",command= helloCallBack)
B.pack()
top.mainloop()
I get the following error when I click on the button:
sh: 1:SendEmail.py:not found.
Could you let me know what is the reason for this error and how it can be resolved.Thanks.
python-2.7 tkinter
I have a python script which has the functionality of sending an email to a user. I executed this script and it is working fine. In another python script I have only a button, so when I click on this button I want the other python script which sends a email to be executed.I have written the following code:
#!/usr/bin/python
import sys
import os
import Tkinter
import tkMessageBox
top=Tkinter.Tk()
def helloCallBack():
os.system('SendEmail.py')
B=Tkinter.Button(top,text="hello",command= helloCallBack)
B.pack()
top.mainloop()
I get the following error when I click on the button:
sh: 1:SendEmail.py:not found.
Could you let me know what is the reason for this error and how it can be resolved.Thanks.
python-2.7 tkinter
python-2.7 tkinter
asked Nov 10 '14 at 20:31
VallaValla
93242752
93242752
If you go to a command prompt and typeSendEmail.py
, what happens? Do you get the same error?
– Bryan Oakley
Nov 10 '14 at 20:44
no it works fine.I executed the same python file separately and then it worked fine.I used python SendEmail.py and it worked.
– Valla
Nov 10 '14 at 20:53
1
Do you notice what you just wrote? You said "I used python SendEmail.py". That's not what I asked, and that's not what you're doing in the script. At a prompt, type literallySendMail.py
notpython SendMail.py
. I suspect you'll get the same error. If it doesn't work from the command line, it's not going to work fromos.system()
.
– Bryan Oakley
Nov 10 '14 at 20:55
add a comment |
If you go to a command prompt and typeSendEmail.py
, what happens? Do you get the same error?
– Bryan Oakley
Nov 10 '14 at 20:44
no it works fine.I executed the same python file separately and then it worked fine.I used python SendEmail.py and it worked.
– Valla
Nov 10 '14 at 20:53
1
Do you notice what you just wrote? You said "I used python SendEmail.py". That's not what I asked, and that's not what you're doing in the script. At a prompt, type literallySendMail.py
notpython SendMail.py
. I suspect you'll get the same error. If it doesn't work from the command line, it's not going to work fromos.system()
.
– Bryan Oakley
Nov 10 '14 at 20:55
If you go to a command prompt and type
SendEmail.py
, what happens? Do you get the same error?– Bryan Oakley
Nov 10 '14 at 20:44
If you go to a command prompt and type
SendEmail.py
, what happens? Do you get the same error?– Bryan Oakley
Nov 10 '14 at 20:44
no it works fine.I executed the same python file separately and then it worked fine.I used python SendEmail.py and it worked.
– Valla
Nov 10 '14 at 20:53
no it works fine.I executed the same python file separately and then it worked fine.I used python SendEmail.py and it worked.
– Valla
Nov 10 '14 at 20:53
1
1
Do you notice what you just wrote? You said "I used python SendEmail.py". That's not what I asked, and that's not what you're doing in the script. At a prompt, type literally
SendMail.py
not python SendMail.py
. I suspect you'll get the same error. If it doesn't work from the command line, it's not going to work from os.system()
.– Bryan Oakley
Nov 10 '14 at 20:55
Do you notice what you just wrote? You said "I used python SendEmail.py". That's not what I asked, and that's not what you're doing in the script. At a prompt, type literally
SendMail.py
not python SendMail.py
. I suspect you'll get the same error. If it doesn't work from the command line, it's not going to work from os.system()
.– Bryan Oakley
Nov 10 '14 at 20:55
add a comment |
4 Answers
4
active
oldest
votes
I was able to figure out a way to call another python script on button click:
instead of using os.system('SendEmail.py') we need to use os.system('python SendEmail.py')
add a comment |
If your SendEmail.py
is in the same location, use os.system('SendEmail.py')
. If it's in a different location, use os.system('python SendEmail.py')
.
add a comment |
import sys
import os
from tkinter import *
window=Tk()
window.title("Running Python Script")
window.geometry('550x200')
def run():
os.system('opencv_video.py')
btn = Button(window, text="Click Me", bg="black", fg="white",command=run)
btn.grid(column=0, row=0)
window.mainloop()
add a comment |
#!/usr/bin/python
import sys
import os
import tkinter as tk
root = tk.Tk()
def helloCallBack():
os.system('call.py')
#Keep_both_files_in_the_same_Folder
b1=tk.Button(root, text="Calendar",bg="white",command=helloCallBack)
b1.pack()
root.mainloop()
Don't forget to actually answer the question. See stackoverflow.com/help/how-to-answer for some guidelines. The original question was asking for the cause of an error.
– Brian Minton
Oct 1 '18 at 17:25
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f26852465%2fcalling-a-python-script-on-button-click-using-python-and-tkinter%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
I was able to figure out a way to call another python script on button click:
instead of using os.system('SendEmail.py') we need to use os.system('python SendEmail.py')
add a comment |
I was able to figure out a way to call another python script on button click:
instead of using os.system('SendEmail.py') we need to use os.system('python SendEmail.py')
add a comment |
I was able to figure out a way to call another python script on button click:
instead of using os.system('SendEmail.py') we need to use os.system('python SendEmail.py')
I was able to figure out a way to call another python script on button click:
instead of using os.system('SendEmail.py') we need to use os.system('python SendEmail.py')
answered Nov 10 '14 at 21:11
VallaValla
93242752
93242752
add a comment |
add a comment |
If your SendEmail.py
is in the same location, use os.system('SendEmail.py')
. If it's in a different location, use os.system('python SendEmail.py')
.
add a comment |
If your SendEmail.py
is in the same location, use os.system('SendEmail.py')
. If it's in a different location, use os.system('python SendEmail.py')
.
add a comment |
If your SendEmail.py
is in the same location, use os.system('SendEmail.py')
. If it's in a different location, use os.system('python SendEmail.py')
.
If your SendEmail.py
is in the same location, use os.system('SendEmail.py')
. If it's in a different location, use os.system('python SendEmail.py')
.
edited Dec 28 '16 at 12:16


Fabian Schultz
8,16822540
8,16822540
answered Dec 28 '16 at 11:11
Zzmilanzz ZzmadubashazzZzmilanzz Zzmadubashazz
31733
31733
add a comment |
add a comment |
import sys
import os
from tkinter import *
window=Tk()
window.title("Running Python Script")
window.geometry('550x200')
def run():
os.system('opencv_video.py')
btn = Button(window, text="Click Me", bg="black", fg="white",command=run)
btn.grid(column=0, row=0)
window.mainloop()
add a comment |
import sys
import os
from tkinter import *
window=Tk()
window.title("Running Python Script")
window.geometry('550x200')
def run():
os.system('opencv_video.py')
btn = Button(window, text="Click Me", bg="black", fg="white",command=run)
btn.grid(column=0, row=0)
window.mainloop()
add a comment |
import sys
import os
from tkinter import *
window=Tk()
window.title("Running Python Script")
window.geometry('550x200')
def run():
os.system('opencv_video.py')
btn = Button(window, text="Click Me", bg="black", fg="white",command=run)
btn.grid(column=0, row=0)
window.mainloop()
import sys
import os
from tkinter import *
window=Tk()
window.title("Running Python Script")
window.geometry('550x200')
def run():
os.system('opencv_video.py')
btn = Button(window, text="Click Me", bg="black", fg="white",command=run)
btn.grid(column=0, row=0)
window.mainloop()
answered Nov 22 '18 at 6:21


RaaRaa
1
1
add a comment |
add a comment |
#!/usr/bin/python
import sys
import os
import tkinter as tk
root = tk.Tk()
def helloCallBack():
os.system('call.py')
#Keep_both_files_in_the_same_Folder
b1=tk.Button(root, text="Calendar",bg="white",command=helloCallBack)
b1.pack()
root.mainloop()
Don't forget to actually answer the question. See stackoverflow.com/help/how-to-answer for some guidelines. The original question was asking for the cause of an error.
– Brian Minton
Oct 1 '18 at 17:25
add a comment |
#!/usr/bin/python
import sys
import os
import tkinter as tk
root = tk.Tk()
def helloCallBack():
os.system('call.py')
#Keep_both_files_in_the_same_Folder
b1=tk.Button(root, text="Calendar",bg="white",command=helloCallBack)
b1.pack()
root.mainloop()
Don't forget to actually answer the question. See stackoverflow.com/help/how-to-answer for some guidelines. The original question was asking for the cause of an error.
– Brian Minton
Oct 1 '18 at 17:25
add a comment |
#!/usr/bin/python
import sys
import os
import tkinter as tk
root = tk.Tk()
def helloCallBack():
os.system('call.py')
#Keep_both_files_in_the_same_Folder
b1=tk.Button(root, text="Calendar",bg="white",command=helloCallBack)
b1.pack()
root.mainloop()
#!/usr/bin/python
import sys
import os
import tkinter as tk
root = tk.Tk()
def helloCallBack():
os.system('call.py')
#Keep_both_files_in_the_same_Folder
b1=tk.Button(root, text="Calendar",bg="white",command=helloCallBack)
b1.pack()
root.mainloop()
edited Oct 1 '18 at 20:21
Michael
1,81551633
1,81551633
answered Oct 1 '18 at 16:05


mohit malimohit mali
11
11
Don't forget to actually answer the question. See stackoverflow.com/help/how-to-answer for some guidelines. The original question was asking for the cause of an error.
– Brian Minton
Oct 1 '18 at 17:25
add a comment |
Don't forget to actually answer the question. See stackoverflow.com/help/how-to-answer for some guidelines. The original question was asking for the cause of an error.
– Brian Minton
Oct 1 '18 at 17:25
Don't forget to actually answer the question. See stackoverflow.com/help/how-to-answer for some guidelines. The original question was asking for the cause of an error.
– Brian Minton
Oct 1 '18 at 17:25
Don't forget to actually answer the question. See stackoverflow.com/help/how-to-answer for some guidelines. The original question was asking for the cause of an error.
– Brian Minton
Oct 1 '18 at 17:25
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f26852465%2fcalling-a-python-script-on-button-click-using-python-and-tkinter%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
If you go to a command prompt and type
SendEmail.py
, what happens? Do you get the same error?– Bryan Oakley
Nov 10 '14 at 20:44
no it works fine.I executed the same python file separately and then it worked fine.I used python SendEmail.py and it worked.
– Valla
Nov 10 '14 at 20:53
1
Do you notice what you just wrote? You said "I used python SendEmail.py". That's not what I asked, and that's not what you're doing in the script. At a prompt, type literally
SendMail.py
notpython SendMail.py
. I suspect you'll get the same error. If it doesn't work from the command line, it's not going to work fromos.system()
.– Bryan Oakley
Nov 10 '14 at 20:55