How can I change a .py file to .pyw? - windows

I tried to right click the file and rename it, but it won't even show me the extension so that I could delete it. I also tried going to properties and I couldn't do it from there either. I didn't code directly with the Tkinter of python, I used a custom made graphics library that came with my book.

You are on the right lines in that you just need to rename it - unfortunately modern versions of Windows hide the extension by default so you can't readily modify it.
I tend to set Windows to always display extensions (as this fixes this issue computer-wide), but if this is undesirable or not possible you can always use the command prompt:
cd C:\Path\To\File
ren MyPythonScript.py MyPythonScript.pyw
Hope this helps.

Related

Unable to set DefaultIcon in registry

I am attempting to update the Windows registry to add an icon for my custom file extension, and I have thus far been unsuccessful. My current version is closest to this stackoverflow question. Unfortunately, my file's icon is still one of the generic built-in Windows icons (see screenshot below).
At this point my best guess is perhaps there is something wrong with my .ICO file. I have shared it here on Dropbox
Here is the full registry update I'm making with regedit. As you can see, I am also associating my file extension with a .bat file for execution. That works great. Also the Type displayed in Windows Explorer is PartQuest Archive which is also great (see above screenshot). Alas, no dice with the last entry for the icon.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\pqunzip]
#="PartQuest Archive"
[HKEY_CLASSES_ROOT\pqunzip\shell]
[HKEY_CLASSES_ROOT\pqunzip\shell\open]
[HKEY_CLASSES_ROOT\pqunzip\shell\open\command]
#="\"C:\\MentorGraphics\\PartQuestTools\\SDD_HOME\\common\\win32\\scripts\\pqunzip.bat\" \"%1\""
[HKEY_CLASSES_ROOT\.pqz]
#="pqunzip"
[HKEY_CLASSES_ROOT\.pqz\DefaultIcon]
#="\"C:\\MentorGraphics\\PartQuestTools\\SDD_HOME\\common\\win32\\config\\decrypted.ico\""
I have also attempted adding a ,1 to the end of the file name since the .ICO file appears it may have two icons embedded in it. This is did not make a difference.
For good measure, I have been rebooting after each change. I'm not certain if this is necessary.
Any tips from the Windows experts around here will certainly be appreciated!
So I did a little reverse-engineering to figure out the issue based on 7Zip's file associations. It turns out that the DefaultIcon key entry should be a child of the application, not the file name. So in my case I need it associated with pqunzip rather than .pqz:
[HKEY_CLASSES_ROOT\pqunzip\DefaultIcon]
#="\"C:\\MentorGraphics\\PartQuestTools\\SDD_HOME\\common\\win32\\config\\decrypted.ico\""
For maximal clarity, this is the entire contents of my .req file that works as expected:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\pqunzip]
#="PartQuest Archive"
[HKEY_CLASSES_ROOT\pqunzip\shell]
[HKEY_CLASSES_ROOT\pqunzip\shell\open]
[HKEY_CLASSES_ROOT\pqunzip\shell\open\command]
#="\"C:\\MentorGraphics\\PartQuestTools\\SDD_HOME\\common\\win32\\scripts\\pqunzip.bat\" \"%1\""
[HKEY_CLASSES_ROOT\pqunzip\DefaultIcon]
#="\"C:\\MentorGraphics\\PartQuestTools\\SDD_HOME\\common\\win32\\config\\decrypted.ico\""
[HKEY_CLASSES_ROOT\.pqz]
#="pqunzip"

ActivePerl. .pl files no longer execute but open in Notepad instead

