Sunday, July 31, 2022

Lesson 16

 No real surprises in this lesson; we are learning how to open

a new window from main. Three scenarios are examined: a toplevel

window, on top of the calling window. Here, closing the bottom window

closes the top one as well but not vice versa. One can just close the top one. 

Toplevel() is a built-in feature.



                                                                




The second case is just two independent windows: one can just close the one

or the other.

                                                                           


In the third situation, opening a new window destroys the one already openend thanks to

a destroy() function.

                                                                             


Clean!!

Saturday, July 30, 2022

Lesson 15

 Frames - in tkinter -  are very easy to code but they play an absoluterly

essential role: that of keeping widgets close to each other. 

Consider: had we just disposed our buttons with the pack() function, 

then making the window larger would move the buttons apart, TOP, Bottom...

whatever, like contiments drifting apart on the globe. A frame container makes 

everything move together.


One is then free to place the container where one wants it in the window, here at

(100, 100)




Another festure of the code: the syntax for coding the buttons is simplified:

all on one line, with frame as the 'master' for the widget rather than window.

Friday, July 29, 2022

More Conversions

 I'm on a roll:

                                                   


                                                                                       


                                                                              


Lesson 14

 Back to our tkinter tutorial, seeing how to create a menybar

at the top of the window. It is built-in, and one just adds the cascading 

options we want. this is purely the visual aspect of things. We are

dispensimg with the cut-off (at the top of the cascade) but going for a 

separator, for the save function:


                                                                     


                                                                    


                                                                           


Thursday, July 28, 2022

Working_away

 Working away at producing a little car utility:



                                                                   *     *     *

CONVERSIONS between miles and kilometers:



AR_untangle

 So Amberlynn Reid is facing discouragement, again. She

is just not loosing weight at a calorie limit where she should,

given her size. Let's untangle some of her issues.


-- Calories: a decent calorie count is a necessary but not sufficient condition

for weight loss. If someone is eating to her calorie limit but it is all

chocolate-covered raisins, she will actually store fat because there is an

overabundance of quick sugars at her meals.  Calories only come

into consideration after other parameters of the diet have been established.


-- Healthy vs unhealthy foods: one needs to keep in mind that no food is

an island. It is not just the food itself that needs to be considered, but the context

of other foods that make up the meal. An italian sausage is a nasty thing, as any

nutritionist will tell you. But an Italian sausage in a garden salad, no dressing for

lunch, with a side of water, is do-able in a pinch. I say in a pinch because the sausage is not

doing the job a boiled egg would, but it is something satiating, with fat and protein.


-- Diet pop: take a break fomr the pop. If you must (it is summertime, after all) make

it carbonated water in a glass, at a party. Until further notice, and that's your birthday.

You don't even like it that much, if truth be told. Overweight people are pleasers, who do

things to fit in. and that has to stop. Um!!! pop! is an advertising gimmick, not reality.


-- Never snack. That too is an advertizer's game. Three meals a day, at set times. if

you miss one, that's it. Wait til the next one. Snakcing and catch-up are for growing children, 

of which you are not.


-- Hydration: you are de-hydrated if your urine is a darker yellow; otherwise you are fine.

Re-hydrating should not be done with water because the latter will only make things worse:

it will leech nutriments from your body. You can have a small amount of...wait for it...diet

pop but this works against on-the-scale weight loss.


-- The scale: weight is weight. There are expensive scales which inform one on body 

composition, but these are used by body-building enthusiasts. Not there yet. 


-- Time. There is subjective time, and there is objective time. If you drink a pop from hell, 

there will be a price to pay on the scale, in the near to medium future. If you freak out

that lemon shortbread bites are out of your life forever, that won't change anything

unless you act on it (and throw out those horrors). Maybe two days down the road. Your

body is great: it always gives you lead-time to adapt to changing situations...you cave-dweller.


--The way back: Sometimes, one just needs to give up control. The best back-from-bingeing

regimen I can think of is the so-called 'Military Diet':three days of fun little meals -progressively

loghter- followed by four days of maintenance. One weighs in after the three days for the

