Python GUI with Tkinter – 2 – Organizing your Layout

Python GUI with Tkinter – 2 – Organizing your Layout

Facebook – https://www.facebook.com/TheNewBoston-464114846956315/
GitHub – https://github.com/buckyroberts
Google+ – https://plus.google.com/+BuckyRoberts
LinkedIn – https://www.linkedin.com/in/buckyroberts
reddit – https://www.reddit.com/r/thenewboston/
Support – https://www.patreon.com/thenewboston
thenewboston – https://thenewboston.com/
Twitter – https://twitter.com/bucky_roberts

50 replies
  1. BasicCoding
    BasicCoding says:

    bucky what is the difference on your other GUI python tutorial? I think it was GTK? whatever but what’s the difference about it?

    Reply
  2. Dario Komar
    Dario Komar says:

    I had a mental breakdown with WinAPI and C. After all those years, I decided to stop forcing myself to do stuff with C. Seeing this made me smile and gave me hope to code again. Thank you.

    Reply
  3. MCDran
    MCDran says:

    It won’t work for me I normally have Python 3 but what ever

    C:Python27python.exe C:/Users/Mr.Retorofit/PycharmProjects/untitled/bucky.py
    Traceback (most recent call last):
    File "C:/Users/Mr.Retorofit/PycharmProjects/untitled/bucky.py", line 10, in <module>
    button1 = Button(topFrame, "Button 1", fg="Red")
    File "C:Python27liblib-tkTkinter.py", line 2166, in __init__
    Widget.__init__(self, master, ‘button’, cnf, kw)
    File "C:Python27liblib-tkTkinter.py", line 2085, in __init__
    cnf = _cnfmerge((cnf, kw))
    File "C:Python27liblib-tkTkinter.py", line 116, in _cnfmerge
    cnf.update(c)
    ValueError: dictionary update sequence element #0 has length 1; 2 is required

    Process finished with exit code 1

    Reply
  4. Tushar Mittal
    Tushar Mittal says:

    hey i am using python 3.6.1 and typed the same code as in the video but it gives an error – NameError: name ‘frame’ is not defined. Any suggestions on how to fix this ?

    Reply
  5. Sajeesh Nair
    Sajeesh Nair says:

    Super clear explanation!!… I watched your first vid and it is awesome. I am trying to build a text editor as part of my project

    Reply
  6. Chisolm Wilson
    Chisolm Wilson says:

    aside from the pronunciation of tkinter … its interesting that you dont pronounce your other T’s either. When you say root, it sounds like youre saying "roo". When you say but, it sounds like "buh". Anyway, Im enjoying the videos, thanks.

    Reply
  7. Leonid Vishankov
    Leonid Vishankov says:

    none the less, i would recommend you to say it explicitly because it make the code more self documenting 4:31

    Reply
  8. ΛLFΛ
    ΛLFΛ says:

    what i like about your videos is you don’t talk like a robot na na na … like a friend teaching me thats the reason i like your videos

    Reply
  9. Minoan Light
    Minoan Light says:

    So, this is the thing, you say that top frame doesn’t have to be explicitly stated/defined, but on MacOS it HAS to be. Otherwise, it just won’t work, my window is empty. Still dunno how to get colored buttons to work, though.

    Reply
  10. xegai hadgu
    xegai hadgu says:

    what is the site you using on this video called.? i tried to import tkinter in repl.it but for some reason it keep saying no module named tkinter found ….(is there any other sites like repl.it)…..
    ………………….thanks

    Reply
  11. Hridoy Ahmed
    Hridoy Ahmed says:

    from tkinter import *

    root =Tk()
    topFrame =Frame(root)
    topFrame.pack()
    bottomFrame =Frame(root)
    bottomFrame.pack(side=BOTTOM)

    button1 =Button(topFrame, text="Button 1",fg="red")
    button2 =Button(topFrame, text="Button 2",fg="blue")
    button3 =Button(topFrame, text="Button 3",fg="green")
    button4 =Button(bottomFrame, text="Button 3",fg="purple")

    button1.pack(side=LEFT)
    button2.pack(side=LEFT)
    button3.pack(side=LEFT)
    button4.pack(side=BOTTOM)

    root.mainloop()

    Reply
  12. Gamesys
    Gamesys says:

    Man you are amazing! Instead of just simply showing code and giving a tiny bit of shitty explanation you put the effort of showing us an example so we understand better. 🙂

    Reply
  13. Ishmeet Bindra
    Ishmeet Bindra says:

    If someone is having a trouble in understanding how the framing works run the following code. In this, I have just added few commands to Frame and Pack to add additional padding around the two Frames.

    from tkinter import *

    root = Tk()

    topframe = Frame(root, bd=5, relief = GROOVE)
    topframe.pack(side=TOP,fill=X, padx=2, pady=2)

    bottomframe = Frame(root, bd=5,relief = GROOVE)
    bottomframe.pack(side=BOTTOM,fill=X, padx=2,pady=2)

    button1 = Button(topframe,text = "button 1",bg=’white’,fg = ‘black’)
    button2 = Button(topframe,text = "button 2",bg=’white’,fg = ‘black’)
    button3 = Button(topframe,text = "button 3",bg=’white’,fg = ‘black’)
    button4 = Button(bottomframe,text = "button 4",bg=’white’,fg = ‘red’)

    button1.pack(side=’left’)
    button2.pack(side=’left’)
    button3.pack(side=’left’)
    button4.pack()

    root.mainloop()

    Reply
  14. John Walker
    John Walker says:

    Why not just bottomFrame = Frame(root).pack(side=BOTTOM) ?
    btn1 = Button(bottomFrame, text="okay", fg="red").pack()

    Reply
  15. Luiz Augusto
    Luiz Augusto says:

    Honestly I just give up PyQt5 cause it’s a mess, I think this Tk is made to be more simple and abstract.

    Reply
  16. Nik K
    Nik K says:

    So he says that when you put side=LEFT, it packs it to the most left as possible, so why doesn’t button 2 just go to the very left and below button 1 (i.e it doesn’t just move the whole column to the left)

    Reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *