Skip to main content

How to add listbox in Table Insertion Python programming language?

 How to add list box in Table Insertion Python programming language

Here...How to add list box in Table Insertion Python 

         the programming language, what is comment How can you add

         There are some excellent idea to help you make the 

         new concepts, you are learning 



Introduction to Tkinter Listbox

...........................................................

Tkinter Listbox widget is used to display a list of items of which all are text 

items having the same font and color and the user can choose more than one items 

from the list to be displayed depending on the configuration of the widget and the 

Listbox is initially empty when it is created and requires the insertion of more than 

one line of text which can be done using insert method for which an index and 

the string must be given as arguments of which index is the item number 

in the list and string is the text item to be displayed.




Listbox uses the following syntax:

..........................................................




w = Listbox(master, option,..)




Where the master represents the parent window and the option is the list of 

options that can be used for the widget and options are the 

key-value pairs that are separated by commas.





Tkinter Listbox Widget

...............................................



The most commonly used list of options for the widget are:


1.bg: Behind the label and indicator, the normal background color is displayed.


2.bd: This represents the border size around the indicator. Its default value is two pixels.


3.cursor: When the mouse is moved over the Listbox, a cursor appears and that is this cursor.


4.font: This represents the font of the text present in the Listbox.


5.fg: This represents the color of the text in the Listbox.


6.height: This represents the number of lines in the Listbox.

              The default value for the number of lines is ten.


7.highlightcolor: This represents the focus highlight 

                       color when the focus is on the widget.


8.highlightthickness: This represents the focus highlight thickness.


9.relief: The border shading effects is selected as three dimensional by relief. The default value for relief is SUNKEN.


10.select background: This represents the background-color 

                             to be used while displaying the text that is selected.



11.selectmode:This specifies the number of items that can be 

     chosen, and the effect of mouse drag on the selection


12.Browse: This is the default setting. One line from the Listbox can be selected. If an item is clicked and dragged to some other line, the chosen line goes along with the mouse.



13.Single: Only one line can be selected, and the mouse cannot be 

              dragged, wherever the button one is clicked, that corresponding line is chosen.



14.Multiple: The number of lines can be selected at once is not fixed. 

                 Selection can be determined by clicking on any 

                 line and it's toggling.


15.Extended: The number of adjacent group of lines can be selected at 

                  once is not fixed and is selected by dragging to last 

                  a line from clicking on the 1st line.



16.width: This represents the width of the character present in the widget. The default value of the widget is twenty.



17.scroll command: The horizontal scrollbar linked to the Listbox 

                            the widget allows the user to horizontally 

                            scroll the Listbox.



18.scroll command: The vertical scrollbar linked to the Listbox widget allows 

                            the user to vertically scroll the Listbox.







.................................................................................

There are several methods that can be implemented 

  on Listbox objects, they are:




1.activate(index): The line which is specified by the index 

                         passed as an argument is selected.


2.curselection():The selected elements line numbers starting from zero is put into a 

                       tuple and is returned by curselection() method. 

                      An empty tuple is returned if there is no selection.



3.delete(first, last=None): The indices in the range [first, last] are deleted using this option. 

                                     The single line having the first index is deleted if 

                                     the second argument is omitted.


4.get(first, last=none): The lines consisting of the text whose indices from the first line to the last line is contained in a tuple and is returned. The text of the line similar to the first line is returned if the first argument is omitted.



5.index(i): The portion of the Listbox that is visible is positioned in such 

               a way that the top of the widget consists of a line with index i.



6.insert(index, *elements): More than one line is inserted into the Listbox keeping the line marked by the index above all the lines. If new lines are to be added to the list box's end, END must be used as the first argument.



7.nearest(y): The index of the line that is visible and which is nearest to 

                   they coordinate Listbox widget’s y relative is returned.



8.see(index): The place of the Listbox is adjusted 

                  so that the index referred lines are visible.



9.size(): The count of lines in the Listbox is returned.



10.xview(): The command option of the horizontal scrollbar is set 

                to view() method to make the Listbox horizontally scrollable.



11.xview_moveto(fraction): When the Listbox is scrolled, the leftmost fraction of the width of the longest line in the list box is present outside the left side of the Listbox. The range of the fraction is [0,1].



12.xview_scroll(number, what): This method is used to horizontally scroll the Listbox. 

                                            What argument uses either unit which scrolls with respect to characters or PAGES which scrolls with respect to pages by the list box's width. The number of times to be scrolled is told by the number argument.



13.yview(): The command option of the vertical scrollbar is set to view() 

                method to make the Listbox vertically scrollable.



14.(fraction): When the Listbox is scrolled, the top fraction of the width of the longest line in the Listbox is present outside the left side of the Listbox. 

                 The range of the fraction is [0,1].



15.yview_scroll(number, what): This method is used to vertically scroll the Listbox. 

                                          What argument uses either unit which scrolls by characters or 

                                          PAGES which scrolls by pages by the list box's height. 

                                          How many to scroll is told by the number argument.





..................................................................

Example on Tkinter Listbox

Below is the example of Tkinter Listbox:

Python program using Tkinter Listbox to display a list of items.




#Here is Code:

..................



from tkinter import *

import tkinter

top1 = Tk()

lb = Listbox(top1)

lb.insert(1, "Bangalore")

lb.insert(2, "Mysore")

lb.insert(3, "Mangalore")

lb.insert(4, "Hubli")

lb.insert(5, "Dharwad")

lb.insert(6, "Belgaum")

lb.pack()

top1.mainloop()




Conclusion-In this tutorial you will have to learn the detailed How to add Listbox 

                in Table Insertion Python programming language

                So hope you liked these tutorials. If you have any questions or 

                suggestions related to Python, please comment below and let us know.

                Finally, if you find this post informative, then share it with 

                your friends on Facebook, Twitter, Instagram. 


Thank you...





Comments

Popular posts from this blog

How to Send OTP in Mobile Number | login with OTP mobile Number | How to send OTP in mobile no with Spring Boot APP

   ðŸ˜‚               Login with Mobile Number OTP ---------------------------------------------------------------------------- If you want to develop a project to log in with OTP mobile Number in Spring Boot Applications then this post for you. In this post, I am going to use some other service to send the OTP in mobile number. we have to use it in this project spring boot. we are going to use Twilio to send SMS. we are going to use a web socket to send the data from the browser to the SMS gateway. Oracle Database for store the user details. <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> <version>2.3.3.RELEASE</version> </dependency> <dependency> <groupId>com.twilio.sdk</grou

Spring Boot With MySQL Database connection with Examples | MySQl Database Configuration with Spring Boot Projects

 ðŸ˜ƒ MySQL Database Configuration with Spring Boot Projects  In this article, we are going to introduce How to connect MySQL Database with the Spring Boot project. pom.xml   <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <scope>runtime</scope> <optional>true</optional> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>org.projectlombok</gro

How can we create Auto generated field or ID for mongodb using spring boot

😂 How can we create an Auto-generated field or ID for MongoDB using spring boot? First Create One Application Like Mongodb_sequence-id-generator Pom.XML <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-mongodb</artifactId> </dependency> <dependency> <groupId>de.flapdoodle.embed</groupId> <artifactId>de.flapdoodle.embed.mongo</artifactId> </dependency> User.java package com.app; import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Transient; import org.springframework.data.mongodb.core.mapping.Document; @Document(collection = "users_db") public class User { @Transient public static final String SEQUENCE_NAME = &