I’ve been writing a program in python and created a button to quit the program. When i run the code in Komodo edit the button does nothing, yet if i run it in python idle it works perfectly. The word ‘quit’ has the normal colour change expected. Its also worth mentioning that the other buttons work, just not one’s were action=quit.
Here is a quick bit of code unrelated to the program but shows the same issue.
from visual import *
from visual.controls import *
stop=button(pos=(0,20,0), width=50, height=30, color=color.red, text='stop', action=quit)
The section after the while is indented.
I don’t know if this is a bug in Komodo or if there is a less then obvious solution to fix this.
Confirm Komodo and Idle are using the same version of Python. You can check under Preferences > Language > Python in Komodo and Idle I guess would just be the Python it’s was installed with.
Are you sure “quit” isn’t supposed to be quoted?
@careyh I’ve just double checked the version of python and it appears to be the same one used for both.
As far as i’m aware quit isn’t supposed to be quoted as its meant to stop the program. I did however check just in case and doing this means it doesn’t work in either Idle or Komodo edit.
Update: I’ve also tried using the word exit. It also has the expected colour change, works in python idle, but again does nothing in komodo edit.
Also by using brackets and placing quit() or exit() as the action for the button prevents the entire thing from running.
Has anyone else come across this and can it be fixed?
@student_k, sorry for the ridiculous delay.
How did you confirm that Komodo is running the same version of Python as Idle? You can see which Python Komodo is using by using the following command in Tools > Run Command: %python -V. That is the version of Python configured under Edit > Preferences > Languages > Python.
Does it run properly when you run it from command line?
And how are you running the program from within Komodo?
@careyh, thanks for your response.
I confirmed the version by going in Edit > Preferences > Languages > Python and looking up the location for python it is using. I then compared this to the location stated in Idle. Having followed your instructions the version used in Komodo edit is the same as that stated by Idle in help>about Idle. For reference 2.7.1
Having run it from the command line it turns out that it works except for that one button with quit. This is the same issue I’ve been having with Komodo edit.
In Komodo edit I have been running it primarily through a command I set up via tools in the right hand pane. The command is: %(python) -u “%F”.
Having done all this, I don’t think it is a issue specifically with Komodo, although I have no idea what allows Idle to work correctly when nothing else seems to. There should be a way to make it work properly in Komodo and the command line.