It is currently February 19th, 2020, 11:45 am

Python 3.3 Plugin (Alpha)

Share and get help with Plugins and Addons
jblume
Posts: 1
Joined: March 2nd, 2013, 11:35 pm

Python 3.3 Plugin (Alpha)

Post by jblume »

I have created a small plugin to enable the use of Python 3.3 scripts as 'measures' for Rainmeter. As I only spent less than a day coding and testing it, it is still of alpha quality and might crash at any moment, but it is working fine for me so far.

You can find the source code, binaries for 32 and 64 bit architectures and two usage examples on the GitHub repository I created for the plugin.

I didn't have any chance to actually try the 32 bit version yet, but I don't see any reason why it shouldn't work.

As a small example of what you can do with it, here is a (rather primitive) Python measure which counts unread messages on an IMAP4 email account:

Code: Select all

import imaplib

class Measure:
    def Reload(self, rm, maxValue):
        self.host = rm.RmReadString('Host', 'example.com', False)
        self.username = rm.RmReadString('Username', 'user', False)
        self.password = rm.RmReadString('Password', 'pass', False)

    def Update(self):
        con = imaplib.IMAP4(self.host)
        con.starttls()
        con.login(self.username, self.password)
        con.select('INBOX', True)
        _, msgnums = con.search(None, '(UNSEEN)')
        con.close()
        con.logout()
        return float(len(msgnums[0].split()))
I hope this plugin will be of use to other people. If you find any bugs or have suggestions on how to improve it, please let me know.
User avatar
MerlinTheRed
Rainmeter Sage
Posts: 911
Joined: September 6th, 2011, 6:34 am

Re: Python 3.3 Plugin (Alpha)

Post by MerlinTheRed »

No one commented on this yet? This is a great idea that has a lot of potential. Please do continue to work on this! We already have Lua, so one might say it's kind of redundant, but since the Rainmeter built-in Lua has some limitations, and diversity is a good thing, I think this is worth pursuing.
Have more fun creating skins with Sublime Text 2 and the Rainmeter Package!
Kokoro
Posts: 8
Joined: February 28th, 2015, 11:31 pm

Re: Python 3.3 Plugin (Alpha)

Post by Kokoro »

I am currently using it, or trying to. Only issue I have found so far is that it only works with 3.3. Even when I pointed it to 3.4, I could only get the scripts to run when I pointed it back to 3.3.
drakulaboy
Posts: 165
Joined: June 29th, 2014, 8:35 pm

Re: Python 3.3 Plugin (Alpha)

Post by drakulaboy »

this is amazing

Code: Select all

[Rainmeter]
Update=1000

[MeasurePy]
Measure=Plugin
Plugin=Python.dll
PythonHome=c:\Python33
ScriptPath=default.py
ClassName=Measure
UpdateDivider=1

[Measure]
Meter=String
MeasureName=MeasurePy
FontSize=20
StringStyle=Bold
FontColor=255,255,255
and default.py (is un same directory)

EDIT: i thing i'm getting this

Code: Select all

import time
class Measure:
  def Reload(self, rm, maxValue):
    rm.RmLog(rm.LOG_NOTICE, "Reload called")

  def Update(self):
    return 1.0

  def GetString(self):
    time.strftime('%d %B %Y %H:%M:%S')
    return ("Hour: " 	+time.strftime('%H:%M:%S'))
    


  def ExecuteBang(self, args):
    pass

  def Finalize(self):
    pass
Whoop whoop :thumbup:
drakulaboy
Posts: 165
Joined: June 29th, 2014, 8:35 pm

Re: Python 3.3 Plugin (Alpha)

Post by drakulaboy »

import os
os.startfile('C:\Program Files\AIMP3\AIMP3.exe')
:lol:
so simple
drakulaboy
Posts: 165
Joined: June 29th, 2014, 8:35 pm

Re: Python 3.3 Plugin (Alpha)

Post by drakulaboy »

installed Python3.4.3
it's working too :thumbup:
Kokoro
Posts: 8
Joined: February 28th, 2015, 11:31 pm

Re: Python 3.3 Plugin (Alpha)

Post by Kokoro »

drakulaboy wrote:installed Python3.4.3
it's working too :thumbup:
Do you still have Python 3.3 installed? I have forked the code, and in several places it is hard referencing the \python33 folder. I have updated the code to the 34 folder, and have been able to compile the x64 dll, which is working properly now on my system. Have to get the x86 version working, and looking at a way to update the code so that at compile time, it will compile the 2.7, 3.3, 3.4 and 3.5 includes, so that it should handle a wide range of python systems.
drakulaboy
Posts: 165
Joined: June 29th, 2014, 8:35 pm

Re: Python 3.3 Plugin (Alpha)

Post by drakulaboy »

yes, i have Python 3.3 installed too

finally i can log in to my favorite tracker and parse new torrents and if i have new private message Image
FlyingHyrax
Posts: 251
Joined: July 1st, 2011, 1:32 am
Location: US

Re: Python 3.3 Plugin (Alpha)

Post by FlyingHyrax »

Very cool! I'll be looking through the code for this sometime for sure.

This is especially nice since the built-in Lua scripting does not include require() and friends for working with libraries. I thought once (very briefly) of trying to make a Lua plugin (or even custom Rainmeter build, just for personal use) with require() etc. included.
Flying Hyrax on DeviantArt
drakulaboy
Posts: 165
Joined: June 29th, 2014, 8:35 pm

Re: Python 3.3 Plugin (Alpha)

Post by drakulaboy »

well, now i'm able to connect and parse then see how many emails i have in my inbox not only on Gmail ;-) i send a email with python from my desktop and i was so happy to see that is working