▶️ 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
@prbprb23 жыл бұрын
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?
@mikem89155 жыл бұрын
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 Жыл бұрын
thanks, I was thinking in that problem while working in my project, now I do not have to get headache trying to solve it.
@kennethobeng91273 жыл бұрын
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.
@Codemycom3 жыл бұрын
haha nice
@JadeJuno3 жыл бұрын
I'm currently doing just that lol
@janpaweii31152 жыл бұрын
Im on 2 weeks sick leave and im bingewhatching all of theese videos :D
@sarthaksrivastava62824 жыл бұрын
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?
@Codemycom4 жыл бұрын
you can use toplevel again, just give it another variable name...or you can name them anything you want
@campanion4 жыл бұрын
idk what I'd do without you
@Codemycom4 жыл бұрын
Glad you're enjoying the videos :-)
@milanspanko2412 жыл бұрын
And again, you spared me a lot more sleepless nights trying to figure out this struggle. Thanks, Codemy :-)
@Codemycom2 жыл бұрын
Happy to help!
@-kerplink-77383 жыл бұрын
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?
@TheKen828152 жыл бұрын
Cannot express how grateful I am to you. Thanks!!
@Codemycom2 жыл бұрын
Thanks! Glad you're enjoying the videos!
@creativecore35753 жыл бұрын
This is master class material! Thank you Codemy :)
@Codemycom3 жыл бұрын
You're very welcome!
@victornunes58882 жыл бұрын
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.
@Codemycom2 жыл бұрын
You're wrong. Tkinter's garbage function does a thing if you don't use global.
@victornunes58882 жыл бұрын
@@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()
@circuit68964 жыл бұрын
This actually really helped for my assignment in programming, cheers for this!! Question though, can I have two Toplevels working under different defs?
@Codemycom4 жыл бұрын
sure, just call them different things..that's how you open a second window for instance
@reginajalandoni3524 Жыл бұрын
I'm losing my mind why the image is not appearing in my second window. You're really a great help thanks!!
@Codemycom Жыл бұрын
Happy to hear it!
@stivunnikolov59413 жыл бұрын
Its freaky friday here in vegas. Your vids are great man
@Codemycom3 жыл бұрын
Thanks!
@procode68814 жыл бұрын
Thanks for your help,they help me a lot!
@funnyclips26962 жыл бұрын
I so much enjoy your tutorials.... 👌🏾👍🏾
@Codemycom2 жыл бұрын
Glad to hear it!
@flyingdinosaur88712 жыл бұрын
THAT GLOBAL THING - Thank you!
@gauravpatell4 жыл бұрын
codemy.com you are awesome . This video helped me a lot. Thanks
@Codemycom4 жыл бұрын
Glad it helped!
@paulwatterson59922 жыл бұрын
Thanks! great video.
@devve73 жыл бұрын
Good for you !! Thanks for the video, helped me!
@Codemycom3 жыл бұрын
Glad it helped!
@amankumarbairagi7944 жыл бұрын
Hello John Sir . But what If we wants to create the third window from the 2nd window tkinter window ! How can we do that ??
@Codemycom4 жыл бұрын
In the same way
@joseluisvelasquezrodriguez51434 жыл бұрын
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.
@Codemycom4 жыл бұрын
No idea...but I don't see why not
@skmplanet95914 жыл бұрын
Thanks a lot, this is what I was searching
@Codemycom4 жыл бұрын
Glad you found it then!
@mister6497 Жыл бұрын
i thought uou would make it: for i in 255: print('Create New Windows in Tkinter - Python Tkinter GUI Tutorial #' + str(i))
@445gautam3 жыл бұрын
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.
@raniduharshana52384 жыл бұрын
thank you so much for this video. Very clear to understand
@Codemycom4 жыл бұрын
sure thing
@abdullahtariq95don3 жыл бұрын
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?
@abdullahtariq95don3 жыл бұрын
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?
@pverprogramz6414 жыл бұрын
Sir, can a variable or a widget in Toplevel be accessed in the main window ?
@Codemycom4 жыл бұрын
It depends. Try making the variable global
@Surferdudeoh3 жыл бұрын
yes obviously
@juanbernal56413 жыл бұрын
Buen video. Una consulta cuantos def puedo anidar dentro de un def
@andrewhadfield77544 жыл бұрын
Super useful video - thanks!
@Codemycom4 жыл бұрын
Thanks for watching!
@parsabahrambeik43814 жыл бұрын
Hi, thank you very much for your video.
@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Ай бұрын
no other code needed, you just did something incorrectly.
@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.
@c0dingwithchris4 жыл бұрын
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!
@bheriraju7223 жыл бұрын
# 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
@bheriraju7223 жыл бұрын
#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()
@mee89633 жыл бұрын
What if we use .quit instead of using destroy..? How to create a third window..?
@hellobro88373 жыл бұрын
Sir, what's is the difference between root.quit & root.destroy? Just wanted to know.
@Codemycom3 жыл бұрын
For all intents and purposes...not much :-p
@pranavguptaa4 жыл бұрын
Using top.mainloop() within the function also displays the image without the use of global variable.WHY?
@Codemycom4 жыл бұрын
That's just how they built it to work
@mee89633 жыл бұрын
What will happen if top is assigned as Tk() I have a doubt whether toplevel () which is assigned to top is a keyword...?
@Codemycom3 жыл бұрын
Give it a try and see
@ะ้ฟืฟแ้นะพพําพําพําพํา4 жыл бұрын
thank you ,teacher
@Codemycom4 жыл бұрын
You're very welcome
@adityarathi43124 жыл бұрын
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?
@Codemycom4 жыл бұрын
I have videos on that in the playlist
@34__priyadharshini.r624 жыл бұрын
Great job sir! Thank you sir
@Codemycom4 жыл бұрын
You are welcome
@varman80484 жыл бұрын
The video was very helpful....can u also pls tell how to close the root window and not the second window
@Codemycom4 жыл бұрын
Think I talk about that in the playlist somewhere...
@varman80484 жыл бұрын
@@Codemycom I actually looked for it but couldn't find it....could u tell me which video particularly if possible
@Codemycom4 жыл бұрын
@@varman8048 Sorry, you'll have to dig thru them
@varman80484 жыл бұрын
@@Codemycom ok, Sir...Thanks
@bhushanwagh71924 жыл бұрын
Please make qt designer series
@Codemycom4 жыл бұрын
I don't know qt designer
@jenishshrestha86133 жыл бұрын
whats the difference between . .quit and .destroy???
@Codemycom3 жыл бұрын
for all intents and purposes...not much
@infogera12 жыл бұрын
How Can I do an InternalTopLevel in Python like as JInternalFrame in Java
@Codemycom2 жыл бұрын
I don't know java
@davejenil15374 жыл бұрын
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.
@Codemycom4 жыл бұрын
I have a video about this further down the tkinter playlist. Check it out.
@davejenil15374 жыл бұрын
@@Codemycom Okay I will check that! Thanks
@Codemycom4 жыл бұрын
@@davejenil1537 Sure thing
@parul06014 жыл бұрын
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'
@Codemycom4 жыл бұрын
maybe it can't handle .gif's....did you import Image at the top of your file? Spell it with a capital I?
@parul06014 жыл бұрын
@@Codemycom i have done it still it doesn't work??
@parul06014 жыл бұрын
it shows that the image has no attribute 'open'
@parul06014 жыл бұрын
@@Codemycom yesterday it was working nicely but now it just stopped??? it is showing that 'ATTRIBUTE ERROR'????
@Codemycom4 жыл бұрын
@@parul0601 yes, I know all that already. You can't use .gif images. Try a png or jpg
@Integrate2 Жыл бұрын
File "", line 2, in ImportError: cannot import name 'ImageTK' from 'PIL' (/usr/lib/python3/dist-packages/PIL/__init__.py)
@javadmahdavi11513 жыл бұрын
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?
@Codemycom3 жыл бұрын
Without knowing what those files are, I couldn’t possibly say
@javadmahdavi11513 жыл бұрын
@@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 ?
@Codemycom3 жыл бұрын
@@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
@javadmahdavi11513 жыл бұрын
@@Codemycom Thank's for your help can you give me a link of title of that video?
@javadmahdavi11513 жыл бұрын
@@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)
@sakshiharbhajanka24813 жыл бұрын
Best playlist
@Codemycom3 жыл бұрын
Thanks!
@sakshiharbhajanka24813 жыл бұрын
@@Codemycom How can i make my player (if he opt being 'Tiger' ) appear to a position on my grid where i mouse click
@Codemycom3 жыл бұрын
@@sakshiharbhajanka2481 USe binding...I have videos on that.
@JFizzzzzzzz4 жыл бұрын
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.
@Codemycom4 жыл бұрын
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
@JFizzzzzzzz4 жыл бұрын
You are a stand up guy thank you so much!!!
@Codemycom4 жыл бұрын
@@JFizzzzzzzz sure thing!
@nicolasrosso38004 жыл бұрын
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?
@Codemycom4 жыл бұрын
yes
@nicolasrosso38004 жыл бұрын
@@Codemycom what should I google to be able to see how it'd done?
@Codemycom4 жыл бұрын
@@nicolasrosso3800 Check the playlist, pretty sure I did a video on it
@procode68814 жыл бұрын
Do you know the reason why .pack() and .grid() cannot be present in a single window
@Codemycom4 жыл бұрын
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.
@procode68814 жыл бұрын
@@Codemycom thanks !!!
@Codemycom4 жыл бұрын
@@procode6881 sure thing
@shubhanshusharma53723 жыл бұрын
How to set toplevel image as background image
@Codemycom3 жыл бұрын
make your image variable global
@krishnakotni92314 жыл бұрын
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),
@Codemycom4 жыл бұрын
It looks fine to me...not bad at all.
@Momo-bb2fn3 жыл бұрын
6:45 why img didn't load, due to scope
@shaunakn58814 жыл бұрын
how to open another window inside a toplevel()? pls reply
@Codemycom4 жыл бұрын
just name it like before
@shaunakn58814 жыл бұрын
@@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
@sanjayrajasreeraja34564 жыл бұрын
sir how can we close the existing window and then open a new window with a button.
@Codemycom4 жыл бұрын
Check the playlist, I go over that
@evinlerrickmosca48533 жыл бұрын
can you help me the submit button does not exit on my new window :(
@evinlerrickmosca48533 жыл бұрын
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
@Codemycom3 жыл бұрын
you you using IDLE?
@evinlerrickmosca48533 жыл бұрын
Yes sir
@GelsYT4 жыл бұрын
Thank you =)
@Codemycom4 жыл бұрын
You're very welcome!
@GelsYT4 жыл бұрын
@@Codemycom I love your tutorials man! =) you explain and do it in the simplest waaaaaay and that is what most of us need
@Codemycom4 жыл бұрын
@@GelsYT Glad you're enjoying them!
@GelsYT4 жыл бұрын
@@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
@Codemycom4 жыл бұрын
@@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.
@juanpaperez1005 жыл бұрын
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 )
@Codemycom5 жыл бұрын
Great Question! use root.withdraw() to hide our main root window, and root.deiconify() to bring it back.
@MedTech13 жыл бұрын
I want to create a new window for my TextEditor And I just want to duplicate my Default window
@Codemycom3 жыл бұрын
go for it
@aryamannatrajan48504 жыл бұрын
You can do it by Tk() also I tried u do not need to do it by Toplevel()
@Codemycom4 жыл бұрын
Yes you can, but you'll run into problems doing it that way.
@aryamannatrajan48504 жыл бұрын
@@Codemycom can you please tell me the errors that i can get
@Codemycom4 жыл бұрын
@@aryamannatrajan4850 No. Why not just do it the way you're supposed to.
@mohammadsorour13 жыл бұрын
how can open new window in the same root window
@Codemycom3 жыл бұрын
you don't open windows inside windows....they are definitionally outside each other.
@dr.strawberry76124 жыл бұрын
I tried this trick but when I did it it said top was not defined! PLEASE HELP!!!
@Codemycom4 жыл бұрын
Rewatch the video and check your code for errors.
@rithiksaran Жыл бұрын
Sir can you please make a vidieo on how to play GIF in tkinter window. PLEASE SIR, I request
@Codemycom Жыл бұрын
No, sorry. There's no easy way to do that in Tkinter.
@rithiksaran Жыл бұрын
Sir, then how can i play loading scenes in tkinter?
@rithiksaran Жыл бұрын
Please help me sir
@Codemycom Жыл бұрын
@@rithiksaran This video shows you how to create new windows.
@rithiksaran Жыл бұрын
No sir, How can i create a loading screen? Please teach me sir
@ninjatribble79614 жыл бұрын
Are you in Vegas?
@Codemycom4 жыл бұрын
Yes
@ninjatribble79614 жыл бұрын
@@Codemycom 😂 loving the tkinter playlist so far. These are just the kind of tutorials I was looking for. Thanks
@Codemycom4 жыл бұрын
@@ninjatribble7961 Awesome, glad you like em!
@randatebina74214 жыл бұрын
I do not own the Pil Library What do I do ?!
@Codemycom4 жыл бұрын
It's free, follow the video and pip install from the terminal
@learnwithstranger5754 жыл бұрын
When you do something wrong then why you blame Vaga's huh?
@Codemycom4 жыл бұрын
huh?
@mister6497 Жыл бұрын
you messed up on the title it says ''tKinter' instead of 'TKinter'
@Codemycom Жыл бұрын
So?
@yamin17024 жыл бұрын
I am having a problem with a login system. Here's the code: from tkinter import * from tkinter import messagebox win = Tk() win.geometry("500x500+100+100") win.title("Hello") lbl = Label(win, text = "Please login below").pack() lbl = Label(win, text = "").pack() lbl = Label(win, text = "").pack() lbl = Label(win, text = "Username").pack() entry1 = Entry(win).pack() lbl = Label(win, text = "").pack() lbl = Label(win, text = "Password").pack() entry2 = Entry(win).pack() lbl = Label(win, text = "").pack() error_text= StringVar() login_label = Label(win, textvariable=error_text, font=('bold', 14), pady=5, fg='red').pack() username = "aaa" password = 111 def login(): if entry1 == username and entry2 == password: new = Tk() new.geometry("500x500+100+100") new.title("Hello new") win.destroy() btn = Button(win, text = "Login", command = login).pack() mainloop() when I try to run it with the correct username and password, the new window doesn't open even though I have defined the username and password. I have written "new = Tk() " under the function as well.
@Codemycom4 жыл бұрын
What error do you get? What does the terminal say?
@yamin17024 жыл бұрын
I don't get an error and there is nothing on terminal. The problem is that the following function just does not work: username = "aaa" password = 111 def login(): if entry1 == username and entry2 == password: new = Tk() new.geometry("500x500+100+100") new.title("Hello new") win.destroy()
@Codemycom4 жыл бұрын
@@yamin1702 entry.get() and entry2.get()
@Binford354 жыл бұрын
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.
@Codemycom4 жыл бұрын
Yep...you can use global variables too, to get around that...
@Codemycom4 жыл бұрын
You're welcome!
@audisgamers66813 жыл бұрын
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!
@lynnmcgarry25803 жыл бұрын
3 days I've spent on this and you solved it in a couple of mins. Can't thank you enough.
@Codemycom3 жыл бұрын
Awesome, glad you found it!
@sahilnigam45363 жыл бұрын
ofc a udemy ad is required before the video starts
@Codemycom3 жыл бұрын
Yeah, that's how youtube works.
@twojdobrykolega8597 Жыл бұрын
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
@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
@vijaykumargupta92593 жыл бұрын
can you plz help with how first window get close when 2nd opens
@johnpro28475 жыл бұрын
cool... got one working already, Thanks John.How do you bring the 2nd window back. Destroy command seems to do just that !!!
@Codemycom5 жыл бұрын
Glad to hear!
@manikandannatarajan96654 жыл бұрын
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
@Codemycom4 жыл бұрын
Great to hear!
@WHWrooolz4 жыл бұрын
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?
@Codemycom4 жыл бұрын
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.
@WHWrooolz4 жыл бұрын
Codemy.com thanks!
@TogrulKazimov4 жыл бұрын
I got this error: NameError: name 'Toplevel' is not defined
@Codemycom4 жыл бұрын
Check your code for typos
@uselessvirus3827 Жыл бұрын
Freshman here, It is possible to add animation to my rock paper scissors game and picture? I desperately need help💀🙏
@Codemycom Жыл бұрын
You can add a timer
@greg_pizzatower2 жыл бұрын
just what i needed thanks
@Codemycom2 жыл бұрын
Nice!
@sandrogianni18212 жыл бұрын
please, but in second window, how insert Entry, label and execute whith button? alwwais in second windows
@Codemycom2 жыл бұрын
The same way as with a first window.
@globalguru213 жыл бұрын
please kindly explain how to create second window inside the first main window, just like MDIForm in Visual Basic.
@nagol26782 жыл бұрын
Thank you for the video! How do I add a frame to a Toplevel() window? I can't seem to find an answer anywhere.
@WalterWhite-dr2yz4 жыл бұрын
The image I want to display in the second window is being displayed over the first window. What should I do?
@Codemycom4 жыл бұрын
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-dr2yz4 жыл бұрын
@@Codemycom thx man this saved me a lot of time
@Codemycom4 жыл бұрын
@@WalterWhite-dr2yz You mean it actually worked? lol ;-)
@WalterWhite-dr2yz4 жыл бұрын
Ya dude ur great 👍
@Codemycom4 жыл бұрын
@@WalterWhite-dr2yz ha thanks
@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
@prbprb23 жыл бұрын
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
@Codemycom3 жыл бұрын
in the same way you put them in the main window...instead of root, use the name of the window
@prbprb23 жыл бұрын
@@Codemycom Thanks very much. It is implicit in what you covered, but now I get it.
@robcox5004 жыл бұрын
How is it that the image 'my_img' is not associated with a window?? Is there some default here?
@Codemycom4 жыл бұрын
Sorry, I'm not sure what you're asking. You did associate it with a window, when you listed it as root.
@robcox5004 жыл бұрын
@@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!
@laurentreynaud44043 жыл бұрын
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
@Codemycom3 жыл бұрын
You're welcome 😊
@sumedhasharma19843 жыл бұрын
So you used Google translate to write this comment??
@laurentreynaud44043 жыл бұрын
@@sumedhasharma1984 yes, I'm sorry but my english level is very low :(
@ForOptomeLearning4 жыл бұрын
Do we need to import ImageTk ?? Won't PhotoImage alone be sufficient enough to load the image ??
@Codemycom4 жыл бұрын
Try it without and see
@ForOptomeLearning4 жыл бұрын
@@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.
@sulagnadas9085 жыл бұрын
Why the Label thing doesn't work in my second window😥.... The error says... Can't invoke 'label' command: the application has been destroyed Plss help me out someone... I need to complete my project 😫
@Codemycom5 жыл бұрын
Check your code, you likely have a typo
@akpanvincent14994 жыл бұрын
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.
@Codemycom4 жыл бұрын
You can learn everything you need to do that by watching the videos of this playlist.
@fastandfurious2171 Жыл бұрын
why I can't use from tkinder import * it showing error at from that is unused import(s)
@Codemycom Жыл бұрын
you misspelled tkinter
@fastandfurious2171 Жыл бұрын
@@Codemycom sorry but while typing I used correct spelling of tkinter, did I need to install all imports like Button, Label,Tk....
@fastandfurious2171 Жыл бұрын
note: typing in VS Code not in this comment
@Codemycom Жыл бұрын
@@fastandfurious2171 I would never use VS Code for tkinter. I have no idea how you need to setup VS Code for tkinter
@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 Жыл бұрын
Welcome
@Kalpesh23319913 жыл бұрын
button on root screen will open second window multiple times, how can i prevent to opn window, if it is already opened once
@Codemycom3 жыл бұрын
Use a counter and if statement
@lucianmardale102 жыл бұрын
Hello. Did you succeed with a counter? Me no :(
@lucianmardale102 жыл бұрын
@@Codemycom I just saw this video kzbin.info/www/bejne/fpDdi5x_odN1bq8 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!
@Codemycom2 жыл бұрын
@@lucianmardale10 sure, why not...just change the counter
@Beast80K4 жыл бұрын
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.
@Codemycom4 жыл бұрын
Disable the button after one click... myButton['state'] = DISABLED
@AdityaSharma-no5ix4 жыл бұрын
can't I use Tk() instead of Toplevel() ? Edit:whats the main difference
@Codemycom4 жыл бұрын
No, you already use Tk()
@thetwenty67844 жыл бұрын
Tkinter looks ugly. Is there any GUI of python for Android Irrespect of Kivy.
@Codemycom4 жыл бұрын
It looks how you code it...
@thetwenty67844 жыл бұрын
@@Codemycom can you refer some apps designed in tkinter
@Codemycom4 жыл бұрын
@@thetwenty6784 I have no idea
@thetwenty67844 жыл бұрын
@@Codemycom okay That's Great.
@P_Rodd3 жыл бұрын
@@thetwenty6784 I think IDLE is written in Tkinter