Thank you for the series of these tutorials. I discovered after I saw your video that I like to use the "tearoff" option to not have the "-------------" at the beginning of the menu. Without this, if you click on it it will open actually the menu in a new window.
Thank you for demystifying Python GUI in this series of lessons. I battled getting my mind around visual basic decades ago and gave up the idea of trying anything with a GUI. This and your lessons on using databases with tkinter you have posted on TH-cam has been a real pleasure to follow. You really should add these series to your academy even if you just link to the TH-cam videos as this lessons are what i signed up with you for and I do feel it adds extra value and your efforts has made becoming a client of yours worth the investment.
My Codemy.com website has a tkinter course with 50+ videos. These youtube videos here on youtube that you mention are...well...here on youtube. Anyone with a codemy membership can watch them here anytime they want. The link to the playlist is in the comment section of every video.
Hey, I just have a question about python Tkinter. If I made a button in Tkinter where text appears on the screen when the button was clicked how do I make it so that when I run my code and press the button the text stays there when I close the program and re run it?
▶️ Watch Entire Tkinter Playlist ✅ Subscribe To My TH-cam 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
sir we used functions like main_menu.add_cascade(label = 'some text', menu = file_manu) i want to know the source code of these functions that how the functions like add_cascade(), Menu() etc are developed. these functions are inbuilt and i want to know how these functions have been created. Please sir explain, pleas sir
small Question: Can we read an Array from Javascript generated (in the Memory) (RAM) and read with python. Python was the wonder magic all inkl. Language. So I think this can gone work.
Love your videos. I was following this tutorial and could not work out why it was "not working" for ages. Turns out if you are on a Mac it IS working but the menu bar is placed at the top of the screen not in the working window!
I got question, how do u remove the fact if u click on the "-------------" at the top of the drop box of a menu, it pops that menu out, how do u stop this from happening??
Hello, thanks so much for your tutorials - but, I have a question, why do some teachers, such as yourself, start with "root = Tk()" and others start with "main_window = Tk()"? What is the difference and can I add the "root" at the beginning of my code or do I have to redo all of my work? Please and thanks...
They're both the same, you can call a variable anything you want. root is short and universal. but you could call it happy_bob if you want, it doesn't matter, you just have to use that throughout the entire app.
@@Codemycom Awesome! Thanks again!! I guess I thought it a command rather than a variable, so I'm glad to understand it now. Maybe it was mentioned somewhere along the line and I missed it, so I appreciate you explaining it. 😊
I was waiting for this to upgrade my simple calculator and I really wanna add a lot of thing but i don’t already know what to do please add a vid named upgrating the calculator please answer me !
Your content is awesome and has really helped me learn tkinter and python to a degree of some effectiveness. I am working on a small GUI. It is being displayed on a 7" HDMI screen connected to a Pi4. To maximize my real estate, I would like to slide/collapse the menu bar out of the way and hide it. I have not been able to find anything anywhere on how to do this without manually creating an entire menubar. Is this possible? If not, I will use tkinter's menu system rather than build it from scratch for this project.
Thanks a million for this video. However, is it possible to have menu bar inside a frame or notebook, instead of having it in the root window? If it is possible, can you please let us know how.
Well, I am not talking about dropdown as in optionmenu. I mean creating menu widget in a frame as file_menu = menu(frame). In your video you placed the menu bar on the root window as file_menu=menu(root). I tried it by replacing the root with a frame widget and got an error
My code is here: github.com/flatplanet/Intro-To-TKinter-TH-cam-Course But you shouldn't need to copy and paste code. Rewatch the video and work it out man.
I am trying to make a menu that opens a python file, I am quite into the video and my code will not work, its almost the same but it still won't work. It just will show a blank gui with a title, Code: Edit: Nvm on mac it just looks diffrent from tkinter import * root = Tk() root.title("Techno Play Menu") root.geometry("400x400") my_menu = Menu(root) root.config(menu=my_menu) def command(): pass file_menu = Menu(my_menu) my_menu.add_cascade(label="File", menu=file_menu) file_menu.add_command(label="New...", command=command) file_menu.add_command(label="Exit", command=root.quit) root.mainloop()
Hi! Thank you sooo much for these tutorials I've copied your code exactly but when its time to compile, there's an error: _tkinter.TclError: unknown option "-menu" this is on the root.config(menu = root) How do I fix this???
@@Codemycom I did try before I posted the comment. I did try it again as you said. First it did not work. Labelframe.config(menu=my_menu) did not work. But root.config(menu=my_menu) worked.
@@awhlox9099 Depends entirely on what you're trying to do...best for what? Building websites? Designing Games? Doing Big Data? Running Server? See what I mean?
@@awhlox9099 I've already answered you...it depends. period. What do you want to do? Build websites? Build games? Do big data? It depends dude. I can't explain it any other way. lol What language you learn next will be determined wholly by what you want to do with it. And anyway, they're all fun...
hello teacher I did same you write but the eror is (( self.tk.call((self._w, 'add', itemType) + _tkinter.TclError: unknown option "-Label")). iam using Mac the same code I did is same what you did could you help pls
Do I have to use "root"? I'm currently using "window" instead and i'm getting some errors. "my_menu = Menu(window) NameError: name 'Menu' is not defined" This is my code: import tkinter as tk import tkinter.messagebox window = tk.Tk() [....] def testFunc(): pass # The menu my_menu = Menu(window) window.config(menu=my_menu) # The menu items file_menu = tk.Menu(my_menu) my_menu.add_cascade(Label="File", menu=file_menu) file_menu.add_command(Label="New", command=testFunc) file_meny.add_command(Label="Exit", command=testFunc)
If you use window, you would use window, not root...but hey, if you don't know what you're doing...which you don't seem to...why not just follow along and do it like I do in the video and save yourself some aggravation? Did you forget to window = Tk() at the top of your program?
Ok i have a problem . After i have done my simple calculator with ‘ thonny’ i decided to move for pycharm and i opened the simple calculator file and there is a trouble in running why ?
Hi John, following is the code I tried after looking at your amazing tutorial but I don't know why it's not working.It would be amazing if you help me out. from tkinter import * root = Tk() root.title("HP SIMPLE FINANCE") w, h = root.winfo_screenwidth(), root.winfo_screenheight() root.geometry("%dx%d+0+0" % (w, h)) def donothing(): pass menubar = Menu(root) root.config(menu=menubar) filemenu = Menu(menubar) menubar.add_cascade(Label="File", Menu=filemenu) filemenu.add_command(Label="Open Portfolio file", command=donothing) filemenu.add_command(Label="Reports", command=donothing) filemenu.add_command(Label="New Portfolio", command=donothing) filemenu.add_command(Label="Restore from backup", command=donothing) filemenu.add_command(Label="Exit", command=root.quit) root.mainloop() The error shows as follows: Traceback (most recent call last): File "F:/Finance software/Main window.py", line 28, in menubar.add_cascade(Label="File", Menu=filemenu) File "C:\Users\harshparmar\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 3289, in add_cascade self.add('cascade', cnf or kw) File "C:\Users\harshparmar\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 3284, in add self.tk.call((self._w, 'add', itemType) + _tkinter.TclError: unknown option "-Label" Process finished with exit code 1
@@Codemycom Hi John, I corrected it still same error, except last error changed to this: self.tk.call((self._w, 'add', itemType) + _tkinter.TclError: unknown option "-Menu"
Thank you for the series of these tutorials. I discovered after I saw your video that I like to use the "tearoff" option to not have the "-------------" at the beginning of the menu. Without this, if you click on it it will open actually the menu in a new window.
Nice
file_menu = Menu(my_menu, tearoff=0)
@@hectorgomez28 thanks :)
I appreciate it :)
@@hectorgomez28 This is what we need! Thanks!
Thank you for demystifying Python GUI in this series of lessons. I battled getting my mind around visual basic decades ago and gave up the idea of trying anything with a GUI. This and your lessons on using databases with tkinter you have posted on TH-cam has been a real pleasure to follow. You really should add these series to your academy even if you just link to the TH-cam videos as this lessons are what i signed up with you for and I do feel it adds extra value and your efforts has made becoming a client of yours worth the investment.
My Codemy.com website has a tkinter course with 50+ videos. These youtube videos here on youtube that you mention are...well...here on youtube. Anyone with a codemy membership can watch them here anytime they want. The link to the playlist is in the comment section of every video.
Thank you very for these video tutorials, it really saves me time in searching in the internet and I really appreciate it.
You're very welcome!
we will one day reference our carrier to this great man!!!. A BIG THANKS FROM THIS SIDE "JOHN". my name is Muhammed from Ghana.
Thanks!
Thanks so much John, I just LOVE your videos. Please know that your efforts are much appreciated from all over the world. Blessings
I appreciate it!
How can I delete the sentences after I select my options?
I mean how I delete Friday text after I select Monday
mine says 'unknown option -Label'
Why?
Hey, I just have a question about python Tkinter. If I made a button in Tkinter where text appears on the screen when the button was clicked how do I make it so that when I run my code and press the button the text stays there when I close the program and re run it?
You don't, unless you save that state to a database or something...or a text file or something.
@@Codemycom Okay thank you, do you have a video on how to save it to a text file or database?
@@KadeMccarroll Sure, lots...check the playlist
Your videos are very helpfull and easy to understand
Thanks! Glad you like them!
▶️ Watch Entire Tkinter Playlist ✅ Subscribe To My TH-cam 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
I LOVE this channel.
I love to hear it!
@codemy Icon doesn't work when we build the app with pyinstaller and ship to another system
sir we used functions like main_menu.add_cascade(label = 'some text', menu = file_manu)
i want to know the source code of these functions that how the functions like add_cascade(), Menu() etc are developed.
these functions are inbuilt and i want to know how these functions have been created.
Please sir explain, pleas sir
small Question:
Can we read an Array from Javascript generated (in the Memory) (RAM) and read with python. Python was the wonder magic all inkl. Language. So I think this can gone work.
Sir, can we remove that dotted line? when we click that it separate out of the Menu
Its look like a separator above New and Edit.
yeah: tearoff=false
@@Codemycom Got it Sir
tearoff=0 worked for me
Love your videos. I was following this tutorial and could not work out why it was "not working" for ages. Turns out if you are on a Mac it IS working but the menu bar is placed at the top of the screen not in the working window!
yep!
thanks so much! I was so confused lol
thank you, sir.
what is the software you are using to write the code? I use IDLE but it is not so user friendly.
Sublime Text and the Git Bash terminal...never use IDLE for anything :-p
Thank you for this great explanation, but I have a question how to make the menu from right to left for Arabic.
Sorry, no clue
sir can you please tell me how i can also add it in customtkinter
I have an entire customtkinter playlist over on the tkinter.com TH-cam channel.
Thank you for the very informative tutorial.
Can you please educate me on changing the background color of the title / menu bar. ?
Thank-you.
Hello tahnk u ! I am asking than. How can i use link with menu bar ?
I got question, how do u remove the fact if u click on the "-------------" at the top of the drop box of a menu, it pops that menu out, how do u stop this from happening??
You can remove that bar...I have videos on that in the playlist somewhere
file_menu = Menu(my_menu, tearoff=False)
Hello, thanks so much for your tutorials - but, I have a question, why do some teachers, such as yourself, start with "root = Tk()" and others start with "main_window = Tk()"? What is the difference and can I add the "root" at the beginning of my code or do I have to redo all of my work? Please and thanks...
They're both the same, you can call a variable anything you want. root is short and universal. but you could call it happy_bob if you want, it doesn't matter, you just have to use that throughout the entire app.
@@Codemycom Awesome! Thanks again!! I guess I thought it a command rather than a variable, so I'm glad to understand it now. Maybe it was mentioned somewhere along the line and I missed it, so I appreciate you explaining it. 😊
Looks cool! I love your edit :)
Thanks!
I was waiting for this to upgrade my simple calculator and I really wanna add a lot of thing but i don’t already know what to do please add a vid named upgrating the calculator please answer me !
huh?
Excellent video and very understandable.
Thanks!
Thank you.... This video is helpful.....
Glad it was helpful!
Your content is awesome and has really helped me learn tkinter and python to a degree of some effectiveness. I am working on a small GUI. It is being displayed on a 7" HDMI screen connected to a Pi4. To maximize my real estate, I would like to slide/collapse the menu bar out of the way and hide it. I have not been able to find anything anywhere on how to do this without manually creating an entire menubar. Is this possible? If not, I will use tkinter's menu system rather than build it from scratch for this project.
No, there's no built in thing for that...you'll have to hack it together yourself
how do you get rid of the dashed lines that appear above the menu items?
tearoff=0 (or maybe 1 I can;t recall)
@@Codemycom thank you
welcome@@MickForjay
how to change the menu size and height?
what do i need to put for root.iconbitmap, just asking and have no clue
That's the icon that goes on the top menu bar of the app
Thank you very for all
Thanks for watching!
Thanks a million for this video. However, is it possible to have menu bar inside a frame or notebook, instead of having it in the root window? If it is possible, can you please let us know how.
Not sure what you mean, but you can have drop down menus in those places.
Well, I am not talking about dropdown as in optionmenu. I mean creating menu widget in a frame as file_menu = menu(frame). In your video you placed the menu bar on the root window as file_menu=menu(root). I tried it by replacing the root with a frame widget and got an error
Sir could u send the code in the description,I was having problem with the program ,so I'll be able to copy paste the code
My code is here: github.com/flatplanet/Intro-To-TKinter-TH-cam-Course
But you shouldn't need to copy and paste code. Rewatch the video and work it out man.
@@Codemycom hmm just will check out the difference
sir, is it possible to delete a menu item when clicking a button ??
Like menu.delete_cascade() or something like that
I'm sure there is, but I don't think I've ever tried it :-p
@@Codemycom I think you should try that . 😜
great video !
it helps me a lot !
Glad to hear that!
thank you Heisenberg :)
My pleasure!
I am trying to make a menu that opens a python file, I am quite into the video and my code will not work, its almost the same but it still won't work. It just will show a blank gui with a title, Code:
Edit: Nvm on mac it just looks diffrent
from tkinter import *
root = Tk()
root.title("Techno Play Menu")
root.geometry("400x400")
my_menu = Menu(root)
root.config(menu=my_menu)
def command():
pass
file_menu = Menu(my_menu)
my_menu.add_cascade(label="File", menu=file_menu)
file_menu.add_command(label="New...", command=command)
file_menu.add_command(label="Exit", command=root.quit)
root.mainloop()
Can u tell how to increse the font size of words in the menu bar like file,edit..
You can't.
Hi! Thank you sooo much for these tutorials
I've copied your code exactly but when its time to compile, there's an error:
_tkinter.TclError: unknown option "-menu"
this is on the root.config(menu = root)
How do I fix this???
Every time someone says that they copied the code exactly but there was an error...they didn't copy the code exactly. Check for typos.
The error you got was from capitalizing the L in label.
@@jesterlw I got the same problem with my program,thanks for showing me the solution
@@Codemycom Lol...seems like you get that a lot!! I can sense the frustration 😉
@@ferdindonbosco246 You have no idea LOL
When add menu bar it will not open middle in the screen...please help me
check your code for typos
Should it work if I place the menu inside of a frame?
Try it and see
Does this work the same with customtkinter?
nothing works quite the same with customtkinter
Thank you!
feed the algorithm! great vid!
Sir, Can you please make a video on pyperclip module ?.
Sorry, I'm not familiar with that
Can I replace the menu with a button? If so how?
Sure, in the normal way you would use any button.
To everyone having errors please check your spelling for 'label'
it's usually a typo yes
ur comment helped thanks a lot, I thought the l was capital because of the font
@@gacem213 :D
Can I cascade a Menu to a label frame instead of root?
Try it and see
@@Codemycom I did try before I posted the comment. I did try it again as you said. First it did not work. Labelframe.config(menu=my_menu) did not work. But root.config(menu=my_menu) worked.
Umm there’s something wrong with pycharm it does not recognize label but
Tkinter recognized Label before...,why is it doing that
No idea, I would never use Pycharm, it's terrible
for future questioners: lower case 'label'
I can already code in python what else should I learn to code ? What’s do you recommend to create things
Depends entirely on the type of things you want to create...
Codemy.com what’s the best language to learn overall instead of python
@@awhlox9099 Depends entirely on what you're trying to do...best for what? Building websites? Designing Games? Doing Big Data? Running Server? See what I mean?
Codemy.com yes. But what language should I learn next I’ve learned python and now what other languages are fun
@@awhlox9099 I've already answered you...it depends. period. What do you want to do? Build websites? Build games? Do big data? It depends dude. I can't explain it any other way. lol What language you learn next will be determined wholly by what you want to do with it. And anyway, they're all fun...
awesome, thanks!
Welcome
hello teacher I did same you write but the eror is (( self.tk.call((self._w, 'add', itemType) +
_tkinter.TclError: unknown option "-Label")). iam using Mac the same code I did is same what you did could you help pls
your code = my code that is why I could not understand whats wrong
No, my code does not equal your code...you have a typo someone. If they equaled, you wouldn't have an error.
@@Codemycom if you can help😊😁
I would to send all the code if you can check
I wached all the previous 45 lessons i dont want to jump th 46th
@@Abdulaziz-e-2030 No sorry, but the error is telling you what the problem is. You've used Label incorrectly somewhere.
@@Codemycom teacher pls see my code on twitter I am sure no mistakes with (Label).
twitter.com/abdoh69424/status/1339420201574690818?s=21
Do I have to use "root"? I'm currently using "window" instead and i'm getting some errors.
"my_menu = Menu(window)
NameError: name 'Menu' is not defined"
This is my code:
import tkinter as tk
import tkinter.messagebox
window = tk.Tk()
[....]
def testFunc():
pass
# The menu
my_menu = Menu(window)
window.config(menu=my_menu)
# The menu items
file_menu = tk.Menu(my_menu)
my_menu.add_cascade(Label="File", menu=file_menu)
file_menu.add_command(Label="New", command=testFunc)
file_meny.add_command(Label="Exit", command=testFunc)
If you use window, you would use window, not root...but hey, if you don't know what you're doing...which you don't seem to...why not just follow along and do it like I do in the video and save yourself some aggravation? Did you forget to window = Tk() at the top of your program?
are you missing a mainloop for your mini instance of tkinter?
How can I add this menu in a class?
In the same way you add anything in a class with tkinter
How to Chance cascade's font. :?
Not sure if you can
@@Codemycom OK, thx anyway!!
Very helpful :)
I'm glad!
Thank you so much
Very Welcome!
Lmao John at 0:00
Excited for teach
Which EDI you are using ?
EDI?
Compeleter ?
@@terfer9128 yeah I don't know what you're talking about...I'm using sublime text
Ok i have a problem . After i have done my simple calculator with ‘ thonny’ i decided to move for pycharm and i opened the simple calculator file and there is a trouble in running why ?
@@terfer9128 Because pycharm sucks...why not just use Sublime Text like I do in the video? It's easy. It's free.
Awesome
Thanks!
Thanks
Welcome
unknown option "-Label" why?
what did you do in your code?
@@Codemycom i just solved my problem , thank you
@@Wuottfac awesome
is label not Label
@@jadenlin3724 glad to hear it!
It is not working sir,showing error
What's the error say? They tell you what to do...
I cant read that with my phone.
Everyone else can...zoom in
Hi John, following is the code I tried after looking at your amazing tutorial but I don't know why it's not working.It would be amazing if you help me out.
from tkinter import *
root = Tk()
root.title("HP SIMPLE FINANCE")
w, h = root.winfo_screenwidth(), root.winfo_screenheight()
root.geometry("%dx%d+0+0" % (w, h))
def donothing():
pass
menubar = Menu(root)
root.config(menu=menubar)
filemenu = Menu(menubar)
menubar.add_cascade(Label="File", Menu=filemenu)
filemenu.add_command(Label="Open Portfolio file", command=donothing)
filemenu.add_command(Label="Reports", command=donothing)
filemenu.add_command(Label="New Portfolio", command=donothing)
filemenu.add_command(Label="Restore from backup", command=donothing)
filemenu.add_command(Label="Exit", command=root.quit)
root.mainloop()
The error shows as follows:
Traceback (most recent call last):
File "F:/Finance software/Main window.py", line 28, in
menubar.add_cascade(Label="File", Menu=filemenu)
File "C:\Users\harshparmar\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 3289, in add_cascade
self.add('cascade', cnf or kw)
File "C:\Users\harshparmar\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 3284, in add
self.tk.call((self._w, 'add', itemType) +
_tkinter.TclError: unknown option "-Label"
Process finished with exit code 1
All those Labels need to be lowercase label
@@Codemycom Hi John, I corrected it still same error, except last error changed to this:
self.tk.call((self._w, 'add', itemType) +
_tkinter.TclError: unknown option "-Menu"
@@Hh12358 Menu (within brackets) needs to be in lower case as it is a key word and not a class.
in menubar.add_cascade(Label="File", Menu=filemenu) change that "Menu" to "menu"
Same problem
Not Working
Then you did it wrong. Watch the video and try again.
Cir, please programme password
If root.quit does not work, use root.destroy
d e s t r o y t h e r o o t
Hii
Hii!
Many thanks to GOOGLE for automatic translation