Wing ide "run" button is greyed out unless I save the file - python

Whenever I create a new wing file in the wing IDE interface, I find the "run code" (play symbol) button is greyed out and I can't click it unless I save the file somewhere on my computer. It didn't used to to this.
This is annoying because it forces you to save every single code you write even if it's just 5 lines you've written to test something out.
I can't recall exactly when the button changed, I didn't notice it immediately. But I've updated both my wing IDE and python to the latest version. I've also shifted the directory that I keep all my python saves in, but I can't see why that would matter.
I've taken a look through settings, but I couldn't make much sense of it. I'm new to programming.

Wing has never been able to debug an unsaved file. I suspect you used Wing 101 previously and now use Wing Personal or Wing Pro where the toolbar buttons are a bit different and run things in the debugger instead of evaluating in the Python Shell.
You can still evaluate the file or a selection in the file in the Python Shell using the items in the Source menu. As of Wing 6 you can also debug things you execute in this way by enabling debug in the Python Shell's Options menu.
You can also select a range in the file, click on the active range icon in top right of the Python Shell to make it the active range and then use the cog icon that appears in top right of the Python Shell whenever you want to reevaluate the range as you edit it in the editor.

Related

How can I make .py files run using Python Shell by default?

I made a Python GUI using Tkinter, but when I run it directly (double click the file) it opens the black python window but automatically closes by itself in less than half a second. I found a way to make it open the IDLE editor but it just opens the editor and doesn't run it.
I want it to run the way it runs when you open the IDLE editor and press Run Module. This runs it using Python Shell.
Is there a way I can make it automatically run using Python Shell?
Based on Mark Tolonen's comment you should do two things
rename your file to a .pyw from .py to prefer console-less runs
set your system to open .pyw files with pythonw if that's not configured already
Linux: configure xdg-open
Windows: right click and choose an application from the context menu (you may need to find where Python is installed to select the pythonw.exe executable)
Okay, one of the comments on the original question is correct.
As Terry Jan Reedy (user:722804) said,
It is possible that your mygui.py file is missing 'root.mainloop()' or the equivalent to start the GUI. IDLE lets you omit that during development so that one can interact with tkinter to retrieve values and make changes to widgets.
Adding gui.mainloop() to the end of my program worked.

cannot open python script by double clicking

i have searched on multiple forums and looks like others met similar issues but I haven't read a straightforward explanation yet. what I am trying to do is to simply open my python script by double clicking it. it used to work, but not anymore. my python scripts can still be opened via idle. and executable when it is opened and F5 pressed.
if on windows or linux, right click, open with ... select python executable, or Idle. whichever you want the default action to be.
then select the option to "always use this to open .py files"
If on a Mac, you can CTRL+Click the file, Get info > Open With and change it to Python Launcher. Click Change All. Double clicking should run the script.
Another way is to use pyinstaller which makes the script into an executable. It is pretty straightforward to use.
Change the "open with..." preference for the py files by shift + right click and choose open with from the menu. Make sure you tick the use always option

Prevent PyCharm from opening the browser/new tab on run

I found a number of people who want PyCharm to open the browser/a new tab every time you click run.
https://intellij-support.jetbrains.com/hc/en-us/community/posts/206590705-How-do-I-setup-Run-Debug-Config-to-open-browser-automatically-for-Flask-
Django manage.py runserver doesn't open browser
Well, I click run often and already have the tabs open I need. It's quite frustrating to have to close the new ones, and I want to turn it off. I have looked thru all the menus and I can't find the Run browser setting some people talk about.
I also tried disabling all Django support for browsers in Settings -> Tools -> Browsers, but this made no difference.
Versions:
PyCharm 2017.1.1
Python 3.5.x
Django 1.10
edit run configurations(right next to the play button at the top of the editor) and uncheck the box that says open new window on run .... – #Joran Beasley
P/s: Just comment again.
For version 2018.3
Go to File | Settings | Build, Execution, Deployment | Console.
Check the option Use existing console for "Run with Python console".
2018 :
Edit run configurations (at the left to the play button at the top of the editor, click on the list of configuration then edit configurations) and check the box that reads single instance only

How to include file in wing-IDE

I have a file called tweet.py located on my desktop which contains numerous functions that I would like to use in the wing-IDE. How do I include the file so I can use the functions in the python shell? I looked online but did not find anything to help me. Thanks guys. I'm using ubuntu 14.04, if that helps.
Open the file in Wing and then select Evaluate File in Python Shell from the Source menu. After that, functions/etc defined in the file can be accessed from the shell. You do need to redo that if you've edited the file.
Or you may want to use the Active Range feature that's new in Wing 5.0.9: Select a range of code, and press the + icon in the Python Shell (top right) to make it the active range. Then you can easily reevaluate that range in the Python Shell by pressing the cog icon (or bind a key to the command python-shell-evaluate-active-range).
Another option is to set a breakpoint, debug to it, and then use the Debug Probe, which is a shell that lets you interact with the runtime state in the currently selected debug stack frame.

Running code in PyCharm's console

Are there any smooth way to run Python scripts in the PyCharm's console?
My previous IDE - PyScripter - provides me with that nice little feature. As far as I know PyCharm has 2 ways of running script in console:
1) Select a bunch of code and press Ctrl+Alt+E.
2) Save the code in a file and import it from the Console.
Are the any way to do it by pressing "Run" or "Debug" buttons? I need to see the result of my script in the console and all variables available to manipulate.
In the Run/Debug Configuration, add -i to the interpreter options. This will stop it from closing a python session even after a successful run. I.e. you will be able to see all the variable contents
Run -> Edit configuration -> select the script you want to run and give it a display name -> OK
Now you can run it with the green "Run" button. The green bug button (next to the run button) will run it in debug mode.
Remark: next to the run button you can monitor the script/configuration you run by selecting it's display name.
If you create run-time configuration then after pressing the run button (green "play" icon) you will get the desired result: your code will give you output in a console which opens atomatically at the bottom.
You can create many different configuraions for run and debug within a single project.
Here is a link from PyCharm's web help which covers the run/debug configurations:
http://www.jetbrains.com/pycharm/webhelp/run-debug-configuration-python.html
A possible way of manipulating the variables using debug mode and evaluate expression window is added in comment but I missed one detail: to see the result of your interactive code execution you have to switch from Debugger to Console output; mode tabs are on the top-left side of the bottom pane.
The way I do it is a create my script in the editor, call it myfirst.py, eg
print "Hello"
a= 1234
then in the console I run:
reload (myfirst)
To check on the variables use:
>>> myfirst.a
Not perfect but that's pyCharm for you. If you want a pyScripter like experience which I think is more useful you can try spyder2.
It may also be a good option for you to use the magic command
%run scriptname.py
in the ipython console (including the %-character). Compared to Cntrl + Alt + E you also get clean information on errors in your code.
Due to autocomplete it's also typed in a second and you can use this in any environment with an ipython shell. For me as a scientist who often uses python to explore data, this is a good option.
With your program in the editor:
Run - Edit Configurations
Then under Execution check the box for "Run with Python console".
When you run the program from the green arrow it will run in a console. After the run all your objects are available to examine and play with.

Categories

Resources