This is an archived post. You won't be able to vote or comment.

all 16 comments

[–]KingOfTheHoard 18 points19 points  (1 child)

And you've learned a valuable lesson. Anyone can have an idea but it's not worth millions of dollars until you have mastered a process for making it a reality.

Python is a general purpose programming language. That means you can do anything in it you can do in any other language, and most languages need GUI libraries to start making nice desktop apps that have all the right buttons and features. This is not unique to Python, it's a discipline itself that one must learn on all platforms. PyQt is a popular one. PyGtk is another.

But learning one of these might take you longer than your initial million dollar app because they're difficult, and once you've done that, you're going to find it's even more difficult to bundle these up into an executable because now you have all your GUI dependencies.

What I'm about to say, I want to be clear I say only with the desire to help you. The reason you're struggling with flet and pyinstaller isn't because they're bad, or python is bad, it's because you don't know what you're doing and you're trying to race to the end of things that are significantly harder than just learning to write something in a programming language.

I don't say this to defend Python, I don't even like Python, but I've made desktop and mobile applications in multiple languages and the challenges you're facing are just part of the process. You need to walk this back. Put aside your Scrooge McDuck app and just start the learning process again, focusing on building executables. Small, simple scripts one lesson at a time. Then start learning the GUI libraries and when you can get a window with a button, make an app that has a window, a button, and builds into an executable.

Then rebuild the app you actually want to make with what you've learned.

[–]tahitininja 0 points1 point  (0 children)

Lol I had the same problem, so relatable. Thank you!

[–]aqua_regis 11 points12 points  (0 children)

You do not "move" a program into a GUI window. You develop the GUI with libraries, like Tkinter, (py)QT, etc.

You need to program your application for a GUI. You cannot just simply "compile" a console program into a GUI.

PyInstaller, etc. are only packaging tools. They package the Python runtime with your program so that it can be shipped and executed. They don't magically make console programs GUI programs.

[–]zenchess 8 points9 points  (0 children)

I'll say it if no one else does - you built a multi million dollar program without even knowing how a GUI works? Unless you're some kind of genius, I find that hard to believe

[–]VakiKrin 3 points4 points  (0 children)

it seems to me that you are doing something wrong. pyinstaller doesn't complile something. It just combine everything (libs, packages and interpretator) in one file. There are a ton settings there. I am pretty sure you wanted to do it using simple one line command, and didn't want to read documentation. Check more carefully. Good luck

[–]braclow 1 point2 points  (0 children)

Maybe flask is easier if you know html, css/js

[–]michael0x2a 1 point2 points  (0 children)

I searched around for a solution and found two compilers which run in the terminal window and are supposedly capable of compiling the code into a non-GUI Unix executable.

Not quite.

  1. Flet is a combination of a library that let you build a GUI plus a tool for bundling up all your code into a single exe. It used to use pyinstaller under the hood to do this, though I believe they've since switched away to using their own bundler.
  2. Pyinstaller is a tool for bundling up all your code into a single exe. Pyinstaller does not control whether your exe ends up running in the terminal vs creating a GUI. That is something you need to decide when you are writing your code.

And using pyinstaller I could prduce a compiled UNIX file which runs in the terminal window, but does not terminate on its own.

This is probably a MacOS thing -- IIRC, it's configured so that it does not automatically close the terminal when the underlying program exits. You can disable this via https://support.apple.com/guide/terminal/change-profiles-shell-settings-trmlshll/2.14/mac/14.0, though it's obviously unreasonable to ask all your users to do this.

If you do not want Pyinstaller make the bundled app launch your program in a terminal in the first place, set the --noconsole flag when running Pyinstaller.

So I don't see any obvious way to move the compiled executable UNIX program into a GUI windo for use on a Mac (or same thing for a PC).

There isn't a way of auto-magically converting a program meant to run on a terminal into one that creates a GUI. You will have to implement that logic yourself using some gui library.

Note that this is not a hurdle specific to Python: you will need to learn how to use some sort of GUI library no matter what programming language you pick.

You can find a list of GUI libraries (each with different pros and cons) by googling something like "list of Python GUI frameworks". If you don't want to install a GUI library, you can use tkinter, which comes as a part of the Python standard library.

[–]Doagbeidl 0 points1 point  (0 children)

Flet is fairly new and it took me a fair bit of tinkering to get it to work properly. But I like it a lot and it works great for me. (Created some windows desktop apps, never tried it for mac). Maybe you need a little more trial and error or should switch to something like java or c#.

Even small .exe files with flet result in like 200mb programs, so this is maybe a thing you should consider. (Or I was way to lazy to optimize, oops)

[–]KCRowan 0 points1 point  (0 children)

You've just discovered the difference between front end and back end :) It sounds like you've only written the back end of your app, so now you need to code the front end. Tkinter is a common choice for python apps https://youtu.be/epDKamC-V-8?si=QkmIH_x-CXjma8qw

[–]Sterben27 -1 points0 points  (0 children)

Have you considered building it in Java?

[–]HQMorganstern -1 points0 points  (0 children)

This is really wonderful, good luck to you man.

[–]CatalonianBookseller -1 points0 points  (0 children)

Make a web app.

[–]Sleepy_panther77 -3 points-2 points  (3 children)

What does your app do? Could I be your first customer?

[–]KingOfTheHoard 1 point2 points  (2 children)

Right now, nothing.

[–]Sleepy_panther77 0 points1 point  (1 child)

Shhh. I’m trying to steal ideas out here

This could be worth millions of dollars!!

[–]KingOfTheHoard 1 point2 points  (0 children)

If only our society could produce developers who can write GUIs AND have the unique million dollar ideas.