Raspberry Pi Python application!?


Im not really sure how to go about explaining what I really want to do. Hopefully this isn’t too complicated to do. But basically, I would like to build a desktop application with python. I would like to turn my Javascript project here into a full screen, desktop application that boots up when I turn on my raspberry pi.

Now, what I really would like to know is, when it comes to designing the visual elements (the HTML and CSS), is there a way to make it so that the html and css DONT need to connect to the internet to run? Because I want to run this with python and not JavaScript (I will be converting the code), I don’t have a need for it to be a website or web based.

How would I go about making this project run offline once I convert the javascript to python? Is this even possible? I am completely new to this and completely in the dark as far as an understanding goes.

This sounds fun and I would really love to get it up and running. Any help will be greatly appreciated.

Thank you.

Hello there,

It is completely possible to build desktop applications with Python (think tkinter).

It is also completely possible to build desktop applications with JavaScript (using wrappers like Electron.js - what VSCode is made with).

HTML and CSS do not need the internet to run - at all…ever. However, they do need something to interpret them like what comes built in with browsers (V8 Engine, Spider, etc…). Also, JavaScript does not need the internet to run, just something to read it - Node.js

If this is definitely what you want, then you will be starting from scratch, anyway. Just use the correct Python libraries, and you can make a desktop application. There might be a Python library out there that also works with HTML/CSS files, but that sounds messy. If you want Python, I recommend starting with Tkinter.

Refer to above - Python/JS/HTML/CSS do not need the internet.

Practically, there are many YouTube tutorials showing you how to make desktop applications with Python. Perhaps start there so you can familiarise yourself with the common libraries used for this.

Some key things to keep in mind:

  • Python requires the Python interpreter to run. So, it must be compiled into a binary, in order to be a stand-alone application.
  • JavaScript requires an interpreter to run. So, it must be compiled into a binary, in order to be a stand-alone application. The de facto is Node.js as interpreter, and Electron.js uses Node.js, as well as Electron Builder to compile your application.
  • You need to keep in mind the architecture of the system your app will be running on.
    • You cannot run x86=built applications on arm systems, and vice-a-versa.
    • You cannot run 64-bit applications on 32-bit systems.
    • I have limited knowledge on this, but, as far as I am aware, you can build a 32-bit application on a 64-bit system, but you cannot build a 64-bit application on a 32-bit machine. That is, you should be able to bundle your app for a 32-bit Raspberry Pi, with your 64-bit PC, but you will have to tell the tools (compiler) to do this.

I hope this helps, and take what I have mentioned with a grain of salt, because there is a good chance I have misused terms.

Happy coding :slightly_smiling_face:


Hey thanks so much for your reply!

This is great news! I really wasn’t sure as I’ve been mostly programing logic for front end websites using vanilla JavaScript.

Not sure what this is yet but I will look more into it :sweat_smile:… Is it like an IDE? Ive been noodling around with Thonny Python so that’s all I know as of right now :thinking:

Soo the main reason I choose to attempt this idea in python is because I thought that it may be easier to get running; seeing as how python has a ‘run’ button and the raspberry pi seems to work so well with python… Does that make sense?

I don’t know, im kind of confused. :thinking: Wouldn’t python be easier when wanting to boot files automatically, say verses a node.js type of file situation? I have no idea which is why I ask.

oh man, I have no idea what this means :sweat_smile: I was thinking that I could just run the python script via the Thonny IDE. Is that what you mean by an interpreter?

I know I have a lot of questions, and I will definitely try and find some YouTube videos on the subject. Ive never done anything like this before.

This shouldn’t be too difficult because I already have the program working for web right??? (not that im afraid of difficult, ijs) :face_with_monocle:


What are your thoughts on Thonny as a tool for python? :face_with_monocle:

Ah I see what Tkinter is now :sweat_smile: Creating Desktop Apps With Python and TKinter - #25 - YouTube this is fascinating.

Im still really confused about how I would go about using my already existing HTML and CSS files for something like this though :face_with_monocle:

Ahhhh I see! THIS is probably what I should be using. Upon researching the many things you’ve mentioned, I see that this one is probably the better option to go with. (I get why you mentioned it first now :thinking:)

Do you know if there is a way to have the application fill the entire screen in a way that shows no borders or menus or those pesky buttons to minimize or enlarge or exit out of the window? Basically true full screen like when using a gaming application or when watching a full screen video?

Is it possible to do this type of design choice with electron?

(sorry for all of the questions Im just working on gaining an understanding of this concept. :sweat_smile:)

Yes, this makes sense. If I were to write a small application for Raspberry Pi on the Raspbian software, I would use the built-in Python stuff. From what I am aware, most Raspberry-aimed OSes do not come with Node.js. So, yes.

