Adding a Full Screen ScrollBar - Python Tkinter GUI Tutorial #96

Поділитися
Вставка
  • Опубліковано 14 жов 2024

КОМЕНТАРІ • 471

  • @Codemycom
    @Codemycom  4 роки тому +18

    ▶️ Watch Entire Tkinter Playlist ✅ Subscribe To My UA-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/3fLFQ8p

    • @aafiyamemon9535
      @aafiyamemon9535 4 роки тому

      Sir can we replace button with label here?

    • @aafiyamemon9535
      @aafiyamemon9535 4 роки тому +1

      Sir i am not able to get the scroll bar even after writing the same code

    • @codeKeshav
      @codeKeshav 4 роки тому

      Thanks..

    • @codeKeshav
      @codeKeshav 4 роки тому

      @@aafiyamemon9535 I got the scroll bar .

    • @aafiyamemon9535
      @aafiyamemon9535 3 роки тому +1

      @@codeKeshav Woah can u provide me that code plz...

  • @techcomparisons7289
    @techcomparisons7289 4 роки тому +41

    Love the videos! You are always so happy and positive while teaching. Can’t thank you enough!

  • @nataliogomes8303
    @nataliogomes8303 4 роки тому +27

    Your videos are amazing
    Don't stop posting it
    even though you don't have a lot views
    There is people that appreciate your work.
    Thank You

  • @larsondavis8155
    @larsondavis8155 11 днів тому

    I really appreciate all of the videos on using Tkinter. Really, I use it for different projects and love being able to come back to these videos

  • @nowybopes
    @nowybopes 4 роки тому +11

    Thanks!! It's sad your channel isn't that popular, you're the best youtube python teacher I've found

  • @cyberbashir5416
    @cyberbashir5416 8 місяців тому +1

    i dont know how i can say this, by you made me a code, now i write logical pogrames, but all i learnt this from you just for free, thank you sir!!!!!!!!!!!!!!!!!!!!!!!😊😊

  • @hannahthompson3403
    @hannahthompson3403 3 роки тому +3

    SO HELPFUL thank you so much!! spent days looking for an explanation as to how this works and youve pretty much cleared it up for me.. i'll be back!!

    • @Codemycom
      @Codemycom  3 роки тому +2

      Glad you enjoyed it!

  • @priteshmehta
    @priteshmehta 3 роки тому +7

    If you dont want to type copy this
    class scrolbar:
    def _on_mouse_wheel(self,event):
    self.canvas.yview_scroll(-1 * int((event.delta / 120)), "units")
    def __init__(self,Master,bg="orange red"):
    self.master = Master
    self.bg = bg
    self.canvas = Canvas(self.master,bg=self.bg)
    self.canvas.pack(side=LEFT,fill=BOTH,expand=TRUE)
    self.scroller = ttk.Scrollbar(self.master,orient=VERTICAL,command=self.canvas.yview)
    self.scroller.pack(side=RIGHT,fill=Y)
    self.canvas.configure(yscrollcommand=self.scroller.set)
    self.canvas.bind('',lambda e: self.canvas.configure(scrollregion=self.canvas.bbox("all")))
    self.frame = Frame(self.canvas,bg=self.bg,padx=10,pady=10)
    self.canvas.create_window((0,0),window=self.frame,anchor=NW)
    self.frame.bind_all("", self._on_mouse_wheel)

  • @michelelaino
    @michelelaino 3 роки тому +5

    Great tutorial.
    I searched this guide from long time.
    Many thanks for all the videos about Tkinter .
    You are an excellent teacher

  • @francescobenedetti3676
    @francescobenedetti3676 2 роки тому +1

    I'm trying to create a GUI for my Python program, I chose to use tkinter, without knowing it is so counter intuitive, hard to understand and bad documented. Your videos are being very helpful, you are a life saver

  • @akmalhsa
    @akmalhsa 2 роки тому

    no one will ever know how much i appreciate this gentleman for all the knowledge he shared in this one youtube channel for a "reasonable" prices, and the vibes, i love it.
    but now you know...

  • @StephenHoban-n9y
    @StephenHoban-n9y 7 місяців тому

    Changed the for loop buttons to text labels and changed colour to match canvas that way hiding them and only display the necessary widgets - works great : thanks !!

  • @ravedavedave
    @ravedavedave 4 місяці тому

    Damn. Two hours looking at stackoverflow questions couldn't do what 10 minutes watching your video did to help me make this work. Thanks!!!

  • @ramehharmouch6245
    @ramehharmouch6245 4 роки тому +29

    How can i make the scroll bar configured to the mouse scroll ?

    • @Dale90ART
      @Dale90ART 3 роки тому +1

      I see no answers anywhere on youtube for this and not much on google for what i want to do with a scale widget, all i know is it involves event.delta /120 , i'd be interested to know if you found out the best way to make it work, I like this channel but think its abit too advanced for a free tutorial , i want to bind it to the scale widget as a zoom feature for an image viewer

    • @Rodrigo-me6nq
      @Rodrigo-me6nq 3 роки тому +2

      @@Dale90ART Check Momo's comment below. It worked well for me

    • @Momo-bb2fn
      @Momo-bb2fn 3 роки тому +22

      @@Rodrigo-me6nq Thanks g, just putting it here too in case anyone else doesn't see in the future:
      If anyone wants to use the mouse wheel to scroll, place this code after binding the canvas and scroll bar:
      def _on_mouse_wheel(event):
      my_canvas.yview_scroll(-1 * int((event.delta / 120)), "units")
      my_canvas.bind_all("", _on_mouse_wheel)
      You can lower the 120 to increase scroll speed.

    • @frozenmolasses5932
      @frozenmolasses5932 3 роки тому +1

      @@Momo-bb2fn thank you so much :)

    • @Momo-bb2fn
      @Momo-bb2fn 3 роки тому +1

      @@frozenmolasses5932 you’re very welcome :)

  • @rastkogojgic699
    @rastkogojgic699 3 роки тому +2

    You are the best teacher John! I recently bought your entire Codemy course, and I'm loving it. I have a question though, and I haven't been able to find an answer anywhere. I have managed to add a scrollbar to my app. However since a new scrollable background is a frame, that means all labels and text will have an ugly gray outline around them. I can't change that, as I'm using an image as a background. On the other hand, Canvas allows us to use images as background. Is there a way to make Canvas itself scrollable? And if so, how to make the background image stretch downwards? I hope that my question is clear. Thanks!!

  • @kostanchikplay9818
    @kostanchikplay9818 Рік тому

    I created scrollbar, it was slightly wrong, I rewatched video and now that's perfect, thank you so much

  • @jesche6240
    @jesche6240 3 роки тому +1

    So great videos about Python and tkinter! Short and comprehensive, right on point! I like your style, thumbs up 👍💪

  • @grzegorzbrzeczyszczykiewic445
    @grzegorzbrzeczyszczykiewic445 3 роки тому +4

    This is exactly what I needed right now. Great tutorial!

  • @devenjain7116
    @devenjain7116 3 роки тому +9

    Hey there! when I add the scroll bar using this method to my project, I put all my stuff into the Second Frame as you said, but it was left aligned and when I used another screen that was bigger than 1080p, I noticed the misalignment difference.
    Also instead of scrolling down, this scrollbar for some reason scrolls up when I try to scroll down.
    Definitely its something that I am doing wrong, but can't figure out what.

    • @damus6665
      @damus6665 2 роки тому +1

      The left alignment happens to me too

  • @saritachaurasia5326
    @saritachaurasia5326 4 роки тому +10

    Sir please make a video on Treeview widget.
    I am in 9th grade and I learnt a lot from you. Thanks.

    • @Codemycom
      @Codemycom  4 роки тому +1

      I plan on doing that soon

  • @paolosestini850
    @paolosestini850 19 днів тому

    Thanks for the exhaustive explanation.
    I noticed, though, that if you resize (shrink) the window horizontally the scrollbar disappears.
    Any idea on how to avoid this?
    Thanks.

  • @shashiranjanhere
    @shashiranjanhere Рік тому +1

    Thank you so much!! I'm however struggling to add both vertical and horizontal scrollbar at the same time. How to do that?

    • @Codemycom
      @Codemycom  Рік тому +1

      I have videos on that in the playlist

  • @khanaatifali007
    @khanaatifali007 4 роки тому +1

    I can't thank you enough. Within one week of watching your videos, I was able to make very useful programs. Thanks John!!

  • @Patricutza20
    @Patricutza20 4 роки тому +8

    I have a situation that is quite specific, and I am trying to find a solution for it. My window is not scrollable straight away, but rather it is meant to get so during the execution of the application, as more widgets are added to the scrollable frame. When the application opens with too few widgets for it to be scrollable, the scrollbar appears inactive, but if I click the up arrow, it does go up to a blank part of the window. As the frame gets populated with widgets, the scrollbar does not get activated, and the down arrow remains inactive, thereby rendering an only upwards scrollable window, where "up" is blank. The same situation occurs if, in the buttons example you have provided, for example only 3 buttons are instantiated. If you have any idea for how to fix this please let me know, as I fail to comprehend how exactly to google this situation.

    • @pranav-kale
      @pranav-kale 3 роки тому

      is your canvas in separate window or the main frame appears in a window with other widgets that are placed using grid system? I had the same issue so i transferred the whole scroll situation onto a new separate window. Still i have to resize the window once so that the scroll becomes active .
      will update if i find any other solutions.... ;)

    • @frozenmolasses5932
      @frozenmolasses5932 3 роки тому

      me three

    • @frozenmolasses5932
      @frozenmolasses5932 3 роки тому +6

      solution! Every time you add a widget, do root.update_idletasks() then my_canvas.configure(scrollregion = self.my_canvas.bbox('all'))

    • @jimjohnson357
      @jimjohnson357 3 роки тому

      @@frozenmolasses5932 self isn't defined for me... I'm assuming this isn't something built in and is actually a variable you've named?

    • @KDmation
      @KDmation 2 роки тому

      @@frozenmolasses5932 thanks that helped

  • @ahmedalday3029
    @ahmedalday3029 2 роки тому

    hi sir its really nice to see your tuterials and your smile make evrey thing is easy to do , ive question
    how can i make an auto scroll txt let say that we hat txt stream and data keep flow how can i fouces to see the last line while update ... thx

  • @DeeceTube
    @DeeceTube 2 роки тому

    It works, and I get the parts. Yet, there's something I don't quite understand about this. I couldn't implement it in sort of a free form way, I had to follow pretty close. I guess there's a chance I just tripped on something syntactic somewhere, or something like that. You're right, though, it's a little bit convoluted.
    I get a lot of none types, which I think means I'm not passing things quite correctly. Arguments and events have to be in order in terms of how the functions are defined in tkinter - I don't exactly want to learn all of python, but I appreciate that those things are generally accessible when I need them.

    • @Codemycom
      @Codemycom  2 роки тому

      It gets easier with practice.

  • @Racing_Rookie
    @Racing_Rookie Рік тому

    amazing tutorial, it all works in my project. however, is there a way to have the scrolll bar not soo far right of the screen, i would like to have it closer to my widgets. again amazing tutorial thankyou! :)

  • @gcharan1
    @gcharan1 2 роки тому +1

    Hello John,
    Thank you so much for the video. It was very very helpful. However, I have a quick question if you don't mind taking some time to answer it. So after adding the second frame to the window in the canvas and executing the code, you get the result what you have shown. I currently have multiple treeview widgets bound to root window frames which stretch in the horizontal direction upon maximizing the root window to fill the screen. However, when I try adding canvas the way you did and binding these treeview widgets to the second frame, these widgets do not expand anymore when I maximize the root window. Could you please help me on this issue?

  • @cbgregoire9
    @cbgregoire9 Рік тому

    Excellent very helpful video for those struggling to get scrolling to work. Thank-you.

  • @gabrielpena5829
    @gabrielpena5829 3 роки тому +1

    I've learned a lot from you John, i wish i could thank you enough

  • @rokkuzner
    @rokkuzner 2 роки тому

    You make the best vodeos! You every time help me so mutch!! THANKS!! Keep going.

    • @Codemycom
      @Codemycom  2 роки тому

      Glad you like them! Tell your friends ;-)

  • @hkar4385
    @hkar4385 7 місяців тому

    thank you so much. been looking for this over youtube.

    • @Codemycom
      @Codemycom  7 місяців тому

      glad you liked it!

  • @nicolasdegaudenzi2802
    @nicolasdegaudenzi2802 8 місяців тому

    Thank you so much John, it was really useful. My scrollbar functions but my frame's information is cut off as it isn't wide enough, how can I make it to be seen completely?

    • @Codemycom
      @Codemycom  8 місяців тому

      Make a horizontal scrollbar

    • @nicolasdegaudenzi2802
      @nicolasdegaudenzi2802 8 місяців тому

      @@Codemycom thanks man, I made that And also added the width command to the canvas!

  • @ushuyayageppeto4225
    @ushuyayageppeto4225 3 роки тому

    Ok in theory, then the true point about it, it's to include frame within and make them fit the size of the window and keep update stuff added within this canvas, so you stop just before things go wild but useful. ty anyway, nice video.

  • @heresast
    @heresast 2 роки тому

    I love you! OMG this video was VERY USEFUL! THANK YOU SO MUCH!!!

  • @philipjenkins2237
    @philipjenkins2237 3 роки тому

    Hi John,
    I really enjoy your videos, you have a knack for explaining things very clearly.
    I have used this method to create a scrollable frame within a program I'm working on. I have written code that adds (and removes) widgets dynamically when an add or remove button is pressed however, when the list of widgets extends beyond the edge of the bottom of the frame, the scrollbar doesn't update and you can't reach the obscured widgets.
    I hope I've explained myself clearly, do you know a fix for this issue?

    • @Codemycom
      @Codemycom  3 роки тому +1

      Why would you have widgets extending beyond the edge of the bottom of the frame? If you want them to be scrollable, they have to be in the frame that scrolls...

    • @philipjenkins2237
      @philipjenkins2237 3 роки тому

      @@Codemycom Hi John,
      Thanks very much for your quick reply, I have managed to find a fix.
      I might not have explained very well, I'm still quite new to coding. I wanted the 'box' to stay the same size relative to other objects that surround it in the UI. As the objects being added to the bottom the frame which contains them will expand but the 'box' that the user sees the item in doesn't update so that the added items are 'scrollable'
      I managed to find a fix on Stack Overflow if anyone has a similar problem to me:
      stackoverflow.com/questions/47008899/tkinter-dynamic-scrollbar-for-a-dynamic-gui-not-updating-with-gui
      The issue was that I had written the scrollable frame as a class and only updated once in the __init__ function.
      I needed to update the scrollable region after each new item was added or removed.

  • @ronak1520
    @ronak1520 Рік тому

    Hello sir,
    I have problem, i am working on my college project and my project have different menus, one of them should have a scrolling window, following your video, the content i put in that frame which you mentioned sticks to left side of the window. How do place it in the center? Btw great video❤

  • @kingmacbeth9704
    @kingmacbeth9704 9 місяців тому

    Man you did me a huge favor with this

  • @kevinhuaman2328
    @kevinhuaman2328 7 місяців тому

    This was what I was looking for. Thank you!

    • @Codemycom
      @Codemycom  7 місяців тому +1

      Glad I could help!

  • @frankcorral4623
    @frankcorral4623 9 місяців тому

    Subscribed! Just what I needed. Thank you.

    • @Codemycom
      @Codemycom  9 місяців тому

      Glad to hear it!

  • @py_tok5589
    @py_tok5589 4 роки тому

    INTERESTING!!, FIRST ATTEMPT ON Wednesday, done successfully, Thank you for this nice Tutorial John

  • @아이언멘붕
    @아이언멘붕 2 роки тому

    WOW!!! It really helped me a lot. I solved the problem that was not solved. [from: a Korean]

  • @TURURURU1992
    @TURURURU1992 3 місяці тому

    video, great, how do you make numbers like the one that accompanies expand=1 look purple in sublime?

    • @Codemycom
      @Codemycom  3 місяці тому

      It does it automatically by default. Just save the file as a .py file

  • @oliverviniciobosarreyesuri8635

    Muchas gracias por tu esfuerzo, espero algún día encontrar videos de tanta ayuda en mi idioma.

  • @vaidehibag6498
    @vaidehibag6498 3 роки тому +2

    How could I put the scrollbar using place() option cause all my rest widgets have been placed using that

    • @kanwaradnan4849
      @kanwaradnan4849 3 роки тому

      class ScrollableFrame:
      """
      # How to use class
      from tkinter import *
      obj = ScrollableFrame(master,height=300 # Total required height of canvas,width=400 # Total width of master)
      objframe = obj.frame
      # use objframe as the main window to make widget
      """
      def __init__ (self,master,width,height,mousescroll=0):
      self.mousescroll = mousescroll
      self.master = master
      self.height = height
      self.width = width
      self.main_frame = Frame(self.master)
      self.main_frame.pack(fill=BOTH,expand=1)
      self.scrollbar = Scrollbar(self.main_frame, orient=VERTICAL)
      self.scrollbar.pack(side=RIGHT,fill=Y)
      self.canvas = Canvas(self.main_frame,yscrollcommand=self.scrollbar.set)
      self.canvas.pack(expand=True,fill=BOTH)
      self.scrollbar.config(command=self.canvas.yview)
      self.canvas.bind('', lambda e: self.canvas.configure(scrollregion = self.canvas.bbox("all")))
      self.frame = Frame(self.canvas,width=self.width,height=self.height)
      self.frame.pack(expand=True,fill=BOTH)
      self.canvas.create_window((0,0), window=self.frame, anchor="nw")
      self.frame.bind("", self.entered)
      self.frame.bind("", self.left)
      def _on_mouse_wheel(self,event):
      self.canvas.yview_scroll(-1 * int((event.delta / 120)), "units")
      def entered(self,event):
      if self.mousescroll:
      self.canvas.bind_all("", self._on_mouse_wheel)

      def left(self,event):
      if self.mousescroll:
      self.canvas.unbind_all("")

  • @sophia9689
    @sophia9689 2 роки тому

    you. are. a. LIFESAVER! i cant thank you enough for this video
    srsly, why cant this be easier?

    • @Codemycom
      @Codemycom  2 роки тому

      Welcome! And it is pretty easy when you know how...

  • @ClaudioBOsorio
    @ClaudioBOsorio 2 роки тому

    This man is so great. I always wanted to make my own software and now im doing so. Thank you!

    • @Codemycom
      @Codemycom  2 роки тому

      Very happy to hear it!

  • @huh__oa
    @huh__oa 3 роки тому +1

    Hello Sir, I tried this code and it worked. However, when I apply it to the code I have written few days ago, I wasn't able to get it to work.
    My code has some frames in it and those frames have some labels and images. So I changed placed the frames into the second frame. Doing this however does not work Does using place instead of pack and grid for the frames I have affect the result. Just some additional information, I use place because I find relx, rely, relwidth, and relheight very useful in layouting a program.
    Any help will be appreciated

  • @maiconlourenco4849
    @maiconlourenco4849 2 роки тому +1

    "It is kind of tricky. " I had the same feeling.

  • @bentsionben-david2769
    @bentsionben-david2769 2 роки тому

    Wow.. amazing it worked to me finally..
    but how can i scroll up and down only by the mouse without selecting and moving the scrollbar itsself?

  • @ThankYouESM
    @ThankYouESM 2 роки тому +1

    The next step for this is to make it work with zooming images and especially have the scrollbars vanish if the image fits well enough on the screen (which avoids flickering).

  • @MianAffanAli
    @MianAffanAli 4 роки тому +1

    Custom Scrollbar means a manually designed scrollbar like in VS code Scrollbar is in black colour

    • @Codemycom
      @Codemycom  4 роки тому

      You can google tkinter themes but I'm not sure that is the solution.

    • @MianAffanAli
      @MianAffanAli 4 роки тому

      * @Codemy.com My Problem is solved using tkinter themes. I have* a made a customized scrollbar by editing ttk style. thank you.
      > Check this code on GitHub
      *github.com/ChAffanAli/Custom-ScrollBar-in-Tkinter-Python*

  • @mGrivley
    @mGrivley 2 роки тому

    Thank you very much for this video, it's just what I needed !

  • @Francisco-me2eu
    @Francisco-me2eu 2 роки тому

    I owe you a beer at least, your videos are the best!

  • @nissivarghese2459
    @nissivarghese2459 2 роки тому

    Hi , it is great video.. I would like to know how we can make scrollbar in entire window using grid layout. I tried to use same method , But I could not get same like pack method. Can you suggest any steps same as pack method.. Thanks in advance

    • @Codemycom
      @Codemycom  2 роки тому

      It's the same as the pack method. No difference.

  • @geniozao
    @geniozao 3 роки тому

    My friend, the code worked perfectly for my case! Thank you soooo much!

  • @ansmunir5277
    @ansmunir5277 Рік тому

    The video is great. I have followed your video and make a scroll bar. But the issue is scroll bar doesn't work with mouse scroll button. Instead I have to scroll up and down by mouse click. Am I making some mistake?

    • @Codemycom
      @Codemycom  Рік тому +1

      Yes, it works fine for me with the mouse scroll wheel.

  • @ame367
    @ame367 2 роки тому +1

    Great video, everything worked perfectly!
    I am using images for each of my buttons to make them look a bit more customized, but when scrolling they become a little distorted and smear a bit. Does anyone have any solutions to this?

    • @willlennox6973
      @willlennox6973 2 роки тому

      It's just the frame updating, it has to run a loop every time. Try to use smaller res images, lighter file formats or SVGs

  • @Hex-Scholar
    @Hex-Scholar Рік тому

    Hey John,
    Can we add a horizontal & vertical scrollbar within the same canvas as-well ?

    • @Codemycom
      @Codemycom  Рік тому

      yes

    • @Hex-Scholar
      @Hex-Scholar Рік тому

      @@Codemycom Thanks, can you help me with that if possible ? like If I use the same code as instructed by you in the video how can that be done ?

    • @Codemycom
      @Codemycom  Рік тому

      @@Hex-Scholar I have videos on using horizontal scrollbars.

    • @Hex-Scholar
      @Hex-Scholar Рік тому

      @@Codemycom Thanks Sir, I’ll look for them 👍🏻

  • @shoyeb25
    @shoyeb25 6 місяців тому

    Is there a way to expand the inner frame to fill canvas width? I tried packing inner frame with fill x and expand 1 but it doesn't work

  • @kylegessner3870
    @kylegessner3870 2 роки тому +1

    I successfully created a scrollbar for my program, but before adding the scrollbar i was using the .pack(fill=tk.X) to make my widgets expand horizontally once i added the scrollbar my widgets no longer expand to the size of the frame. Any ideas on how to fix this issue.

  • @victorlima8205
    @victorlima8205 Рік тому

    Great video, teacher!

  • @ansmunir5277
    @ansmunir5277 Рік тому

    I have another question that to maximize the window I am using
    window = Tk()
    window.state('zoomed')
    But issue is the scroll bar. When the window opens there is no scroll bar but when I click the maximize button in top right corner then the scroll bar appears and also works fine. I think there would be the issue of focus. I need to give focus to the scroll bar but I don't know how can give it. If I remove the zoomed state then scroll bar also works fine but I need to maximize it to full screen with top and task bar present. That is why I am using state zoom. Please help me in this regard. Thank you

  • @maxwellhawk
    @maxwellhawk Рік тому

    I have 1 little problem with this code. When I create list of widgets on all window and there is a little widgets - so basically they do not need scrolling, its still scrolling. So I have 3 label widgets that I want present as list scrolling over the empty screen down and up. Is there a way to avoid it? Make it scroll ONLY if it's exceed the screen damention?

  • @cmputerprgrammer7800
    @cmputerprgrammer7800 4 роки тому +1

    Sir, how about adding colors to scroll bars?? And also changing their relief?

    • @alphascript
      @alphascript 3 роки тому +1

      You need to use ttk styling and create a theme for it then apply that to the scrollbar.

  • @martinchalot9411
    @martinchalot9411 5 місяців тому

    I followed this steps, and okay the scrollbar works fine but the second frame does not take the full width of the canvas, how to make the second frame fit the full width of the canvas?

  • @mchammerkristofer
    @mchammerkristofer 4 роки тому

    Thank you. I learned a lot on your tutorials.

  • @balazsmolnar2386
    @balazsmolnar2386 3 роки тому

    This was very helpful, thanks!

  • @damienj3980
    @damienj3980 3 роки тому

    Thank you !
    Now it's clear to my mind

  • @RyanDanielG
    @RyanDanielG 3 роки тому

    Smash that like button guys n gals! its free! great python tkinter tutorial, Codemy. Thanks

  • @SergejsDmitrijevs-jo2du
    @SergejsDmitrijevs-jo2du 9 місяців тому

    Excellent, thank you very much!

  • @jackmazzella4920
    @jackmazzella4920 3 роки тому

    I used this scrollbar and it works well, except that the scrollbar always orients itself at the bottom of the screen. Is there a way to have the scrollbar always start at the top of the screen?

  • @insertx2k_dev
    @insertx2k_dev 3 роки тому

    You deserve all the best!

  • @jimhaffner9583
    @jimhaffner9583 2 роки тому

    t tave app that will show data from API url calls. The app is 2 side by side frames. Left frame is details to run the api calls and the right frame (output frame) has the canvas displayed. I'm assuming my next step is to add the label for displaying the result and then scroll the canvas?? I don't have to create a new frame??

  • @katatonos
    @katatonos 3 роки тому

    Is there a way to make the scrollbar dynamically update? I'm using the frame to output data from a button click, and I have it so it is printing labels on the button press, but it is always one less click than I have done, unless I manually change the window size.
    Anyways, thanks for the videos. Because of them, in two weeks I've gone from knowing literally nothing about python, to building my own GUI to automate my home laboratory equipment.

    • @Codemycom
      @Codemycom  3 роки тому

      not sure what you mean…but congrats on your progress! that’s great to hear!

    • @katatonos
      @katatonos 3 роки тому

      Yeah that wasn't the best explanation. Basically I have a button click that send a command to a power supply. I used your code to create an output window with a scroll bar. When I click the button n Number of times, the output window will only display n-1 commands. It'll display the last command only when I manually expand the app window. Hope that was more clear

  • @shehab976
    @shehab976 3 роки тому

    Sir,how to relatively change the origin x,y of a canvas after being scrolled??i'm stucked in a problem

  • @vivekkm5543
    @vivekkm5543 Рік тому

    Hi John, same code i tried for 2000 box it didnt capture all the boxes when i scrolled down, can u pls help on that. Thanks..

  • @aritraj10b28
    @aritraj10b28 3 роки тому

    Awesome ! It added life to my program. ☺️

  • @maniskul
    @maniskul Рік тому

    Thanks. this solved my problem :)

  • @Darclient
    @Darclient 3 роки тому

    Can I add stuff like labels etc to that? I have been trying to apply this code to my programm but it doesnt display anything.

  • @henriqueoliveira5270
    @henriqueoliveira5270 2 роки тому

    I did all these instructions, and it is working. But when I delete some widgets, the scrollbar does not resize automatically.... how can I do it?

  • @cherryman2908
    @cherryman2908 4 роки тому +1

    this way has the problems. idk how to refresh all this widgetes or scrollbar when I add new button in the second_frame. by the button in the bottom for ex. i want to add new buttoms but scrollbar doesn't refresh.

    • @cherryman2908
      @cherryman2908 4 роки тому

      also if there are little widgetes in the frame u can scroll it to the top and to the bottom. looks ugly. if u have answer to my first problem, please, comment it.

  • @nikolar5847
    @nikolar5847 2 роки тому

    I love your videos!

  • @insertx2k_dev
    @insertx2k_dev 3 роки тому

    Thank you for such a great tutorial, I completely appreciate your effort to make this easier for everyone to understand, but each time I try to execute the commands I write, it throws me an error which tells me that .grid is not supposed to be used here as the grid we created is controlling such function, how do I resolve this problem?

    • @Codemycom
      @Codemycom  3 роки тому +1

      Are you using both grid and pack? You can only use one or the other in any parent

    • @insertx2k_dev
      @insertx2k_dev 3 роки тому

      @@Codemycom I just followed what you do in the video, and it seems like you used both.

    • @Codemycom
      @Codemycom  3 роки тому +1

      @@insertx2k_dev No, you didn't follow or you wouldn't be getting errors. You can use both as long as they are in different parents...so only under certain circumstances that you don't understand.

    • @insertx2k_dev
      @insertx2k_dev 3 роки тому

      @@Codemycom I am pretty sure that I understand most of the video, and yes, the compiler I use is Visual Studio Code, and I am running Microsoft Windows 10 64-bit, could this problem be a compiler one?

    • @Codemycom
      @Codemycom  3 роки тому +1

      @@insertx2k_dev No...it's exactly what I said it was. You can't use grid and pack in the same parent ever.

  • @dm-vh9yu
    @dm-vh9yu 3 роки тому

    Amazing video. Thank you!

  • @mimicottage
    @mimicottage 3 роки тому

    This was a nice tutorial....YO!!

  • @waddadutoit8174
    @waddadutoit8174 2 роки тому

    Hi, how can i make the buttons appear in the centre of the window rather than the left-hand side (without using grid)? Should you make the frame or canvas appear in the centre rather than the left? If so, how?

    • @waddadutoit8174
      @waddadutoit8174 2 роки тому

      Figured it out, >> my_canvas.create_window((X,0),window = self.second_frame, anchor = "nw"), just increase X

  • @jandykman7851
    @jandykman7851 4 роки тому

    Thanks John, much appreciated!

  • @miguelcastillolanderos.2357
    @miguelcastillolanderos.2357 4 роки тому

    thank you so much, finally a good explain for that.

  • @rushexpert2665
    @rushexpert2665 Рік тому

    In same code if we set the range upto 1000 in for loop then the buttons display till 711 button only is there any solution for this?

  • @infinitespace1982
    @infinitespace1982 2 роки тому

    Hi! I was wondering, if we add a new widget during run-time, woul the scrollbar adjust to be able to scroll all the way down to that new widget?

    • @Codemycom
      @Codemycom  2 роки тому

      give it a try and see :-p

  • @mohanedmohsen8263
    @mohanedmohsen8263 2 роки тому

    thank you for the great video any ideas what should i do to make it add new buttons at run time ? i tried to do this but its not working i expect it to add one more button when i click any keyboard button
    def onKeyPress(event):
    global second_frame
    print("key clicked")
    Button(second_frame, text='test').grid(row=10, column=0, pady=10, padx=10)

    root.bind('', onKeyPress)
    root.mainloop()

    • @Codemycom
      @Codemycom  2 роки тому

      You haven't packed or gridded the second frame.

  • @darkchoclate
    @darkchoclate 4 роки тому +1

    Love your style... Suggestion: if you do the whole coding in python interpreter directly, and show the effect of the code at same time, it would be much easier to understand.

    • @Codemycom
      @Codemycom  4 роки тому +7

      You shouldn't do code in the python interpreter. 1. Tkinter doesn't always work there and 2. you would never do that in a professional setting, so why do it ever? 3. It would be way more confusing in every way.

  • @aadishm4793
    @aadishm4793 2 роки тому

    yes the code worked perfectley but the second frame is not the size of the canvas and thats why i am not able to label text in the right side, any way ?

  • @AtulKumar-dj8vg
    @AtulKumar-dj8vg 4 роки тому

    Well done, this helped me a lot

  • @surajmoolya9462
    @surajmoolya9462 3 роки тому

    Sir i tried in your code in my project.
    but scroolbar area is not upadting for the widget added at the runtime.
    but if i resize the window it gets updated.
    can you sugest a way to update the scrollbar area every time the new widget is added

  • @ZiyaoHe-f1c
    @ZiyaoHe-f1c 4 роки тому

    Sir, one question: Since there is no Canvas in the ttk module, how can I make the style of Canvas (from tk) the same as the one I set in ttk?
    Thank you!

    • @ZiyaoHe-f1c
      @ZiyaoHe-f1c 4 роки тому

      Okay, problem solved, but still thank you! It is really a nice tutorial.
      stackoverflow.com/questions/27892994/get-default-background-of-ttk-frame

    • @Codemycom
      @Codemycom  4 роки тому

      sure

  • @upprrdimensions892
    @upprrdimensions892 4 роки тому

    Very Interactive video and teaching 😍😍

  • @Nelaach
    @Nelaach 3 роки тому +1

    Thanks! Really helpfull :D

  • @UlTrAXcH
    @UlTrAXcH 3 роки тому

    Hello, I followed your code and successfully employed it in my project. However, I have one question, I modified the window size a bit as I am using the buttons as the .place method. However, I am having a hard time creating rectangles using create_rectangle now as they are always behind the new window that is being created. Can you help me with how can I create a rectangle that will be over this window?

    • @Codemycom
      @Codemycom  3 роки тому

      Sorry, I don't have any videos on place method

    • @kanwaradnan4849
      @kanwaradnan4849 3 роки тому

      @@Codemycom
      Here's the way to use place method.
      from tkinter import *
      from tkinter import ttk
      root = Tk()
      root.title('Learn To Code at Codemy.com')
      Height=600
      Width=625
      Sizeofwin=f"{Width}x{Height}"
      root.geometry(Sizeofwin)
      SizeofCanvas = 3100 # You can add y of every widget to get this value
      # Create A Main Frame
      main_frame = Frame(root)
      main_frame.pack(fill=BOTH,expand=1)
      # Add A Scrollbar To The Canvas
      my_scrollbar = ttk.Scrollbar(main_frame, orient=VERTICAL)
      my_scrollbar.pack(side=RIGHT,fill=Y)
      # Create A Canvas
      my_canvas = Canvas(main_frame,yscrollcommand=my_scrollbar.set)
      my_canvas.pack(expand=True,fill=BOTH)
      # Configure The Scrollbar
      my_scrollbar.config(command=my_canvas.yview)
      # Configure The Canvas
      my_canvas.bind('', lambda e: my_canvas.configure(scrollregion = my_canvas.bbox("all")))
      def _on_mouse_wheel(event):
      my_canvas.yview_scroll(-1 * int((event.delta / 120)), "units")
      my_canvas.bind_all("", _on_mouse_wheel)
      # Create ANOTHER Frame INSIDE the Canvas
      frame = Frame(my_canvas)
      frame.pack(expand=True,fill=BOTH)
      # Add that New frame To a Window In The Canvas
      my_canvas.create_window((0,0), window=frame, anchor="nw")
      posY=0
      for thing in range(101):
      posY = posY + 30
      Button(frame, text=f'Button {thing} Yo!').place(x=50,y=posY)
      # Adding the real size of canvas
      frame.configure(width=Width,height=SizeofCanvas)
      root.mainloop()

    • @kanwaradnan4849
      @kanwaradnan4849 3 роки тому

      You can create a frame anywhere of the root having any height width and pass frame inplace of root it will work well with that also.