jython

Fading a picture gradually

馋奶兔 提交于 2019-12-05 06:42:32
The idea of this function is to fade the top half only of the picture (make it gradually darker). Here is what I have but it seems to be making all of the top half solid black. def fadeDownFromBlack(pic1): w=getWidth(pic1) h=getHeight(pic1) for y in range(0,h/2): for x in range(0,w): px=getPixel(pic1,x,y) setBlue(px,y*(2.0/h)) setRed(px,y*(2.0/h)) setGreen(px,y*(2.0/h)) Let's look at just one line here: setBlue(px,y*(2.0/h)) and key part here is y*(2.0/h) y changes, as you go down. Let's try some simple values for y and h. Let's say h is 100 and we will examine when y is both 0 and 50 (h/2).

Import jar API in Jython

删除回忆录丶 提交于 2019-12-05 06:02:14
I am trying to import a Java API, which is distributed as a jar file. I followed the instructions from this answer at a similar question in Stack Overflow, but it didn't work. In Jython, I did: >>> import sys >>> sys.path.append("/path/to/jar/api") >>> from com.thingmagic import * Traceback (most recent calls last): File "<stdin>", line 1, in <module> ImportError: no module named thingmagic Am I missing something or did I do something wrong? You need to provide the full path of the JAR file. Change sys.path.append("/path/to/jar/api") to sys.path.append("/path/to/jar/api/whatever_the_name_is

Jython 2.5.1: “ImportError: No Module named os”

我们两清 提交于 2019-12-05 03:34:05
I looked through the other posts and bug reports and couldn't figure out what's causing this. I'm using Jython 2.5.1, in a Java project in Eclipse (Ubuntu 8.10). It has been added to the project as a standalone .jar file (I just replaced the old Jython 2.1 jar with this one). I'm running a script that uses the threading.py class. At some point the statement "import os" is evaluated from linecache.py and I get this error, which I can't seem to figure out how to fix: 'Execution failed. Traceback (most recent call last): File "<string>", line 1, in <module> File "../lib/python/threading.py", line

.class file from jython with pydev

六眼飞鱼酱① 提交于 2019-12-05 02:51:02
问题 My first attempt at jython is a java/jython project I'm writing in eclipse with pydev. I created a java project and then made it a pydev project by the RightClick project >> pydev >> set as... you get the idea. I then added two source folders, one for java and one for jython, and each source folder has a package. And I set each folder as a buildpath for the project. I guess I'm letting you know all this so hopefully you can tell me wether or not I set the project up correctly. But the real

Jython - Using Spring, Programming in Python?

人走茶凉 提交于 2019-12-05 02:19:01
问题 Ok, I'm a total newbie in this stuff. So, I know Spring is really good as a framework, and I've been programming in Python for a while, so I was wondering if somehow I can use the Spring Framework but use code from Python. I heard that maybe Jython was a good possibility for doing this, since it's (I think) Python running on the JVM, right? So, is this possible? For me to use Spring while coding in Python? 回答1: First, you're right that Jython is Python running in the JVM. And it's not just

Using JRuby/Jython for Ruby/Python interoperability?

£可爱£侵袭症+ 提交于 2019-12-05 01:12:19
Quite-probably a silly question, as I don't know much about Java/Jython/JRuby/bytecode, but.. I stumbled across _why's unholy again today.. It allows you to output Python bytecode from Ruby code.. Basically allowing them to produce the same bytecode.. Jython outputs Java bytecode, as does JRuby.. Since these both compile to the same bytecode, does this mean you could potentially use any Python library from Ruby, and Ruby libraries from Python? No, that won't work. At least not the way you think it would. Interoperability between Jython and JRuby works the same way as between CPython and YARV:

“sys-package-mgr*: can't create package cache dir” when run python script with Jython

烂漫一生 提交于 2019-12-04 23:04:40
问题 I want to run Python script with Jython. the result show correctly, but at the same time there is an warning message, "sys-package-mgr*: can't create package cache dir" How could I solve this problem? thanks in advance~~~ 回答1: 1) By changing permissions to allow writing to the directory in the error message. 2) By setting python.cachedir.skip = true You can read this: http://www.jython.org/jythonbook/en/1.0/ModulesPackages.html#module-search-path-compilation-and-loading for further insights.

Why aren't breakpoints working on the Swing Event Dispatch Thread in PyDev?

ぃ、小莉子 提交于 2019-12-04 21:42:40
I'm using Jython, Swing, and PyDev (Eclipse). Breakpoints are not being hit on any code that runs on the EDT (aka AWT Event Queue?). This includes: Functions that are invoked from a Swing event (eg JButton click) Functions that, via a decorator, are run through SwingUtilities.invokeLater() (See the last example here . Functions that registered as hooks to a Java package (socket class), that I'm using. Swing event code to reproduce: from javax.swing import JFrame, JButton def TestFunc(event): #breakpoints in this function don't work print "Hey" if __name__ == '__main__': mainWindow = JFrame(

Could not install packages due to an EnvironmentError: Could not find a suitable TLS CA certificate bundle

你离开我真会死。 提交于 2019-12-04 19:43:30
I am trying to install a robotframework library called ImageHorizonLibrary. However, I am running into an issue. I am trying to install it using pip in the jython environment: /Users/nimam/jython2.7.0/Lib/site-packages I do the following: sudo -H pip install robotframework-imagehorizonlibrary And I get the following error: Could not install packages due to an EnvironmentError: Could not find a suitable TLS CA certificate bundle, invalid path: __pyclasspath__/pip/_vendor/certifi/cacert.pem If I try to install the library without sudo, i get the following error: Exception: Traceback (most recent

Jython webapp performance

蹲街弑〆低调 提交于 2019-12-04 14:33:19
I'm currently building a Jython web app but am concerned about Jython application performance. I take some comfort in that any compute intensive tasks I can write in a separate Java jar and invoke them from Jython. Has anyone had problems doing this, or forsee issues with such a setup? You'll find a nice comparison here: http://blog.dhananjaynene.com/2008/07/performance-comparison-c-java-python-ruby-jython-jruby-groovy/ Jython is slower, but depending on what you want to do, that may not be a big problem. I use Jython primarily for allowing me to debug the application on the fly, and it works