Sliders With TKinter - Python Tkinter GUI Tutorial #16

  Рет қаралды 71,048

Codemy.com

Codemy.com

Күн бұрын

Пікірлер: 135
@Codemycom
@Codemycom 4 жыл бұрын
▶️ Watch Entire Tkinter Playlist ✅ Subscribe To My KZbin Channel: bit.ly/2UFLKgj bit.ly/2IGzvOR ▶️ See More At: ✅ Join My Facebook Group: Codemy.com bit.ly/2GFmOBz ▶️ Learn to Code at Codemy.com ✅ Buy a Codemy T-Shirt! Take $30 off with coupon code: youtube1 bit.ly/2VC9WUN
@Codemycom
@Codemycom 2 жыл бұрын
@ANONYMOUS Sure, use the .set() function with whatever value you want. .set(20) etc
@sunchitlakhanpal
@sunchitlakhanpal 4 жыл бұрын
The best Tkinter tutorials out there, Great Job ! :D
@Codemycom
@Codemycom 4 жыл бұрын
Thanks man!
@TheRevan5576
@TheRevan5576 4 жыл бұрын
10:00 You can fix this problem easily by binding your function to take place after you release the mouse, place the code before you call .pack() horizontal.bind("", lambda var=event: slide(var))
@Codemycom
@Codemycom 4 жыл бұрын
Of course, there's always many ways to do a thing
@walternyc
@walternyc 4 жыл бұрын
I put together a simulation in tkinter. Your GUI tutorials have been extremely useful. Thanks!
@Codemycom
@Codemycom 4 жыл бұрын
Glad you liked them!
@MonkeyDLuffy-ld5iy
@MonkeyDLuffy-ld5iy 3 жыл бұрын
You need a "_" and the end of the " from_" parameter because the is a buildin keyword from in python like "from tkinter import *"
@Codemycom
@Codemycom 3 жыл бұрын
yeah
@jscherer26
@jscherer26 3 жыл бұрын
These are great. My first time with GUI. Thank you for making them. horizontal.pack(anchor=W) will solve your slider issue. It's centered, so as your moving it, it's recentering. If it stays to the left its fine.
@dylancampbell6433
@dylancampbell6433 3 жыл бұрын
Yes, also if you are a fan of the side option you could use that as well. Example: vertical.pack(side=RIGHT, fill=Y) horizontal.pack(side=BOTTOM, fill=X) fill makes the slider expand with the window.... you know.... for style points 😎
@ninjatribble7961
@ninjatribble7961 4 жыл бұрын
Smashing through this playlist. Great stuff. Looking forward to the database vids.
@Codemycom
@Codemycom 4 жыл бұрын
fun!
@Abdulkadir-vb3vj
@Abdulkadir-vb3vj 3 жыл бұрын
9:58 the reason for resizing weirdness is that there is keydown and keyup difference. You need to use a key up(key release). So, delete command area in horizontal and add another line under it horizontal.bind("", get_value)
@AyanKhan-dc3eu
@AyanKhan-dc3eu 4 жыл бұрын
It's amazing sir learning bunch of cool stuff during quarantine
@Codemycom
@Codemycom 4 жыл бұрын
Glad you're enjoying it!
@mm333-e1t
@mm333-e1t 5 жыл бұрын
Concepts are beautifully explained. This is good stuff... Great job man !!
@Codemycom
@Codemycom 5 жыл бұрын
Thanks! Glad you're enjoying it!
@TheOleHermit
@TheOleHermit 4 жыл бұрын
Excellent series! I'm building a GUI for a RPi security camera with stepper motors controlling X/Y position, zoom, focus, and aperture. Your previous tutorials showed me how to input x and y values into text boxes, then use a button to send those +/- step values to the steppers. Great! Now, I'm ready to add some x/y preset buttons with 10 stored values, pulled from a csv file. Awesome! These sliders should allow me to also control the zoom, focus and aperture steppers. Almost home! Q: Is there a way to display the camera's live image as a background, with a hot spot to show/hide the GUI controls? That would be the cherry on the cake.🥳 Thanks for posting tutorials that make these things happen.🙏
@Codemycom
@Codemycom 4 жыл бұрын
I'm sure there is, but not knowing anything about that camera, I couldn't guess how..
@TheOleHermit
@TheOleHermit 4 жыл бұрын
@@Codemycom Thanks for the quick reply. It's a simple RPi USB camera. Just googled it and found the following article, which looks promising. I'm not so sure about a hotspot for hide/show GUI. But, where there's a will, there's usually a way. Might need to simply switch between windows, tabs, or something. 😎 solarianprogrammer.com/2018/04/21/python-opencv-show-video-tkinter-window/
@aidangurevich9904
@aidangurevich9904 4 жыл бұрын
Your tutorials are very helpful! I was just wondering how you can adjust the length of the slider.
@Codemycom
@Codemycom 4 жыл бұрын
give it a length of some number; ie length=600
@aidangurevich9904
@aidangurevich9904 4 жыл бұрын
@@Codemycom Thank you!
@Codemycom
@Codemycom 4 жыл бұрын
@@aidangurevich9904 Sure thing!
@devjeetmandal1472
@devjeetmandal1472 3 жыл бұрын
At 2:00, 'from_' is used because 'from' is a keyword in Python, it's like to differentiate between keyword and the slider variable.
@Codemycom
@Codemycom 3 жыл бұрын
yep
@darshanbothra2673
@darshanbothra2673 3 жыл бұрын
suggestion: using grid with horizontal and vertical will actually remove the lag thing..
@Blubberland
@Blubberland 2 жыл бұрын
1:56 because it's a python keyword. That's very essential for a course on a language and something you could've and should've corrected since april '19 €: I commented before reading the other comments. After reading the reaction Devjeet Mandal I felt even more, that this should be said.
@keerthivaasannandakumar9974
@keerthivaasannandakumar9974 3 жыл бұрын
We have to add an underscore after from i.e. from_ because from is a pre-defined function
@furrane
@furrane 2 жыл бұрын
FYI : The command inside the Scale will pass the scale value. Which means you could use this in your code for example : def slide(n): root.geometry(str(n)+'x400')
@mikemurphy1896
@mikemurphy1896 3 жыл бұрын
you are da man, thx
@Codemycom
@Codemycom 3 жыл бұрын
Thanks!
@liyudanfikirdan1221
@liyudanfikirdan1221 3 жыл бұрын
thank you, i am 12 years old and i like your videos
@Codemycom
@Codemycom 3 жыл бұрын
Awesome, thanks for watching!
@react_meme
@react_meme 3 жыл бұрын
1:58 cuz there is something in python called from and if u use from except of from_ python wont get witch one do u mean
@kocorech
@kocorech 4 жыл бұрын
is possible to change the way slider looks? other than just changing the color or size?
@Codemycom
@Codemycom 4 жыл бұрын
not this slider
@kocorech
@kocorech 4 жыл бұрын
@@Codemycom so in tkinter is there any other slider types? I am asking because i am trying to build a music player with it and this one just looks horrible. I am trying to decide based on that if i should go with pyqt5 instead.
@Codemycom
@Codemycom 4 жыл бұрын
@@kocorech ttk has a scale widget that might be a little better.. we've used ttk comboboxes but I haven't talked about scale yet
@SatishKumar-mn6bi
@SatishKumar-mn6bi 4 жыл бұрын
I am facing problem to complete my project for multiply table in gui in which we take int input from user. Further we take int input for both range and display results. All to be on gui, we will take 3 input and then results display
@parsabahrambeik4381
@parsabahrambeik4381 4 жыл бұрын
Hi, thank you very much for your video.
@Codemycom
@Codemycom 4 жыл бұрын
So nice of you
@maxwellhawk
@maxwellhawk Жыл бұрын
i think the problem with changing size with slider bc when it change windows size, center of the window change and slider position change, however u keep holding same old spot. That's pretty much why its blinking. If we put slider in frame and grid it or use sticky to left top corner, it should work just fine.
@johnjoe7803
@johnjoe7803 11 ай бұрын
Not really is bc he is using the .pack that's why it centred in the middle by default.the .grid is use to place it anywhere in the window
@barackuse
@barackuse Жыл бұрын
Why do you need the "orient =horizontal," and does horizontal need to be all in caps? I noticed that this still was not done on the vertical slide.
@Codemycom
@Codemycom Жыл бұрын
really? Because that's how you orient the slider horizontally... come on man.
@KineticPebble
@KineticPebble 3 жыл бұрын
I don't understand why we need to pass in parameter to the slide function? We are not using the parameter in the function and also not passing it in the command for the horizontal slider. Shouldn't it give a missing argument error?
@SatishKumar-mn6bi
@SatishKumar-mn6bi 4 жыл бұрын
I am watching KZbin which are really good as tutorial
@Codemycom
@Codemycom 4 жыл бұрын
:-)
@MrGerrardo681
@MrGerrardo681 4 жыл бұрын
very cool video, i was wondering how you could connect the number you get from the slider in the GUI, into a database field. for instance shirt number.
@Codemycom
@Codemycom 4 жыл бұрын
The same way you connect any variable to a database field
@djilytech385
@djilytech385 4 жыл бұрын
@@Codemycom you can do var1 = horizontal_slider.get() var2 = vertical_slider.get() Then when you do INSERT, include var1 and var2 etc..
@Codemycom
@Codemycom 4 жыл бұрын
@@djilytech385 cool
@Zhaxxy
@Zhaxxy Жыл бұрын
you probably dont read the comments anymore, but how can i make a slider that has 2 different colours, like if its fully empty it would be red and if full it would be green, the slider would be red to the right of the knob, and green to the left of the knob
@Codemycom
@Codemycom Жыл бұрын
You'd have to probably create a custom style() widget...or use ttkbootstrap or something
@Zhaxxy
@Zhaxxy Жыл бұрын
@@Codemycom i ended up making a canvas with a colour and a rectangle. i used the motion bind
@Codemycom
@Codemycom Жыл бұрын
@@Zhaxxy nice
@sara-ql1xs
@sara-ql1xs 5 жыл бұрын
Thanks man
@Codemycom
@Codemycom 5 жыл бұрын
You got it!
@xith-eb1jeevanraj.l485
@xith-eb1jeevanraj.l485 5 ай бұрын
I have running problem with horizontal.get( ) , it shows this object show no attribute
@Codemycom
@Codemycom 5 ай бұрын
did you define the widget and pack it on the same line? You can't do that.
@sudinmaharjan9326
@sudinmaharjan9326 4 жыл бұрын
how u got that multiply sign because in my case i have * sign and it say this is a bad geometry specifier and i get a TclError
@Codemycom
@Codemycom 4 жыл бұрын
try the x instead not *
@leamlisophara731
@leamlisophara731 3 жыл бұрын
Excuse me!!! Could you explain what difference between slide and slide() ???
@Codemycom
@Codemycom 3 жыл бұрын
() generally denotes a function in python
@sveinndagur
@sveinndagur 5 жыл бұрын
Good stuff!
@Codemycom
@Codemycom 5 жыл бұрын
Thanks!
@luisjoa6535
@luisjoa6535 2 жыл бұрын
adópteme señor
@rajkumarshirol7832
@rajkumarshirol7832 3 жыл бұрын
When I assign root=Tk(), the error shows "no display name and no $DISPLAY environment variable" someone please help. I need to submit my assignment tommorrow. I need to create a slider to plot graphs.
@Codemycom
@Codemycom 3 жыл бұрын
The code must be exactly the same as the video...you have a typo somewhere
@franciscovialli3183
@franciscovialli3183 2 жыл бұрын
When i write parameter var inside the slide() it shows that slide requires misses 1 position argument
@Codemycom
@Codemycom 2 жыл бұрын
What did you do differently from the video?
@franciscovialli3183
@franciscovialli3183 2 жыл бұрын
@@Codemycom nothing at all i just wrote def slide(var): that's all and it showed an error
@Codemycom
@Codemycom 2 жыл бұрын
@@franciscovialli3183 Hm, weird.
@gurucharan5618
@gurucharan5618 4 жыл бұрын
How to adjust the length of the scroll bar ? (I'm not talking about width)
@Codemycom
@Codemycom 4 жыл бұрын
if not width, what ARE you talking about?
@oilartxikia7884
@oilartxikia7884 Жыл бұрын
hey, can anyone help me? i try doing " mylabel = Label(settings,text = Horizontal.get()).pack() " or " Volume = Horizontal.get() " but it comes up with the error: Exception in Tkinter callback Traceback (most recent call last): File "C:\Users\User\AppData\Local\Programs\Thonny\lib\tkinter\__init__.py", line 1921, in __call__ return self.func(*args) File "", line 29, in Test_Audio AttributeError: 'NoneType' object has no attribute 'get' can anyone help me? what have i done wrong? EDIT: i read through the comments and i understand what i did wrong, but now how would i set the value to a standard value, for example, when i first load the page, i want the volume to be set to 50, so its like half way.
@Codemycom
@Codemycom Жыл бұрын
don't ever .pack() a widget on the same line you define it.
@mbbbbbbbbb6582
@mbbbbbbbbb6582 11 ай бұрын
Hi why does it say error Scale isn’t defined in my code
@Codemycom
@Codemycom 11 ай бұрын
Because you didn't define Scale in your code...compare your code to the video to see what you did wrong.
@stephenmascarenhas3595
@stephenmascarenhas3595 3 жыл бұрын
Well can i do it with pycharm
@Codemycom
@Codemycom 3 жыл бұрын
I don't use Pycharm, or recommend it to anyone ever.
@fentonmsu
@fentonmsu 3 жыл бұрын
Why not,?
@Codemycom
@Codemycom 3 жыл бұрын
@@fentonmsu Because it's garbage, and creates many problems for new coders.
@hamakhdir6610
@hamakhdir6610 4 жыл бұрын
the reason of using from_ , because from is a python keyword!
@Codemycom
@Codemycom 4 жыл бұрын
Yep
@alekhyobanerjee2099
@alekhyobanerjee2099 4 жыл бұрын
Please show how to add Scrollbar for a login like page
@Codemycom
@Codemycom 4 жыл бұрын
Sorry I don't know what you mean by login like page
@geojose5045
@geojose5045 4 жыл бұрын
Can we From and To as strings?
@Codemycom
@Codemycom 4 жыл бұрын
try it and see
@geojose5045
@geojose5045 4 жыл бұрын
@@Codemycom it doesn't work. Only numerical values
@Codemycom
@Codemycom 4 жыл бұрын
@@geojose5045 yep
@geojose5045
@geojose5045 4 жыл бұрын
@@Codemycom sir when I try to place radio buttons using grid, they are aligned correctly? Why is that?
@Codemycom
@Codemycom 4 жыл бұрын
@@geojose5045 I don't know what you mean
@slobodantajisic2762
@slobodantajisic2762 4 жыл бұрын
I played with this a little bit. This may be useful. Or not, but anyway: from tkinter import * root = Tk() root.title("Learning to Code") root.geometry("180x180+0+0") def ver(vertical_value, horizontal_value): root.geometry(str(horizontal_value) + "x" + str(vertical_value) + "+0+0") vertical_label["text"] = str(vertical_value) def hor(vertical_value, horizontal_value): root.geometry(str(horizontal_value) + "x" + str(vertical_value) + "+0+0") horizontal_label["text"] = str(horizontal_value) vertical = Scale(root, from_=180, to=830, command=lambda x: ver(vertical.get(), horizontal.get())) vertical.grid(row=0, column=0) horizontal = Scale(root, from_=180, to=1600, orient=HORIZONTAL, command=lambda x: hor(vertical.get(), horizontal.get())) horizontal.grid(row=0, column=1) vertical_label = Label(root, text=vertical.get()) vertical_label.grid(row=1, column=0) horizontal_label = Label(root, text=horizontal.get()) horizontal_label.grid(row=1, column=1) root.mainloop()
@pratyushmisra2516
@pratyushmisra2516 4 жыл бұрын
ur code is really great!!!!! but i believe its not required to create 2 different function, here is the modified code: from tkinter import root = Tk() root.title("Learning to Code") root.geometry("180x180+0+0") def newGeometry(vertical_value, horizontal_value): root.geometry(str(horizontal_value) + "x" + str(vertical_value) + "+0+0") vertical_label["text"] = str(vertical_value) horizontal_label["text"] = str(horizontal_value) vertical = Scale(root, from_=180, to=830, command=lambda x: newGeometry(vertical.get(), horizontal.get())) vertical.grid(row=0, column=0) horizontal = Scale(root, from_=180, to=1600, orient=HORIZONTAL, command=lambda x: newGeometry(vertical.get(), horizontal.get())) horizontal.grid(row=0, column=1) vertical_label = Label(root, text=vertical.get()) vertical_label.grid(row=1, column=0) horizontal_label = Label(root, text=horizontal.get()) horizontal_label.grid(row=1, column=1) root.mainloop()
@slobodantajisic2762
@slobodantajisic2762 4 жыл бұрын
@@pratyushmisra2516 Yes of course. I see now. Just edit the variables vertical and horizontal. Command attribute.Thanks....
@NEXC
@NEXC 3 жыл бұрын
HOW can we change the slider button ?
@Codemycom
@Codemycom 3 жыл бұрын
What do you mean?
@NEXC
@NEXC 3 жыл бұрын
@@Codemycom How to change the slider icon to our custom icon and how to resize the slider because this is too small
@Codemycom
@Codemycom 3 жыл бұрын
@@NEXC I have videos on that in the playlist
@pranavbhat7262
@pranavbhat7262 4 жыл бұрын
How do I add a vertical scroll bar?
@Codemycom
@Codemycom 4 жыл бұрын
Set the widget’s yscrollcommand callbacks to the set method of the scrollbar. listbox = Listbox(master, yscrollcommand=scrollbar.set) And..Set the scrollbar’s command to the yview method of the widget. scrollbar.config(command=listbox.yview)
@pranavbhat7262
@pranavbhat7262 4 жыл бұрын
@@Codemycom Thank you so much sir... I really enjoy watching ur helpful tutorials
@Codemycom
@Codemycom 4 жыл бұрын
@@pranavbhat7262 Glad you enjoy them!
@rokkuzner
@rokkuzner 2 жыл бұрын
How to resize scale?
@Codemycom
@Codemycom 2 жыл бұрын
what do you mean?
@ruturajpatil8689
@ruturajpatil8689 4 жыл бұрын
AttributeError: 'NoneType' object has no attribute 'get' Please tell solution
@Codemycom
@Codemycom 4 жыл бұрын
You can't pack and define a widget on the same line. Break them into two lines
@ruturajpatil8689
@ruturajpatil8689 4 жыл бұрын
Thank you sir it worked....
@Codemycom
@Codemycom 4 жыл бұрын
@@ruturajpatil8689 Good :-)
@jeremydeceuster6912
@jeremydeceuster6912 4 жыл бұрын
I assume 'from_' is used because 'from' is a Python keyword.
@Codemycom
@Codemycom 4 жыл бұрын
Yep
@yeknom5g
@yeknom5g 3 жыл бұрын
I tried "to_=200", instead of "to=200". It worked well here, and hopefully won't break anything in the future. Oops! fixed.
@Codemycom
@Codemycom 3 жыл бұрын
I don't see the difference between the two things you typed.
@GameXaadict
@GameXaadict 7 ай бұрын
. Get function is not working
@Codemycom
@Codemycom 7 ай бұрын
lowercase g in .get() - it can't not work.
@GameXaadict
@GameXaadict 7 ай бұрын
@@Codemycom tried it multiple times but still it's not working...
@Ty1er
@Ty1er 4 жыл бұрын
⁦❤️⁩
@Codemycom
@Codemycom 4 жыл бұрын
Thanks!
@brycebolton17
@brycebolton17 4 ай бұрын
haha i was waiting for the root.geometry since the first video, but i didn't want it to look up just waited for it's appearing in the series :D
@Codemycom
@Codemycom 4 ай бұрын
Ha!
@gamertronky8648
@gamertronky8648 2 жыл бұрын
why TKinter its not Tkinter?
@slobodantajisic2762
@slobodantajisic2762 4 жыл бұрын
from is a keyword in python, so here we have from and underscore...
@Codemycom
@Codemycom 4 жыл бұрын
huh?
@slobodantajisic2762
@slobodantajisic2762 4 жыл бұрын
@@Codemycom The BeautifulSoup class from the bs4 module has a find method, which receives the keyword argument class_. I read that the underscore is because class is a special keyword in Python and that in such cases we put the underscore. If they lie to me then I lie to you. :-)
@Codemycom
@Codemycom 4 жыл бұрын
@@slobodantajisic2762 Ok, but I still have no idea what you're talking about or why
@slobodantajisic2762
@slobodantajisic2762 4 жыл бұрын
@@Codemycom Haha. Ok. At 2:00 you said "I have no idea why you need an underscore, but you do and then you need to designate 'to' and notice there is no underscore for 'to' which doesn't make sense. I mean let's be consistent here people. I don't know who built this." No big deal.
@Codemycom
@Codemycom 4 жыл бұрын
@@slobodantajisic2762 ah, ok...yes from is a reserved word in python
@abkani4279
@abkani4279 3 жыл бұрын
Say my name, Heisenberg!!!
@Codemycom
@Codemycom 3 жыл бұрын
Haha
@mrj6967
@mrj6967 2 жыл бұрын
unlike previous videos it was not that practical!!!
@Codemycom
@Codemycom 2 жыл бұрын
lol you are incorrect
Checkboxes With TKinter - Python Tkinter GUI Tutorial #17
9:55
Codemy.com
Рет қаралды 91 М.
Good teacher wows kids with practical examples #shorts
00:32
I migliori trucchetti di Fabiosa
Рет қаралды 13 МЛН
She's very CREATIVE💡💦 #camping #survival #bushcraft #outdoors #lifehack
00:26
didn't manage to catch the ball #tiktok
00:19
Анастасия Тарасова
Рет қаралды 33 МЛН
Here's The Secret How To Create These Animated Diagrams
11:12
Amigoscode
Рет қаралды 467 М.
Adding a Full Screen ScrollBar - Python Tkinter GUI Tutorial #96
15:08
Python GUI Development With PySimpleGUI
15:15
Real Python
Рет қаралды 1 МЛН
If __name__ == "__main__" for Python Developers
8:47
Python Simplified
Рет қаралды 408 М.
Create Stunning Python GUIs in 10 Minutes With Drag & Drop
11:38
Coding Is Fun
Рет қаралды 79 М.
Learn Python tkinter GUI scales easy 🌡️
10:20
Bro Code
Рет қаралды 14 М.
Modern Graphical User Interfaces in Python
11:12
NeuralNine
Рет қаралды 1,6 МЛН
Pydantic Tutorial • Solving Python's Biggest Problem
11:07
pixegami
Рет қаралды 280 М.
Good teacher wows kids with practical examples #shorts
00:32
I migliori trucchetti di Fabiosa
Рет қаралды 13 МЛН