The Spinbox widget is a variant of the Standard Tkinter - learnit

Home Top Ad

Post Top Ad

Friday, July 30, 2021

The Spinbox widget is a variant of the Standard Tkinter

The Spinbox widget is a variant of the Standard 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.


PyGame

pygame is a free and open-source cross-platform library for the development of multimedia applications like video games using Python. It uses the Simple DirectMedia Layer library and several other popular libraries to abstract the most common functions, making writing these programs a more intuitive task.


Spinbox

The Spinbox widget is a variant of the standard Tkinter Entry widget, which can be used to select from a fixed number of values.


Syntax

Here is the simple syntax to create this widget −

w = Spinbox( 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 and Description
1 activebackground The color of the slider and arrowheads when the mouse is over them.
2 bg The color of the slider and arrowheads when the mouse is not over them.
3 bd The 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 command A procedure to be called whenever the scrollbar is moved.
5 cursor The cursor that appears when the mouse is over the scrollbar.
6 disabledbackground The background color to use when the widget is disabled.
7 disabledforeground The text color to use when the widget is disabled.
8 fg Text color.
9 font The font to use in this widget.
10 format Format string. No default value.
11 from_ The minimum value. Used together with to to limit the spinbox range.
12 justify Default is LEFT
13 relief Default is SUNKEN.
14 repeatdelay Together with repeatinterval, this option controls button auto-repeat. Both values are given in milliseconds.
15 repeatinterval See repeatdelay.
16 state One of NORMAL, DISABLED, or "readonly". Default is NORMAL.
17 textvariable No default value.
18 to See from.
19 validate Validation mode. Default is NONE.
20 validatecommand Validation callback. No default value.
21 values A tuple containing valid values for this widget. Overrides from/to/increment
22 vcmd Same as validatecommand.
23 width Widget width, in character units. Default is 20.
24 wrap If true, the up and down buttons will wrap around.
25 xscrollcommand Used to connect a spinbox field to a horizontal scrollbar. This option should be set to the set method of the corresponding scrollbar.

Example Code

from tkinter import *
root= Tk()
root.title('reanits.com')
root.iconbitmap('1.png')
root.geometry('300x400')
def getdata():
    mylabel.config(text=myspinbox.get())
names=("Thida","Nimol","Marady","Heng")
#myspinbox = Spinbox(root, from_=0, to=15, increment=2, font=("Preah Vihear",20))
myspinbox = Spinbox(root, value=names,font=("Preah Vihear",20))
myspinbox.pack(pady=20)
Mybutton = Button(root, text="Submit", command=getdata)
Mybutton.pack(pady=20)
mylabel = Label(root, text="",font=("Preah Vihear",20))
mylabel.pack(pady=20)
root.mainloop()


Please Watching My Video is Below

No comments:

Post a Comment

Post Top Ad