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

Поделиться
HTML-код
  • Опубликовано: 4 окт 2024

Комментарии • 283

  • @Codemycom
    @Codemycom  4 года назад +8

    ▶️ Watch Entire Tkinter Playlist ✅ Subscribe To My RUclips 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 года назад +26

    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 года назад +2

      haha nice

    • @JadeJuno
      @JadeJuno 3 года назад +2

      I'm currently doing just that lol

    • @janpaweii3115
      @janpaweii3115 2 года назад +2

      Im on 2 weeks sick leave and im bingewhatching all of theese videos :D

  • @lynnmcgarry2580
    @lynnmcgarry2580 3 года назад +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!

  • @manikandannatarajan9665
    @manikandannatarajan9665 4 года назад +1

    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

  • @mikem8915
    @mikem8915 5 лет назад +34

    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.

  • @jamalalkelani4439
    @jamalalkelani4439 4 года назад

    Your videos are the best on RUclips.
    professional, clear, smart, easy to understand ... etc

  • @Codemycom
    @Codemycom  4 года назад +2

    You're welcome!

  • @campanion
    @campanion 4 года назад +1

    idk what I'd do without you

    • @Codemycom
      @Codemycom  4 года назад

      Glad you're enjoying the videos :-)

  • @Binford35
    @Binford35 4 года назад +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 года назад +1

      Yep...you can use global variables too, to get around that...

  • @WHWrooolz
    @WHWrooolz 4 года назад +1

    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 года назад +1

      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!

  • @laurentreynaud4404
    @laurentreynaud4404 3 года назад +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 года назад +1

      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 :(

  • @milanspanko241
    @milanspanko241 2 года назад

    And again, you spared me a lot more sleepless nights trying to figure out this struggle. Thanks, Codemy :-)

  • @sarthaksrivastava6282
    @sarthaksrivastava6282 4 года назад +3

    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 года назад +3

      you can use toplevel again, just give it another variable name...or you can name them anything you want

  • @TheKen82815
    @TheKen82815 2 года назад

    Cannot express how grateful I am to you. Thanks!!

    • @Codemycom
      @Codemycom  2 года назад

      Thanks! Glad you're enjoying the videos!

  • @creativecore3575
    @creativecore3575 3 года назад +1

    This is master class material! Thank you Codemy :)

    • @Codemycom
      @Codemycom  3 года назад

      You're very welcome!

  • @stivunnikolov5941
    @stivunnikolov5941 3 года назад

    Its freaky friday here in vegas. Your vids are great man

  • @-kerplink-7738
    @-kerplink-7738 3 года назад +2

    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?

  • @victornunes5888
    @victornunes5888 2 года назад +1

    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()

  • @flyingdinosaur8871
    @flyingdinosaur8871 2 года назад

    THAT GLOBAL THING - Thank you!

  • @procode6881
    @procode6881 4 года назад +2

    Thanks for your help,they help me a lot!

  • @circuit6896
    @circuit6896 4 года назад +2

    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 года назад +2

      sure, just call them different things..that's how you open a second window for instance

  • @audisgamers6681
    @audisgamers6681 3 года назад +2

    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!

  • @funnyclips2696
    @funnyclips2696 2 года назад

    I so much enjoy your tutorials.... 👌🏾👍🏾

  • @gauravpatell
    @gauravpatell 4 года назад

    codemy.com you are awesome . This video helped me a lot. Thanks

  • @reginajalandoni3524
    @reginajalandoni3524 Год назад

    I'm losing my mind why the image is not appearing in my second window. You're really a great help thanks!!

  • @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.

  • @LifterAndy
    @LifterAndy Год назад +1

    '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

  • @raniduharshana5238
    @raniduharshana5238 4 года назад

    thank you so much for this video. Very clear to understand

  • @devve7
    @devve7 3 года назад

    Good for you !! Thanks for the video, helped me!

  • @greg_pizzatower
    @greg_pizzatower 2 года назад

    just what i needed thanks

  • @johnpro2847
    @johnpro2847 5 лет назад +1

    cool... got one working already, Thanks John.How do you bring the 2nd window back. Destroy command seems to do just that !!!

  • @joseluisvelasquezrodriguez5143
    @joseluisvelasquezrodriguez5143 4 года назад +1

    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

  • @skmplanet9591
    @skmplanet9591 4 года назад

    Thanks a lot, this is what I was searching

    • @Codemycom
      @Codemycom  4 года назад

      Glad you found it then!

  • @amankumarbairagi794
    @amankumarbairagi794 4 года назад +1

    Hello John Sir .
    But what If we wants to create the third window from the 2nd window tkinter window !
    How can we do that ??

  • @globalguru21
    @globalguru21 3 года назад

    please kindly explain how to create second window inside the first main window, just like MDIForm in Visual Basic.

  • @parsabahrambeik4381
    @parsabahrambeik4381 4 года назад

    Hi, thank you very much for your video.

  • @pranavguptaa
    @pranavguptaa 4 года назад +1

    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

  • @pverprogramz641
    @pverprogramz641 4 года назад +1

    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

  • @ะ้ฟืฟแ้นะพพําพําพําพํา

    thank you ,teacher

  • @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 года назад +2

      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)

  • @andrewhadfield7754
    @andrewhadfield7754 4 года назад

    Super useful video - thanks!

    • @Codemycom
      @Codemycom  4 года назад

      Thanks for watching!

  • @vijaykumargupta9259
    @vijaykumargupta9259 3 года назад

    can you plz help with how first window get close when 2nd opens

  • @c0dingwithchris
    @c0dingwithchris 4 года назад +1

    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()

  • @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.

  • @twojdobrykolega8597
    @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

  • @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.

  • @mee8963
    @mee8963 3 года назад

    What if we use .quit instead of using destroy..?
    How to create a third window..?

  • @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?

  • @mister6497
    @mister6497 Год назад

    i thought uou would make it:
    for i in 255:
    print('Create New Windows in Tkinter - Python Tkinter GUI Tutorial #' + str(i))

  • @juanbernal5641
    @juanbernal5641 3 года назад

    Buen video.
    Una consulta cuantos def puedo anidar dentro de un def

  • @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

  • @aryamannatrajan4850
    @aryamannatrajan4850 4 года назад

    Overall amzing tutorials

  • @34__priyadharshini.r62
    @34__priyadharshini.r62 4 года назад

    Great job sir! Thank you sir

  • @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.

  • @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

  • @WalterWhite-dr2yz
    @WalterWhite-dr2yz 4 года назад +1

    The image I want to display in the second window is being displayed over the first window. What should I do?

    • @Codemycom
      @Codemycom  4 года назад +1

      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

  • @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 года назад +1

      I have videos on that in the playlist

  • @gold_miner.
    @gold_miner. 4 года назад

    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

  • @bhushanwagh7192
    @bhushanwagh7192 4 года назад

    Please make qt designer series

    • @Codemycom
      @Codemycom  4 года назад

      I don't know qt designer

  • @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

  • @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.

  • @sahilnigam4536
    @sahilnigam4536 3 года назад +1

    ofc a udemy ad is required before the video starts

    • @Codemycom
      @Codemycom  3 года назад

      Yeah, that's how youtube works.

  • @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.

  • @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

  • @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 года назад +1

      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 :-)

  • @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 года назад +1

      @@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.

  • @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

  • @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.

  • @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()

  • @Max-lr6dk
    @Max-lr6dk 4 года назад

    Why not using a class where you fix ImageTk as self.ImageTk ?

  • @jenishshrestha8613
    @jenishshrestha8613 4 года назад

    whats the difference between . .quit and .destroy???

    • @Codemycom
      @Codemycom  4 года назад

      for all intents and purposes...not much

  • @GelsYT
    @GelsYT 4 года назад +1

    Thank you =)

    • @Codemycom
      @Codemycom  4 года назад +1

      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 года назад +1

      @@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.

  • @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

  • @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

  • @procode6881
    @procode6881 4 года назад

    Do you know the reason why .pack() and .grid() cannot be present in a single window

    • @Codemycom
      @Codemycom  4 года назад +1

      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 года назад +1

      @@procode6881 sure thing

  • @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.

  • @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!

  • @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

  • @avact6226
    @avact6226 4 года назад

    which version of python are you using?

    • @Codemycom
      @Codemycom  4 года назад

      The latest version...it doesn't matter.

  • @akpanvincent1499
    @akpanvincent1499 4 года назад

    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  4 года назад +1

      You can learn everything you need to do that by watching the videos of this playlist.

  • @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 года назад +1

      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!

  • @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

  • @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.

  • @infogera1
    @infogera1 2 года назад

    How Can I do an InternalTopLevel in Python like as JInternalFrame in Java

  • @Momo-bb2fn
    @Momo-bb2fn 3 года назад

    6:45 why img didn't load, due to scope

  • @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

  • @juanpaperez100
    @juanpaperez100 5 лет назад +1

    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 лет назад +5

      Great Question! use root.withdraw() to hide our main root window, and root.deiconify() to bring it back.

  • @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

  • @dr.strawberry7612
    @dr.strawberry7612 4 года назад

    I tried this trick but when I did it it said top was not defined! PLEASE HELP!!!

    • @Codemycom
      @Codemycom  4 года назад

      Rewatch the video and check your code for errors.

  • @TogrulKazimov
    @TogrulKazimov 4 года назад

    I got this error: NameError: name 'Toplevel' is not defined

    • @Codemycom
      @Codemycom  4 года назад

      Check your code for typos

  • @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 ruclips.net/video/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

  • @sulagnadas908
    @sulagnadas908 5 лет назад

    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 😫

    • @Codemycom
      @Codemycom  5 лет назад

      Check your code, you likely have a typo

  • @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

  • @MedTech1
    @MedTech1 3 года назад

    I want to create a new window for my TextEditor And I just want to duplicate my Default window

  • @aryamannatrajan4850
    @aryamannatrajan4850 4 года назад

    You can do it by Tk() also I tried u do not need to do it by Toplevel()

    • @Codemycom
      @Codemycom  4 года назад +1

      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 года назад +1

      @@aryamannatrajan4850 No. Why not just do it the way you're supposed to.

  • @ninjatribble7961
    @ninjatribble7961 4 года назад

    Are you in Vegas?

    • @Codemycom
      @Codemycom  4 года назад

      Yes

    • @ninjatribble7961
      @ninjatribble7961 4 года назад

      @@Codemycom 😂 loving the tkinter playlist so far. These are just the kind of tutorials I was looking for. Thanks

    • @Codemycom
      @Codemycom  4 года назад

      @@ninjatribble7961 Awesome, glad you like em!

  • @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

  • @mister6497
    @mister6497 Год назад

    you messed up on the title it says ''tKinter' instead of 'TKinter'