Python GUI with Tkinter – 10 – Creating a Toolbar

[ad_1]
Facebook –
GitHub –
Google+ –
LinkedIn –
reddit –
Support –
thenewboston –
Twitter –


Posted

in

by

Tags:

Comments

26 responses to “Python GUI with Tkinter – 10 – Creating a Toolbar”

  1. The Amazing Dr. Sophisto Avatar

    And up comes the toolbar …

  2. David Scully Avatar

    can anybody see why mine is not working?
    using pycharm community edition 2017.2.3

    from tkinter import *

    def doNothing():
    print("oK Doing nothing")

    root = Tk()

    menu = Menu(root)
    root.config(menu=menu)

    subMenu = Menu(menu)
    menu.add_cascade(label="File", menu=subMenu)
    subMenu.add_command(label='New Project…', command=doNothing)
    subMenu.add_command(label='New…', command=doNothing)
    subMenu.add_separator()
    subMenu.add_command(label='Exit…', command=doNothing)

    editMenu = Menu(menu)
    menu.add_cascade(label='Edit', menu=editMenu)
    editMenu.add_command(label="Redo", command=doNothing)

    toolbar = Frame(root, bg="blue")

    insertButt = Button(toolbar, text="Insert Image", command=doNothing)
    insertButt.pack(side=LEFT, padx=2, pady=2)
    printButt = Button(toolbar, text="Print", command=doNothing)
    printButt.pack(side=LEFT, padx=2, pady=2)

    toolbar.pack(side=TOP, fill=X)

    root.mainloop()

  3. Kostas Nikolouts Avatar

    Does anyone know what "expand" is doing?
    for example: Frame(root, bg="blue").pack(expand=1)

  4. Rufus Smith Avatar

    Macos is a pain, because the menu stays on the top line of the main screen,while the toolbar travels with your window.

  5. aparna tiwari Avatar

    where is your forum.where can i find the source code!!
    this is pissing me off coz i am as lazy as you.i guess a bit more!!

  6. David Borger Avatar

    Where is this forum of which you speak (with the source code)?

  7. JOS BEX Avatar

    print("thaks….")

  8. T. Z. Avatar

    why can't i find the code for gui on github???

  9. Marc Tecpile Avatar

    Thank you man, I am learning program in Python

  10. Jonathon Mohon Avatar

    Are menus and toolbars usually created in the class of the main program gui or in their own class or like in this video without using a class? FYI — I'm a noob and learning.

  11. Alex vW Avatar

    your videos are amazing and the comments you make from time to time as well hahaha 😀

  12. Batman Avatar

    that menu thing like how to make menu is confusion cuz the reference of menu come many times

  13. BCC Physics Club Avatar

    I've been having problem with "pack"… the tool bar is not showing… help please

  14. Sean Hubbard Avatar

    from tkinter import *

    def doNothing():
    print("Ok, ok I won't!")

    root = Tk()

    # * Main menu * #

    menu = Menu(root, tearoff = False)
    root.config(menu = menu)

    subMenu = Menu(menu, tearoff = False)

    menu.add_cascade(label = "File", menu = subMenu)

    subMenu.add_command(label = "New project", command = doNothing)

    subMenu.add_command(label = "New…", command = doNothing)

    subMenu.add_separator()

    subMenu.add_command(label = "Exit", command = root.destroy)

    editMenu = Menu(menu, tearoff = False)

    menu.add_cascade(label = "Edit", menu = editMenu)

    editMenu.add_command(label = "Redo", command = doNothing)

    # * Toolbar * #

    toolbar = Frame(root, bg = "blue")

    insertButt = Button(toolbar,
    text = "Insert image",
    command = doNothing).pack(side = LEFT, padx = 2, pady = 2)

    printButt = Button(toolbar,
    text = "Print",
    command = doNothing).pack(side = LEFT, padx = 2, pady = 2)

    toolbar.pack(side = TOP, fill = X)

    root.mainloop()

  15. Rockyzach88 Avatar

    How do you get columnspan for .grid function to expand all the way across the X axis? I only ask because apparently Tkinter doesn't like mixing .grid and .pack.

  16. Ben Fletcher Avatar

    how do you get it to fill x and y axis

  17. YTSjoerd Avatar

    thanks for the tutorials bucky, i've already managed to create my own little text editor which can actually function.

  18. VitezFit Avatar

    THANK YOU! But how do i add image to my buttons in toolbar?

  19. Tanay Pathak Avatar

    Hmm! I have been noticing, your videos got degraded from 1080p to 720p. 1080p was so better, clear and crisp. 

  20. Daniel Jones Avatar

    How would I be able to place the toolbar with '.grid()' ?? and still have it 'fill=X'?

  21. eric phung Avatar

    lol nice.  insert butt(on), pack it in…  3:50
    I'm right there with you, buddy.  I get bored doing code (ie: last night I got lazy and named all of my Assertion commands "ass")
    Keeps things light-hearted.

    Good video by the way.  I've never made a gui before so this is fun.

  22. Jonathan Avatar

    Just a little FYI, for anybody that gets tired to the root window small dimensions.

    root = Tk()
    root.geometry("500×300") whatever values you'd like.

  23. Herbert Holeman Avatar

    Thanks Bucky for good, useful stuff.

  24. fulltimegeek Avatar

    Good stuff +thenewboston. As always, your videos are entertaining and educational. Here is a small token of my appreciation: $5 via +ChangeTip 

  25. Andy Myers Avatar

    Not just cooking lessons that's full of double entendres.

Leave a Reply

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