Binding Dropdown Menus and Combo Boxes - Python Tkinter GUI Tutorial #45

แชร์
ฝัง
  • เผยแพร่เมื่อ 1 ส.ค. 2024
  • In this video I'll show you how to bind drop down menus (OptionMenus) and Combo Boxes with tKinter and Python so that you don't have to click a button to take action based on your selection.
    Normally, after you select something from a drop down menu, you have to then click a button to take some action. But what if you could take the action just based on clicking and selecting from the drop down menu itself...without clicking a button afterward?
    That's what I'll show you in this video...

ความคิดเห็น • 216

  • @Codemycom
    @Codemycom  4 ปีที่แล้ว

    ▶️ 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

  • @tentra7548
    @tentra7548 2 ปีที่แล้ว +1

    Hey, just want to say thanks for this excellent video! Your explanations are awesome.
    Including a use case of how to add logic to a combo box helped me a lot! Keep up the awesome content.

  • @DanielSilva-fv8br
    @DanielSilva-fv8br 4 ปีที่แล้ว +1

    Great video! I've been trying to bind a combobox for like 1 hour. Thank you.

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว +1

      Glad it helped!

  • @jorge1869
    @jorge1869 ปีที่แล้ว +1

    I can't explain how I had not found this channel before. New subscriber.

  • @eitangreenberg6255
    @eitangreenberg6255 3 ปีที่แล้ว

    thank you very much!! already watched over 15 episodes which I really needed for the chat program i'm currently working on!

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว +1

      Glad you found them useful!

  • @good-gpt2-chatbot
    @good-gpt2-chatbot 3 ปีที่แล้ว +3

    Thank you very much sir, I can't explain how much you've helped me!

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว +2

      Happy to hear it!

  • @chendian-jing6037
    @chendian-jing6037 2 ปีที่แล้ว

    Supper great video. I extended your example codes to my company project to develop strategies to industrial problems. I really appreciate your help.

    • @Codemycom
      @Codemycom  2 ปีที่แล้ว

      Glad you found it helpful!

  • @tutoriaisdeinstrucoesdecel8455
    @tutoriaisdeinstrucoesdecel8455 4 ปีที่แล้ว +1

    Thank you very much for the smooth content and your great humor.

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว

      My pleasure!

    • @bxstiii
      @bxstiii 3 ปีที่แล้ว +1

      Comboy

  • @kapibara2440
    @kapibara2440 2 หลายเดือนก่อน

    Great work from John! Thank you 😊

    • @Codemycom
      @Codemycom  2 หลายเดือนก่อน

      welcome

  • @manjunathanc1389
    @manjunathanc1389 3 ปีที่แล้ว

    It clears my doubt. Thank You !

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว

      You’re welcome

  • @sujitsingh7279
    @sujitsingh7279 4 ปีที่แล้ว

    Thanks a lot for this video sir. Keep making videos on tkinter as I am learning to develop app watching your videos.

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว

      Glad you're enjoying them!

  • @charxcx_Purr
    @charxcx_Purr 3 ปีที่แล้ว

    Yey! Finally I found a great tutorial 😍 Thanks!

  • @__leelight
    @__leelight 2 ปีที่แล้ว

    Amazing videos and simple .Thank you man

  • @nitinkashyap1821
    @nitinkashyap1821 3 ปีที่แล้ว

    this was extremely helpful
    thank you sir

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว +1

      Glad it helped

  • @NoureddineBahi
    @NoureddineBahi 2 ปีที่แล้ว

    You are a great prof...specifiquely your smail...thanks from morocco in north afriqua

  • @asaadkittaneh2928
    @asaadkittaneh2928 2 ปีที่แล้ว

    great video, thank you, you are a genius.

  • @RyanDanielG
    @RyanDanielG 2 ปีที่แล้ว

    Feed the algorithm! Great vid

  • @whitebird365
    @whitebird365 4 ปีที่แล้ว +1

    Very interesting.. Thank you!
    I hope that you're gonna make more tutorials in that ttk module :-)

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว +1

      Probably so :-p

    • @tonystark2358
      @tonystark2358 4 ปีที่แล้ว +1

      yeah bro,
      there are very few videos on youtube who teach ttk very well

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว +1

      @@tonystark2358 for sure

  • @chillwavefrequency8108
    @chillwavefrequency8108 4 ปีที่แล้ว +1

    I love your videos man! Thank You so much! I am currently working on a project like most people here and I have a question: I have a dropdown menu with a list of numbers from 1 to 10 and I want my customer to be able to fill the dropdown menu just by clicking on the keyboard number.
    I would really appreciate it if you could help me with this.
    Thank You!

  • @jacktoddy9783
    @jacktoddy9783 ปีที่แล้ว

    Now, here's the thing - I make useful applications for people to interface with, such as quiz tables for self-assessment respecting climate change. The sort of thing whereby you open a box, select a button; and that loops to another issue through combi dropdowns - all old fashioned I guess. Why? because human life is complex when taking in account all of the intricate paths and foibles we possess. People like 'buttons' and 'boxes' as they wish to open the combi box; it is intuitive to them. Whereby, they select an option and scroll on through to another set of questions; and so on ... If a box appears, that imprints into their minds better - the lesson of 'what they are responsible for through their actions' registers. The point I am making is that although this is an excellent tutorial video, you appear to be a 'coder' rather than a 'programmer'. To me the difference is huge. One provides the code, the other is more philosophical through knowing what to design code for - the end product's purpose. I would have liked this video more if it had buttons designed into the GUI. Nonetheless, I have subscribed to your channel.

    • @Codemycom
      @Codemycom  ปีที่แล้ว

      well the name of the channel is codemy.com...so yeah, I focus on coding.

  • @jussitoivanen5097
    @jussitoivanen5097 3 ปีที่แล้ว

    Thank you Mr. White!

  • @sinamobasheri3632
    @sinamobasheri3632 4 ปีที่แล้ว

    Thank you Mr 🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว

      You are very welcome

  • @bondiliyeshesh1999
    @bondiliyeshesh1999 3 ปีที่แล้ว

    hello. thank you for the video. but i have a doubt, i want a function to be executed for no matter what the selected option from the combobox. i guess i have to use for loop but i am having trouble how to do it. please shred some knowledge in this regard

  • @anintrovertabroad2065
    @anintrovertabroad2065 2 ปีที่แล้ว

    I'd like to see how to do this where the options are the results of a function. So if I'm pulling employee names from file names with a function getEmployeeName, how do I assign the output of that function to the Options for the drop down. As you've shown here, its not very flexible. I need to be able to have the options change according to the files selected.

  • @jacquesimbert1644
    @jacquesimbert1644 3 ปีที่แล้ว

    Much appreciated W.W.

  • @nelsonbeneche2372
    @nelsonbeneche2372 ปีที่แล้ว

    Best videos

  • @neiljohnmorales6718
    @neiljohnmorales6718 3 ปีที่แล้ว

    how would i do if my project is about font size and font style using combobox (my whole project is about text formatting with sample)

  • @ankitha4797
    @ankitha4797 3 ปีที่แล้ว

    Thank you, great videp!
    One question, could you please show how to create a multiple select combobox with drop down ?

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว

      I think I've already done a video about that on the playlist

  • @hosamsayed2652
    @hosamsayed2652 3 ปีที่แล้ว +2

    Hi, Thanks for the tutorial.
    Can I make the scrollbar in the combobox at the left side. I am writing in combobox values in Arabic so when i choose a value from dropdown like ' I like your tutotial'. It implemented as 'tutorial your like I'.

    • @randomdude7386
      @randomdude7386 2 ปีที่แล้ว

      Yeah you can do that with .grid() instead of .pack

  • @__leelight
    @__leelight 2 ปีที่แล้ว

    Thanks!

  • @seshududdu8308
    @seshududdu8308 3 ปีที่แล้ว

    Thank you very much for your tkinter videos. Could you guide , is there any option for autofill the combobox list

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว

      Not without hacking together something

  • @serious6037
    @serious6037 2 ปีที่แล้ว

    how do you make previously picked list outcome to hide, after picking the next item from the list?? 6:18

  • @babysaga6726
    @babysaga6726 3 ปีที่แล้ว +2

    Hi John, thanks for this tutorial. May I know how to display the output in just one line instead of showing everything you've selected? So if I choose Monday, it will display Monday and if Tuesday, the result from Monday will be replaced by Tuesday and will not create rows of what I've selected?
    Also, can I create a button out of what I'd selected and linked to open a file? Thank you!

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว +1

      Once you select a thing, you can do whatever you want with it. To learn how to use labels and buttons, check the playlist for their basic usage

    • @EduardoRandall
      @EduardoRandall 2 ปีที่แล้ว +1

      Hey, friend. Have you found the solution to your issue? I'm having the same issue right now and it would help me a lot. Thank you!

  • @sivasundaram781
    @sivasundaram781 2 ปีที่แล้ว

    sir, thank you for your video. but in combobox we press a letter the cursor cant go that word. what can i do?

  • @helenayeung1020
    @helenayeung1020 ปีที่แล้ว

    can we use combobox without defining options ? e.g. option=list(np.sort(wf['raw data column header'].unique ?

  • @daneshpatel5638
    @daneshpatel5638 3 ปีที่แล้ว

    Can we use if else in function checking the clicked check box is eight Or wrong

  • @nandhinisivakumar3523
    @nandhinisivakumar3523 4 ปีที่แล้ว

    Thankyou for the code, I have a doubt like after passing a value through ComboSelected to a function I need that value to be passed to another function - which is working through another button??how could I make that possible??

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว

      Call the other function from inside the first function, passing whatever along inside it: second_function(pass_a_thing)

  • @jerrysavarino2113
    @jerrysavarino2113 2 ปีที่แล้ว

    Hi John. Loving your videos! One aspect of my app that I am struggling with is that I have around 6 different comboboxes. 1 combobox is the 'master' whereby whatever value is selected from the list, will make 1 or 2 comboboxes (depending which ones are relevant) appear. Each time you select a different value from this 1 combobox, the linked comboxes are hidden/shown. I am trying to use a bind on the 'master' combobox and then in that function, create multiple 'if' statements to link the other comboxes to the relevant value in the 'master' combobox. I am trying to add a .destroy() in this function so that the non-related comboboxes are hidden but it doesn't really seem to be working. Is there a better way to do this? Hope I have explained my issue ok!

    • @Codemycom
      @Codemycom  2 ปีที่แล้ว +2

      If you destroy a thing, it's gone for good...you likely don't want to do that. You can just hide it with pack_forget() and reshow it again with pack()

    • @jerrysavarino2113
      @jerrysavarino2113 2 ปีที่แล้ว +1

      @@Codemycom Hi John, thanks for your reply! I am using grid() on the widgets and I actually found that grid_remove() seems to do what I need. What is the main difference between grid_forget() and grid_remove()?

  • @NotEnoughTime-cf2pi
    @NotEnoughTime-cf2pi 3 หลายเดือนก่อน

    Is there any way to nest a list box in a combobox. I need a multiselect option?

  • @SmartProgrammer
    @SmartProgrammer 3 ปีที่แล้ว

    How can we put to combo box default value?
    like("MONTH")
    But it should not be on my list.

  • @margaretlai2494
    @margaretlai2494 3 ปีที่แล้ว

    Hi John, can we jump to a particular spot of the dropdown list instead of scrolling all the way down? Say by clicking "S" on the keyboard which then send us to "Saturday"?

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว

      You might be able to do that with binding..but I’ve never tried it.

  • @cunninghamb505
    @cunninghamb505 4 ปีที่แล้ว

    great vid, any plans to do anything on Kivy

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว

      Yes, actually

  • @KornJohnGaming
    @KornJohnGaming 3 ปีที่แล้ว +2

    can you do a video on updating the dropdown when u add to options?

    • @ZombieKing05220
      @ZombieKing05220 ปีที่แล้ว

      hey, been a while but have you had any luck? i need help with this

  • @mounttaineer
    @mounttaineer 3 ปีที่แล้ว

    HI, great videos. I have a combobox which then has a dependent listbox that brings up several option based on the drop down value. i was able to do it by using another of your tutorial, it is really cool, and I would not have been able to do it just by reading the descriptions. I also want to display the value of the drop down as you show in this video, and I have that working. The issue I am having is getting both of the functions working when in the binding, only the last function listed works. I tried two separate functions, still only the last one works, I tried using comma or "And" between the two, but still only the last function called will work. my_combo.bind("", display, parks_listbox) - here is a universal version of my bind code. Any ideas?

    • @mounttaineer
      @mounttaineer 3 ปีที่แล้ว

      i figures it out, just write a new function or set them = True.

  • @noureddinen72
    @noureddinen72 10 หลายเดือนก่อน

    hi
    Thanks for this excellent video.
    I have a litle problem here, when i select a value from a combox, the value selected is not showing immediatly in the box, it waits until the main action of the program finished, can you help me to solve this problem.
    Cdlt

  • @charliefoo7581
    @charliefoo7581 4 ปีที่แล้ว +6

    Thank you for the Tkinter videos. I have a quick question: Is it possible to get the list position of the user selection instead of the text itself?

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว +3

      Sure, likely in the normal way you would find a list position...right? Play around with it...

    • @raghunathansundaresan8017
      @raghunathansundaresan8017 2 ปีที่แล้ว

      just use index function to find the position using the text.

  • @tonyabadia860
    @tonyabadia860 4 ปีที่แล้ว

    hello, thanks a lot for your video it is very helpful, I would like to ask you a question,
    actually I have almost the same code as yours :
    combobox=ttk.Combobox(toplevel,values=listebox,width=75)
    combobox.grid(row=nb_row,column=1)
    combobox.bind("",action)
    and the action function is :
    def action(event):
    print(combobox.get())
    but when I run it it says that combobox is not defined, could you help me please ?

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว +1

      try naming it something other than combobox

  • @benjaguzman4957
    @benjaguzman4957 4 ปีที่แล้ว +1

    how can i use de variable returned from comboclick in other function? thanks

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว

      Depends on how you want to do that

  • @MultiGoldensilver
    @MultiGoldensilver 3 ปีที่แล้ว

    which video covers combo boxes?

  • @ArunYadav-ke2nu
    @ArunYadav-ke2nu 9 หลายเดือนก่อน

    How to make a dropdown box that is scrollable and shows 5 elements at once and have nearly 60 elements?
    Please Help

  • @kosidairy
    @kosidairy 3 ปีที่แล้ว

    sir i need a help in combobox. when i type the first letter so it shows all the items in combobox related to the similar first letter. plzz help me out sir

  • @sambleyle7192
    @sambleyle7192 4 ปีที่แล้ว

    Do you have a video on how to clear the selected values in combo box and text widgets after you've sent those values to a database or searched for them, etc.?

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว +1

      yes

    • @sambleyle7192
      @sambleyle7192 4 ปีที่แล้ว

      @@Codemycom link? I'm struggling to find it

  • @claudineievangelistanascim2562
    @claudineievangelistanascim2562 3 ปีที่แล้ว +1

    Hi Codemy. Thank you for sharing this content. You've helped me (20210324 20:06pm brazil)

  • @ryuokami8924
    @ryuokami8924 ปีที่แล้ว

    Nice tuto ! But i have a question. How change the color of the text after you selected it ? (not change the selectbackground but the text itself) of the combobox ?

    • @malakalbakri2392
      @malakalbakri2392 ปีที่แล้ว

      cant u config it and use fg?

    • @ryuokami8924
      @ryuokami8924 ปีที่แล้ว

      @@malakalbakri2392 Yep i can thx !

  • @denniszignin7745
    @denniszignin7745 4 ปีที่แล้ว

    Great Tutorial. I have a question about combo: is a way to let open the combo after click? I want show a long item list even after the click...

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว

      Not sure exactly what you mean

    • @denniszignin7745
      @denniszignin7745 4 ปีที่แล้ว

      @@Codemycom sorry for late, I have asked a banality. The behaviour of combo is exactly what I want... 🤦🏻‍♂️

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว

      @@denniszignin7745 I don't know what any of those words together mean...

  • @Kennerdoll
    @Kennerdoll 2 ปีที่แล้ว

    John, how can I use the value selected on a Combobox in another function?
    I have tried to use a return type and make a variable global but still getting errors

    • @Codemycom
      @Codemycom  2 ปีที่แล้ว

      In the same way you pass anything to a function

  • @radhayamini9761
    @radhayamini9761 4 ปีที่แล้ว

    how can we clear the previous selection...like override the label text displayed when we change the selection??

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว +1

      I think I discuss that in the playlist

  • @chrisfrom3cheapdudes769
    @chrisfrom3cheapdudes769 2 ปีที่แล้ว

    how would you return the option selected to a variable? Not inside of the window, but just store the selection into a variable in the code.

    • @Codemycom
      @Codemycom  2 ปีที่แล้ว

      In the same way you create any variable ever. variable_name = clicked.get()

  • @alphainfinitum3445
    @alphainfinitum3445 2 ปีที่แล้ว +1

    My combo box behaves differently when I have it inside a function compared to when it's not inside a function. What I noticed is that when it's not inside a function, the default item is displayed, but once I put the same combobox code inside a function, the default item doesn't display. Otherwise, the rest of the code works as expected. Can any one help with this, or has anyone experienced this before.

    • @Codemycom
      @Codemycom  2 ปีที่แล้ว

      No, that shouldn't be the case.. you're doing something wrong there. You likely forgot to copy the code that sets the default into the function.

  • @swarajsamal6864
    @swarajsamal6864 4 ปีที่แล้ว

    Can we attached it in CSV/XML row ? I need a drop-down list attached with CSV and then want to access in HTML. is it possible. Pls pls explain

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว

      Yes it's possible, you'll have to figure it out yourself tho.

  • @joeyblaq9952
    @joeyblaq9952 2 ปีที่แล้ว

    👍🔥

  • @monzonco
    @monzonco 2 ปีที่แล้ว

    I would like to see a video that one combo box impacts the content of another combo box for example if the combo box has the days of the week the other combo box is set with classes available in a university for each day. The data could be come from a database table,

    • @Codemycom
      @Codemycom  2 ปีที่แล้ว

      Check the playlist...dependent dropdowns...pretty sure I've already done it.

  • @STEFANisNOOB
    @STEFANisNOOB 3 ปีที่แล้ว

    Can anyone tell me how to add a option list on a canvas?I've been struggling with this option list for so long

    • @avpzquizi2103
      @avpzquizi2103 3 ปีที่แล้ว

      Hello Sree Vignesh, I have the same problem can you help me ? or you still don't know?

  • @krishnapatil136
    @krishnapatil136 3 ปีที่แล้ว

    Hi, 1st of all, you are doing an amazing job,
    I want to knw hw to change font/Size of options of the combobox, n can i set it to Readonly, whats syntax for that?
    Also how to change font/size of whatever we are displaying through
    myLabel = Label(root, text= " ")

    • @alphainfinitum3445
      @alphainfinitum3445 2 ปีที่แล้ว

      Let me answer at least your first question. To make the combobox read-only, you should include inside its definition an option called 'state', and set that equal to 'readonly'. So here is the syntax:
      myBox=ttk.Combobox(root, state='readonly', font=(' ',15),...and so on). That should make the combobox read-only. The way I defined the font here will adjust the size of the selection inside the combo box, but not its drop down menu. So you will notice that the size of the drop-down menu itself will not change. I discovered a way to tackle that, but it's too complicated to describe here. If you have solved that problem and an easier solution please share it with us.

  • @livenere
    @livenere 4 ปีที่แล้ว

    Hi i am trying to make a combo from my database. I got the combox to appear, but no data is in it
    myCombo = ttk.Combobox(root, value= c.execute("SELECT DISTINCT DefectCategory FROM [Teardown ].[dbo].[Defect]"))
    myCombo.set("Defects Category")
    myCombo.grid(row=13, column=1)
    This the code im using, any ideals?

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว +1

      Yeah, what made you think you could make a database call from inside the combo box? Put all that stuff in a variable outside the combo box in the normal way you would make a database call, and try putting the variable in the combo box.

    • @livenere
      @livenere 4 ปีที่แล้ว

      @@Codemycom I did the same thing for the drop down and it worked
      clicked = StringVar()
      clicked.set("Defects Category")
      drop = OptionMenu(root, clicked, *c.execute("SELECT DISTINCT DefectCategory FROM [Teardown ].[dbo].[Defect]"))
      drop.grid(row=7, column=1, columnspan=2, pady=10, padx=10, ipadx=80)
      I try turning it into a variable and see if that works.
      Thanks

  • @randatebina7421
    @randatebina7421 4 ปีที่แล้ว +1

    Where do I write (bd,relief , pady, padx)?? In order to change the shape

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว

      what the videos to see.

    • @alphainfinitum3445
      @alphainfinitum3445 2 ปีที่แล้ว

      I don't believe you can change the shape of a widget. Try creating another widget with the disired shape, then kill the old widget.

  • @himanshukhanna5583
    @himanshukhanna5583 4 ปีที่แล้ว

    How do we get value store in a variable, if we use multiple combox & want to get value on single button click.. like, DOB !?

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว +1

      Sorry, not sure what you mean

    • @himanshukhanna5583
      @himanshukhanna5583 4 ปีที่แล้ว

      @@Codemycom suppose we want to enter user date of birth, so we create 3 combobox (dd-mm-yyyy) now how do we get all three values on single button click..?
      & Store then in an empty variable.. like empty=dd-mm-yyyy

  • @justone4272
    @justone4272 4 ปีที่แล้ว

    @Codemy.com can you please help, I am using ttk themes but It doesn't show OptionMenu() as an option, how do I work around this?

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว

      What do you mean, doesn't show it as an option? That's not a thing...

    • @justone4272
      @justone4272 4 ปีที่แล้ว

      Wait- What?

  • @minute-ai
    @minute-ai 2 ปีที่แล้ว

    how to chnage the color in of the widget in azure theme?

    • @Codemycom
      @Codemycom  2 ปีที่แล้ว

      I don't know what azure theme is

  • @shubhanshusharma5372
    @shubhanshusharma5372 3 ปีที่แล้ว +1

    Can i call this from toplevel it shows that top is not defined

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว

      Sure you can

  • @naveeni2644
    @naveeni2644 3 ปีที่แล้ว

    Im trying do combobox which will get data from excel and display in scorlled text box

  • @rakeshshankar2154
    @rakeshshankar2154 3 ปีที่แล้ว +2

    Sir, can we give any background color for combobox?

    • @hishamashour5771
      @hishamashour5771 3 ปีที่แล้ว +1

      root = tk.Tk()
      combostyle = ttk.Style()
      combostyle.theme_create('combostyle', parent='alt',
      settings = {'TCombobox':
      {'configure':
      {'selectbackground': 'blue',
      'fieldbackground': 'red',
      'background': 'green'
      }}}
      )
      # ATTENTION: this applies the new style 'combostyle' to all ttk.Combobox
      combostyle.theme_use('combostyle')
      # show the current styles
      # print(combostyle.theme_names())
      combo = ttk.Combobox(root, values=['1', '2', '3'])
      combo['state'] = 'readonly'
      combo.pack()
      entry = tk.Entry(root)
      entry.pack()
      root.mainloop()
      Taken from Stackoverflow.com

    • @rakeshshankar2154
      @rakeshshankar2154 3 ปีที่แล้ว +1

      @@hishamashour5771 Thank you so much

    • @hishamashour5771
      @hishamashour5771 3 ปีที่แล้ว +1

      @@rakeshshankar2154 Most Welcome!

  • @malakalbakri2392
    @malakalbakri2392 ปีที่แล้ว

    when i link the combobox to a list it doesnt work unless its an already exsisting list, how can i link it to the box while letting the user create the items of the list?

    • @Codemycom
      @Codemycom  ปีที่แล้ว +1

      you can .config() it later with whatever list you want

    • @malakalbakri2392
      @malakalbakri2392 ปีที่แล้ว

      @@Codemycom thanks sm

  • @nellaimuthuvels7099
    @nellaimuthuvels7099 2 ปีที่แล้ว

    How can we increase the sixe and height of the combobox

    • @Codemycom
      @Codemycom  2 ปีที่แล้ว

      Change the font size of the text

  • @ananyasingh1976
    @ananyasingh1976 3 ปีที่แล้ว

    can you please tell me what to do in order to get a value from my dropdown menu to display on a new window?

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว

      the same way you get a value from a dropdown menu any time.

    • @ananyasingh1976
      @ananyasingh1976 3 ปีที่แล้ว

      @@Codemycom I am made a product page where the user can buy the desired products and choose the quantity of products through the dropdown menu. I want that quantity to be displayed on a new window where I am making the invoice. Can you help me get through this problem? I'm a complete newbie and am learning Tkinter from your channel and I have to make this GUI and submit it to my school soon.

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว

      @@ananyasingh1976 Just make the variables global: global variable_name and then you can access them from other windows.

    • @ananyasingh1976
      @ananyasingh1976 3 ปีที่แล้ว

      @@Codemycom thank you so much!

  • @TaxManianDevil
    @TaxManianDevil ปีที่แล้ว

    Does this work the same on customtkinter?

    • @Codemycom
      @Codemycom  ปีที่แล้ว

      nothing works quite the same with customtkinter...

  • @abed839
    @abed839 4 ปีที่แล้ว

    i apply every thing but only the window come up but not the menu

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว

      Are you on a mac?

  • @emmanuelsambo875
    @emmanuelsambo875 3 ปีที่แล้ว

    What if I want my new option to take the position of my first option. E.g, if my first choice was 'yay! It's Friday', can I make my second option, say Tuesday, replace 'yay! It's Friday' ?

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว

      Sure, why not

    • @emmanuelsambo875
      @emmanuelsambo875 3 ปีที่แล้ว

      I tried it, but I'm having difficulties, could you throw a little light on it please?🙏🏿

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว

      @@emmanuelsambo875 update your label...my_label.config(text=new_stuff) or whatever

    • @EduardoRandall
      @EduardoRandall 2 ปีที่แล้ว

      Hey, friend. Have you found the solution to your issue? I'm having the same issue right now and it would help me a lot. Thank you!

    • @alphainfinitum3445
      @alphainfinitum3445 2 ปีที่แล้ว

      @@emmanuelsambo875 you have to manipulate the list from where your selections come. Once you do that, it will be reflected in the drop down of the combo box. This issus has nothing to do with the combo box itself. So write code that will manipulate the list, and your problem will be solved. Just make sure your list has global scope, or you can carefully pass the list as an argument when making the appropriate function call.

  • @tazulislam2698
    @tazulislam2698 2 ปีที่แล้ว

    How to searchable/autocomplete combo box?

    • @Codemycom
      @Codemycom  2 ปีที่แล้ว

      I think I have a video on that in the playlist

  • @christophertnguyen
    @christophertnguyen 3 ปีที่แล้ว

    i tried running this on my mac and it would crash and log me out ... any suggestions on how to run this properly?

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว

      There's no reason for that to happen just because you're on a mac...you must have some typo or error in your code..

    • @christophertnguyen
      @christophertnguyen 3 ปีที่แล้ว

      @@Codemycom hi I completely copied word for word ... but what I did realize that I was not the only one ... a quick google search gave me this which is related but not exactly your code ... github.com/matplotlib/matplotlib/issues/14999 and I realized if I used a conda version of python 3.7.0 version and not 3.7.6 it worked perfectly and no crashing involved. Specifically this:
      Setup the environment using Python 3.7.0, as @ImpatientLearning suggested.
      $ conda create --n python=3.7.0 pip
      $ conda activate
      Thanks for your videos!!

    • @christophertnguyen
      @christophertnguyen 3 ปีที่แล้ว

      @@Codemycom bugs.python.org/issue37833 also see this

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว

      @@christophertnguyen interesting

  • @sujitsingh7279
    @sujitsingh7279 4 ปีที่แล้ว

    Hi sir , I have one question.
    You must have seen in websites where there is a little icon adjacent to a text box which has a calendar icon on which we can click to select our date, month and year. How to do that in tkinter?

    • @sujitsingh7279
      @sujitsingh7279 4 ปีที่แล้ว

      If it is not possible (calendar icon) then how to take date as a user input in tkinter ?

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว

      @@sujitsingh7279 I'm not sure what you mean about the calendar icon...

    • @sujitsingh7279
      @sujitsingh7279 4 ปีที่แล้ว

      @@Codemycom sir I just found the exact word on internet. Actually it's called date picker. So when we want someone to enter a date we provide them an icon where a user clicks and he/she chooses the date, month and year and once a user selects that it enters the date in the text box or entry box. I hope it was explanatory. :)

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว

      @@sujitsingh7279 There's no built in tkinter thing for that..you could hack something together to make something similar, but too complicated to put in a comment here.

    • @sujitsingh7279
      @sujitsingh7279 4 ปีที่แล้ว

      @@Codemycom Thanks for the response sir. What are you going to teach us next in this amazing tkinter series?

  • @raulprahoveanu3980
    @raulprahoveanu3980 3 ปีที่แล้ว

    Hello,I really need help,I want to make multiple OptionMenus with integers,then make a button to add the integers selected from the optionmenu.Can you help me?

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว +1

      I can just point you to my tkinter playlist...I don't see anything difficult or weird about what you want to do..you should find answers to all of it in the playlist

    • @raulprahoveanu3980
      @raulprahoveanu3980 3 ปีที่แล้ว

      @@Codemycom i just ant to know how to store multiple optionmenus in a variable

    • @raulprahoveanu3980
      @raulprahoveanu3980 3 ปีที่แล้ว

      want*

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว

      @@raulprahoveanu3980 make the variable a list, store whatever you want in it

    • @raulprahoveanu3980
      @raulprahoveanu3980 3 ปีที่แล้ว

      @@Codemycom if i use clicked.get(),it just store the last optionmenu,i dont know how to store all of them:(

  • @errorhostnotfound1165
    @errorhostnotfound1165 3 ปีที่แล้ว

    'from tkinter import *' raises a bunch of Wildcard errors. What should I do about it?

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว

      Get rid of whatever weird IDE you're using and use the tools I do.

    • @errorhostnotfound1165
      @errorhostnotfound1165 3 ปีที่แล้ว

      @@Codemycom What tools do you use?

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว

      @@errorhostnotfound1165 Sublime Text Editor and git-scm.com git bash terminal

    • @alphainfinitum3445
      @alphainfinitum3445 2 ปีที่แล้ว

      You also have to import ttk. The very next line of what you wrote should say: from tkinter import ttk, that's where combo boxes live.

  • @bakchodgamer2882
    @bakchodgamer2882 4 ปีที่แล้ว

    def click():
    lab = Label(root, text=var.get())
    lab.place(x=100,y=100)
    list = ["hello","hey","huuu"]
    Var=Stringvar()
    Var.set(list[0])
    Op=OptionMenu(root, Var, *list, command=click)
    Op.pack()
    When I select any option from option box this gives me a error
    TypeError: click() takes 0 positional arguments but 1 was given
    Please help me how can I solve this error

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว

      I don't think you can pack and place at the same time...

    • @bakchodgamer2882
      @bakchodgamer2882 4 ปีที่แล้ว

      @@Codemycom I tried it again by packing the things but it still gives the same error

    • @bakchodgamer2882
      @bakchodgamer2882 4 ปีที่แล้ว

      @@Codemycom but I found the solution for that error from stackoverflow website
      "command = lambda event : click()"
      This gives no error everything works properly
      But "command = click" worked in your video how?

  • @mithunm507
    @mithunm507 2 ปีที่แล้ว

    How to insert separator to combobox in tkinter

    • @Codemycom
      @Codemycom  2 ปีที่แล้ว

      What do you mean?

  • @tonystark2358
    @tonystark2358 4 ปีที่แล้ว +1

    sir, I am having a problem with my code. Help me please
    from tkinter import *
    window = Tk()
    def re(string):
    print(string)
    for i in range(0,11):
    Checkbutton(window, text=f"N{i}", command=lambda:re(i)).pack()
    window.geometry("600x500+120+120")
    window.mainloop()
    when I click a checkbutton, I should have got different number according to checkbutton
    but I am getting 10 every time, I click any checkbutton
    Help me please, I am working on my first application.
    I learn coding from youtube and I am a high school kid.

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว +2

      you aren't setting a variable in your checkbox.

  • @sakshishafi6223
    @sakshishafi6223 3 ปีที่แล้ว

    Sir How to increase size of text in Comboboxes sir.
    Sir please Reply sir

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว

      In the normal way you change text font size

    • @alphainfinitum3445
      @alphainfinitum3445 2 ปีที่แล้ว

      @@Codemycom I had a more specific issues with fonts for combo box: The drop down menu will have a different size from the item in the entry of the combo box. Do you please have a better way of solving that. The method I used altered all combo boxes in my project, instead of just modifying the specific one.

  • @eidnanrohod8788
    @eidnanrohod8788 2 ปีที่แล้ว

    is that heisenberg coding?

  • @MoMo-id6ri
    @MoMo-id6ri 3 ปีที่แล้ว +1

    Combo boxes at 7:52

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว

      yep

    • @Momo-bb2fn
      @Momo-bb2fn 3 ปีที่แล้ว

      @@Codemycom ur great

    • @Momo-bb2fn
      @Momo-bb2fn 3 ปีที่แล้ว

      ​@@Codemycom holy crap i just saw ur linked in: bannerclicks, vitalbio, submission-spider... i don't know if you yourself responded to me, but if you are John Elder, why do you do these tutorials (i mean to ask with genuine, heart-felt curiosity)? What drives you to these specific actions (teaching on youtube)?

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว

      @@Momo-bb2fn Thanks!

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว

      @@Momo-bb2fn Yeah it's me....I do it because I enjoy it.

  • @skystep2
    @skystep2 3 ปีที่แล้ว

    In nearly every tutorial, programmers using import * - that is not helping... trust me. Person may get confused is this build in thing or other.

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว

      Sorry, but you're wrong.