I have never heard of Thonny. So, I cannot say. I have made automated scripts using both Python and Node.js. All you do is create a bash file (on Windows - I assume this works for Linux-based OSes as well), and write something like start C:/path/to/Node/or/Python/executable C:/path/to/file/you/want/to/run (there is a bit more than that, but then you just set a task using the built-in software (Ubuntu has it) to start the bash script on start.

Frameless Window | Electron - has all the information on both starting window size, and the frameless window.

The questions are good. This stuff is difficult to navigate. Especially, if you do not know the jargon/keywords to search.

1 Like

Thats great! Im going to look into this. Ive seen tutorials using the bash file but I didn’t quite understand what it was and Ive never used it myself. But I see that this is basically the file that is used to automate the load. Im googling it now :+1:

Will a bash file work with all types of scripts? Like scripts made in Electron JS for example? :thinking:

nice :sunglasses:

Thank you so much for your knowledge :pray:

Do you have any tips or advise on learning the command line?

Code is just text.
In order to run a program, some other program has to “read” the text and actually interprete it’s meaning to execute the commands.

Obviously this cannot go on forevery. Every computer has a fundamental code-base, which is within it’s hardware (like the CPU) and every command to be executed has to be translated to the CPU-language. As computers work with binary code, calling something the computer can execute is a binary-file. You might know them as files ending with .exe → for “executeable”.

Ofcourse writing binary code is horrible. So is the next best thing (machine code, then assembler). Because computer work binary but we speak a complex language, it’s nice to have programming-languages so we can write human understandable code and have programs inbetween turning it into computer-language.
Now there are two ways of doing this: One is creating .exe (or similar) files. This is called “compiling” (with a compiler) and it means the written code is turned into a file the computer can understand → then you execute the file.

The other way is “interpreting” (with an interpreter) meaning the code is read line by line and translated into the computer-language on the spot.

The first way creates a file which is independent from your coding-program because it’s already translated.
The second is faster to execute on the fly (because it doesn’t need to translate everything before execution), but it only translates the commands for execution and then saves the calculated results in memory NOT the translation itself. Hence it doesn’t provide a computer-readable file and must always use the interpreter to execute code. Making interpreter-languages slower in their execution of commands as they need to be translated every time.

An IDE is a “integrated developement environment”. They contain various features like code-highlighting, help to find errors and whatnot.
As I said, “code” is just text. And IDE contains the interpreter/compiler of their supported languages - but you don’t need any specific IDE. Compiled need a compatible operation system / base. Interpreters just need any environment with their appropriate interpreter. So a website with an integrated Python-Interpreter can run Python code. Most internet browsers come with a Javascript interpreter and can run it from the get-go.

1 Like

Ok great! Thanks for clearing that up! You did a fantastic job of explaining all of this.

So just a step further, Javascript does not require a compiler because it is interpreted via the IDE and the browser, where as if you want to run a python script, it can be interpreted via an IDE or compiled into an exe file for the computer to run outside of the IDE?

And moreover, if javascript IS running outside of a browser say via Electron js, it can be compiled to run as an exe script? :face_with_monocle:

Is this a correct understanding?

Not exactly ^^° The two methods are usually exclusive. You have EITHER a compiler-language (like C++) OR an interpreter-language also known as script-language (Python, JavaScript).
I’ve heard there are Python libraries which actually allow to compile code into executables, but I haven’t looked into it.

Usually you want compilers if you are looking for optimized and efficient code. Hence those are low-level languages where you have to write a lot more to make it work - but at the same time save a lot of computational power because it’s just optimized for the problem. Those are used for games and engines, where a lot of data has to be calculated fast, so players can enjoy the games without lag and such.

Interpreter languages are used for things where you can accept some level of delay. They take more computational-power and -time, but are easier to write and maintain. If a website takes two seconds longer to load, that’s ok. If a machine-learning algorithm takes 10 hours instead of 9 for training, nobody cares → because you save weeks of writing the code and worst case, it’s easier and cheaper to just upgrade the machine, than to find and pay additional programmers.

Data-types are one key difference. C++ has strict typing: meaning if you make an integer variable, it will have a fixed size in memory ( like one Byte ), a max and min value and if you go beyond those or try to write anything but an integer number on that variable, the program will produce garbage.
Python doesn’t give a damn. If you create an integer variable there, it will be like 20 Bytes because it comes pre-made with all kinds of additional functionality. And if you combine it with a float and/or a string, Python will try to produce something reasonable - meaning a lot of stuff happening in the background.

That’s why compiling it is pretty hard. Because there is so much background functionality within script-languages, turning them into an executable would need the inclusion of all the background stuff. And if you’d need to put the entire interpreter into the .exe, you could just install the interpreter directly and not bother, instead of having it added into every single executable file.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.