I have set keybinding Ctrl+Alt+B to run code in sublimeREPL. But, recently when I run a code it wont show the last change I have made to my code. I have to first Ctrl+B and then do Ctrl+Alt+B to run properly
Code:
print("Hello")
print("added this line just now, this wont show up")
the line which was added later won't sync, it just runs the old code
Finally figured it out. I just had to turn on autosave. You can turn it on and it should be fixed. (methods are different for mac and windows, just search in youtube and everything will be alright)
Regards!
Related
I wrote this script in python
import pyautogui
import time
time.sleep(.1)
pyautogui.keyDown("ctrl")
pyautogui.press("a")
pyautogui.keyUp("ctrl")
pyautogui.press("c")
pyautogui.press("p")
pyautogui.press("p")
pyautogui.press("t")
pyautogui.press("enter")
pyautogui.keyDown("ctrl")
pyautogui.keyDown("shift")
pyautogui.press(",")
pyautogui.keyUp("ctrl")
pyautogui.keyUp("shift")
pyautogui.press("tab")
And I created a shortcut in ubuntu to run it. python3 Scripts/cpp.py
The script works correctly when I make focus on any text element (on the browser for example). But when I make focus on the sublime text or any other text editor It does not work.
What is the reason for this issue?
(This script makes sense and do something useful for me)
If you’re running your program as administrator, pyautogui won’t be able to interact with it. This can catch people out pretty easily because you can set certain programs to always run as administrator, so it won’t be the first thing you think of. This is the case for Windows anyway.
On Ubuntu, from your experience, it seems like it is actually important to run it as an admin. So I guess in general keep the privileges in mind when you have programs interacting with other programs.
Also, your script can be cleaned up a bit.
# Probably a good idea to have a bit of a slightly longer sleep.
time.sleep(0.3)
#pyautogui.keyDown("ctrl")
#pyautogui.press("a")
#pyautogui.keyUp("ctrl")
# Is equivalent to
pyautogui.hotkey("ctrl", "a")
# The next block looks like you're writing text. So write some text.
#pyautogui.press("c")
#pyautogui.press("p")
#pyautogui.press("p")
#pyautogui.press("t")
pyautogui.write("cppt")
pyautogui.press("enter")
#pyautogui.keyDown("ctrl")
#pyautogui.keyDown("shift")
#pyautogui.press(",")
#pyautogui.keyUp("ctrl")
#pyautogui.keyUp("shift")
# Again, use a hotkey here.
pyautogui.hotkey("ctrl", "shift", ",")
pyautogui.press("tab")
I have written code in a New file window in IDLE.
When I run the code there is no output.
Instead a dialog box appears showing a window accessing Python Folder 37-32.
When i closed the dialog box and the file I tried to create a new simple code below but I when I ran the code I got the same Dialog box.
What is wrong?
sum = 2+3 print(sum)
I have attached a screenshot showing the code and the dialog box that appears when the Module is run
Before you can execute your code, your first need to save the file. Thats the dialog box that popped up.
You should have seen a popup box like below. Did you? Is is unclear?
Save Before Run or Check
? Source Must Be Saved
OK to Save?
[OK] [Cancel]
One reason to require saving is that exception tracebacks refer to the file and line of lines that lead to the exception.
If you had saved, sum = 2+3 print(sum) would be a SyntaxError.
You can run single statements in Shell without saving.
The RESTART lines says that the shell re-initialized the environment for executing your code.
You should normally not save your code buried in the installation Scripts directory. Better to make a directory in your user directory, for instance, C:/Users/yourname/py/.
Yes, one should usually open a new question for unrelated questions. But without access to your machine, it is hard to know what happened with 'new'. It may be that IDLE could create a file under .../appdate/.../Scripts/, but your code cannot. If the open call did not raise and exception, it was likely created somewhere. Until you are more experienced, better to use absolute paths, such as C:/Users/yourname/py/new.txt.
This answer on Stack Overflow offers a solution I am trying to implement. In particular, see the sections "Installation Instructions" and "How to Use".
Can anyone tell me the steps required to "restart" IDLE?
New Information:
Just as people have suggested I thought this simply meant closing the program and opening it back up again...but I already tried that.
The other twist to my situation is that I'm working on a virtual machine so I was unable to do the installation of IDLE2HTML.py myself. My work's Help Desk had to do it so I cannot speak for the accuracy of their work. For now I'm assuming they did it correctly, but when I go to the "Options" menu there is no option to "Save as HTML".
My only guess at this point is that I still need to "restart IDLE".
Just wanted to double check if there was something else I could do before going back to my Help Desk department.
IDLE reads the idlelib/config-xyz.def files, including config-extensions.def, just once, when it starts. So any changes to config-extensions.def only takes effect the next time you start IDLE.
If you do not see 'Save as HTML' after starting IDLE, the extension is not installed properly.
It means you need to close the IDLE so that any changes made by the script can affect the IDLE
Simply close the IDLE either via the X, Ctrl+Q or File>Exit, then open the IDLE again.
If you are using idlelib module from a Python program then close your program and run it again.
I'm currently using PyCharm and Sublime Text in Window to develop some Python script, but this morning something quite strange happens.
I am changing my code and testing it by running my code over test input. It is supposed to change the output text quite a lot. The output text at the end did not change at all. Then I try commenting out my output function, simply pass through the reading script. I thought "Now it should print nothing". But it prints the same output as yesterday, as if I never modified it today.
Any suggestion?
It turns out it's because my colleague has pushed an unexpected change up to repo last night...I always pulled before I end the day. The text output was forced by his logger:)
Mystery solved! Thanks for reading guys.
I've had exactly the same thing happen with Sublime. In my case I had moved / renamed the file after closing sublime. I reopened sublime some time later which reopened the old version of the file because I had left the file open when I last closed down sublime.
Have you tried closing the file and then opening it again from windows i.e. right-click => open with Sublime Text, to make sure you're editing the correct version?
I've got 2 problems with Eric4 IDE.
Can't find an option in preferences to autosave my changed files before running script. It's very annoying that I have to save my file and then run script.
Second problem is running a script. I can't find any button to run a script/project instantly. 'Run Script' button always opens a setting window.
One way to get around this, as it seems there is no built in way is to bind a key to save the file (ctrl+s), then run the script (F2), and finally hit enter (to close the settings window and run the code).
This bothered me a lot too, and I know this is 2 years late but it might help some else who comes here looking for this very solution, like I did. Here are the actual answers, ERIC v4.4:
Press F4 instead of F2.
The first time you have to use F2 to 'Start' the script, so dismiss the settings window. After that you can use F4 'Restart' and it will run with the settings you chose initially.
The Autosave option is well hidden unfortunately:
Settings-->Preferences-->Debugger-->General-->!Scroll down to!-->Start Debugging-->Autosave changed scripts
And you were spot on - these two things do have a huge impact on productivity.