▶️ Watch Entire Tkinter Playlist ✅ Subscribe To My TH-cam 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
Exactly what I was looking for. Thanks mate. I love your videos, you are doing very good job. They are nice, easy to understand and not very long. Well done.
Nice keeping up the upload on the Tkinter series, having a university project and decided to use Tkinter, and learnt so much from you. Keep up the good job!
I have mixed feeling about this, depending on projects it might either make it cleaner or messier (sometimes adding complexity). So it really depends on the project you're doing. I never consider them until I feel like they're required.
One of the greatest channel of programming!! Keep it up! And Please upload a video about the best way how to run another tkinter file with for example clicking on the button in the first file. Thanks
YO thank you this is exactly what I was looking for, I had taken a python course at my college and one chapter had us use a module they created which was an easier version of tkinter, The problem was all the code looked like this and I could not for the life of me figure out what any of this stuff meant, thanks my guy.
there is the thing i couldn't understand: why did you create the button inside the root window instead of the frame? that frame seems useless for this case if im not mistaken.
I usually make my classes inherit from the tkinter classes. For example I create a class called App that inherits from Tk, where all the app function and processing etc is done inside of the class)
I did exactly the same that you did. In the code line that I mentioned, the error is shown that the class does not have any arguments. It is having problem with the line Elder(root).
How about a video on how to create "real" reusable objects tkinter objects rather than just wrapping code inside a class definition ? Examples would be a "status line" or a "button row" object.
Awesome bro, thank you! You used the variable 'myFrame' without the keyword 'self' like you did with 'myButton' and it's working perfectly without showing an error.. Can you explain that please?
That story is much more complex. I think it's a mistake because in this case, myFrame ( the frame which we do not see anyway) is not a variable that belongs to the instances of the Elder class (instance variable) but a local variable stored on the stack and will be discarded when the init method goes out of scope. For example, setting variable myButton as self.myButton sets that variable as member of the Elder objects (accessible for the lifetime of the objects). Try this at the end of this program : e = Elder(root) e.myButton["text"] = "Changed" e.myFrame["width"] = 200 root.mainloop() and you will get the error AttributeError: 'Elder' object has no attribute 'myFrame'. Hope you can understand. My English is so so.
@@slobodantajisic2762 thank you very much for your brief explanation, it is very comprehensive! I just wonder what happened if we put self.Frame instead of just frame? Will it display then? P.S. your English is quite better than mine.
@@slobodantajisic2762 oh waow, that's impressive, appreciate your help! To be honest, I just started working with tkinter and getting a better understanding of it. I would be very grateful if you could leave your email or any other form of connections. My email: koimdodov98@gmail.com Hope hearing from you.
I have a tkinter custom made class in one python file. I need to use that in another py file whenever i call it. but the root is outside the class and hence it runs and window pops up before i want it too
Thanks for the clear introduction. But what I see is just that the functions to create the widgets are called inside a class definition. I am interested how to create wrapper objects around the tk widgets so I can execute the standard inside the class definition and don't need to write the same code for every object used to make the code more robust. Is there a chance to create objects so I use them like I do f.re. in C#. In C# I just some standard objects like Form, Label, Textbox, Button, etc. in a OOP way.
you just great , i happy to be one of ur subscriber, great job for always and i learn alot from your side men, just a question: when u created a frame why not useing self.frame to the frame?
John I noticed some videos where they inherit tk.TK when creating a class vs what you do which is creating the frame inside the class, is there an advantage on either approach?
How to switch to different pages if I click a button. For Example if I click 'about us' I want another page to open in the same window. If u cud link the video, or tell me it would be of great help. Awesome tutorials btw.
I have a question. Why is a Frame() object needed inside the __init__ function at the start? Anyway the button is placed in root. That object doesn't seemed to be used anywhere else too
Quick question man. So I’ve gotten this far I’m re structuring my code to be more in scope. But the issue I’m facing, is I have created images for my buttons. The buttons show up blank on the screen, a simple login and sign up button, but the images don’t load on them they are just grey. They are the appropriate size of the png’s, I’ve imported PIL and have the required imports. What am I doing wrong?
@@Codemycom it worked! So I made the images for the buttons global, but then I also had to put the buttons outside of the main window class, as well as the main logo image. They show up but 2 things happened. The logo, and buttons don’t constrain to the dimensions of the main window, when it pops up. If I expand the gui, the buttons are in the right place, the logo is not. And the click functions don’t operate properly. Do you think you could do a quick video on using buttons with images, inside of window classes? I’ll donate to see this happen or however that works lol
Wait, is it not creating the window because of all the code that he has at the top of the script? I thought the point was to create a class first, then create the window by creating an object that will allow me to pass the attributes or properties (title of the window, it's dimensions and so on...)
Hey John,, thanks for the video,, I have a little quesiton in here,, why didnt u use "self" before myFrame = Frame(master)? In other words when to use "self" and when not to? Thanks a lot in advance.
I wouldn’t really be able to explain that to you as clearly as Slodoban Tajisic, so I would recommend you and all the people who asked this question lately to go back to Slodoban’s answer (posted 11 months ago) to the comment of White Bird (poster 1 year ago) ( comments to this video) where he explains in detail the reason why we didn’t use self and what using it would change.
Hi Sir Please I need your help with the below query as it gives me error say that the query is wrong but i dont know what wrong in it? , SQL = "SELECT Drivers.Driver_ID, Taxi_Rent.Rent_ID, Drivers.Full_Name, Taxi_Rent.Weekly_Rent, Taxi_Rent.Weekly_Access, Taxi_Rent.Pay_Date, Drivers.Mobile, Drivers.City FROM Drivers INNER JOIN Taxi_Rent ON Drivers.Driver_ID = Taxi_Rent.Driver_ID WHERE Taxi_Rent.Driver_ID = %s;" command = drop1.get() result = my_cursor.execute(SQL,command) result = my_cursor.fetchall() for row in result: print(row)
Hi sir hope you have wonderful weekend. Sir i have't seen in your tutorials that you have highlighted the widget Toplevel ( self.newWindow = Toplevel(self.master) self.app = Window2(self.newWindow). Sir can you help me with this when we need to use the widget Toplevel. confusable for me. I will appreciate your reply. thanks
Hi sir, i made a project for a shope using python-tkinter-mysql. No i dont know how to install it in his PC. Can you guide me please. How to make its installation setup. Thanks
Hey John I need a help for my tkinter project can you pls tell ?? See I want first window and a button in that for eg(open) and when I like on that it should open my desired file which is actual tkinter project in the second window If you could help would be great btw love your videos I understood whole tkinter with your 5 hour video.😃
hi, you make good job, but what about multiple classes? :) I want make same bigger ap and this is very important for me and i think I need ur help. For example: Class with Main window, there we have button to second window(with another class) In second window i want to have multipleclass but i not sure have to make this. For now i have one class where i put everythings in def, but it is not look nice. I think i should show you my code., if you want/can help i will be glad :)
Looks like you go back away from using classes in the subsequent videos. Seems like classes are the "right" way to do it so why go backward in the future?
No, you're incorrect. Classes aren't the "right" way. There is no right way. Functional programming is useful for what it's useful for. Class based programming is useful for what it's useful for. Using Classes for a basic tkinter app is overkill that's simply not necessary.
▶️ Watch Entire Tkinter Playlist ✅ Subscribe To My TH-cam 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
Miss your 5 hours tutorials, when I could listen to you for the whole day !!
Set my playlists to auto play and it's the same thing
@@Codemycom problem solving level: infinite 👌👌😆
@@shubhamshirdhone6557 lol
Exactly what I was looking for. Thanks mate. I love your videos, you are doing very good job. They are nice, easy to understand and not very long. Well done.
Hey glad you like them!
Nice keeping up the upload on the Tkinter series, having a university project and decided to use Tkinter, and learnt so much from you. Keep up the good job!
Awesome, glad you're enjoying them!
Same here hehe, good timing
@@deki90to ha good!
Dejan Jovanovic that’s coool! , if you need any help lmk, not the best in it but can try lol
This is great. Classes really help to clean up your code and easy to modify things.
it just depends why you are using them.
I have mixed feeling about this, depending on projects it might either make it cleaner or messier (sometimes adding complexity). So it really depends on the project you're doing. I never consider them until I feel like they're required.
@@thelittlecousinto exactly so
One of the greatest channel of programming!! Keep it up! And Please upload a video about the best way how to run another tkinter file with for example clicking on the button in the first file. Thanks
Thank you for doing a series with classes and tkinter. Looking forward to seeing where this series goes.
It doesn't go anywhere. Check the playlist.
Besides the point that the video "really starts" at 2:13 everything else in it was helpful and straight to the point.
What is the point of that snark? Take it somewhere else.
@@Codemycom he's not exactly wrong though is he, learn to take criticism.
Love the courses keep up the good work.
Thanks!
Thank you very much. I was able to create my button class with events. Awesome.
Awesome!
Im always mad when i'm stuck, and i come here, and then it works. 🤦♀ But i guess thats a compliment to you. haha
YO thank you this is exactly what I was looking for, I had taken a python course at my college and one chapter had us use a module they created which was an easier version of tkinter, The problem was all the code looked like this and I could not for the life of me figure out what any of this stuff meant, thanks my guy.
Yea this video has really helped me too for uni stuff
I think we had the same textbook. Were you using BreezyPythonGUI? lol
Ok guys I did stay long enough to see Johns corrections --too much in a hurry --Thanks for the help
there is the thing i couldn't understand:
why did you create the button inside the root window instead of the frame? that frame seems useless for this case if im not mistaken.
Thanks, listening tkinter from you is awesome.
Glad you like it!
By the way, in classes __init__() function is a constructor. I believe even without it python initialized it when classes are called.
why did we not write self before making the frame?
That is what i am asking my self 👍
Very good explanation!!! Thank you!!!
I usually make my classes inherit from the tkinter classes. For example I create a class called App that inherits from Tk, where all the app function and processing etc is done inside of the class)
That's one way to do it, sure.
You're the man!!!! Thanks!!!
Welcome!
Help a lot..
Thanks from Pakistan 🙂
Cheers
Sir Ur Videos Are GREAT!!!!!!!!!!!!!!!!!!!!
thnx for helping
Glad you like them!
The e=Elder(root)command not working and showing error that Elder does not have arguments. Can you help?
what's the exact error and what did you do differently than I did?
I did exactly the same that you did. In the code line that I mentioned, the error is shown that the class does not have any arguments. It is having problem with the line Elder(root).
I had the same problem, be sure you type def __init__ correctly
I had the same issue. Didn't realize I needed two underscores on either side of init. "__ini__"
How about a video on how to create "real" reusable objects tkinter objects rather than just wrapping code inside a class definition ? Examples would be a "status line" or a "button row" object.
Awesome bro, thank you!
You used the variable 'myFrame' without the keyword 'self' like you did with 'myButton' and it's working perfectly without showing an error.. Can you explain that please?
That story is much more complex.
I think it's a mistake because in this case, myFrame ( the frame which we do not see anyway) is not a variable that belongs to the instances of the Elder class (instance variable) but a local variable stored on the stack and will be discarded when the init method goes out of scope. For example, setting variable myButton as self.myButton sets that variable as member of the Elder objects (accessible for the lifetime of the objects).
Try this at the end of this program :
e = Elder(root)
e.myButton["text"] = "Changed"
e.myFrame["width"] = 200
root.mainloop()
and you will get the error AttributeError: 'Elder' object has no attribute 'myFrame'. Hope you can understand. My English is so so.
@@slobodantajisic2762 thank you very much for your brief explanation, it is very comprehensive! I just wonder what happened if we put self.Frame instead of just frame? Will it display then?
P.S. your English is quite better than mine.
@@murodqoimdodov1221
Thanks. Try this, and you'll see what's happening if we mark Frames as instance variable (self.my_frame1, self.my_frame2, self.my_frame3). The frames are there, it just depends how we see them.
from tkinter import *
root1 = Tk()
root1.title("ROOT 1")
root1.geometry("400x400")
root2 = Tk()
root2.title("ROOT 2")
root2.geometry("400x400")
root3 = Tk()
root3.title("ROOT 3")
root3.geometry("400x400")
class Elder:
def __init__(self, master1, master2, master3):
self.my_frame1 = Frame(master1)
self.my_frame2 = Frame(master2, width=100, height=100)
self.my_frame3 = Frame(master3, highlightbackground="green", highlightcolor="green", highlightthickness=10, width=100, height=100)
self.my_frame1.pack(padx=10, pady=10)
self.my_frame2.pack(padx=10, pady=10)
self.my_frame3.pack(padx=10, pady=10)
self.my_button1 = Button(master1, text="Click Me!", command=self.clicker)
self.my_button1.pack(pady=10)
self.my_button2 = Button(master2, text="Click Me!", command=self.clicker)
self.my_button2.pack(pady=10)
self.my_button3 = Button(master3, text="Click Me!", command=self.clicker)
self.my_button3.pack(pady=10)
@staticmethod
def clicker():
print("Look at you... you clicked a button!")
e = Elder(root1, root2, root3)
root1.mainloop()
root2.mainloop()
root3.mainloop()
@@slobodantajisic2762 oh waow, that's impressive, appreciate your help! To be honest, I just started working with tkinter and getting a better understanding of it. I would be very grateful if you could leave your email or any other form of connections.
My email:
koimdodov98@gmail.com
Hope hearing from you.
@@murodqoimdodov1221 O'zbekmisiz?
Hi, I had a problem in passing root as argument in class Elder: TypeError: Elder() takes no arguments. Please help me, why is it so.
Re-Watch the video and figure out what you did differently from the video.
I have a tkinter custom made class in one python file. I need to use that in another py file whenever i call it. but the root is outside the class and hence it runs and window pops up before i want it too
Very well explained!
Thanks!
Why you didn’t put self.myFrame like what you did with myButton
Hi John! Is there any follow up video on this topic? I haven't found it
Not yet
why frame is not initialised with self.myframe
Thanks for the clear introduction. But what I see is just that the functions to create the widgets are called inside a class definition. I am interested how to create wrapper objects around the tk widgets so I can execute the standard inside the class definition and don't need to write the same code for every object used to make the code more robust. Is there a chance to create objects so I use them like I do f.re. in C#. In C# I just some standard objects like Form, Label, Textbox, Button, etc. in a OOP way.
why doesn't "myFrame" need a "self" infront of it?
you just great , i happy to be one of ur subscriber, great job for always and i learn alot from your side men, just a question: when u created a frame why not useing self.frame to the frame?
Thanks! We're not using self.frame because that wouldn't work because we aren't using Classes here.
wtf man. so why you created this frame for...? xD@@Codemycom
I like the warning with classes
ha
Did you ever come back to Tkinter with classes? I've searched your videos without any luck
No I didn't..
So would inputs all be handled in the init function, say if the class was to create details for an item to be added to a list?
Any chance of a Tutorial on using multiple .py for a app / modules?
John I noticed some videos where they inherit tk.TK when creating a class vs what you do which is creating the frame inside the class, is there an advantage on either approach?
Mine is easier. If you don't understand the purpose of class based programming, then you don't need to use class based programming.
what if we used self.frame instead of frame or do we need frame here cozvif we dont use class there is no use of frame
Hi where can I find the other videos using classes with tkinter? I can't find them I want to explore this as deeply as possible. Great video
There aren't any
How to switch to different pages if I click a button. For Example if I click 'about us' I want another page to open in the same window. If u cud link the video, or tell me it would be of great help. Awesome tutorials btw.
I have videos in the playlist on adding new windows
@@Codemycom yeah I saw that, but I wanted different pages in the same window, thanks for the reply
Would you please show the app in use?
I usually do
First, I want to thank you for hard work, it's really helpful. I want to ask how I can run a class for a period and then open onther function?
I have a question. Why is a Frame() object needed inside the __init__ function at the start? Anyway the button is placed in root. That object doesn't seemed to be used anywhere else too
because we want the frame created when the program is initiated. The button is not placed in root.
Codemy.com Ok. I understand that frame in necessary . But the button is packed in master which of course is root...
@@srinivasanveeraraagavan271 Dude, everything is in root eventually, including the frame...you aren't understanding something here.
@@Codemycom You told the button is not placed in root. What did you mean by that?
very very useful
Glad you think so!
Tutorial 43 did not work with my ChromeBook OS but most tutorials work
You likely made a typo in the code. There's nothing about it that simply doesn't work on a ChromeBook...
Quick question man. So I’ve gotten this far I’m re structuring my code to be more in scope. But the issue I’m facing, is I have created images for my buttons. The buttons show up blank on the screen, a simple login and sign up button, but the images don’t load on them they are just grey. They are the appropriate size of the png’s, I’ve imported PIL and have the required imports. What am I doing wrong?
make the image variables global
@@Codemycom it worked! So I made the images for the buttons global, but then I also had to put the buttons outside of the main window class, as well as the main logo image. They show up but 2 things happened. The logo, and buttons don’t constrain to the dimensions of the main window, when it pops up. If I expand the gui, the buttons are in the right place, the logo is not. And the click functions don’t operate properly. Do you think you could do a quick video on using buttons with images, inside of window classes? I’ll donate to see this happen or however that works lol
Hey John, you need more material/content on Tkinter 'classes'. I believe that this is the only video you have on it, correct?
Correct...I'll add some over on the Tkinter.com youtube channel soonish.
why myframe = self.myframe pls explain
Dean Dean Dean, a programming machine!
Who's dean? lol
You are king
thank you!
Wait, is it not creating the window because of all the code that he has at the top of the script? I thought the point was to create a class first, then create the window by creating an object that will allow me to pass the attributes or properties (title of the window, it's dimensions and so on...)
What’s self?
What is the meaning of ‘pads and pady’
pady gives padding on the y cordinate. padx gives it on the x corrdinate
Thank you heisenberg
Welcome
Can you teach me chemistry too?
@@hamzabilal4602 lol
@@hamzabilal4602 lmao bro you're so funny
Hey John,, thanks for the video,, I have a little quesiton in here,, why didnt u use "self" before myFrame = Frame(master)? In other words when to use "self" and when not to? Thanks a lot in advance.
I wouldn’t really be able to explain that to you as clearly as Slodoban Tajisic, so I would recommend you and all the people who asked this question lately to go back to Slodoban’s answer (posted 11 months ago) to the comment of White Bird (poster 1 year ago) ( comments to this video) where he explains in detail the reason why we didn’t use self and what using it would change.
Getting an error and can't understand how to get rid of it. Code is the same
Code is not the same..you have a typo.
Are you using an old version of tkinter? The way I am using tkinter right now is different. Instead of .pack for example I do .grid(row=1, column=1)
No I'm not using an old version. You can use pack or grid or place.
Hi Sir Please I need your help with the below query as it gives me error say that the query is wrong but i dont know what wrong in it? ,
SQL = "SELECT Drivers.Driver_ID, Taxi_Rent.Rent_ID, Drivers.Full_Name, Taxi_Rent.Weekly_Rent, Taxi_Rent.Weekly_Access, Taxi_Rent.Pay_Date, Drivers.Mobile, Drivers.City FROM Drivers INNER JOIN Taxi_Rent ON Drivers.Driver_ID = Taxi_Rent.Driver_ID WHERE Taxi_Rent.Driver_ID = %s;"
command = drop1.get()
result = my_cursor.execute(SQL,command)
result = my_cursor.fetchall()
for row in result:
print(row)
Thanks
Welcome
Hi sir hope you have wonderful weekend.
Sir i have't seen in your tutorials that you have highlighted the widget Toplevel ( self.newWindow = Toplevel(self.master)
self.app = Window2(self.newWindow). Sir can you help me with this when we need to use the widget Toplevel. confusable for me. I will appreciate your reply. thanks
Use Toplevel whenever you want to create another window.
Sir is it posible to fix a color for a specific column or record to print on a label from the database ? Thanks
@@afridinaseer sure
Hi sir, i made a project for a shope using python-tkinter-mysql. No i dont know how to install it in his PC. Can you guide me please. How to make its installation setup. Thanks
@@afridinaseer I have a video on the playlist that shows you how to make an exe file.
Hey John I need a help for my tkinter project can you pls tell ??
See I want first window and a button in that for eg(open) and when I like on that it should open my desired file which is actual tkinter project in the second window
If you could help would be great btw love your videos I understood whole tkinter with your 5 hour video.😃
Check the playlist, I have videos on opening windows.
Thanx bud
Sure thing
Why not:
class Elder(Tkinter): ?
:-p
I need ttk tutorial
Super
tkinter.ttk tutorial please
@@critical_handle I talk about all the ttk widgets in the playlist
hi, you make good job,
but what about multiple classes? :)
I want make same bigger ap and this is very important for me and i think I need ur help.
For example:
Class with Main window, there we have button to second window(with another class)
In second window i want to have multipleclass but i not sure have to make this. For now i have one class where i put everythings in def, but it is not look nice.
I think i should show you my code., if you want/can help i will be glad :)
I'll discuss multiple classes in future videos.. in the mean time, just try creating multiple classes. See what happens.
@@Codemycom Ok, I will try
You remind me of Walter White from Breaking Bad.
Ive never heard that before :-p
Sir from which country do you belong?
USA
Is it my imagination, or is it Monday morning in all your videos?
Well I have over 500 videos, so yeah it's just your imagination lol
Looks like you go back away from using classes in the subsequent videos. Seems like classes are the "right" way to do it so why go backward in the future?
No, you're incorrect. Classes aren't the "right" way. There is no right way. Functional programming is useful for what it's useful for. Class based programming is useful for what it's useful for. Using Classes for a basic tkinter app is overkill that's simply not necessary.
@Codemy.com
koreksi,
mungkin maksud anda :
self.myButton=Button(myFrame,text="Klick Me!",command=self.clicker)
bukan master, tapi myFrame