background top icon
background center wave icon
background filled rhombus icon
background two lines icon
background stroke rhombus icon

Download "Оконное приложение на Python c Tkinter | #1"

input logo icon
Video tags
|

Video tags

видеоурок
Десктоп приложения
приложения
оконное приложение
tkinter
график
график функции
Python (Programming Language)
gui
десктопные приложения
высокоуровневые языки
python
применение python
python tkinter
программа на python
библиотека tkinter
приложение на python
уроки tkinter
уроки python
создание программы на python
python программа с интерфейсом
создание приложения на python
python gui приложение
python gui
python gui tkinter
Subtitles
|

Subtitles

subtitles menu arrow
  • ruRussian
Download
00:00:01
Hello everyone, and this is the it hobes project with you, and in
00:00:04
this video I’ll tell you how to use
00:00:06
standard Python 3 tools, namely
00:00:08
using the library for developing the
00:00:10
tkinter graphical interface,
00:00:12
create icon applications, build
00:00:13
graphs of functions in them, for example,
00:00:16
let’s look at the construction of a graph of the
00:00:17
sine function in detail, but not only the software
00:00:19
part But also a little theory To
00:00:21
understand the logic of the
00:00:22
program, of course, there are a number of
00:00:25
libraries that solve the problem more
00:00:26
efficiently and much simpler, but it is
00:00:29
equally important for us to understand How to create and
00:00:30
work with a graphical interface in
00:00:32
Python Well, let's get started
00:00:35
as D we will use py
00:00:37
Community Edition free liquidation
00:00:39
from
00:00:40
jetbrains let's launch dde and create a
00:00:49
project, give it the name
00:00:54
lineart, press the Create button,
00:01:03
then with the right key in the project tree,
00:01:06
create a Python
00:01:07
file called
00:01:13
Main
00:01:15
ok, and now we're ready to write code, let's
00:01:18
create a simple window application
00:01:20
using the integrated
00:01:22
tkinter library. To do this, we need to
00:01:24
import The module ITSELF
00:01:28
From tein
00:01:31
import and
00:01:33
asterisk the following command will
00:01:35
create the root window of the
00:01:43
program and finally To display the
00:01:46
main window you need to call the
00:01:48
Main loop method, be sure to use the last line of
00:01:56
code to run the resulting Code and
00:01:59
make sure it is
00:02:03
correct As you can see, Three lines of
00:02:06
code are enough to create a horse application
00:02:08
which So far, nothing doesn’t do it But
00:02:10
the main thing is already
00:02:12
working Now let’s set the title and
00:02:14
set the size of the window (
00:02:30
brackets) and
00:02:32
now
00:02:34
write the name of our program in quotes
00:02:37
Let’s say it will be plotting a
00:02:39
function y as a function of
00:02:53
x Next let’s set its
00:02:57
size to Root
00:03:06
Geometry
00:03:08
120 by
00:03:15
620 Let’s launch
00:03:18
the application and As
00:03:20
you can see, the size of the window has changed on
00:03:23
the corresponding one the name has also changed,
00:03:27
looking ahead, I want to say why the
00:03:31
window size is not equal to 000. Our
00:03:33
juice is made for ease of construction
00:03:35
so that there are indent boundaries of 10
00:03:37
pixels on each side, then the
00:03:39
coordinate grid in the window will be exactly
00:03:41
1 in 600 under the coordinate grid
00:03:45
Of course that coordinate grid of our
00:03:50
chart for drawing graphic
00:03:52
primitives. And in our case, the grid lines
00:03:54
need to call a module object
00:03:56
called canvas can or allows you
00:04:00
to place other objects on itself such as
00:04:02
image primitives, buttons, text
00:04:05
fields, etc. Let’s create our object
00:04:09
you you
00:04:15
you and in parentheses we’ll give it parameters the
00:04:18
first parameter will be
00:04:22
Root then the
00:04:30
20th is
00:04:33
equal to
00:04:36
620 and
00:04:50
BG actually these four parameters
00:04:52
indicate the following the first indicates the
00:04:54
parent window the second the third is the
00:04:56
width and height of the canvas and the last is the
00:04:58
background color
00:05:01
to display our canvas object
00:05:03
we need to apply the method to it let's
00:05:12
see what we have we
00:05:15
got it, as you can see, the background color has changed
00:05:18
and the size of the canvas is now equal to
00:05:19
the size of the parent
00:05:22
window. The next step is to build a
00:05:25
coordinate grid of the graph, but before that
00:05:27
we should talk about the markings or the
00:05:31
origin of the object is in the
00:05:34
upper left corner in the figure, what you
00:05:36
see on the screen shows the coordinates of the
00:05:38
points first the number is the value in X,
00:05:41
respectively, the second value in and both of
00:05:43
these values ​​give us an understanding of where in
00:05:45
space the beginning of the object is located on the
00:05:47
canvas; the coordinate grid consists of
00:05:49
intersecting perpendicular
00:05:51
horizontal and vertical lines; what
00:05:58
lines we need will vary depending on the size of the window,
00:06:01
that is, the number of vertical lines
00:06:03
equal to the width of the object can divided by the
00:06:05
distance between the lines, take this
00:06:07
distance equal to 50 pixels,
00:06:09
respectively 1020 / 50 = 24 About round,
00:06:13
this value is
00:06:14
21, let's calculate the number of horizontal
00:06:17
grid lines, dividing the
00:06:19
height by the distance between the lines,
00:06:22
we get the number 20 12.4, again rounded
00:06:25
to 13 So we will get a grid of 21 by 13 50
00:06:30
pixels, now let's start writing
00:06:32
the code. Draw the grid lines vertically.
00:06:35
To do this, we need to create a loop with the
00:06:36
number of iterations equal to
00:06:45
21 or Y in
00:06:54
Range in the body of the loop, create a variable K
00:06:59
which will be equal to the product of the
00:07:01
distance between the lines and the
00:07:02
loop counter or 50 Smart on
00:07:07
Y, now you need to call the Create
00:07:19
L method, give it the following
00:07:27
parameters 10 n,
00:07:30
next parameter
00:07:32
610, next 10 +
00:07:37
K and 10, set
00:07:44
wids equal to one ifl the
00:08:03
first pair of numbers or the first pair of
00:08:06
parameters specifies the coordinates of the beginning of the
00:08:09
line itself, and the second pair is the end of this
00:08:12
line and the first In the second pair,
00:08:15
we add a variable to the X value so that
00:08:17
each subsequent line is drawn at a
00:08:18
distance of 50 pixels from the previous one. The
00:08:22
parameter sets the thickness of the line and its color
00:08:29
so that they understand which line is being built,
00:08:31
or rather which cycle is responsible for constructing
00:08:33
which
00:08:37
line of the grid line
00:08:45
vertically. We will write similar code for
00:08:48
horizontal lines. grid only
00:08:50
the number of iterations of the loop will be equal to 13
00:08:52
and the variable K will be added to the
00:08:54
value of the coordinate along the river, we will
00:09:08
immediately write a
00:09:12
comment on the horizontal grid line
00:09:19
now we will implement the
00:09:26
loop itself Range
00:09:34
K =
00:09:37
50 multiplied by
00:09:41
X Well, now let’s call the same Create
00:09:52
line method and give it the following parameters
00:10:06
How you remember the first pair of numbers
00:10:09
is responsible for
00:10:11
the beginning, for the origin of the coordinates for constructing the
00:10:14
line, and the second pair for the end of
00:10:17
the coordinates for constructing this
00:10:23
line, we will set the
00:10:25
wids parameter to one and F, that is,
00:10:31
we will set the color of our line the same as in
00:10:43
the previous one, we will run our
00:10:49
code. As you can see, we have a pretty
00:10:53
nice grid, we will implement it now the
00:10:56
coordinate axes are the same as before Using the
00:10:58
Create line method we will
00:11:14
also immediately write
00:11:23
a comment on the
00:11:26
X and
00:11:34
Y coordinate line, call the
00:11:39
can Create line method and set the following
00:11:44
parameters
00:12:00
W will still be equal to
00:12:06
one, the
00:12:10
parameter will be responsible for
00:12:13
drawing an arrow at the end of the line
00:12:17
and will take the
00:12:24
First color of the line let's make it white
00:12:42
in this case, we had the Y axis and
00:12:44
now draw the
00:12:57
X axis, it will divide our
00:13:01
coordinate Svetka in half.
00:13:32
Let's also add a comment so that
00:13:34
you understand where to build which axis,
00:13:41
this will be our
00:13:45
Y axis, this will be our
00:13:55
X axis. Well, Let's see what we
00:13:58
got,
00:14:02
we got the coordinate axes and the coordinate
00:14:04
grid, thereby approaching the main
00:14:06
functionality of our program, namely
00:14:08
the construction of a
00:14:11
sine graph, for this we must implement
00:14:13
the formula that is now on
00:14:17
the screen where A is the amplitude of the graph
00:14:21
Omega cyclic
00:14:23
frequency A is the initial oscillation phase, in
00:14:27
more detail, the meaning of the definition of
00:14:29
this formula can be found on Wikipedia,
00:14:30
the link is in the
00:14:33
description Well, let's
00:14:37
initialize another one that will
00:14:39
respond to the next shift of the graph
00:14:41
along the
00:14:53
Y axis, so
00:15:05
I have already selected the W value of these variables.
00:15:09
In principle, after playing with them,
00:15:11
you
00:15:12
can set it yourself parameters What do you
00:15:15
want
00:15:17
to get, but let’s start with
00:15:25
this and now set the graph offset
00:15:28
to be
00:15:31
equal to 310 Let’s immediately write
00:15:35
a comment on all this To understand
00:15:38
what is
00:15:42
responsible for in this case, it will be the
00:15:44
cyclic
00:15:56
frequency, this is our graph offset along
00:16:10
X, this will be our amplitude
00:16:19
and shift of the graph along the river
00:16:29
Oh what is
00:16:38
it now we need to
00:16:41
initialize the list in which
00:16:43
our function value
00:16:52
x XY will be stored yes what is it
00:16:59
we will write a loop in which the
00:17:00
value of our
00:17:09
function will be calculated we will count 1,000
00:17:16
points now we need to import the module M to work with
00:17:20
mathematical expressions
00:17:21
we import
00:17:24
accordingly at the beginning of the
00:17:34
iporma so the module we
00:17:44
imported coordinates along the Y axis and
00:17:47
will change According to the
00:17:50
sine function Y
00:17:55
=
00:17:57
sine in brackets
00:17:59
X multiplied by our W or
00:18:06
Omega itself in brackets we will
00:18:11
do this part of
00:18:14
the formula, add the calculated value of the
00:18:16
X coordinate to the list using the method
00:18:19
append
00:18:38
in parentheses we will add phi the initial
00:18:41
phase of the oscillations. Or in other words,
00:18:45
shift the graph along the X axis, add the
00:18:48
calculated value of the Y coordinate to the list
00:19:01
plus
00:19:05
ours in
00:19:07
brackets, multiply the y value by the amplitude
00:19:10
According to the form and also add
00:19:12
D to shift the graph along the
00:19:16
Y axis and finally call the L method and display
00:19:20
Our sine graph in the window
00:19:31
equals
00:19:33
you Create
00:19:38
line indicate our list with our
00:19:42
values ​​and set the color of the line Let
00:19:45
it be
00:19:50
blue o
00:19:59
Well, let's Now try to run it and
00:20:00
see what we
00:20:02
got So somewhere we got an error
00:20:16
Yeah, let's look at line
00:20:21
34 but we need to get out of the
00:20:25
loop like this Well,
00:20:30
as you can see, we succeeded. I
00:20:33
recommend that you play with these
00:20:34
variables, familiarize yourself with
00:20:36
harmonic oscillations on Wikipedia,
00:20:38
the link will be in the description and ask
00:20:40
questions, I hope it was
00:20:42
clear to you. Well, in the next video we will
00:20:44
upgrade our project add a lot of
00:20:46
interesting features so subscribe
00:20:48
to the channel and like
00:20:50
See you soon

