Graphic module Tkinter II

8 1 1
                                        

Coordinates in python aren't as easy as it looks = you will need some practice if you want to be able to work with coordinates effectively.

Before we start lets take a look on two more commands:

1. Making text in tkinter

canvas.create_text(100, 150, text = "Hi", font=("Arial", 16))


2. Making a function

Using command def we can make our own function.
Syntax for this command is: 
def Name_of_function():
        
canvas.create_text(x, y,,, font=("Arial", 16))

To call this function we will use this:
Name_of_function()
in case of any confusion look at next screenshot

Combining our previously gained knowledge and tkinter

You will better understand it on example:

You will better understand it on example:

Oops! This image does not follow our content guidelines. To continue publishing, please remove it or upload a different image.

1. In this code right on begnninig I set up root geometry and canvas size - root geometry determines the size of window that will pop up after running the program.
canvas size determines how much of this space created by root geometry can we actually use.
2. I gave random values to variables and made the flag - this whole thing is under function called flag
3. At the end using loop "for" I summoned this flag 9 times 

Coordinates in python aren't as easy as it looks = you will need some practice if you want to be able to work with coordinates effectively.




Try it yourself:

1. create a werewolf, yea for some unknown reasons i've put werewolf into hashtags and i dont want to have trouble with wattpad (legends says they sometimes care about clickbait hashtags)

I gave this great task to Chat gpt as am too lazy to make a werewolf myself anyways here are the results:

I gave this great task to Chat gpt as am too lazy to make a werewolf myself anyways here are the results:

Oops! This image does not follow our content guidelines. To continue publishing, please remove it or upload a different image.

more like weredog

2.  make a cubeman

The biggest square has every side = 100 
middle has every side = 80
smallest one has every side  = 60

The biggest square has every side = 100 middle has every side = 80smallest one has every side  = 60

Oops! This image does not follow our content guidelines. To continue publishing, please remove it or upload a different image.



3.  try to recreate this picture, to make a mouth use dot ( . ), eyes are in reality ovals too

The biggest snowball has diameter = 100
middle has diameter = 80
smallest one has = 60

The biggest snowball has diameter = 100middle has diameter = 80smallest one has = 60

Oops! This image does not follow our content guidelines. To continue publishing, please remove it or upload a different image.


In next chapter/capitole i will post possible solutions.

Daily challange: make a program that will combine graphical module tkinter and loop: "while"

Python for beginnersWhere stories live. Discover now