top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Creating an interactive graphical project in the browser using python?

+1 vote
533 views

I'm trying to work through Skienna's algorithms handbook, and note that the author often uses graphical representations of the diagrams to help understand (and even debug) the algorithms. I'd like to reproduce this in python.

How would you go about this? pyQt, pygame and pyglet immediately come to mind, but if I go that route the number of people that I can share my work with becomes quite limited, as compared to the portability of javascript projects.

I guess my question really is: has anyone had success creating an interactive graphical project in the browser using python?

posted Jan 19, 2014 by Sumit Pokharna

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button
Something like this help http://ipython.org/notebook.html ?

1 Answer

+1 vote

You should be able to do something without much fuss using HTML 5 and either Pyjamas (which compiles Python code to Javascript) or Brython (a more or less complete implementation of Python within Javascript).
For example, see the clock demo on the Brython web page.

Pyjamas is the more established and probably more stable of the two projects, but you should be aware that there are currently two active forks of Pyjamas and some controversy surrounding the project leadership.

answer Jan 19, 2014 by Bob Wise
Similar Questions
–1 vote

R has the function edit() which allows the editing of the definition of a function. Does python have something similar so that users can edit python functions on the fly?

Ref:
https://www.rdocumentation.org/packages/utils/versions/3.4.3/topics/edit

0 votes

The sys module defines two hooks that are used in the interactive interpreter:

  • sys.displayhook(value) gets called with the result of evaluating the line when you press ENTER;

  • sys.excepthook(type, value, traceback) gets called with the details of the exception when your line raises an exception.

Is there a way to hook into the interactive interpreter *before* it is evaluated? That is, if I type "len([])" at the prompt and hit ENTER, I want a hook that runs before len([]) is evaluated to 0, so that I get the string "len([])".

0 votes

I'm trying to come up with more project ideas for intermediate learners, somewhat along the lines of
http://bit.ly/intermediate-python-projects .

So here's a question for people who remember coming up from beginner: as you moved from exercises like those in Learn Python the Hard Way, up to your own self-guided work on small projects, what project were you working on that made you feel independent and skilled? What program first felt like your own work rather than an exercise the teacher had assigned?

I don't want anything too large, but big enough that there's room for design, and multiple approaches, etc.

+1 vote

What is the best way to distribute a private, pure python, Python 3 project that needs several modules (some available on pypi but some private and used by several separate projects) in order to run?

I'd like to include everything that my project needs to run in a single package. The best way to do this seems to be to be to create symlinks to the source code of the "3rd party" modules I need and create a setup.py file that includes them in its "packages" list. Is this what other people do?

But even more ideally, I'd like to package my script and its dependencies in a single zip file that can be executed by python directly. I see several declarations that this is possible online, but I can't find a simple recipe for converting a script and its dependencies into this kind of distribution. Could someone give me a
pointer to a description of "the right way to do it".

I'm making life harder for myself by using python 3 (PyInstaller still only supports Python 2) and by the fact that I can't release some of the necessary code publicly.

+2 votes

I want to take the file, "desktop/test.txt" and write it to "desktop/newfolder/test.txt". I tried the below script, and it gave me: "IOError: [Errno 2] No such file or directory: 'desktop/%s.txt'". Any suggestions would be great.

def firstdev(file):
 in_file = open("desktop/%s.txt") % file
 indata = in_file.read()
 out_file = open("desktop/newfolder/%s.txt", 'w') % file
 out_file.write(indata)
 out_file.close()
 in_file.close()

firstdev("test")
...