Description:

Первое видео по созданию оконного приложения на Python с помощью Tkinter. Реализация элементов GUI. Инструменты создания десктоп приложений. Группа в VK - https://vk.com/ithobbies Телеграмм канал - https://t.me/ithobbies

Preparing download options

popular icon
Popular
hd icon
HD video
audio icon
Only sound
total icon
All
* — If the video is playing in a new tab, go to it, then right-click on the video and select "Save video as..."
** — Link intended for online playback in specialized players

Questions about downloading video

mobile menu iconHow can I download "Оконное приложение на Python c Tkinter | #1" video?mobile menu icon

  • http://unidownloader.com/ website is the best way to download a video or a separate audio track if you want to do without installing programs and extensions.

  • The UDL Helper extension is a convenient button that is seamlessly integrated into YouTube, Instagram and OK.ru sites for fast content download.

  • UDL Client program (for Windows) is the most powerful solution that supports more than 900 websites, social networks and video hosting sites, as well as any video quality that is available in the source.

  • UDL Lite is a really convenient way to access a website from your mobile device. With its help, you can easily download videos directly to your smartphone.

mobile menu iconWhich format of "Оконное приложение на Python c Tkinter | #1" video should I choose?mobile menu icon

  • The best quality formats are FullHD (1080p), 2K (1440p), 4K (2160p) and 8K (4320p). The higher the resolution of your screen, the higher the video quality should be. However, there are other factors to consider: download speed, amount of free space, and device performance during playback.

