Interactive plot with Matplotlib in web browser for anyone to run - python

I have made a script in Python to visualize the intersection of a line between two points and 2 circles. The code runs really well but I'd like to also be able to share this with people who don't have to install python or library to run it. Like in a web browser.
I have found a library called mpld3 that could do the job but unfortunately the sliders that I used don't work at all, and they are glitched for some reason. The glitch in question
So I was wondering first if mpld3 was a good solution and if so, how can I solve my problem? I really can't find anything online related to my issue so it's really bothering me. Thanks in advance.

Related

Pyautogui for different resolution

I have done an automation using python by importing pyautogui module (using coordinates). It is working fine. Now, I am running the same code on my Laptop. It is not working as expected due to change in coordinates. I don't want to change the coordinates according to my Laptop resolution. I need to generalize the code. So that it should work in any system. Please help me. Thanks in advance

Matplotlib backend for multiple operating systems?

Okay, so I started a school project where I need to make multiple plots pop up during runtime and each requires an event handler for user input. My main machine is a Mac, and I've got it working without any issue. The problem is that my research lab also has a few linux and windows machines, and I would like to get my program working on them as well. It seems that the underlying culprit is that each operating system uses a different backend for how it plots figures in matplotlib. I'm not a CS student, and thus feel a little unsure how to fix this. Is there a standard backend that windows 10, ubuntu, Mac, etc. that I could hard code into my program to make sure my code runs correctly on all of them?
The main idea of having backends is that you wouldn't need to care about how the plotting is performed and let the backend do everything. That said, you probably wouldn't want to hardcode any specific backend and let matplotlib decide which one to use on each machine.
You also may want to read matplotlib backends - do I care?
There might be some special issues, such that certain things don't work with certain backends, but since there is no information about that given in the question, the general tendency would be not to set any backend at all.

Python Code Completion for C++ Libraries (Using Pycharm, VTK)

I'm trying to get back into coding for some math/physics experimentations and found VTK as a powerful tool using python. So I installed Python(x,y) and Pycharm Community edition. But I cannot get the Code Completion for VTK to work. I know this question has been posted quite a lot of times, but I couldn't find any concrete answer.
Here's what I know so far:
In order for Code Completion to work Pycharm constructs Skeletons. (Basically Python files with empty Classes/Methods that match the C++ API and can then be used like any other Python file for code completion.)
If I locate these files they don't appear to be complete and look something like this:
If this is indeed the skeleton (the file is called vtkRenderingPython.py) then shouldn't there be empty function declarations?
The result is that I get code completion for the classnames, but not the functions. For a library this huge that's rather annoying. Is there an easy way to get this working, or is this just a limitation I have to live with? Is there maybe a way to get complete Skeletons and replace the ones I have here? Am I missing the point entirely?
After another couple of hours I tried my luck with the PyDev extension for Eclipse. I didn't think that would work, but to my surprise it did! No settings necessary, it just worked out of the box.
The only drawback is that inherited methods are not shown in code completion. The base class is shown in the documentation window though so you can get the available functions by creating a temporary object of the base class and scrolling through the code completion there.

How to distribute a python game to OS X users?

I recently finished up a small game I wrote in python, using pygame, at the request of some of my friends. Currently, I have the .pyw game file, and an assets folder containing all files used in the program. I used py2exe to distribute the game, which worked fine, although it still does not seem very user friendly to people downloading the game. One of my friends requested a mac version of it, and although I know about py2app, I am unsure of how to use it, and whether or not it is the best way to package my game.
Basically, I want a single file that I can send to any mac user, so they can easily use the program I have made, while preferably not seeing the source code.
I have googled around for a simple solution, but have not found one. If anyone could give a very simple explanation of how to easily do this, that would be great. Please keep in mind I am fairly new to programming, and may not understand all the programming lingo, so if you could keep it simple, I would appreciate it.
Thanks in advance.
The answer to How can I distribute python programs? suggests Pyinstaller which looks promising, although I have not tried it myself.
See this tutorial by Irwin Kwan to see how Pyinstaller can actually be used with Pygame. He describes a procedure for preparing a Windows executable as well as one for OS X.

Best way to write Python Scripts on a Mac (IDE?) [duplicate]

This question already has an answer here:
What IDE to use for Python? [closed]
(1 answer)
Closed 9 years ago.
I would love to find out what the best way to go about writing Python scripts on a Mac would be. I've gone through two ways (mind you, I'm trying to avoid using vim because I want an IDE rather bland text editor). I went through using PyDev in Eclipse (the more I went through their recommendations and steps, the more of a hassle everything seemed to be.. although I do have everything set up and it can compile.. I want to know if there's a better way. I'm not too fond of Eclipse as is) and I tried to set up Xcode through the following steps: Xcode4 to run Python scripts. The problem with the Xcode version, is I would have to consistently setup the project like this every time. That, and every time I compiled something that needed to create a file it didn't (say using the command conn = sqlite3.connect('list.sqlite3'). Is there a simple way to do this? I've been trying to follow various iOS tutorials that want me to use python scripts (which I'm not familiar with at all) such as raywenderlich.com and Oreilly tutorials. Can anyone provide some guidelines on the best way to go about this?
Personally, I prefer the one that is found on the official Python website, IDLE, which can be downloaded here. It is very easy to deal with, and with the Shell it offers an area to test things out on, it has more than Eclipse can offer- in my opinion. I'm sure that people would feel the complete opposite that I do, but with my experience, IDLE is the way to go.
I think PyDev in Eclipse is pretty good. For scientific programming I wrote the following installation guide:
http://hywelowen.org/installing-python-for-scientific-computing-on-osx/
Spyder appears to be a decent alternative, but I haven't used it myself.

Categories