rush of the quick loss (water-weight loss; I'll take it!!). One weighs in again after the four

normal days. Free to do it again. I would also suggest keeping busy with non-food thins, and 

perhaps letting a friend help organize the maintenance days. A vacation from one's troubles 

can do a world of good!


Indeed, this is where exercise comes in. It may not help much for weight loss, but it is essential

for mental health!!

Fun Time

 I've been secretly bemoaning my 'all work and no play' status

with these python lessons, so I decided to break out of this mood. 

Downloaded Code Bro's version of the Snake Game, which is a standard

exercise for beginner coders. Ha! the game itself is difficult to play, let alone

code; but I have downloaded the code, and will be making an executable

of it later today. And this code does not use the pygame library, so it is the real

deal, from which I will try to learn.


So what is the Snake game about. The snake is a rectangle on a plain background

that the player moves in the desired direction to 'eat' a colored rectangle. If it succeeds,

the snake's body grows by one as does the score. If it hits any of the sides, it is game over.

That's it. It must eat the food from its head,  the leading rectangle.


Needless to say, the settings are everything. The game speed setting is how long

between updates, so a highr number is a slower game. One can also alter

 the board size and that of the game elements.


It's FUN TIME!


https://youtu.be/bfRwxS5d0SI

Wednesday, July 27, 2022

Lesson 13

 this is a continuation of using the filedialog package, here to

save a file. Tje basic set-up requires us to specify the type of

fi;e we want, and then writing to file. Otherwise, nothing happens...


                                                                       


                                                                         


the second possibility is specifying an initial directory, here that of the project.

Sure enough, tapping save takes us to this directory. And the file gets added

to the project.


                                                                    



f
Finally, if we save a project file first, we can write to it -or alter it - from the

console.
                                                                                



Finally, should we make a mistake and exit our save box without saving, we need

the 'file none' code to avoid unleashing an exception...

                                                        





Tuesday, July 26, 2022

Lesson 12

 Here working with the filedialog library, which is part

of tkinker. I have a folder on th desktop called Test file that contains a

simple message which I have saved .txt. The code allows me

to open it (1) in the usual way, by visually clicking around; (2)

where the Test File folder has been copied to my Pycharm project; (3)

same, only through specifying file type, which may or may not

let my file appear, depending onthe parametrs that are specified.


                                                         


                                                                   





Lorries

 If you have ever wondered how many lorries can get on a ferry,

the Internet has the answer. Ferries leave from Dover and the entrance

to the Eurotunnel is at Folkestone:


https://www.thesun.co.uk/news/13556592/how-many-lorries-ferry-dover/



Monday, July 25, 2022

Installer

 I sneak-peeked ahead on how to create a windows executable once

I have a gui-based python app put together. Udes the Paris-Diderot code

for the pshchedelic Canvas. Pyinstaller does all the lifting, and it works!!

One needs to use 'pip install pyinstaller' first.


                                                  


https://youtu.be/LmhOcdewJU4


                                                             *     *     *

Lesson 11 in the tkinter series is for the text widget, which creates

a text area one can then harvest. Has a few thoughtful features. The font family

and font size go together, and is in pixels. The height of the window is specified in

characters; here, 8 characters high. the settings on the get() ... 1.0, END, starts

at first line, first character.


                                           





Sunday, July 24, 2022

Lesson 10

 A short lesson, here, calling the colorchooser:



                                                                            




Easy, as ever!

                                                              *     *     *

something new to e explored in tkinter would be the ttk libray, which

is a styling library. 

Gives widget a more modern look!


                                                                   


Saturday, July 23, 2022

Lesson 9

 The messagebox widget lends itself to much variation. First, though, I have

given a fixed size to my window by calling geometry(). The latter function is not called

on Tk() - which is itself a method - but on the window or root itself. the practice

of assigning Tk() to the window is what makes the tkinter widgets available!!

Follows examples of the three built-in types: information, warning and error. In the last, 

what started out as an information window became a warning, because I asked for

a change to icon...




                                  

                                                                                                             

                                                                                


                                                                           



*     *     *

There is also a choice of question messageboxes. The code that catches the answer is a boolean. 

Clicking 'yes' makes the assertion TRUE.

                                                                        

                                                                           



                                                                              




                                                                              

Traffic

 As a Canadian, I see it as a plague on both my houses:

people are waiting inordinate amounts of time at the port of Dover to

go on vacatiom and tempers are running short. A quick check with the 

French newspapers informs one that the problem is not lack of staff, but the 

very simple fact that they now have to stamp each and every British passport, 

where they often didn't bother during busy times prior to Brexit. That and 

the small matter of some 3000 transport trucks wanting access to the tunnel as well!!


France is also experiencing internal traffic, as many French people use the 

week-ends of mid-summer to reach the sea-side and other tourist spots.

Friday, July 22, 2022

Lesson 8

 Working with a listbox gadget, in this lesson. Starting from a 5 item

menu, I added one more - the cheesecake - and deleted three: the pizza, pasta and

garlic bread, before submitting my selection. My order is then confirmed at

the terminal window.

                                                             


                                                                               






                                                                             

I already know how to set-up a tkinter window from previous examples. The new

material here is how the listbox is configured and what the functiom code does.


The listbox is one wideg, it is given a frame and a paper-colored background, and an

entrybox is added. listbox.size() - ie height - is reconfigured after every function and is set

to the length of the list. 'getindex()' gives access to the foodlist list items. 'curselection( )' means current 

selection of items. listbox.size() returns the number of lines in the listbox.