mobile menu iconWhy does my computer freeze when loading a "Оконное приложение на Python c Tkinter | #1" video?mobile menu icon

  • The browser/computer should not freeze completely! If this happens, please report it with a link to the video. Sometimes videos cannot be downloaded directly in a suitable format, so we have added the ability to convert the file to the desired format. In some cases, this process may actively use computer resources.

mobile menu iconHow can I download "Оконное приложение на Python c Tkinter | #1" video to my phone?mobile menu icon

  • You can download a video to your smartphone using the website or the PWA application UDL Lite. It is also possible to send a download link via QR code using the UDL Helper extension.

mobile menu iconHow can I download an audio track (music) to MP3 "Оконное приложение на Python c Tkinter | #1"?mobile menu icon

  • The most convenient way is to use the UDL Client program, which supports converting video to MP3 format. In some cases, MP3 can also be downloaded through the UDL Helper extension.

mobile menu iconHow can I save a frame from a video "Оконное приложение на Python c Tkinter | #1"?mobile menu icon

  • This feature is available in the UDL Helper extension. Make sure that "Show the video snapshot button" is checked in the settings. A camera icon should appear in the lower right corner of the player to the left of the "Settings" icon. When you click on it, the current frame from the video will be saved to your computer in JPEG format.

mobile menu iconWhat's the price of all this stuff?mobile menu icon

  • It costs nothing. Our services are absolutely free for all users. There are no PRO subscriptions, no restrictions on the number or maximum length of downloaded videos.