Skip to main content

Brython: Python in Browser

Brython is python in browser.

Yes, You can just run it in the browser.

What you need is to get brython.js from their github.

https://raw.githubusercontent.com/brython-dev/brython/master/www/src/brython.js

And put it into some folder of your choice.

Now create a html file and call that js.


<html>
<head>
<script src="brython.js"></script>
</head>
<body onload="brython()">
<script type="text/python">
from browser import document, alert, console

def echo(ev):
    alert(document["zone"].value)

console.log('Hi, this is from python')
document['mybutton'].bind('click',echo)
</script>
<input id="zone"><button id="mybutton">click !</button>
</body>
</html>

Here is piece of code i copied from their website (Infact, modified a little bit).

What is important?
1. including

 <script src="brython.js"></script>

Yes this line, calling/including browser.js file.

3.Body onload function 

<html>

<head>
<script src="brython.js"></script>
</head>

<body onload="brython()">
<script type="text/python" src="test.py"></script>
<input id="zone"><button id="mybutton">click!</button>
</body>

</html>

And here is python code (test.py) i used


from browser import document, alert, console

def echo(ev):
    alert(document["zone"].value)

console.log('Hi, this is from python')
document['mybutton'].bind('click',echo)


Here you can try it online

http://brython.info/tests/console.html

OR Here

http://brython.info/tests/editor.html

Popular posts from this blog

How to run android apk in your Google Chrome browser with Google's ARC

Google's plan on merging android with ChromeOS is on the way.



What you need is

1. Google Chrome 41+. It works on PC,Linux,Mac.
Or Chromebook on Chrome Version 41+.
2. You apk files to run
3. The ARC Welder app

1. To get chrome
https://www.google.com/intl/en/chrome/browser/desktop/index.html

In ubuntu/debian you can install *.deb file by


sudo dpkg -i google*.deb
In fedora/ RedHat Linux 


rpm -ivh google*.rpm
2. To get your apk files
Either use
https://play.google.com/store/apps/details?id=mobi.infolife.appbackup
Or some sites like
http://apps.evozi.com/apk-downloader/

3. Go to The ARC Welder app.And install it from Google Chrome browser.

I used this game (2048) for testing.

http://apps.evozi.com/apk-downloader/?id=com.digiplex.game

This is the result i got.






NB:- There is a limitation. It's is only possible to do one app at time


I tested on Ubuntu 14.04 and Fedora 21.

Reference:-
https://developer.chrome.com/apps/getstarted_arc

AndroVMPlayer : Improved Android Virtual Machine

AnrdoVMPlayer
AndroiVMPlayer is built on on VirtualBox it provides a performance increase to our installed Android (AndroVM's built in Android Virtual Machine, see Official Page )

What you want to do is just install Android as i mentioned in the post (AndroVM).

Just extract the zip file into a place where you like. (Zip 32-bit, Zip 64-bit Download appropriate version for your operating System).

Right click on AndroiVMPlayer.exe , then from the menu, Send To > Desktop (Create Shortcut) .

Now on Desktop there will be a icon







 Running the AndroVMPlayer Now right click on it and Run it as Admin

WhatsApp on PC: Installation

Hi Friends,

This post will show you how to install WhatsApp on PC. And how to import your contacts from phone or other devices, how to add your photos etc willl be on another Post.


It can be divided into two parts.
1.Installation.
2.Configuring.

1.Installation.

In order to install WhatsApp on PC you have to download some files first.

Install virtualbox by following the link.


VirtualBox

Then you have to restart the your computer.

Download the pre-configured Virtual Machine (You may visit AndroVM Page to know more )

AndroVM



After downloading the AndroVM you can double clickon it . androVM_vbox86tp_4.1.1_r6.1-20130222-gapps-houdini-flash.ova
(If your VirtualBox is installed correctly your file should be shown with an orange colored icon).

Now press Import Button

Thus you are done the installation. Now you can press the Start button in the VirtualBox. And see your virtual Android machine.(Or you can import from VirtualBox by File>Import Appliance... Then select the file above.)

Now you should …