Skip to main content

Posts

Showing posts with the label Python

Installing Kivy 1.11.1 on MX Linux 19 - faster method

MX Linux 19 is the most downloaded distribution as per DistroWatch as of Jan 19, 2020. Since MX Linux is based of Debian, this quick how to should apply to Debian/Ubuntu derivatives as well. Kivy is an open source cross platform Python library for rapid application development. Kivy generated applications run on Linux, Windows, OSX, Android, iOS and Raspberry Pi. To install Kivy on MX Linux 19 (and other Debian derivatives), do install Python packages Pip and Venv, like: $: sudo apt -y install python3-pip $: sudo apt -y install python3-venv Create virtual environment, install Python library dependencies and then install Kivy, like: $: python3 -m venv ~/kivy_venv $: source ~/kivy_venv/bin/activate $: pip3 install --upgrade --user pip $: pip3 install wheel $: pip3 install -U --force-reinstall Cython==0.29.9 $: mkdir ~/tmp $: cd ~/tmp $: wget https://files.pythonhosted.org/packages/aa/20/8d5553d7bb57dfae0ac9c1a68532f8cbdb017baee154f649b90ee012317b/Kivy-1.11.1-cp37-cp37m-many

Installing Kivy 1.11.1 on MX Linux 19

MX Linux 19 is the most downloaded distribution as per DistroWatch as of Jan 19, 2020. Since MX Linux is based of Debian, this quick how to should apply to Debian/Ubuntu derivatives as well. Kivy is an open source cross platform Python library for rapid application development. Kivy generated applications run on Linux, Windows, OSX, Android, iOS and Raspberry Pi. To install Kivy on MX Linux 19 (and other Debian derivatives), do install library dependencies, like: $: sudo apt -y install python3-pip python3-dev libgstreamer1.0-dev libsdl2-dev libsdl2-ttf-dev libsdl2-image-dev libsdl2-mixer-dev libpango1.0-dev python3-venv Create virtual environment, install Python library dependencies and then install Kivy, like: $: python3 -m venv ~/kivy_venv $: source ~/kivy_venv/bin/activate $: pip3 install --upgrade --user pip setuptools $: pip3 install wheel $: pip3 install -U --force-reinstall Cython==0.29.9 $: pip3 install kivy This can take a while, so relax and enjoy!

Enable ClearType using Python

When I remote desktop to Windows machines most of the time the fonts just looks ugly. This can be improved by enabling ClearType and I do this every time I connect to a box which I do several times a day. Below is a Python code that enables ClearType which I shamelessly copied from StackOverflow. Reference(s): http://stackoverflow.com/questions/5676768/enable-disable-cleartype-in-windows7

Howto: Installing pywin32 on Python 3.5.1 64-bit

Installing Python for Windows Extensions on Python 3.5.1 64-bit C:\>pip install pypiwin32 If you are getting the following error message in importing win32gui install VC++ 2010 redistributable. >>> import win32gui Traceback (most recent call last):   File "<stdin>", line 1, in <module> ImportError: DLL load failed: The specified module could not be found. Reference(s): http://sourceforge.net/projects/pywin32/ https://www.python.org/downloads/

Check Windows input message queue idle in Python

Code below shows how to check for message queue input idle. Note that WaitForInputIdle waits only once per process on any thread. So if one of the thread returns idle then it will return right away.  Tested on: Windows 10 TH2 (build 1511) Python 3.5.1 64-bit Also need to install pywin32, like: c:\> pip install pypiwin32 This should be run on elevated prompt.

pip fails to run on Windows 10 E build 10074

Installed Windows 10 E 64-bit build 10074, followed by Python 2.7.9 32-bit. Running pip fails the with message Fatal error in launcher: Job information querying failed Issue is open in Github, see below https://github.com/pypa/pip/issues/2748 This issue is also reported in Python.org, see https://bugs.python.org/issue24127 Workaround: C:\>python -m pip install comtypes

Send email via GMAIL using Python

Send email via GMAIL using Python. Note: Need to disable CAPTCHA and enable access for less secure apps https://www.google.com/settings/security https://accounts.google.com/DisplayUnlockCaptcha References: www.mkyong.com/python/how-do-send-email-in-python-via-smtplib/ http://joequery.me/guides/python-smtp-authenticationerror/

wxPython nuggets

Sample code playing around canvas, cursors, images. Another wxPython Tutorial The wxPython Tutorial - The wxPython tutorial is the largest and most advanced wxPython tutorial available on the Internet. Suitable for beginners and intermediate programmers Rubberbanding in wxPython

Print active application and title using pywinauto

Code snippet below shows how to get the window title and application name of the active application. That is the application on top of the z-order. Need to install pywinauto to get this to work. import pywinauto.application import pywinauto.handleprops as _handleprops import pywinauto.win32functions as _win32functions import time while 1:     hwnd = _win32functions.GetForegroundWindow()     print "Active Window title is %s"%(_handleprops.text(hwnd))     print "Application name is %s"%(pywinauto.application.process_module(_handleprops.processid(hwnd)))     time.sleep(2)    ~ts

Generating UUID in Jython

I have been poking around STAX/STAF recently and I found a need to generate UUID or GUID in Windows. I tried uuid module in CPython but I can't call it inside my STAX job. I tried to create STAX process but I noticed that if the program is under heavy usage I cannot guarantee that the STAX process that runs the CPython gets the resulting UUID string. Since STAX is using Jython, I reasoned out that this should be possible in Java. A quick search in Google shows java.util.UUID. This class is just what I need. So, basically, in Jython I can generate a UUID using the following command: import java print java . util . UUID . randomUUID () ~ts~