Тёмный

Create New Windows in tKinter - Python Tkinter GUI Tutorial #14 

Codemy.com
Подписаться 235 тыс.
Просмотров 164 тыс.
50% 1

Опубликовано:

 

18 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 285   
@Codemycom
@Codemycom 4 года назад
▶️ Watch Entire Tkinter Playlist ✅ Subscribe To My RU-vid 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
@prbprb2
@prbprb2 3 года назад
This is great for putting an image in the new window. Suppose I want to put a plot in the new window? There are many examples on the internet that don't work. Can someone share a piece of working code, that is as simple as this video?
@kennethobeng9127
@kennethobeng9127 3 года назад
At this point, I think I should pause my life and watch all your videos before I continue. It'll really save me a lot of stress and time.
@Codemycom
@Codemycom 3 года назад
haha nice
@JadeJuno
@JadeJuno 3 года назад
I'm currently doing just that lol
@janpaweii3115
@janpaweii3115 2 года назад
Im on 2 weeks sick leave and im bingewhatching all of theese videos :D
@lynnmcgarry2580
@lynnmcgarry2580 3 года назад
3 days I've spent on this and you solved it in a couple of mins. Can't thank you enough.
@Codemycom
@Codemycom 3 года назад
Awesome, glad you found it!
@mikem8915
@mikem8915 5 лет назад
I've been following John's series. It's been great. On this particular video, I noticed that if I kept clicking the "open another window" button, several new windows would open and the images would disappear from the previous windows. Just out of curiosity and know how, I wanted to close the previous window if I opened another window without using the "close button". The way I did it is this (my variable topWindow = John's variable top): 1) add "topWindow = None" to the line above root.mainloop(): topWindow = None root.mainloop() 2) add the follow to just under the first global variable in the open second window def: global topWindow if topWindow is not None: topWindow.destroy()
@adonisnunez6078
@adonisnunez6078 Год назад
thanks, I was thinking in that problem while working in my project, now I do not have to get headache trying to solve it.
@manikandannatarajan9665
@manikandannatarajan9665 4 года назад
HI, same 13 year old here, I feel extremely satisfied after watching your tutorials, hope you won't stop making more, I never disliked any of your tutorials
@Codemycom
@Codemycom 4 года назад
Great to hear!
@Codemycom
@Codemycom 4 года назад
You're welcome!
@WHWrooolz
@WHWrooolz 4 года назад
I'm new to coding to tkinter, so my question might sound vague, please bear with me. This video shows basically how to open up a SEPARATE window with the buttons, which makes sense... But what if I wanted to open up a new window layout INSIDE the main window, not as a separate window? Let us say you're at an options menu for a game lobby: When you click on the options menu button, there pops up new buttons for each option category, such as "Game play", "Sound", "Interface", "Network", etc. etc. There's also a button to go back to the previous menu, with it's own set of buttons such as "New game", "Load Game", "Options", "Exit". You wouldn't open up a whole bunch of NEW windows, separate from the main, to get to each menu option. You'd still navigate each selection from within the original window. Otherwise You'd have a whole bunch of messy windows.... So what exactly do I do in order to code a button widget to open up a new layer with menu buttons of it's own, WITHIN the main window, not as a separate window?
@Codemycom
@Codemycom 4 года назад
You don't want to add a new window for that, you want to add a new frame...then, in that new frame, put whatever new stuff you want. Keep watching the playlist, I discuss frames a lot.
@WHWrooolz
@WHWrooolz 4 года назад
Codemy.com thanks!
@sarthaksrivastava6282
@sarthaksrivastava6282 4 года назад
These videos are very helpful in learning Tkinter, I am very thankful for your support too. Want to ask what will the further windows be named like for the second window we used toplevel what for third?
@Codemycom
@Codemycom 4 года назад
you can use toplevel again, just give it another variable name...or you can name them anything you want
@jamalalkelani4439
@jamalalkelani4439 3 года назад
Your videos are the best on RU-vid. professional, clear, smart, easy to understand ... etc
@Codemycom
@Codemycom 3 года назад
Wow, thanks!
@Binford35
@Binford35 4 года назад
Thanks for the help. I was trying to figure out why none of my variables worked in a second window. It's because if you have more than one Tk() instance, Python gets really confused. If you only do one Tk() and the rest are Toplevel() you won't have this issue.
@Codemycom
@Codemycom 4 года назад
Yep...you can use global variables too, to get around that...
@campanion
@campanion 4 года назад
idk what I'd do without you
@Codemycom
@Codemycom 4 года назад
Glad you're enjoying the videos :-)
@laurentreynaud4404
@laurentreynaud4404 3 года назад
I don't speak English, I don't understand English, and yet I manage to understand your classes ... isn't it miraculous ? Thank you very much for these courses ;) -> phrase traduite sur Deepl :D
@Codemycom
@Codemycom 3 года назад
You're welcome 😊
@sumedhasharma1984
@sumedhasharma1984 3 года назад
So you used Google translate to write this comment??
@laurentreynaud4404
@laurentreynaud4404 3 года назад
@@sumedhasharma1984 yes, I'm sorry but my english level is very low :(
@Rlearning1
@Rlearning1 Год назад
Great help! I was stuck on the image part for many hours but found no solution until I found the global var part. Thanks!
@Codemycom
@Codemycom Год назад
Welcome
@circuit6896
@circuit6896 4 года назад
This actually really helped for my assignment in programming, cheers for this!! Question though, can I have two Toplevels working under different defs?
@Codemycom
@Codemycom 4 года назад
sure, just call them different things..that's how you open a second window for instance
@victornunes5888
@victornunes5888 2 года назад
John, I think that declaring the image variable out of the function is a better option than using "global". Because you just load the picture on runtime, and pack it when the function is triggered by the button. Please, correct me if I'm wrong.
@Codemycom
@Codemycom 2 года назад
You're wrong. Tkinter's garbage function does a thing if you don't use global.
@victornunes5888
@victornunes5888 2 года назад
@@Codemycom Well... I tried the code below. And it worked... the only difference is that I used just PhotoImage class to load the picture: root = Tk() def open(): toplevel = Toplevel() my_label = Label(toplevel, image=my_img) my_label.pack() my_img = PhotoImage(file= "< 'file path' >") my_button = Button(root, text='Open TopLevel', command=open).pack() root.mainloop()
@procode6881
@procode6881 4 года назад
Thanks for your help,they help me a lot!
@-kerplink-7738
@-kerplink-7738 3 года назад
I've noticed that you can open the same window twice at once using this method, is there a way to make it so you can only open the second window so no more than one at a time can be opened?
@audisgamers6681
@audisgamers6681 3 года назад
Very helpful video! But I do have a query: when I use this open new window function, the treeview that I have specified to show up doesn't have any data in it. It's just an empty treeview. Can anybody help me with this? Thanks!
@creativecore3575
@creativecore3575 3 года назад
This is master class material! Thank you Codemy :)
@Codemycom
@Codemycom 3 года назад
You're very welcome!
@milanspanko241
@milanspanko241 2 года назад
And again, you spared me a lot more sleepless nights trying to figure out this struggle. Thanks, Codemy :-)
@Codemycom
@Codemycom 2 года назад
Happy to help!
@stivunnikolov5941
@stivunnikolov5941 3 года назад
Its freaky friday here in vegas. Your vids are great man
@Codemycom
@Codemycom 3 года назад
Thanks!
@TheKen82815
@TheKen82815 2 года назад
Cannot express how grateful I am to you. Thanks!!
@Codemycom
@Codemycom 2 года назад
Thanks! Glad you're enjoying the videos!
@funnyclips2696
@funnyclips2696 2 года назад
I so much enjoy your tutorials.... 👌🏾👍🏾
@Codemycom
@Codemycom 2 года назад
Glad to hear it!
@greg_pizzatower
@greg_pizzatower 2 года назад
just what i needed thanks
@Codemycom
@Codemycom 2 года назад
Nice!
@flyingdinosaur8871
@flyingdinosaur8871 2 года назад
THAT GLOBAL THING - Thank you!
@johnpro2847
@johnpro2847 5 лет назад
cool... got one working already, Thanks John.How do you bring the 2nd window back. Destroy command seems to do just that !!!
@Codemycom
@Codemycom 5 лет назад
Glad to hear!
@LifterAndy
@LifterAndy Год назад
'top' variable is inside the function and in some cases may not be in scope. This will sometimes result in an error. NameError: name 'top' is not defined. for the function to work correctly, the top variable must be placed before the function definition, and inside the function itself
@joseluisvelasquezrodriguez5143
@joseluisvelasquezrodriguez5143 4 года назад
Awesome tutorial! Would it work with two touch screens? Say like master screen displayed in a 10in touch screen, and slave displayer in a 7in touch screen.
@Codemycom
@Codemycom 4 года назад
No idea...but I don't see why not
@nagol2678
@nagol2678 2 года назад
Thank you for the video! How do I add a frame to a Toplevel() window? I can't seem to find an answer anywhere.
@paulwatterson5992
@paulwatterson5992 2 года назад
Thanks! great video.
@globalguru21
@globalguru21 3 года назад
please kindly explain how to create second window inside the first main window, just like MDIForm in Visual Basic.
@reginajalandoni3524
@reginajalandoni3524 Год назад
I'm losing my mind why the image is not appearing in my second window. You're really a great help thanks!!
@Codemycom
@Codemycom Год назад
Happy to hear it!
@gauravpatell
@gauravpatell 4 года назад
codemy.com you are awesome . This video helped me a lot. Thanks
@Codemycom
@Codemycom 4 года назад
Glad it helped!
@pverprogramz641
@pverprogramz641 4 года назад
Sir, can a variable or a widget in Toplevel be accessed in the main window ?
@Codemycom
@Codemycom 4 года назад
It depends. Try making the variable global
@Surferdudeoh
@Surferdudeoh 3 года назад
yes obviously
@abdullahtariq95don
@abdullahtariq95don 3 года назад
what logic should apply to if " In one window 6 buttons and behind these btns a new window will open " i mean toplevel() is OK or some other logic should apply?
@abdullahtariq95don
@abdullahtariq95don 3 года назад
what logic should apply to if " In one window has 6 buttons and behind these btns a new window will open " i mean toplevel() is OK or some other logic should apply?
@juanbernal5641
@juanbernal5641 3 года назад
Buen video. Una consulta cuantos def puedo anidar dentro de un def
@pranavguptaa
@pranavguptaa 4 года назад
Using top.mainloop() within the function also displays the image without the use of global variable.WHY?
@Codemycom
@Codemycom 4 года назад
That's just how they built it to work
@pratyushmisra2516
@pratyushmisra2516 4 года назад
great tutorials thanks u for helping me learn Tkinter so easily. want to ask that when I close root window, the toplevel window also closes , so how do i stop that?????
@Codemycom
@Codemycom 4 года назад
Instead of closing the main root window, you can hide it with root.withdraw and bring it back with root.deiconify (put them in buttons or in a function or something that gets called when you create your toplevel window)
@devve7
@devve7 3 года назад
Good for you !! Thanks for the video, helped me!
@Codemycom
@Codemycom 3 года назад
Glad it helped!
@c0dingwithchris
@c0dingwithchris 4 года назад
HI there, if I click on the "create new window" button more than once, the image will ONLY show on the most recent window, and disappears from the previous window. Could you please explain why this happens and a possible work around to get the image to stay on the screen, despite calling "open" multiple times? Thanks in advance!
@bheriraju722
@bheriraju722 3 года назад
# I really dont know why but tried this way and got that working # solution : put the image definition in an array from tkinter import * from PIL import ImageTk,Image img=[] i=0 root=Tk() root.title("Sample window creation") def winopn(): global img,top,lbl1,i top=Toplevel() top.title("Sample second window creation") img.append(ImageTk.PhotoImage(Image.open("d.jpeg")))#instead of d.jpeg you change your image name lbl1=Label(top,image=img[i]).pack() i=i+1 btno=Button(root,text="open the window",command=winopn).pack() root.mainloop() #Well You should put your image name
@bheriraju722
@bheriraju722 3 года назад
#I also did this way from tkinter import * from PIL import ImageTk,Image root=Tk() root.title("Sample window creation") openw=1 def winclose(): global openw,top,btnc openw=1 top.destroy() btnc.pack_forget() def winopn(): global openw,img,top,btnc if openw: top=Toplevel() top.title("Sample second window creation") lbl=Label(top,text="hello I am a new window").pack() img=ImageTk.PhotoImage(Image.open("d.jpeg")) lbl1=Label(top,image=img).pack() openw=0 top.protocol("WM_DELETE_WINDOW", winclose) btnc=Button(root,text="Close the window",command=winclose) btnc.pack() btno=Button(root,text="open the window",command=winopn).pack() root.mainloop()
@vijaykumargupta9259
@vijaykumargupta9259 3 года назад
can you plz help with how first window get close when 2nd opens
@skmplanet9591
@skmplanet9591 4 года назад
Thanks a lot, this is what I was searching
@Codemycom
@Codemycom 4 года назад
Glad you found it then!
@amankumarbairagi794
@amankumarbairagi794 4 года назад
Hello John Sir . But what If we wants to create the third window from the 2nd window tkinter window ! How can we do that ??
@Codemycom
@Codemycom 4 года назад
In the same way
@raniduharshana5238
@raniduharshana5238 4 года назад
thank you so much for this video. Very clear to understand
@Codemycom
@Codemycom 4 года назад
sure thing
@ForOptomeLearning
@ForOptomeLearning 4 года назад
Do we need to import ImageTk ?? Won't PhotoImage alone be sufficient enough to load the image ??
@Codemycom
@Codemycom 4 года назад
Try it without and see
@ForOptomeLearning
@ForOptomeLearning 4 года назад
@@Codemycom Yes Indeed should have tried that. Got my answer now. :) Tkinter only accepts .gif files as an image hence we need to import the ImageTk from the PIL Module to let it import other formats.
@twojdobrykolega8597
@twojdobrykolega8597 11 месяцев назад
why cant I open images? i tried r"...." as raw string. I also tried \\ double backshlshes instead of normal ones. Nothing doesnt work. Help me pls
@andrewhadfield7754
@andrewhadfield7754 4 года назад
Super useful video - thanks!
@Codemycom
@Codemycom 4 года назад
Thanks for watching!
@parsabahrambeik4381
@parsabahrambeik4381 4 года назад
Hi, thank you very much for your video.
@445gautam
@445gautam 3 года назад
Sir I am using OOP. with class involved and I want to popup a window from function present inside a class. but when I write it says 'RAM ROM' (class name) object has no attribute Toplevel.Plz help me sir.
@WalterWhite-dr2yz
@WalterWhite-dr2yz 4 года назад
The image I want to display in the second window is being displayed over the first window. What should I do?
@Codemycom
@Codemycom 4 года назад
You need to designate it to the new window. Make sure your new window is Toplevel() instance, so: new_window = Toplevel() and then make sure your image label references that: my_label = Label(new_window, image=my_img)
@WalterWhite-dr2yz
@WalterWhite-dr2yz 4 года назад
@@Codemycom thx man this saved me a lot of time
@Codemycom
@Codemycom 4 года назад
@@WalterWhite-dr2yz You mean it actually worked? lol ;-)
@WalterWhite-dr2yz
@WalterWhite-dr2yz 4 года назад
Ya dude ur great 👍
@Codemycom
@Codemycom 4 года назад
@@WalterWhite-dr2yz ha thanks
@tarekererajeeva3917
@tarekererajeeva3917 3 года назад
Can you show how to insert values into a database in a second window please
@Codemycom
@Codemycom 3 года назад
Same as doing it in the first window.
@trdgenixyt5920
@trdgenixyt5920 4 года назад
i have a question about the syntax highlighting in a tkinter code editor can you please make a video in this topic would be very helpful for various people around the globe.
@Codemycom
@Codemycom 4 года назад
Sorry, I don't understand what you mean by 'syntax highlighting in a tkinter code editor'
@alexsteinkamp9431
@alexsteinkamp9431 4 года назад
@@Codemycom I think what he's asking about is your IDE and its colorization.
@Codemycom
@Codemycom 4 года назад
@@alexsteinkamp9431 I just use the default Sublime Text.
@samaneeh7264
@samaneeh7264 3 года назад
Hello i have question and i will thank you that help me, I want to create a small program that moves files on my Windows PC from one folder to another, with a simple GUI. How do I do this using python?
@P_Rodd
@P_Rodd 3 года назад
I wonder if you could use command line for that and have python execute the command line.
@samaneeh7264
@samaneeh7264 3 года назад
@@P_Rodd hello thanks for ur answer but i dont know what u means plz help me more
@adityarathi4312
@adityarathi4312 4 года назад
Hello John, How to hide the main root window when the top window is open or get back the root window when top window is destroyed?
@Codemycom
@Codemycom 4 года назад
I have videos on that in the playlist
@Codemycom
@Codemycom 3 года назад
You're very welcome
@varman8048
@varman8048 4 года назад
The video was very helpful....can u also pls tell how to close the root window and not the second window
@Codemycom
@Codemycom 4 года назад
Think I talk about that in the playlist somewhere...
@varman8048
@varman8048 4 года назад
@@Codemycom I actually looked for it but couldn't find it....could u tell me which video particularly if possible
@Codemycom
@Codemycom 4 года назад
@@varman8048 Sorry, you'll have to dig thru them
@varman8048
@varman8048 4 года назад
@@Codemycom ok, Sir...Thanks
@bhushanwagh7192
@bhushanwagh7192 4 года назад
Please make qt designer series
@Codemycom
@Codemycom 4 года назад
I don't know qt designer
@aryamannatrajan4850
@aryamannatrajan4850 4 года назад
Overall amzing tutorials
@Codemycom
@Codemycom 4 года назад
Thanks
@davejenil1537
@davejenil1537 4 года назад
Can you tell me how can I acheive on opening second window by closing first window? Example: I click a button on my first window and second window should open with the first window closed. I have tried withdraw() but facing problem of mainloop still being on even if I close second window.
@Codemycom
@Codemycom 4 года назад
I have a video about this further down the tkinter playlist. Check it out.
@davejenil1537
@davejenil1537 4 года назад
@@Codemycom Okay I will check that! Thanks
@Codemycom
@Codemycom 4 года назад
@@davejenil1537 Sure thing
@mee8963
@mee8963 3 года назад
What will happen if top is assigned as Tk() I have a doubt whether toplevel () which is assigned to top is a keyword...?
@Codemycom
@Codemycom 3 года назад
Give it a try and see
@34__priyadharshini.r62
@34__priyadharshini.r62 4 года назад
Great job sir! Thank you sir
@Codemycom
@Codemycom 4 года назад
You are welcome
@asimjasim6103
@asimjasim6103 4 года назад
Thanks for the video man,great help for my project. Just a doubt: is it possible to open a text file (about 400 lines : about7000 words) in the new window
@Codemycom
@Codemycom 4 года назад
Sure...why not? Check the playlist towards the end, I'm building a text editor where we open text files.
@asimjasim6103
@asimjasim6103 4 года назад
@@Codemycom k man thx , you have been a great help
@Codemycom
@Codemycom 4 года назад
@@asimjasim6103 Happy to help :-)
@hellobro8837
@hellobro8837 3 года назад
Sir, what's is the difference between root.quit & root.destroy? Just wanted to know.
@Codemycom
@Codemycom 3 года назад
For all intents and purposes...not much :-p
@yuxuyang3196
@yuxuyang3196 Месяц назад
I tried to make a third window with the same method but failed. I guess it will require other codes to build a third window on top of the second one?
@Codemycom
@Codemycom Месяц назад
no other code needed, you just did something incorrectly.
@yuxuyang3196
@yuxuyang3196 Месяц назад
@@Codemycom Ohh, I will try again this weekend. Should I define the second top in the first one? I think that's what I did. I would also like to use this opportunity to thank you for all these brilliant videos! They are very informative. I learnt a lot from you. Especially I knew literally nothing abt python but randomly wanted to start learning it someday.
@mee8963
@mee8963 3 года назад
What if we use .quit instead of using destroy..? How to create a third window..?
@P_Rodd
@P_Rodd 3 года назад
Instead of making the image global I create my_img outside the function and then create the label/pack it in the function. Any reason not to do this?
@Codemycom
@Codemycom 3 года назад
Try it and see.
@P_Rodd
@P_Rodd 3 года назад
@@Codemycom So far so good. I guess time will tell if I run into issues as the program grows.
@prbprb2
@prbprb2 3 года назад
How can one add a figure in the new window? I am having trouble and there is a lot of non-working examples on the internet
@Codemycom
@Codemycom 3 года назад
in the same way you put them in the main window...instead of root, use the name of the window
@prbprb2
@prbprb2 3 года назад
@@Codemycom Thanks very much. It is implicit in what you covered, but now I get it.
@infogera1
@infogera1 2 года назад
How Can I do an InternalTopLevel in Python like as JInternalFrame in Java
@Codemycom
@Codemycom 2 года назад
I don't know java
@JFizzzzzzzz
@JFizzzzzzzz 4 года назад
Is there a way when I click open (It opens a new window) the new window opens and is fixed side by side the original window, kind of like a tray? I don't know if I'm explaining what I'm trying to do correctly.
@Codemycom
@Codemycom 4 года назад
yes, you can set the geometry for each with x,y coordinates. Something like: root.geometry("800x800+100+100") other_windows.geometry("800x800+900+100") or something like that
@JFizzzzzzzz
@JFizzzzzzzz 4 года назад
You are a stand up guy thank you so much!!!
@Codemycom
@Codemycom 4 года назад
@@JFizzzzzzzz sure thing!
@robcox500
@robcox500 4 года назад
How is it that the image 'my_img' is not associated with a window?? Is there some default here?
@Codemycom
@Codemycom 4 года назад
Sorry, I'm not sure what you're asking. You did associate it with a window, when you listed it as root.
@robcox500
@robcox500 4 года назад
@@Codemycom Sorry, I worked it out afterwards. The statement "my_img = ImageTk.PhotoImage(Image.open("images/aspen.png")) " simply opens the image but its the label statement below that actually displays the image in the "top" window. So its the label statement doing the work. Thanks, got it!
@mister6497
@mister6497 Год назад
i thought uou would make it: for i in 255: print('Create New Windows in Tkinter - Python Tkinter GUI Tutorial #' + str(i))
@akpanvincent1499
@akpanvincent1499 3 года назад
Please guide me to create a tkinter login system, having mainscreen and subscreen where the username and password is gotten from the user and saved. Then will show invalid if a wrong user inputs details.
@Codemycom
@Codemycom 3 года назад
You can learn everything you need to do that by watching the videos of this playlist.
@jenishshrestha8613
@jenishshrestha8613 3 года назад
whats the difference between . .quit and .destroy???
@Codemycom
@Codemycom 3 года назад
for all intents and purposes...not much
@sakshiharbhajanka2481
@sakshiharbhajanka2481 3 года назад
Best playlist
@Codemycom
@Codemycom 3 года назад
Thanks!
@sakshiharbhajanka2481
@sakshiharbhajanka2481 3 года назад
@@Codemycom How can i make my player (if he opt being 'Tiger' ) appear to a position on my grid where i mouse click
@Codemycom
@Codemycom 3 года назад
@@sakshiharbhajanka2481 USe binding...I have videos on that.
@sandrogianni1821
@sandrogianni1821 2 года назад
please, but in second window, how insert Entry, label and execute whith button? alwwais in second windows
@Codemycom
@Codemycom 2 года назад
The same way as with a first window.
@Beast80K
@Beast80K 4 года назад
Sir, i created a button on clicking opens window1 but it creates window2,3,4.... on every click i want to limit that only one window. Any solution.
@Codemycom
@Codemycom 4 года назад
Disable the button after one click... myButton['state'] = DISABLED
@vipinpainuly9998
@vipinpainuly9998 4 года назад
Sir I want to know how to import another window in python where I can add new labels entry text field
@Codemycom
@Codemycom 4 года назад
Sorry, I don't know what that means
@gold_miner.
@gold_miner. 3 года назад
Sir jab mai new window me koi normal data insert kar rha hu to wo usi window me insert ho ja rha button pe click karne ke baad. Actually mai usme Python code Krna chahta hun magar mujse ho nhi pa rha. 🙏🙏🙏 Pls sir help me
@nicolasrosso3800
@nicolasrosso3800 4 года назад
is it possible to instead of just opening a second window also close the first, so that the second window is all that remains on screen?
@Codemycom
@Codemycom 4 года назад
yes
@nicolasrosso3800
@nicolasrosso3800 4 года назад
@@Codemycom what should I google to be able to see how it'd done?
@Codemycom
@Codemycom 4 года назад
@@nicolasrosso3800 Check the playlist, pretty sure I did a video on it
@GelsYT
@GelsYT 4 года назад
Thank you =)
@Codemycom
@Codemycom 4 года назад
You're very welcome!
@GelsYT
@GelsYT 4 года назад
@@Codemycom I love your tutorials man! =) you explain and do it in the simplest waaaaaay and that is what most of us need
@Codemycom
@Codemycom 4 года назад
@@GelsYT Glad you're enjoying them!
@GelsYT
@GelsYT 4 года назад
@@Codemycom Hello again! may I ask if you have a tutorial on how to display new window is an item is clicked from a dropdown? thank you
@Codemycom
@Codemycom 4 года назад
@@GelsYT No, but do you click a button after selecting an item in a drop down? Because if so it's no different than any button being clicked..you'd just need to run some if/else statements to determine which drop down was selected.
@krishnakotni9231
@krishnakotni9231 4 года назад
why is the image quality in the tkinter is pretty bad. While displaying an image in the tkinter it looks pretty bad. Any idea how to make everything look beautiful. (i tried ttk),
@Codemycom
@Codemycom 4 года назад
It looks fine to me...not bad at all.
@juanpaperez100
@juanpaperez100 5 лет назад
But if i want to close the first window when the second windows is open, ¿how i do it?, for example, i will do a program with many pages, so, i don't want that always the before windows showed when i created a new it. (Sorry for my english im practicing )
@Codemycom
@Codemycom 5 лет назад
Great Question! use root.withdraw() to hide our main root window, and root.deiconify() to bring it back.
@procode6881
@procode6881 4 года назад
Do you know the reason why .pack() and .grid() cannot be present in a single window
@Codemycom
@Codemycom 4 года назад
They can be, but just not in the same parent. So if you pack a frame onto a window...inside the frame you can grid etc.
@procode6881
@procode6881 4 года назад
@@Codemycom thanks !!!
@Codemycom
@Codemycom 4 года назад
@@procode6881 sure thing
@javadmahdavi1151
@javadmahdavi1151 3 года назад
Hi, I have two files x2_ui.py and x1_ui.py that I want to open in a file as a window. How should I do this?
@Codemycom
@Codemycom 3 года назад
Without knowing what those files are, I couldn’t possibly say
@javadmahdavi1151
@javadmahdavi1151 3 года назад
@@Codemycom I have two files (F1.py) and (F2.py), each of which is a window, and I have another file called (main.py) that opens a window with two buttons, I want to click one of the (F1) files every time Or (F2) open. What should I do ?
@Codemycom
@Codemycom 3 года назад
@@javadmahdavi1151 import the python files into the main file in the normal way and just call them as you would call any new window with tkinter. I have videos on each of those things on the playlist
@javadmahdavi1151
@javadmahdavi1151 3 года назад
@@Codemycom Thank's for your help can you give me a link of title of that video?
@javadmahdavi1151
@javadmahdavi1151 3 года назад
@@Codemycom When I import all the files in the first code, all my files are opened and executed involuntarily. And also when I import them in a function I get this error. (_ Tkinter.TclError: image "pyimage2" does not exist)
@Momo-bb2fn
@Momo-bb2fn 3 года назад
6:45 why img didn't load, due to scope
@parul0601
@parul0601 4 года назад
how do I solve this problem? It is coming after a day but before a day this was not coming?: line 13, in my_img1 = ImageTk.PhotoImage(Image.open("images/de2.gif")) AttributeError: type object 'Image' has no attribute 'open'
@Codemycom
@Codemycom 4 года назад
maybe it can't handle .gif's....did you import Image at the top of your file? Spell it with a capital I?
@parul0601
@parul0601 4 года назад
@@Codemycom i have done it still it doesn't work??
@parul0601
@parul0601 4 года назад
it shows that the image has no attribute 'open'
@parul0601
@parul0601 4 года назад
@@Codemycom yesterday it was working nicely but now it just stopped??? it is showing that 'ATTRIBUTE ERROR'????
@Codemycom
@Codemycom 4 года назад
@@parul0601 yes, I know all that already. You can't use .gif images. Try a png or jpg
@Kalpesh2331991
@Kalpesh2331991 3 года назад
button on root screen will open second window multiple times, how can i prevent to opn window, if it is already opened once
@Codemycom
@Codemycom 3 года назад
Use a counter and if statement
@lucianmardale10
@lucianmardale10 2 года назад
Hello. Did you succeed with a counter? Me no :(
@lucianmardale10
@lucianmardale10 2 года назад
@@Codemycom I just saw this video ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-H_zZiIlnB8M.html and I don't want to limit at 1. I would like the counter to decrease after the window is closed, so window can be opened and closed many times. It is possible? Thank you!
@Codemycom
@Codemycom 2 года назад
@@lucianmardale10 sure, why not...just change the counter
@sahilnigam4536
@sahilnigam4536 3 года назад
ofc a udemy ad is required before the video starts
@Codemycom
@Codemycom 3 года назад
Yeah, that's how youtube works.
@sanjayrajasreeraja3456
@sanjayrajasreeraja3456 4 года назад
sir how can we close the existing window and then open a new window with a button.
@Codemycom
@Codemycom 4 года назад
Check the playlist, I go over that
@Max-lr6dk
@Max-lr6dk 4 года назад
Why not using a class where you fix ImageTk as self.ImageTk ?
@Codemycom
@Codemycom 4 года назад
Why bother?
@deki90to
@deki90to 4 года назад
I have a problem, I want to use two pictures, first for main and second for second window, so, in first window everything is ok, when I run it, but...if I run another window, first window lost wallpaper, why? How to fix?
@Codemycom
@Codemycom 4 года назад
Without seeing your code, I couldn't guess...
@deki90to
@deki90to 4 года назад
@@Codemycom give mi 3min, I'll give you link
@deki90to
@deki90to 4 года назад
@@Codemycom files.fm/u/r2dea99z Ok it was 23min xD Was trying to fix, but nothing
@deki90to
@deki90to 4 года назад
@@Codemycom How code should look if I want background, like on window behind it?
@Codemycom
@Codemycom 4 года назад
@@deki90to check my tkinter playlist, I have videos on images
@shaunakn5881
@shaunakn5881 4 года назад
how to open another window inside a toplevel()? pls reply
@Codemycom
@Codemycom 4 года назад
just name it like before
@shaunakn5881
@shaunakn5881 4 года назад
@@Codemycom sir i did it and it said TopLevel() not defined so I tried "Tk()" and it worked lol.. anyways sir you are my inspiration to code tkinter thanks very much may you get a billion subs
@fastandfurious2171
@fastandfurious2171 Год назад
why I can't use from tkinder import * it showing error at from that is unused import(s)
@Codemycom
@Codemycom Год назад
you misspelled tkinter
@fastandfurious2171
@fastandfurious2171 Год назад
@@Codemycom sorry but while typing I used correct spelling of tkinter, did I need to install all imports like Button, Label,Tk....
@fastandfurious2171
@fastandfurious2171 Год назад
note: typing in VS Code not in this comment
@Codemycom
@Codemycom Год назад
@@fastandfurious2171 I would never use VS Code for tkinter. I have no idea how you need to setup VS Code for tkinter
@avact6226
@avact6226 4 года назад
which version of python are you using?
@Codemycom
@Codemycom 4 года назад
The latest version...it doesn't matter.
@AdityaSharma-no5ix
@AdityaSharma-no5ix 4 года назад
can't I use Tk() instead of Toplevel() ? Edit:whats the main difference
@Codemycom
@Codemycom 4 года назад
No, you already use Tk()
@aryamannatrajan4850
@aryamannatrajan4850 4 года назад
You can do it by Tk() also I tried u do not need to do it by Toplevel()
@Codemycom
@Codemycom 4 года назад
Yes you can, but you'll run into problems doing it that way.
@aryamannatrajan4850
@aryamannatrajan4850 4 года назад
@@Codemycom can you please tell me the errors that i can get
@Codemycom
@Codemycom 4 года назад
@@aryamannatrajan4850 No. Why not just do it the way you're supposed to.
@TogrulKazimov
@TogrulKazimov 4 года назад
I got this error: NameError: name 'Toplevel' is not defined
@Codemycom
@Codemycom 4 года назад
Check your code for typos
@evinlerrickmosca4853
@evinlerrickmosca4853 3 года назад
can you help me the submit button does not exit on my new window :(
@evinlerrickmosca4853
@evinlerrickmosca4853 3 года назад
from tkinter import * from tkinter.ttk import* def play(): top = Toplevel() top.title("Riddle me this") top.geometry("500x500") Label(top,text ="1. Riddle: What starts with ‘e,' ends with ‘e,' and contains one letter?").pack() Label(top,text ="Type your guess, or type 'hint' or give up' in cmd.").pack() entry1 = Entry(top, text ="").pack() guess = entry1.get() b1 = Button(top, text="Submit").pack() print(guess) root = Tk() root.title("asdasd") app = Frame(root) app.grid() playb = Button(app, text = "Play", command = play) playb.grid() root.mainloop() here's my code
@Codemycom
@Codemycom 3 года назад
you you using IDLE?
@evinlerrickmosca4853
@evinlerrickmosca4853 3 года назад
Yes sir
@MedTech1
@MedTech1 3 года назад
I want to create a new window for my TextEditor And I just want to duplicate my Default window
@Codemycom
@Codemycom 3 года назад
go for it
@mohammadsorour1
@mohammadsorour1 3 года назад
how can open new window in the same root window
@Codemycom
@Codemycom 3 года назад
you don't open windows inside windows....they are definitionally outside each other.
Далее
Open Files Dialog Box - Python Tkinter GUI Tutorial #15
12:34
How to Pass Data between Multiple Windows in Tkinter
18:19
The grid layout method in tkinter
22:44
Просмотров 30 тыс.
creating tables in tkinter with the treeview widget
14:44
Using tkinter with classes
28:23
Просмотров 64 тыс.
C++ Developer Learns Python
9:26
Просмотров 2,7 млн
Tkinter Layout Managers - Simple Crash Course
15:43
Просмотров 8 тыс.