Category Archives: Scripting – Development

Using atom as Python editor

atom

I have been testing atom for editing Python code. (https://atom.io/)

Overall I was impressed.  A lot of add-ins (called ‘Packages’) are available on top of the default ones.

I installed the ‘Script’ (https://atom.io/packages/script) package to run scripts from within Python.   You can install this package from atom: ‘Settings’, ‘Install’ (search for script …)

Once this is done you need to remember starting atom with the command “atom .” (and configure script using ‘Packages’, ‘Script’, ‘Configure Script’) – then you can run a script with the shortcut ‘shift-ctrl-b’ (for Windows), or from the atom menu: ‘Packages’, ‘Script’, …’

Multiple Notepad++ windows

Notepad++

Viewing multiple files side by side in Notepad++ comes in handy.  I was looking how this can be done and apparently it’s easier than you may think.

Just rightclick on the tab of the file you want to see next to the current one.  In the lowest part of this menu you can find what you need:

Move to Other View
Clone to Other View
Move to New Instance (you may prefer this or the next one if you are working with  multiple monitors)
Clone to New Instance

Another option – less obvious is to start Notepadd++ with the parameter -multiInst.  I found this here.

Python: view line numbers in standard editor

python-logo

By default IDLE (the standard Python IDE) does not show line numbers 😦

You can install the extension IdleX to do this.  This is only one of IdleX’s features. See http://idlex.sourceforge.net/features.html for an overview of all features.

You can download IdleX here.  After decompressing the ZIP file you only need to run idlex.py to use this extension (and show/hide line numbers).

Python: creating executables

python-logo

Out of the box Python is an interpreted programming language.

One way to create an exe file from the standard Python py files is using PyInstaller.  (note: I am working with Python 3.5.  PyInstaller supports Python 3.  Py2exe – which also allows to make exe files – currently only supports Python 2.7)

Preparation:

  1. Download PyInstaller (http://www.pyinstaller.org/ – documentation can also be found here)
  2. Install PyInstaller with the pip command:
    • Start Cmd
      Go to the folder containing PyInstaller-3.0.zip (using CD FOLDERNAME)
    • Execute the pip command:
    • > pip install pyinstaller

Now package your py file with the command PyInstaller xxx.py; for example:

> PyInstaller Testapp.py

The exe file will now be created under the dist folder.  You need all files in the dist folder containing the exe file.

Other examples:

> PyInstaller -F Testapp.py

Now Testapp.exe will also be created in the subfolder caller “dist” in a one-file bundled exe file.

> PyInstaller -F -w Testapp.py

This also creates a one-file bundled exe file, but does not show a console window; this is probably what you need when you create a GUI application.

Changing colors in SciTE

autoit

When attaching an external monitor I was not able to see a code selection on this screen in the AutoIt editor SciTE.

I found out that changing the colors involved modifying the “c:\Program Files (x86)\AutoIt3\SciTE\SciTEGlobal.properties” file.

More specifically changing the selection.fore, alpha and back solved the issue.

AutoIt-colors

As the alpha.selection settings apparently can behave differenty on a laptop display and an external monitor, it makes sense to disable this setting …

AutoIt Colors 2

Tips:

  1. When you modify the colors in SciTE, you can immediately see the result after saving the file.
  2. Put # in front of the original line to keep a backup of the original setting.
  3. See for example this page on w3schools.com for an overview of hex values colors
  4. Modify indicators.alpha, for example to “indicators.alpha=150” to improve visibility when highlighting a word (see below)

AutoIt_Highlight

Building in Visual C# Express 2010

If the Build option is missing in the Build menu there are some possible causes/solutions:

  • Press F6: this will build the solution (whether the Build option is in the Build menu or not)
  • Rightclick your solution and click Build

visual-studio-2010-expert-settings

 

  1. Enable the Tools → Settings → Expert Settings menu option
  2. Go to Tools → Options
    In the dialog box, check Show All Settings option in the bottom left.
  3. In the above dialog, now choose Projects and Solutions → General.
    Check the option Show advanced build configurations.
  4. Click OK.
  • For me this did not help, but when I switched from Expert Settings to Basic Settings, the Build option was back again.  This made me conclude there was something screwed up in my settings.
  • I switched back to Expert Settings, and reset the Settings (Tools, Settings, Reset): now the Build option was back, and everything was back to normal after I manually set the settings.

To switch between Release and Debug:

  • Show advanced build configurations need to be checked
  • Build, Configuration Manager
  • Active solution configuration: select Debug or Release