Is there a way to use Pyhton in websites? - python

I need to make a very specific program to calculate text RPG results based on user inputs, currently Im making it in Python because thats what I know to use, but we play in a website and most players dont have any program to use Python and some even play on their phones, is there any way to play it on a website?
I've looked for ways and most sources said I need to convert it to HTML or another language like C or C++, but I dont even know how to do this and the auto-converters I've tried didnt worked. Jupyter Notebook also wouldnt work because some of the players doesnt know how to use it and it would be too hard to teach them all.
Is there ANY way to keep it in Python and use it on a website?

You can use any python web framework and host it.
If you are a beginner, I recommend you to use Flask framework and try hosting it in https://www.pythonanywhere.com/

Related

Python and Bridge for JS

Im starting a new project for personal porpuse!
Im working personally in finance, I decided to create personal chart viewing software to suit my needs. I thought I'd create a good part of the backend in Python as it is a language I know quite well. Use Javascript for the graphic side, and use a webview in a windows form to make everything available as if it were software.
As for the graphics I thought of using: Lightweight Library for JS, I find that today it is the most avant-garde library compared to the classic plotly, matplotlib.
Use pywebview as a bridge between Python and JS and to redirect everything in a windows form.
However I find it a bit difficult to use this library (pywebview), there is a poor documentation around and not very clear to me (my level of JS is really basic). However, I believe it is one of the most convenient solutions.
I would have thought of using pyscript, but it still seems early to use this library in production.
Questions:
Do you think such a job is feasible?
Do you know other libraries/better solutions to do such jobs?
What kind of approach would you use if you were to do such work?
What I am trying to achieve is to write most of the functions in python and use only JS to make calls through buttons or to get data from various inputs.
Wandering around the web I found a work already partially created by this guy (if you are reading, Thanks Filipe you have been very helpful! here you can see his project hosted on Github) but unfortunately it is difficult for me to get my hands on a code not produced by me.

Python Reading Specific Parts of the screen and Taking actions Based on them

i am kind of new to Python and trying to learn the language the best i can. Right now i am having a problem of trying to automate something. I dont know how i should
What i am trying to automate I was trying to make the Programm being able to Read the value of how much Food, Wood etc is in the Storage right now(maybe also know if the storage is full or not) If it is full, or has reached the value needed to upgrade the storage for Food for ecaple, then it should do so.
I was thinking at first of how it should know that the storage is full, should be done by using pyautogui using but i am unsure...i am sorry that this is such a long massage and i dont know if you guys understand what i am trying to explain,...if not so, just ask
Python does not recognize (nor know) the value of the characters for this type of automation it is recommended to use an image recognition library. (I Recommend Opencv) and for clicking on the screen you can use pyput.
Opencv Link: https://pypi.org/project/opencv-python/
Pyput Link: https://pypi.org/project/pynput/
and you can also watch the following project since it can help you get started.
https://www.youtube.com/watch?v=vXqKniVe6P8

Is there a way to make a display window in python?

I’m just starting to learn python and we have to do a coding assigment in school. There a few examples of problems you can do , or you can create your own, but i want use one of the examples. i want to know if theres a way to create a seperate display window in python to display images for a game. Ive seen tutorials using “pygame” but we’re not allowed to download anything onto the school computers so i cant use any add-ons. Ive only been learning very basic stuff thats entirely text based.
You could use Tkinter. It comes with Python so you should not need to download anything.
https://www.geeksforgeeks.org/python-gui-tkinter/
I've had a pretty good experience using Kivy. It's easier to learn than Tkinter, in my opinion, though it's possibly less flexible.

Best way to make a multiplayer turn-by-turn online game with python back end

As a project for a friend's birthday I am trying to create an online multiplayer game which is based on this derivative of poker we play. I only really know how to code python so started with that and have managed to create the game basics and I guess it could be a good back end for the game but don't know how to get it online or as an app so my friend could actually play it with me.
Is there a way to use python code as a back end for an online game? I've read about Django and other frameworks but can't seem to get my head around how that would actually work.
The UI for the game really doesn't matter too much as long as theres some way to take multiple user inputs.
Appreciate any help and apologies if I use any wrong terminology Im self taught for the most part
You can use Django to make your game a web app and play it with you friend. There are many tutorials online to do this;
I suggest this one, it uses django and reactJS.
However, if his birthday is soon and you're in hurry, I don't recommend learning reactJS now (in case you're not already familiar with it). You can use simple django templates with html, css and javascript, wont take that much time. You can refer to Django official documentation to learn the basics of Django and then pull it off yourself.
Good luck.

Pamie and python-win32 question pamie3 not working

currently im making some web scraping script.
and i was choice PAMIE to use my script.
actually im new to python and programming.
so i have no idea ,if i use PAMIE,it really helpful to make script to relate with win32-python.
ok my problem is ,
while im making script,i was encounter two probelm.
first , i want to let work my script work together Beautifulsoup and PAMIE.
or it also ok..if can work native internet explorer interface together.
but it not work for me.
im using PAMIE3 version.even if i changed to pamie 2b version ,i couldn't make it working.
my second problem is,while im making script,i think sometime i need normal IE interface.
is it possible to change PAMIE's IE interface to just normal IE interface(InternetExplorer.Application)?
i don't want to open new IE window to work with normal IE interface,want to continue work with current PAMIE's IE windows.
sorry for my bad english
Paul
PAMIE might be getting a bit dated. You could take a look at Selenium which will also automate a web browser, but is more current.
http://jimmyg.org/blog/2009/getting-started-with-selenium-and-python.html

Categories