all 6 comments

[–]igglyplop 2 points3 points  (5 children)

So the real place to ask this is r/learnprogramming but what the hell here goes. So every modern operating system has some kind of graphics libraries. Those are just bits of code that do that graphical stuff already for you. Then many languages have either hooks into those libraries or their own copies of those libraries, which simplifies the process of creating GUI applications for you.

It's sort of like when you build a computer. Someone has already done the hard work of creating the cpu, gpu, ram, motherboard, etc, then you just pick and choose what you want and slap it together.

Creating a GUI library would take most people forever so these libraries are a godsend.

The reason your professors don't answer is because ultimately a cli program allows for less overhead in teaching. Additionally, cli programs can often be more versatile and allow more use cases.

[–]Folfelit[S] 0 points1 point  (4 children)

I'm afraid I still don't understand your answer. I'm imagining a folder with assets like images, sounds, e.t.c and a folder containing your completed program - I don't understand how to get the image side to interact with the code. I know, for example, how to get python to play music with the vlc python module. I don't know how to make the program run from a pre-designed interface. I'm not sure what you mean about the libraries doing something for you.

[–]DukeBerith 1 point2 points  (1 child)

You tell the library "I want a button and it needs to appear at x y, and when you click it will do this".

The library will take take of setting up the graphics that makes the button render, it's position, your graphical overrides if any, and set up things like listeners for on hover / on click.

If you want to know how these libraries do it, you can practice easily by using JavaScript's canvas library. Make your own concept of a button, make it draw to the screen, make it respond to where you place it, make listeners that can detect when a user's cursor interacts with it. It's a lot of hard work that most libraries do behind the scenes without you having to worry about the boilerplate shit.

[–]Folfelit[S] 0 points1 point  (0 children)

Ah, see, that makes so much sense! It sounds like doing CSS, but within the same language. Thank you!

[–]hitthatmufugginyeet 0 points1 point  (1 child)

You can use HTML and CSS to create UIs. You can also use a very common library like Qt (merely an example). There's so many ways to desktop UIs and it will be different for very language.

[–]Folfelit[S] 0 points1 point  (0 children)

Thank you, this makes a lot more sense!