Hello World!



When you shall programme, one do need a bit more than just «print('Hello World!)» even if entering that in the editor and pressing «Run» would make a programme that could run on the command line. That is not my goal. I want to make desktop applications that run as a true .exe -file. And to do that, you need more. I happen to know that starting programming most of the courses do not add enough complexity to the examples for the pupil to feel enough progress.

Using that method, I will give far more information in every «class» so you might have to use some time figuring out what all the elements and routines really mean, and how you can use them in your programming.


The «Hello World!» app

Now let's have a look on the example on the top of this page.

On the first line, there is a comment. Comments start with a #. They might start in the middle of the line, but it makes the rest of the line a comment.

The second line includes the plugin we need to draw the window(s).

The next line defines the theme of the window. The picture is clickable, so it can be seen bigger and then will be readable.

The «layout» comes next. It is here (at least for now) we'll put all the stuff that's going in our window. This part might be a bit confusing. but I'll try and make sense of it as we go along.

Now that the layout is well and done, it's time to create a window. We use «sg» (now short for PySimpleGUI) to do that. sg.window takes two arguments, title that goes in the upper most line of the application and the layout.

I want it to react to the «X» in the top right corner. As this is a very simple programme, th «OK»-button will just make the programme exit normally, but I still must define just that. for now we do not investigate the event loop.
I will go much into that later. The comment at the same line as the defining the OK-button says «Cancel», but that's just me forgetting to change the comment, when I decided to use an «OK»-button in stead of a «Cancel»-button.

You can download the example here.

Have a day better than most!

« First -- Previous -- Next -- Last »