I have perl scripts which were running in Windows 7 just fine as of this morning. I made the mistake of using NotePad as the default for opening/editng my .pl files. Now, when I attempt to run the unedited .pl files from a DOS prompt, the script does not execute but opens the associated source code file in Windows Explorer. This is the same for all my .pl files no matter the complexity (including classic "hello world".
I have been researching changes need to the registry - it all looks fine. Tried assoc and ftype changes - nothing. Tried reinstalling ActivePerl - no solution.
You don't need to go into the Registry.
Go into Windows Explorer.
Find a file that ends in a *.pl suffix.
Right click on it and bring up the Context menu.
Select "Open With" (It might just be Open... with an ellipse after it. I don't have a Windows machine at the moment to verify this). This will bring up a dialog box with all the various programs. NOTE: Perl may not be listed in the initial set of programs. No worry, just navigate to it.
On the bottom of the dialog box is a checkbox (Something like open all extensions with this program). Make sure that checkbox is checked.
After this, all files that end with *.pl will open with Perl instead of Notepad.
It is highly likely that someone did this with a Perl script in order to edit it, and messed up the file association.
However, who ever did this should be doped slap -- not for messing up the file association, but for editing a program with Notepad. Bad Developer! No doughnuts for you!
Programs should be opened with a Program Editor. If you're a real he-man, you can use VIM. VIM is a fast, and powerful program editor, but you will need to spend an internship at the feet of a VIM Ninja master in order to learn how to use it. Your first three to six months with VIM will be What a idiotic program! This is awful. Who wrote this crap?. Then, one day, you will understand its power and efficiency. You will be one with the program.
If you aren't brave or fearless or don't have six months to waste learning a programming editor, you can use Notepad++. Compared to VIM Notepad++ is like driving a Minivan. It's safe, it's practical, and it gets the job done.
Both editors do Syntax Highlighting which can help you find issues. Both, (VIM can -- I think Notepad++ can too) offer help with syntax and usage. Both can edit a file without messing up the line endings (They'll both detect whether a file has Unix or Windows line endings and keep those or allow you to convert them). Both will number your lines, have extensive cut/paste buffers, powerful search and replace features. And will not mess up your file encoding. Both offer visual diffing between files and do automatic backups when you edit a file.
Finally, these two editors will embed themselves into the context menu you get when you right click on a file. You can edit a file by clicking on it, and selecting VIM or Notepad++ directly from the context menu. No need to select "Open with..." and possibly mess up the file suffix association.
Never ever use Notepad to edit a program.
Sounds like your .pl extention association is now set to Notepad rather than perl.exe. If you are too busy to fix that, just type "perl yourscript.pl" in a command promot window to start the perl interpreter and to send your script to it to run.
See this answer to fix the association:
File Type .pl Association and Using cmd.exe to Run the Script
I have the same problem. None of the method mentioned above solve the problem. The problem actually came from Windows 7! Windows 7 Doesn't allow you to associate .pl to perl.exe in c:\Perl64 directory, for whatever reason.
Here is the solution:
If you look at c:\Perl64\Bin directory (or the path where your ActivePerl binary installed), you'll see another file: Perl5.14.2.exe. This is the same file as perl.exe in same directory but with version number attached as postfix in the name.
You can associate .pl file to that Perl5.14.2.exe instead of perl.exe. Bingo, it works now.

Setting the Search Path... global setting in MacVim

Noticed an interesting GUI based setting in MacVim, that seems useful but I can't seem to find any official word on what it does exactly.
It is located at Edit Menu > Global Settings > Search Path...
Once there a dialog drops down with the following:
"Enter search path for files"
Separate directory names with a comma.
.,/usr/include,,
From that editable line I get the clue that this appears to be a header search path. Something I would hope works with ctags, etc. But the setting I put in there don't seem to stick between open and closing just MacVim windows with out even quitting the MacVim Application.
Searing Vim help only really turns up new-search-path which I am not sure how to use or set if it is even related?
Is this what I think it is? The header search path. If yes then how do I set the path in my .vimrc or where needed so that the changes to it are persistent.
If this is not a header search path then what does it do?
I think you are right about its purpose, the setting is simply called path: its default value (:set path?) is .,/usr/include,, just as in your question.
You can use it to tell Vim to look for files in specific places.

Update desktop "show window contents while dragging" setting programatically

One of my programs seems to be changing the Display Properties > Appearance > Effects > Show window contents while dragging setting to off every few hours.
I'm not sure exactly which program, or when it happens. I have a number of programs that seem like likely culprits - wallpaper rotators, software for multiple monitors, multiple virual desktops and switching, and a few others.
I am just thinking to create a little batch script to run periodically and set the setting back to on.
Does anyone know how to do this in windows? I'm using xp pro sp3.
Thanks!
The best option is to do this programmatically using the supported API. i haven't tested this, but it should do the trick:
SystemParametersInfo(SPI_SETDRAGFULLWINDOWS,
TRUE,
NULL,
SPIF_UPDATEINIFILE | SPIF_SENDCHANGE)
You can use SPI_GETDRAGFULLWINDOWS to see if the the bit has been flipped to avoid unnecessarily triggering a WM_SETTINGCHANGE.
You can use RegMon to find the program that keeps changing your settings. Maybe that's a better start than hacking around it.
There is a simple and effective solution to this problem. In Notepad type the following lines :
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Control Panel\Desktop] "DragFullWindows"="1"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects\DragFullWindows] "CheckedValue"=dword:00000001 "UncheckedValue"=dword:00000001
Save the file as "Show Window Contents.reg" Double clicking this file and restarting will cure the problem permanently. Post a message if you find this useful.
Aravind Banerjee
It seems the registry setting which controls that preference is HKCU\Control Panel\Desktop\DragFullWindows. You can read more about it here. However, trying it on my own computer does not register the change right away, so a batch script won't do it. You'll probably have to write a program to manipulate it using SystemParametersInfo(). You can pass it the SPI_SETDRAGFULLWINDOWS parameter. Here's a page explaining it more. Here's a page showing how to call it, albeit not for the same parameter.
I suspect it's kept in the registry - maybe [HKEY_CURRENT_USER\Control Panel\Desktop] - "DragFullWindows"?
It would be easy to flip the registry setting back to "1" every hour or so with a batch file.

Is there a Firefox add-on to use vim to edit textboxes?

or "How do I answer questions on SO in Firefox using gVim inside the textboxes?"
It's All Text!
From the extension page:
At the bottom right corner of any edit
box, a little edit button will appear.
Click it. If this is the first time
you've used "It's All Text!" then you
will be asked to set your preferences,
most importantly the editor.
The web page will pop up in your
selected editor. When you save it,
it'll refresh in the web page. Wait
for the magic yellow glow that means
that the radiation has taken effect!
Vimperator makes Firefox act very much like VIM:
Vimperator is a free browser add-on for Firefox, which makes it look and behave like the Vim text editor. It has similar key bindings, and you could call it a modal web browser, as key bindings differ according to which mode you are in.
Once you have the cursor in a text box, hit Ctrl-I to open in your editor, which defaults to gvim.
The current answers don't work anymore now that Mozilla removed XUL in favour of WebExtensions. With recent firefox versions, there are the following options (sorted in descending order by the current popularity on addons.mozilla.org).
GhostText provides instant synchronization between editor and textbox via editor-specific plugins. The project is on github and the vim extension is written in Tcl.
withExEditor is cross-platform but requires a native application written in node.js. In addition to editing text fields it also allows viewing the source of the page, MathML, SVG and the current selection. The project on github and the native node.js application
Textern requires a (currently) Linux-only native application written in Python. Synchronizes the content of the text field while you type in the editor. The extension and the native app can be found on github
Tridactyl is probably what you're looking for nowadays.
It's the spiritual successor to the likes of Pentadactyl and Vimperator, which are not available for the current version of Firefox.
If you want something more like It's All Text, where the editing area appears right on top of the browser text area rather than launching an editor window, and you're willing to use Neovim, check out firenvim.
It's All Text! will let you use whatever editor you want. To use vim with it, you'll need a small shell script to open it in a terminal:
#!/bin/sh
exec xterm -e /usr/bin/vim "$#"
If you have GVim, you won't need the shell, script, obviously.
ViewSourceWith is another addon worth lookng at. It supports more than just edit boxes and text. For example, you can configure it to open images in the GIMP.
Another feature that I find useful is that it can pop-up a dialog box that shows all the js and css scripts used on the page. You can then choose to view/edit file in your preferred editor.
For answering questions on SO, you may also want to get the Vim Markdown Syntax file
The "It's all Text" extension, perhaps?
http://addons.mozilla.org/en-US/firefox/addon/4125
If you use vimperator and have the markdown syntax file installed, a useful line for your .vimperatorrc is:
au LocationChange .* :set editor="gvim -f"
au LocationChange stackoverflow\.com :set editor="gvim -f -c 'set ft=mkd'"
This will tell vim to do syntax highlighting for markdown when you are on stackoverflow.com, but not when you are any other site. There are similar hacks for wikipedia/mediawiki etc. Enjoy :)
One way to do this is to use the vimperator extension - of course, that does a lot more than what you're looking for.
At the time of writing it is experimental, but the jV extension looks good. To quote from the page:
This extension makes all html textareas into a very stripped-down version of Vi[m]. It's modal, supports infinite undo, has register support, search, visual mode, and various movement and editing commands.
When using Vimperator in Windows (I am using Vista) you may need to double-escape the path to gvim.exe to use it as the external editor. Single escaping did not work for me as Vimperator unescapes it twice. Eg:
:set editor="C:\\\\Program\\ Files\\ (x86)\\\\Vim\\\\vim72\\\\gvim.exe" -f
Then while in a text box you use Ctrl+I and it will open gvim for editing. When you save and exit it will update the text box.
There is an experimental way to directly embed the real vim in firefox using embedded editor - though it requires mozplugger and will only work on Linux.
Try out the wasavi extension. You might want to check out the all versions page to make sure you try out the latest version. (Copy of this answer.)
You can also use the ViewSourceWith addon to achieve the same. Just right-click on any text input and you can edit it using Vim.
As said by others,
as a Vi/(g)Vim user you'll probably want to look at the Vimperator addon, which also provides the what you ask:
inside a textbox, hit <C-i> to launch the external editor.
(can be defined in _vimperatorrc: set editor=gvim -f )
A hint for Mac users: if you want to use "It's all text" with vim, the easiest way is to use http://code.google.com/p/macvim/ . Point "It's all text" to the mvim script that's provided along with the .app (you can place this script anywhere, I choose /usr/bin/ so that I can load mvim from the command line)
Pterosaur is a Firefox plugin that allows you to use Vim in all input fields. It uses an actual Vim process in the background so it has all the functionality you expect, including reading your .vimrc configuration and your plugins.
With Firefox-57 on Linux, I installed textern https://addons.mozilla.org/en-US/firefox/addon/textern/, and found it to be a suitable replacement for ViewSourceWith for editing text boxes.

Resources