Dynamically Resize Buttons When Resizing a Window - Python Tkinter GUI Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 11 ม.ค. 2025

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

  • @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
    ▶️ Get The Code
    bit.ly/3pFqlnU

  • @nabeelshoukat2133
    @nabeelshoukat2133 4 ปีที่แล้ว +10

    i don't know how to say Thank you .You made my life exciting. i was missing this feature and i was searching for 1 year ,but nothing found .You are great just Love you .
    Thank you ❤

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

      Glad I could help!

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

    Ah, my man, You made my GUI for xclel a lot prettier. Thank you. Did not know i needed that in my life.

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

    Your explanation is very good sir I watch your videos daily ☺️

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

    Wow tkinter has these many abilities ? Thx to codemy for showing this. Your video is always worth watching

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

      Yes, thanks

  • @c.j.hatton
    @c.j.hatton 3 ปีที่แล้ว +2

    which video is for doing this with .pack?

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

    Instead of two rowconfigure or loop...we can pass list[0, 1]
    Like Grid.rowconfigure(root, [0, 1] , weight)
    Its easier

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

      Ah good point!

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

      can we do resizing with text too?

  • @manishpandey-xk9el
    @manishpandey-xk9el 3 ปีที่แล้ว

    Thanks buddy, for simply making my life easier

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

      Happy to help!

  • @ab123-j7v
    @ab123-j7v ปีที่แล้ว

    thanks very much amazing channel and amazing person, can this solve unfit widgets and window on different resolution screens?

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

    Now, with this, how do I make it where my buttons don't stretch to the sides of the window. I'm looking for a dynamic resizing of the buttons and entry fields that are normal sized and aesthetic when a user changes the size of the window.

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

    hey.. can we do this without sticky?
    i mean if i want to make a button in the center with always 50% size. even if we resize the window size , how can we reduce the button size

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

    can you do it for dynamically resizing the other tkinter widgets

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

    content is amaizing, really helpfull

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

      Glad you like it!

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

    Sir please tell how to resize the text of the buttons also, when we are resizing the buttons.

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

      A little more complicated...would have to do a video on it.

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

    Great vid, very helpful.

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

    Thanks

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

    Hey, new thumbnail looks awesome

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

      Hey, thanks!

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

    Hello John. I have been working my way through your tutorials on tkinter. They are clear and nicely compact. Each time you introduce a new method for a particular command i.e. Grid.rowconfig, I add it to my notes and to the table of tkinter commands i am compiling. I have been trying to find an online source that has a comprehensive table of ALL tkinter commands, methods, options, and syntax but have been unsuccesful. Every source has only a subset of "common" options. Can you help point this out to us so we can start crossing off the ones covered and experiment with the unfamiliar ones? This might help us give cogent feedback and make requests for topics to cover in future tutorials. The tuts so far are great. The topics are relevant, covered well, and each builds up to the next lesson. Very satisfying and well paced. Thank you.

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

      Sorry, I don't have any sort of comprehensive list to share with you...

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

      Codemy.com -- oh well, thanks for trying.
      Any suggestions to help my search for a full list of tkinter commands,objects,arguments?
      Perhaps you could pass along my query to the appropriate code gods?

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

      tkinter is a thin wrapper around a tcl/tk interpreter. The tcl man pages have a canonical list of all widgets, commands, options, variables, etc. The documentation is written for a tcl programmer rather than a python programmer, but it's a very easy mental task to translate. The official python tkinter documentation covers the differences between tcl and tkinter. See www.tcl.tk/man and docs.python.org/3.6/library/tkinter.html?highlight=tkinter#tkinter-life-preserver.

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

      Bryan Oakley --- That sounds like the place I should start. Thank you Bryan.

  • @Supraj-S
    @Supraj-S 3 ปีที่แล้ว +1

    Sir, can you please make a video for pack layout

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

      I have almost 200 videos on this playlist using pack

    • @Supraj-S
      @Supraj-S 3 ปีที่แล้ว

      @@Codemycom Thank you so much sir, I'll go through them

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

    Can u saw a way to change color in scroll bar.. which u created on your full window scrollbar video... pls help😢

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

      you may be able to do it with Style()

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

    I am making a calculator as you suggested in one of your videos and in just a day it's up a running! I manage to do dynamically resize all items in the calculator with this tutorial but I have a problem with the entry. It does resize but when the windows it's too small it reduces the height until I can't read any text on it. Ideally I would need a function that no matter what the height of the entry will always stay the same (while allowing to resize the width). How can I do it?

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

    When i try to do this it just says Grid not defined...would appreciate all the help...
    Edit-I tried tk window name(root in my case).rowconfigure and columnconfigure and it worked....so if this doesn't work try doing root.rowconfigure and root.columnconfigure

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

    I use place and not GRID what do I do now
    And I want the frame to move, not the button

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

    Plz tell how to use this with label

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

    I am making something with a frame in the middle. I'd like to put buttons and labels in it, in an organized way. But when I try to grid them, the frame size changes and the sizes of the buttons and labels are very weird too. Is there a proper way to organize them?

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

      you're likely doing something wrong with the grid stuff...

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

      @@Codemycom If I make a label with a size of 10 and place it in the frame, it will be at least 50 pixels. I feel like the proportions are different

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

      @@rensgalesloot3628 In what way? It's all relative

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

      @@Codemycom I think I am going to have to try different things out, it is hard to explain

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

    Check out enumerate...
    for row_number, button in enumerate(button_list):

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

    I tried coding dynamically resize buttons when resizing a window using .place or .place_configure instead but didnt work... Do you think its somehow possible to do this using place() rather than row/column? I find place() easy to work with

  • @KrishnaPatil-qp7yn
    @KrishnaPatil-qp7yn 2 ปีที่แล้ว

    is there any way to make the Tkinter responsive and adjust in a different system with resolution??????

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

      Yes but it's a pain and very time consuming

  • @Teo-dw3ti
    @Teo-dw3ti 4 ปีที่แล้ว +1

    Hi exist a widget of web view in tkinter or other gui library

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

      What do you mean by web view?

    • @Teo-dw3ti
      @Teo-dw3ti 4 ปีที่แล้ว

      @@Codemycom I mean something like a component that displays web pages

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

      @@Teo-dw3ti Ah...I'd have to think about that...nothing comes to mind off the top of my head

    • @Teo-dw3ti
      @Teo-dw3ti 4 ปีที่แล้ว

      @@Codemycom ok can you make a tutorial that's a good idea

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

    Heelp if i resize it from left side, it works byt if i resize it from another side it doesnt woork, whyyy?
    Please help me :c

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

    Hi John. Excellent tuts.
    Here's a question... In some books they explicitly call classes with Tk. For instance...
    button_01 = Tk.Button(text = "blahblahblah")
    Is this deprecated? Is it wrong? Did I misunderstand? Or was it a different version of python/tkinter?
    I see that ttk classes must use ttk. in front e.g. my_notebook_01 = ttk.notebook()
    Can you clarify please?
    And thank you again for the fast paced compact tuts.

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

      Just a different way of doing it. I wouldn't overthink it. It depends on how you import it at the top of your file.

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

    Thats amazing sir..
    But if i use place method in every where in whole project then how to manage like this.

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

      This is for grid

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

      @@Codemycom ohk ✌️btw there is any other option to do that in place method

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

      @@twinbook9025 Of course, there are always unlimited ways of doing all things. Try something like:
      button_1.place(relx=.25, rely=.25, relwidth=.5, relheight=.5)

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

      @@Codemycom thanks a lot sir🙏for having attention on my query. I recently subscribed your channel i found lot of good stuff on that so thanks for take care of my question.

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

    you solved my life biggest problem

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

      Glad I could help!

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

    I use .place on my widgets.Is there a way of resizing them too ?

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

      using place has nothing to do with it. You can always resize any widget in it's normal way.

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

      @@Codemycom Okay,but maybe I asked the Question in a strange way.I meant it like this :
      If I place a Widget via .place in the center of the screen at x,y and I resize it,it doesnt stay centered because it is bound to the coordinates.I hope this describes it better😅

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

      @@themodguy3233 That's not something I can really explain in a comment, you're basically asking how to design a responsive gui.

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

      @@Codemycom Okay,but thanks for trying ✌️

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

    Sir, is there any way to resize label width and height dynamically with mouse buttons in tkinter

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

      sure

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

      @@Codemycom please make a video on this topic

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

      @@akashjain5852 what do you mean by "with mouse button"

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

      @@Codemycom I mean that on pressing the mouse left button and then dragging the mouse , the widget or label increase its size
      And on pressing mouse right button and then dragging the mouse, the widget or label decrease its size
      Something like your tutorial move image on canvas but I want it can grow and shrink image on canvas

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

    can i do this with " button.place(x=", y=" ", height="", and width="")

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

      Give it a try and see

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

      @@Codemycom it does not work with place only work with grid

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

      @@Codemycom if you can please do a video

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

    U are my problem_solver sir this is what i need.

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

      Glad you liked it!

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

    how can i make a label that is in a canvas not move when i resize the window? Ty in advance

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

      Isn't that the default behavior?

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

      @@Codemycom for some reason it moves. The label is inside a window i created in the canvas as you have shown and if i resize my app it moves downwards.
      Maybe im mistaken idk . Ty for responding so soon tho

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

    also can you tell me if there is a way if there is a way to use images on two windows without destroying them without receiving pyimage error. It could make the code more efficient ( I mean the size of the code reduces

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

      Don't know what you mean.

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

      @@Codemycom I meant that is there is a way to use images (with PIL ) on two different tkinter windows at the same time (at the same time I mean having two different windows open with images).

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

      @@justyouraverageviewer Of course there is...why not? There's nothing special to do, just put them up in the customary way.

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

      @@Codemycom please make a video about it
      It would be a lot helpful

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

      @@justyouraverageviewer I already have videos on using images. There's nothing different in doing two images vs doing one image or on multiple windows. Just do everything twice.

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

    Why not just use place?
    button_1 = tkinter.Button(root, text="Button 1")
    button_1.place(relx=.25, rely=.25, relwidth=.5, relheight=.5)

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

      Because this video is to show how to do it with grid

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

      Ugh. One step at a time. 'Place' seems like fancy work for layout experts.
      Although I will play with your example for the fun of it.
      Hmm... Maybe I can be a prankster and make the buttons randomly swim around the frame.

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

      Hey. Why did you type tkinter.Button()? Is that manditory? I thought we just had to type Button().

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

      @@aliceanderson5154 I've been using tk and tkinter since the mid 90's. I can probably count on one hand the number of times I've needed to use place. It has its uses, but the vast majority of the time grid and pack are easier and will result in a more responsive layout. With place, you have to do much more work to get things to both be organized properly from the start and to react properly when you resize the window or run on a system with different fonts or screen sizes.

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

      Bryan Oakley --- thank you Bryan, I'm sure the topic will eventually make it's way to the tutorials. I have patience.

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

    Does this method only work on buttons?

  • @siddharthsingh-cw4sd
    @siddharthsingh-cw4sd 3 ปีที่แล้ว

    can any one tell me what is Grid my compiler showing error

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

      You have a simple typo in your code

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

    This is What I did.
    Grid.rowconfigure(root,(0,1),weight=1)

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

    Thank you so much

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

      Glad you liked it!

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

    Video is great and useful. But ... it is not understood why he does not include the source code for his demos. Why not just cut and paste the final into a link and share the link in the video ? I've asked him for the code from the demos before, I've joined/paid CODEMY, and he just dosn't seem to get it. YES ! The source code would be useful please !

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

      The code is in the pinned comment lol Also, I just searched my gmail and saw that I've sent you emails with direct links to the code when you've asked. So I'm not sure what you're talking about. Maybe I'm not the one who doesn't get it? My github is github.com/flatplanet and the code is ALWAYS there...

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

    This is what i need

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

    thanks!!

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

      You're welcome!

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

    thanx