Full Screen ScrollBar-Python Tkinter - learnit

Home Top Ad

Post Top Ad

Friday, July 23, 2021

Full Screen ScrollBar-Python Tkinter

Full Screen ScrollBar-Python Tkinter

What is Python

Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Its high-level built in data structures, combined with dynamic typing and dynamic binding, make it very attractive for Rapid Application Development, as well as for use as a scripting or glue language to connect existing components together. Python is simple, easy to learn syntax emphasizes readability and therefore reduces the cost of program maintenance. Python supports modules and packages, which encourages program modularity and code reuse. The Python interpreter and the extensive standard library are available in source or binary form without charge for all major platforms, and can be freely distributed.


Often, programmers fall in love with Python because of the increased productivity it provides. Since there is no compilation step, the edit-test-debug cycle is incredibly fast. Debugging Python programs is easy: a bug or bad input will never cause a segmentation fault. Instead, when the interpreter discovers an error, it raises an exception. When the program does not catch the exception, the interpreter prints a stack trace. A source level debugger allows inspection of local and global variables, evaluation of arbitrary expressions, setting breakpoints, stepping through the code a line at a time, and so on. The debugger is written in Python itself, testifying to Python's introspective power. On the other hand, often the quickest way to debug a program is to add a few print statements to the source: the fast edit-test-debug cycle makes this simple approach very effective.


Scroll Python

This widget provides a slide controller that is used to implement vertical scrolled widgets, such as Listbox, Text and Canvas. Note that you can also create horizontal scrollbars on Entry widgets.


Syntax

w = Scrollbar ( master, option, ... )

Parameters

master − This represents the parent window

options − Here is the list of most commonly used options for this widget. These options can be used as key-value pairs separated by commas

No Option/Description
1 activebackgroundThe color of the slider and arrowheads when the mouse is over them.
2 bgThe color of the slider and arrowheads when the mouse is not over them.
3 bdThe width of the 3-d borders around the entire perimeter of the trough, and also the width of the 3-d effects on the arrowheads and slider. Default is no border around the trough, and a 2-pixel border around the arrowheads and slider.
4 CursorThe cursor that appears when the mouse is over the scrollbar.
5 elementborderwidthThe width of the borders around the arrowheads and slider. The default is elementborderwidth=-1, which means to use the value of the borderwidth option
6 commandA procedure to be called whenever the scrollbar is moved.
7 highlightthicknessThe thickness of the focus highlight. Default is 1. Set to 0 to suppress display of the focus highlight.
8 jumpThis option controls what happens when a user drags the slider. Normally (jump=0), every small drag of the slider causes the command callback to be called. If you set this option to 1, the callback isn't called until the user releases the mouse button.
9 highlightcolorThe color of the focus highlight when the scrollbar has the focus.
10 highlightbackgroundThe color of the focus highlight when the scrollbar does not have focus.
11 orientSet orient=HORIZONTAL for a horizontal scrollbar, orient=VERTICAL for a vertical one
12 widthWidth of the scrollbar (its y dimension if horizontal, and its x dimension if vertical). Default is 16.
13 repeatdelayThis option controls how long button 1 has to be held down in the trough before the slider starts moving in that direction repeatedly. Default is repeatdelay=300, and the units are milliseconds
14 takefocusNormally, you can tab the focus through a scrollbar widget. Set takefocus=0 if you don't want this behavior.
15 repeatinterval
16 troughcolorThe color of the trough.

Code

from tkinter import *
import pygame
from tkinter import filedialog
import time
from mutagen.mp3 import MP3
import tkinter.ttk as ttk
root= Tk()
root.title('reanits.com')
root.iconbitmap('1.png')
root.geometry('300x400')
pygame.mixer.init()
mainframe= Frame(root)
mainframe.pack(fill=BOTH, expand=1)
mycanvas= Canvas(mainframe)
mycanvas.pack(side=LEFT, fill=BOTH, expand=1)
myscrollbar= ttk.Scrollbar(mainframe, orient=VERTICAL,command=mycanvas.yview)
myscrollbar.pack(side=RIGHT, fill=Y)
mycanvas.configure(yscrollcommand=myscrollbar.set)
mycanvas.bind('', lambda e:mycanvas.configure(scrollregion=mycanvas.bbox("all")))
secondframe= Frame(mycanvas)
mycanvas.create_window((0,0), window=secondframe, anchor="nw")
for i in range(80):
    Button(secondframe, text=f'reanits.com{i}').grid(row=i, column=0, pady=15, padx=10)
    MyLabel= Label(secondframe, text="reanit.com").grid(row=i,column=1, pady=15, padx=10)
root.mainloop()

Please Watching My Video is Below

No comments:

Post a Comment

Post Top Ad