<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-2258844867892945003</atom:id><lastBuildDate>Sat, 21 Mar 2026 18:42:03 +0000</lastBuildDate><category>Work with VB6.0</category><category>NetBeans</category><category>Java</category><category>Work with PDF</category><category>Python</category><category>Work with ASP.NET</category><category>Tips And Tricks</category><category>VB.Net</category><category>Blog Tips</category><category>HTML</category><category>Linux Tips</category><title>SKOTechLearn Tips</title><description>The Blog described the learning process of PDF edit, watermark, conversion, Tag, Clean PDF, Reduce Size, Compression type, Metadata Searchable process etc and Image process with tiff, JPG, PNG, Learn Software Development  with Visual Basic6.0 or VB6.0, VB.net, ASP.Net, Netbeans, HTML, JScript, Blog,  website programming and Its related Back end Database such as Text, Excel, Ms-Access, SQL). Command Line (CMD). Learn Java, Netbeans, Code, MSSQL, MYSQL, Eclipse, Xampp, PHP, Website development.</description><link>https://www.skotechlearn.com/</link><managingEditor>noreply@blogger.com (SKOTechLearn)</managingEditor><generator>Blogger</generator><openSearch:totalResults>95</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2258844867892945003.post-8948943991787469047</guid><pubDate>Wed, 29 Jun 2022 21:34:00 +0000</pubDate><atom:updated>2022-06-29T14:34:43.976-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Tips And Tricks</category><title>Find Duplicate Items in Excel Tips</title><description>&lt;p&gt;Suppose, we have records containing duplicate values. And we want to find records that can repeat many times in records in Excel. So, In MS Excel tools provide following way to find &lt;b&gt;Duplicate value in Excel&lt;/b&gt; or &lt;b&gt;Find Duplicate in Excel&lt;/b&gt;.&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMhy51t4VKTeldeDK_ZcXvYT13Y2O5bs7Wq9c9qzywVUVSQchiqgkAZC7CFK97CTxUrTWZuvR6zHUjgT9IR-VYmRppWFoFbNoWw25fYEP_Os8wWkAr7WR7qTeRh4GhQQlV51L9HHPzxUzFUTNSx2s_MaHb44IXGbIlC_AfV3rR2oqLDOA5nlI2Z76XNA/s764/Duplicate_In_Excel_Mini.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Find Duplicate in Excel&quot; border=&quot;0&quot; data-original-height=&quot;326&quot; data-original-width=&quot;764&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMhy51t4VKTeldeDK_ZcXvYT13Y2O5bs7Wq9c9qzywVUVSQchiqgkAZC7CFK97CTxUrTWZuvR6zHUjgT9IR-VYmRppWFoFbNoWw25fYEP_Os8wWkAr7WR7qTeRh4GhQQlV51L9HHPzxUzFUTNSx2s_MaHb44IXGbIlC_AfV3rR2oqLDOA5nlI2Z76XNA/s16000/Duplicate_In_Excel_Mini.jpg&quot; title=&quot;Find Duplicate items in Excel&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Find Duplicate through Simple Process in Excel&lt;/li&gt;
&lt;/b&gt;  &lt;b&gt;
&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Find Duplicate with Custom Color or Style in Excel&lt;/li&gt;
 &lt;/b&gt;  &lt;b&gt;
&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Find Duplicate through Function in Excel&lt;/li&gt;
  &lt;/b&gt;  &lt;b&gt;
&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Find Duplicate Row in Excel Using Formula&lt;/li&gt;
&lt;/b&gt;
&lt;/ol&gt;

&lt;br /&gt;
So, Lets start with every option in given above with following steps:&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 17px;&quot;&gt;&lt;b&gt;(1). Find Duplicate through Simple Process in Excel :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;
For Simple Process, you have to follow the steps:
&lt;br /&gt;&lt;br /&gt;
&lt;div style=&quot;background-color: #f59e42; border-radius: 12px; border: 1.4px solid rgb(98, 62, 96); color: white; float: left; font-family: verdana; font-size: 14px; margin: 0px 3px; text-align: center; width: 25px;&quot;&gt;&lt;b&gt; 1.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;Select All Rows And Columns in Which you want to find duplicate items.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

&lt;div style=&quot;background-color: #f59e42; border-radius: 12px; border: 1.4px solid rgb(98, 62, 96); color: white; float: left; font-family: verdana; font-size: 14px; margin: 0px 3px; text-align: center; width: 25px;&quot;&gt;&lt;b&gt; 2.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;Find “&lt;b&gt;Conditional Formatting&lt;/b&gt;” option from “&lt;b&gt;Home&lt;/b&gt;” Tab.
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

&lt;div style=&quot;background-color: #f59e42; border-radius: 12px; border: 1.4px solid rgb(98, 62, 96); color: white; float: left; font-family: verdana; font-size: 14px; margin: 0px 3px; text-align: center; width: 25px;&quot;&gt;&lt;b&gt; 3.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;Click on “&lt;b&gt;Conditional Formatting&lt;/b&gt;”, it will show popup List Containing many options.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

&lt;div style=&quot;background-color: #f59e42; border-radius: 12px; border: 1.4px solid rgb(98, 62, 96); color: white; float: left; font-family: verdana; font-size: 14px; margin: 0px 3px; text-align: center; width: 25px;&quot;&gt;&lt;b&gt; 4.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;Go to “&lt;b&gt;Highlight Cells Rules&lt;/b&gt;”.  It also shows a list of Option. Click on “&lt;b&gt;Duplicate Values..&lt;/b&gt;” option.&lt;div&gt;&lt;br /&gt;

&lt;div style=&quot;background-color: #f59e42; border-radius: 12px; border: 1.4px solid rgb(98, 62, 96); color: white; float: left; font-family: verdana; font-size: 14px; margin: 0px 3px; text-align: center; width: 25px;&quot;&gt;&lt;b&gt; 5.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;This will show “&lt;b&gt;Duplicate Vales&lt;/b&gt;” window. Contains options and Color indicator for duplicate value.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;

&lt;div style=&quot;background-color: #f59e42; border-radius: 12px; border: 1.4px solid rgb(98, 62, 96); color: white; float: left; font-family: verdana; font-size: 14px; margin: 0px 3px; text-align: center; width: 25px;&quot;&gt;&lt;b&gt; 6.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;After Selecting desire color. Click on “&lt;b&gt;OK&lt;/b&gt;” button. This will highlight duplicate values or items with chosen color.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBMtW73y9LfNEvEyEGIoEg8ddk6MrSTemQJ9Dto-yTQFyWepM8DHG1J9SdWR0yUpsiXWQOj8m6nofrQ7Nvjk4zUjA7mQgfEbl6RyBFYPn3WEvURgCJMZVFguNYXnUoYL3oifRwMUwwa3isHa7KfbW0vUKq51f8dJbb1-iiOKWOiE95ud5qBRX5Jd96_A/s611/Find%20Duplicate%20through%20Simple%20Process%20in%20Excel_mini.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Find Duplicate in Excel with Simple Process&quot; border=&quot;0&quot; data-original-height=&quot;514&quot; data-original-width=&quot;611&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBMtW73y9LfNEvEyEGIoEg8ddk6MrSTemQJ9Dto-yTQFyWepM8DHG1J9SdWR0yUpsiXWQOj8m6nofrQ7Nvjk4zUjA7mQgfEbl6RyBFYPn3WEvURgCJMZVFguNYXnUoYL3oifRwMUwwa3isHa7KfbW0vUKq51f8dJbb1-iiOKWOiE95ud5qBRX5Jd96_A/s16000/Find%20Duplicate%20through%20Simple%20Process%20in%20Excel_mini.jpg&quot; title=&quot;Simple Process to Find Duplicate In Excel&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
As you can see, there will be colored cells of &lt;b&gt;duplicate items in MS Excel&lt;/b&gt;. &lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 17px;&quot;&gt;&lt;b&gt;(2). Find Duplicate with Custom Color or Style in Excel :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;
If you want to change Duplicate Item’s cell’s color, border or font then, you have to follow steps:
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

&lt;div style=&quot;background-color: #6fbcd6; border-radius: 12px; border: 1.4px solid rgb(98, 62, 96); color: white; float: left; font-family: verdana; font-size: 14px; margin: 0px 3px; text-align: center; width: 25px;&quot;&gt;&lt;b&gt; 1.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;First Select All Rows and Columns in which you want to indicate duplicate values or items.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

&lt;div style=&quot;background-color: #6fbcd6; border-radius: 12px; border: 1.4px solid rgb(98, 62, 96); color: white; float: left; font-family: verdana; font-size: 14px; margin: 0px 3px; text-align: center; width: 25px;&quot;&gt;&lt;b&gt; 2.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;In “&lt;b&gt;Conditional Formatting&lt;/b&gt;” click on “&lt;b&gt;New Rule…&lt;/b&gt;” from it.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

&lt;div style=&quot;background-color: #6fbcd6; border-radius: 12px; border: 1.4px solid rgb(98, 62, 96); color: white; float: left; font-family: verdana; font-size: 14px; margin: 0px 3px; text-align: center; width: 25px;&quot;&gt;&lt;b&gt; 3.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;This will display “&lt;b&gt;New Formatting Rule&lt;/b&gt;” dialog.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

&lt;div style=&quot;background-color: #6fbcd6; border-radius: 12px; border: 1.4px solid rgb(98, 62, 96); color: white; float: left; font-family: verdana; font-size: 14px; margin: 0px 3px; text-align: center; width: 25px;&quot;&gt;&lt;b&gt; 4.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;Select “&lt;b&gt;Format only unique or duplicate values&lt;/b&gt;”. After this option selection, press “&lt;b&gt;Format…&lt;/b&gt;” button. This will show “&lt;b&gt;Format Cells&lt;/b&gt;” dialog.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

&lt;div style=&quot;background-color: #6fbcd6; border-radius: 12px; border: 1.4px solid rgb(98, 62, 96); color: white; float: left; font-family: verdana; font-size: 14px; margin: 0px 3px; text-align: center; width: 25px;&quot;&gt;&lt;b&gt; 5.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;If you want to Change Font Name, Size or Font Color then go to “&lt;b&gt;Font&lt;/b&gt;” Tab. If you want to change border Style then go to “&lt;b&gt;Border&lt;/b&gt;” Tab. If you want To change cell’s &lt;b&gt;background color&lt;/b&gt; then go to “&lt;b&gt;Fill&lt;/b&gt;” Tab.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

&lt;div style=&quot;background-color: #6fbcd6; border-radius: 12px; border: 1.4px solid rgb(98, 62, 96); color: white; float: left; font-family: verdana; font-size: 14px; margin: 0px 3px; text-align: center; width: 25px;&quot;&gt;&lt;b&gt; 6.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;After that press “&lt;b&gt;OK&lt;/b&gt;” button from “&lt;b&gt;Format Cells&lt;/b&gt;” dialog. Then press “&lt;b&gt;OK&lt;/b&gt;” button from the dialog of “&lt;b&gt;New Formatting Rule&lt;/b&gt;”. &lt;div&gt;&lt;br /&gt;&lt;/div&gt;

This steps show Duplicate Items in different style like bellow:&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-LiUXS7x9_ef19zo8lAGw5xp6cP51_i2pb9Xao1iRFnYGscYYNWVwufOlJcRgwLoJ2DALs5490e_FQAiu4bZz0iyYoz24IE4fqwG0-iz3MlivjDjrJoVmsTEY5HapL2TLgRslKTpmrv7f_mC3L9xIkBhUQyP_rWZdH3bJ6nVc5kkjN2PKdQiauHezsw/s783/Find%20Duplicate%20with%20Custom%20Color%20or%20Style%20in%20Excel_mini.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Duplicate with Custom Color and Style in Excel&quot; border=&quot;0&quot; data-original-height=&quot;450&quot; data-original-width=&quot;783&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-LiUXS7x9_ef19zo8lAGw5xp6cP51_i2pb9Xao1iRFnYGscYYNWVwufOlJcRgwLoJ2DALs5490e_FQAiu4bZz0iyYoz24IE4fqwG0-iz3MlivjDjrJoVmsTEY5HapL2TLgRslKTpmrv7f_mC3L9xIkBhUQyP_rWZdH3bJ6nVc5kkjN2PKdQiauHezsw/s16000/Find%20Duplicate%20with%20Custom%20Color%20or%20Style%20in%20Excel_mini.jpg&quot; title=&quot;Find Duplicate with custom color and Style in Excel&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;This way you can&lt;/span&gt; &lt;b&gt;Highlight Duplicate in Excel&lt;/b&gt;.&lt;/h4&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 17px;&quot;&gt;&lt;b&gt;(3). Find Duplicate through Function in Excel :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;
Now if you want to find duplicate items through custom rules applying with formula. Then we have to use “&lt;b&gt;COUNTIF&lt;/b&gt;” function like following steps:
&lt;br /&gt;&lt;br /&gt;

&lt;div style=&quot;background-color: #ac7dc9; border-radius: 12px; border: 1.4px solid rgb(98, 62, 96); color: white; float: left; font-family: verdana; font-size: 14px; margin: 0px 3px; text-align: center; width: 25px;&quot;&gt;&lt;b&gt; 1.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;Same as above Go to “&lt;b&gt;Conditional Formatting&lt;/b&gt;” then click on “&lt;b&gt;New Rule…&lt;/b&gt;”. &lt;div&gt;&lt;br /&gt;&lt;/div&gt;

&lt;div style=&quot;background-color: #ac7dc9; border-radius: 12px; border: 1.4px solid rgb(98, 62, 96); color: white; float: left; font-family: verdana; font-size: 14px; margin: 0px 3px; text-align: center; width: 25px;&quot;&gt;&lt;b&gt; 2.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;This will show “&lt;b&gt;New Formatting Rule&lt;/b&gt;” dialog. Here we select “&lt;b&gt;Use a formula to determine which cells to format&lt;/b&gt;”. After selecting this, “&lt;b&gt;Format values where this formula is true:&lt;/b&gt;” Formula Box will appear.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

&lt;div style=&quot;background-color: #ac7dc9; border-radius: 12px; border: 1.4px solid rgb(98, 62, 96); color: white; float: left; font-family: verdana; font-size: 14px; margin: 0px 3px; text-align: center; width: 25px;&quot;&gt;&lt;b&gt; 3.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;The duplicate formula function Syntax is :&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;b style=&quot;background-color: #cfe2f3;&quot;&gt;=COUNTIF (range, criteria)&amp;gt;1&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;Details:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;background-color: #cfe2f3; font-size: medium;&quot;&gt;=COUNTIF(Selection Of Rows and Columns, Selection For Which cell will be count) &amp;gt; 1&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
Example:&lt;div&gt;&lt;br /&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;b style=&quot;background-color: #fff2cc;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;=COUNTIF($A$2:$B$11, A2:B11) &amp;gt;1&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div style=&quot;background-color: #ac7dc9; border-radius: 12px; border: 1.4px solid rgb(98, 62, 96); color: white; float: left; font-family: verdana; font-size: 14px; margin: 0px 3px; text-align: center; width: 25px;&quot;&gt;&lt;b&gt; 4.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;Then click on “&lt;b&gt;Format…&lt;/b&gt;” button for color and style of duplicate items. Then click “&lt;b&gt;OK&lt;/b&gt;” button.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

This process will also show duplicate items with style and color.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEieg1VgECHAqBusCaVDtnZG0lQwFZD6AMODrLgOerROKMv40zKobczRZYnIUsfa2GUNc8tJTIIjWEzSoCObGC1sU2gnF6tPno_HkEI4H6AITayT_ufGLQiAR72LCKyPK5aBCPTzR7pHF-WOjE3A4Ak-dZS4jDnvtCD2l8BnGZ1m5_cQUJrbhjS5CslABw/s988/Find%20Duplicate%20through%20Function%20in%20Excel_mini.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Find Duplicate through function in Excel&quot; border=&quot;0&quot; data-original-height=&quot;540&quot; data-original-width=&quot;988&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEieg1VgECHAqBusCaVDtnZG0lQwFZD6AMODrLgOerROKMv40zKobczRZYnIUsfa2GUNc8tJTIIjWEzSoCObGC1sU2gnF6tPno_HkEI4H6AITayT_ufGLQiAR72LCKyPK5aBCPTzR7pHF-WOjE3A4Ak-dZS4jDnvtCD2l8BnGZ1m5_cQUJrbhjS5CslABw/s16000/Find%20Duplicate%20through%20Function%20in%20Excel_mini.jpg&quot; title=&quot;Function to Find Duplicate in Excel&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 17px;&quot;&gt;&lt;b&gt;(4). Find Duplicate Row in Excel Using Formula :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;
Suppose, you want to check duplicate Row in Excel not duplicate cell. Then you have to use same process as describe above but using different formula “&lt;b&gt;COUNTIFS&lt;/b&gt;” with following steps:
&lt;br /&gt;&lt;br /&gt;
&lt;div style=&quot;background-color: #6aa685; border-radius: 12px; border: 1.4px solid rgb(98, 62, 96); color: white; float: left; font-family: verdana; font-size: 14px; margin: 0px 3px; text-align: center; width: 25px;&quot;&gt;&lt;b&gt; 1.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;Same as above Go to “&lt;b&gt;Conditional Formatting&lt;/b&gt;” then Click on “&lt;b&gt;New Rule…&lt;/b&gt;”. &lt;div&gt;&lt;br /&gt;&lt;/div&gt;

&lt;div style=&quot;background-color: #6aa685; border-radius: 12px; border: 1.4px solid rgb(98, 62, 96); color: white; float: left; font-family: verdana; font-size: 14px; margin: 0px 3px; text-align: center; width: 25px;&quot;&gt;&lt;b&gt; 2.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;This will show “&lt;b&gt;New Formatting Rule&lt;/b&gt;” dialog. Now go to the option “&lt;b&gt;Use a formula to determine which cells to format&lt;/b&gt;”. After Selecting this, “&lt;b&gt;Format values where this formula is true:&lt;/b&gt;” Formula Box will appear. &lt;div&gt;&lt;br /&gt;&lt;/div&gt;

&lt;div style=&quot;background-color: #6aa685; border-radius: 12px; border: 1.4px solid rgb(98, 62, 96); color: white; float: left; font-family: verdana; font-size: 14px; margin: 0px 3px; text-align: center; width: 25px;&quot;&gt;&lt;b&gt; 3.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;Write formula as describe below:&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;b&gt;&lt;span style=&quot;background-color: #fce5cd; font-family: verdana;&quot;&gt;=COUNTIFS(&lt;/span&gt;&lt;span style=&quot;background-color: #e9fbdd; font-family: verdana;&quot;&gt;$A$2:$A$11&lt;/span&gt;&lt;span style=&quot;background-color: #fce5cd; font-family: verdana;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;background-color: #cfe2f3; font-family: verdana;&quot;&gt; $A1&lt;/span&gt;&lt;span style=&quot;background-color: #fce5cd; font-family: verdana;&quot;&gt;, &lt;span style=&quot;background-color: #e9fbdd; font-family: verdana;&quot;&gt;$C$2:$C$11&lt;/span&gt;,&lt;/span&gt;&lt;span style=&quot;background-color: #cfe2f3; font-family: verdana;&quot;&gt; $C1&lt;/span&gt;&lt;span style=&quot;background-color: #fce5cd; font-family: verdana;&quot;&gt;)&amp;gt;1&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;

&lt;br /&gt;&lt;br /&gt;
This will show &lt;b&gt;Duplicate Row in Excel&lt;/b&gt;.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiS-nUolVOXr3aW6ztbUvEysHNhZbOYXH8qUwDEbWkpHK6Y2smI0GbewfTuvGBOBkAVHZVrjV1SYpWeilDMoABHsaGFXO9BJ-nQDfLYeNPhxOEE7NTanN9YL-c5IKJOdvgpQQNYDo4iH7ScGmDQ3AMexc99IW7vl-24gKmDhSaTSExUISm4izuVSvkaxQ/s988/show%20Duplicate%20Row%20in%20Excel_mini.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Find Duplicate Row in Excel&quot; border=&quot;0&quot; data-original-height=&quot;540&quot; data-original-width=&quot;988&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiS-nUolVOXr3aW6ztbUvEysHNhZbOYXH8qUwDEbWkpHK6Y2smI0GbewfTuvGBOBkAVHZVrjV1SYpWeilDMoABHsaGFXO9BJ-nQDfLYeNPhxOEE7NTanN9YL-c5IKJOdvgpQQNYDo4iH7ScGmDQ3AMexc99IW7vl-24gKmDhSaTSExUISm4izuVSvkaxQ/s16000/show%20Duplicate%20Row%20in%20Excel_mini.jpg&quot; title=&quot;Duplicate Row in Excel&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So, In this way we can find the &lt;b&gt;duplicate items in Excel&lt;/b&gt;&amp;nbsp;and &lt;b&gt;Duplicate rows in Excel&lt;/b&gt;&amp;nbsp;and find &lt;b&gt;Duplicate in Excel&lt;/b&gt; with easy tech tips.&lt;/div&gt;</description><link>https://www.skotechlearn.com/2022/06/find-duplicate-in-excel-tips.html</link><author>noreply@blogger.com (SKOTechLearn)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMhy51t4VKTeldeDK_ZcXvYT13Y2O5bs7Wq9c9qzywVUVSQchiqgkAZC7CFK97CTxUrTWZuvR6zHUjgT9IR-VYmRppWFoFbNoWw25fYEP_Os8wWkAr7WR7qTeRh4GhQQlV51L9HHPzxUzFUTNSx2s_MaHb44IXGbIlC_AfV3rR2oqLDOA5nlI2Z76XNA/s72-c/Duplicate_In_Excel_Mini.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2258844867892945003.post-3721126485698438317</guid><pubDate>Sat, 25 Jun 2022 20:54:00 +0000</pubDate><atom:updated>2022-06-26T00:37:10.263-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Tips And Tricks</category><title>Excel Filter Types And Use Filter in Excel Tips</title><description>&lt;p&gt;In MS Office, you will find that there is many features which provide easy data handling for any company or concern. So here we will discuss and learn about Types of Filter in Excel and Use Excel Filter with easy tech tips. In &lt;a href=&quot;https://www.microsoft.com/en-in/download/office.aspx&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;MS Office&lt;/a&gt;, Excel provide many advanced features.&lt;/p&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3cLWj3mKADWYuYFwkQRVqJx4RES6k9PHIzEMzkjsLaKwOpMo0RV5PztloYPHy2U6v8j19W7ToSonO2GsHIozNZmSEQMSLEUGi1zFKqdvEhAN0fAszGWFb_LXb-SMtw1iv-cgKeZIsG1sKJeXj3rQoTymgS9V5sELON4lyuEPBAd8M4zyeVMKJ3e-iuQ/s762/02_Text_And_Number_Filters_In_Excel%20-%20Mini2.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Text_And_Number_Filters_In_Excel&quot; border=&quot;0&quot; data-original-height=&quot;274&quot; data-original-width=&quot;762&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3cLWj3mKADWYuYFwkQRVqJx4RES6k9PHIzEMzkjsLaKwOpMo0RV5PztloYPHy2U6v8j19W7ToSonO2GsHIozNZmSEQMSLEUGi1zFKqdvEhAN0fAszGWFb_LXb-SMtw1iv-cgKeZIsG1sKJeXj3rQoTymgS9V5sELON4lyuEPBAd8M4zyeVMKJ3e-iuQ/s16000/02_Text_And_Number_Filters_In_Excel%20-%20Mini2.jpg&quot; title=&quot;Text Filter And Number Filters In Excel&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;b&gt;&lt;span style=&quot;background-color: #0b5394; color: #fcff01; font-size: medium;&quot;&gt;
Shortcut Key :&amp;nbsp; &lt;/span&gt;&lt;/b&gt;( &lt;b&gt;Ctrl + Shift + L&lt;/b&gt;) or ( &lt;b&gt;Ctrl + Shift + l&lt;/b&gt;) for Add Filter in Excel Column or Remove Filter in Excel Column.&lt;div&gt;&lt;br /&gt;
&lt;h2 style=&quot;background-color: #614d70; border-radius: 3px; border: 2px solid rgb(178, 154, 148); line-height: 28px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 19px;&quot;&gt;&lt;b&gt;Find Filter Option In Excel :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;

First When you open excel sheet, you will find that your excel file open with “&lt;b&gt;Home&lt;/b&gt;” tab. This tab contain some option.&lt;div&gt;&lt;br /&gt;&lt;div&gt;&lt;b style=&quot;background-color: #f6b26b;&quot;&gt;&amp;nbsp;1.&amp;nbsp;&lt;/b&gt; Find ‘&lt;b&gt;Editing&lt;/b&gt;’ option from this tab.&amp;nbsp;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b style=&quot;background-color: #f6b26b;&quot;&gt;&amp;nbsp;2.&amp;nbsp;&lt;/b&gt;&amp;nbsp;‘&lt;b&gt;Editing&lt;/b&gt;’ option contain many options (‘AutoSum’, ‘Fill’, ‘Clear’, ‘&lt;b&gt;Sort &amp;amp; Filter&lt;/b&gt;’, ‘Find &amp;amp; Select’).&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b style=&quot;background-color: #f6b26b;&quot;&gt;&amp;nbsp;3.&amp;nbsp;&lt;/b&gt;&amp;nbsp;Here, you will click on ‘&lt;b&gt;Sort &amp;amp; Filter&lt;/b&gt;’ Option. This will Show Options List. Select ‘&lt;b&gt;&lt;u&gt;F&lt;/u&gt;ilter&lt;/b&gt;’ option.&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtFkFOaPmPFDyxLRWTx-U56VlBgLy3E6pf72Ex0iPAC94Zw_vA2nZT7HEaVf6LekTe4UnNzdbn-VZCPYr8zinRDC4hVtswEyg36TJX-nLKOZEqcskcTdldNwh0KYUSpBpetxAqq-WAUOLiNBYM2PLF9JQwPvpZ6ltULZBZl7Z3gnUj-XcIKmUn2gwUEA/s204/FilterOpttion_Excel_1_Mini.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Filter Option Excel&quot; border=&quot;0&quot; data-original-height=&quot;198&quot; data-original-width=&quot;204&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtFkFOaPmPFDyxLRWTx-U56VlBgLy3E6pf72Ex0iPAC94Zw_vA2nZT7HEaVf6LekTe4UnNzdbn-VZCPYr8zinRDC4hVtswEyg36TJX-nLKOZEqcskcTdldNwh0KYUSpBpetxAqq-WAUOLiNBYM2PLF9JQwPvpZ6ltULZBZl7Z3gnUj-XcIKmUn2gwUEA/s16000/FilterOpttion_Excel_1_Mini.jpg&quot; title=&quot;Filter Option in Excel Steps&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;Or&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;b style=&quot;background-color: #b6d7a8;&quot;&gt;&amp;nbsp;1.&amp;nbsp;&lt;/b&gt; Find “&lt;b&gt;Data&lt;/b&gt;” Tab from menu. This Tab contain many option.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b style=&quot;background-color: #b6d7a8;&quot;&gt;&amp;nbsp;2.&amp;nbsp;&lt;/b&gt; Go to “&lt;b&gt;Sort &amp;amp; Filter&lt;/b&gt;” Option. And Select “&lt;b&gt;Filter&lt;/b&gt;” option.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxrGAGdlyQf-crFCuXD2Wzlgvfugl9g-ehMSpjey5iaW4y4sNBCAwKx0G0eW39KLPB6sU_Po7Wn_5LJhM5m1psuV5IaOSK8pTSnXfwZQ77GTUruMRrfvXNJwMogJsP9OKiKNEAvFdUTA2tGkI7TXNVk7Gl39Rl1CK-pqKa1LPTybjCdEdZ53w32wYSTg/s293/FilterOpttion_Excel_2_Mini.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Filter Option Excel Step 2&quot; border=&quot;0&quot; data-original-height=&quot;165&quot; data-original-width=&quot;293&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxrGAGdlyQf-crFCuXD2Wzlgvfugl9g-ehMSpjey5iaW4y4sNBCAwKx0G0eW39KLPB6sU_Po7Wn_5LJhM5m1psuV5IaOSK8pTSnXfwZQ77GTUruMRrfvXNJwMogJsP9OKiKNEAvFdUTA2tGkI7TXNVk7Gl39Rl1CK-pqKa1LPTybjCdEdZ53w32wYSTg/s16000/FilterOpttion_Excel_2_Mini.jpg&quot; title=&quot;Filter Option in Excel Step 2&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b style=&quot;background-color: #b6d7a8;&quot;&gt;&amp;nbsp;3.&amp;nbsp;&lt;/b&gt;&amp;nbsp;This will add filter button&amp;nbsp;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisrC33uu8vGCNrSO-L_PHIjquuOGOaENKeTapbN-XCCtVN3XdslCU5omIIGIwHBq6RpujXYp4tlsKvg9EyoSE01WBfY-6_Dv7nc2Uj-sh6wUqUk_L00cZui8WPcBONUz8E_Vx-J_dnGPmTJSZJNeIlrOmUpJmNxFXvtBXFjRjVypzzADGhwdSfQTf_eA/s19/Filter_Button.jpg&quot; style=&quot;clear: left; display: inline; margin-bottom: 0em; margin-right: 0em; text-align: center;&quot;&gt;&lt;img alt=&quot;Filter Button in Excel&quot; border=&quot;0&quot; data-original-height=&quot;19&quot; data-original-width=&quot;19&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisrC33uu8vGCNrSO-L_PHIjquuOGOaENKeTapbN-XCCtVN3XdslCU5omIIGIwHBq6RpujXYp4tlsKvg9EyoSE01WBfY-6_Dv7nc2Uj-sh6wUqUk_L00cZui8WPcBONUz8E_Vx-J_dnGPmTJSZJNeIlrOmUpJmNxFXvtBXFjRjVypzzADGhwdSfQTf_eA/s16000/Filter_Button.jpg&quot; title=&quot;Add Filter Button In Excel Column&quot; /&gt;&lt;/a&gt;&amp;nbsp;on every Column Header as describe above image.&amp;nbsp;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;b style=&quot;background-color: #b6d7a8;&quot;&gt;&amp;nbsp;4.&amp;nbsp;&lt;/b&gt;&amp;nbsp;When you click on this button, it will show popup window containing filter option. Like above image. And when you apply filter then the Filter Button&amp;nbsp;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjssKXOw1NOS4AghJVg1A3b7aa0MlVm1nuYfdEn6sC4oU858A4Lxhy9KJ_zywc9xCvgwkrgxyzn2zAF6AM9EkaTYor4UJa8VwjruCAxpwpms5dwYv0FXQB7E4oOpBwRkRJVcW_fces3XPJEDZPCyyKBxsffOOJlY04H0fqThESmdirmoOUUToLCq7h7bA/s19/After_Apply_Filter.jpg&quot; style=&quot;margin-left: 0em; margin-right: 0em; text-align: center;&quot;&gt;&lt;img alt=&quot;Apply Filter Button in Excel&quot; border=&quot;0&quot; data-original-height=&quot;19&quot; data-original-width=&quot;19&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjssKXOw1NOS4AghJVg1A3b7aa0MlVm1nuYfdEn6sC4oU858A4Lxhy9KJ_zywc9xCvgwkrgxyzn2zAF6AM9EkaTYor4UJa8VwjruCAxpwpms5dwYv0FXQB7E4oOpBwRkRJVcW_fces3XPJEDZPCyyKBxsffOOJlY04H0fqThESmdirmoOUUToLCq7h7bA/s16000/After_Apply_Filter.jpg&quot; title=&quot;Apply Filter Button Icon in Excel&quot; /&gt;&lt;/a&gt;&amp;nbsp;icon will change.&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;
  
  &lt;div style=&quot;background-color: #cfe2f3; border-radius: 3px; border: 1px solid rgb(178, 154, 148); line-height: 28px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Here are following excel filter types:&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;br /&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Manual Filters &lt;/li&gt;
&lt;/b&gt;  &lt;b&gt;
&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Text Filters&lt;/li&gt;
 &lt;/b&gt;  &lt;b&gt;
&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Numbers Filters&lt;/li&gt;
  &lt;/b&gt;  &lt;b&gt;
&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Filter by Color in Excel&lt;/li&gt;
&lt;/b&gt;
&lt;/ol&gt;

&lt;br /&gt;
&lt;br /&gt;
Now Lets Start with Point to Point and step by step to understand amazing feature of filters.
&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 17px;&quot;&gt;&lt;b&gt;(1). Manual Filters :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;
If you want to set filter manually, then there is a list will popup when you click on &lt;b&gt;Filter &lt;/b&gt;button containing particular column record.&amp;nbsp;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;First remove check from “&lt;b&gt;Select All&lt;/b&gt;”.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Or Clear tick mark from all Check Boxes. Then check that items which you want to show like bellow.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhA-cN1UJlT95MaiqtOifvhuYERqyCObOLqX5HiM0-haZ9rf80n_88WSaNU3TbzlvREJscRJ3jBpNgIzeQptNgLEM3zWjqKKTxfzIEGDYC-kIjioaS7GFd3TlAZ6_s0E2XmK75EdvPOFav1kuXuICn9pRP3cO4_OtnGrpA7bNRhda4wfrjhtjTe_NbO1Q/s734/Manual_Filter_Process_Mini.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Manual Filter in Excel&quot; border=&quot;0&quot; data-original-height=&quot;324&quot; data-original-width=&quot;734&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhA-cN1UJlT95MaiqtOifvhuYERqyCObOLqX5HiM0-haZ9rf80n_88WSaNU3TbzlvREJscRJ3jBpNgIzeQptNgLEM3zWjqKKTxfzIEGDYC-kIjioaS7GFd3TlAZ6_s0E2XmK75EdvPOFav1kuXuICn9pRP3cO4_OtnGrpA7bNRhda4wfrjhtjTe_NbO1Q/s16000/Manual_Filter_Process_Mini.jpg&quot; title=&quot;Manual Filter In Excel Steps&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;As you can see, the output will appear in desire filter selection base.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 17px;&quot;&gt;&lt;b&gt;(2). Text Filters :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;In this filter, if table column&#39;s rows contain &lt;b&gt;string &lt;/b&gt;or &lt;b&gt;alphanumeric &lt;/b&gt;value then this filter automatic show &quot;&lt;b&gt;Text &lt;u&gt;F&lt;/u&gt;ilters&lt;/b&gt;&quot; option after clicking on &lt;b&gt;filter &lt;/b&gt;button on particular &lt;b&gt;column&lt;/b&gt;.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This Filter have many options. The details and steps are as follows:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: #f5f3a2; border-radius: 2px; border: 1px solid rgb(72, 117, 90); line-height: 25px; padding: 2px 4px; width: 250px;&quot;&gt;&lt;span style=&quot;color: #695f7a;&quot;&gt;&lt;span style=&quot;font-size: 17px;&quot;&gt;&lt;b&gt;Equal Filter in Excel :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;b&gt;1.&lt;/b&gt; In this filter select &quot;&lt;b&gt;Equal&lt;/b&gt;&quot; option.&amp;nbsp;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;2.&lt;/b&gt; Input your filter value or string in &quot;&lt;b&gt;Custom AutoFilter&lt;/b&gt;&quot; window&#39;s Textbox.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;3. &lt;/b&gt;Then click on &quot;OK&quot; button.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi90jh0t-OI322WhSizDKVeGUYXQAdP2R1-4_oAzTvC2zUCu_99Va9-nOU4p_D68XgvtZ3dnRj6T82Li1JrNDUeK9H_W4SdwQ7HnBe7SuNnLEW1Upt9qxZRoBazYye5dZYtTWLvSpGa3VoLVKyjiWzK6uEzsZov7yN4ZjNWc_JCm9m-4Zi4H-zw4HeM2g/s835/Equal_Filter_In_Excel_mini.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Equal Filter in Excel&quot; border=&quot;0&quot; data-original-height=&quot;344&quot; data-original-width=&quot;835&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi90jh0t-OI322WhSizDKVeGUYXQAdP2R1-4_oAzTvC2zUCu_99Va9-nOU4p_D68XgvtZ3dnRj6T82Li1JrNDUeK9H_W4SdwQ7HnBe7SuNnLEW1Upt9qxZRoBazYye5dZYtTWLvSpGa3VoLVKyjiWzK6uEzsZov7yN4ZjNWc_JCm9m-4Zi4H-zw4HeM2g/s16000/Equal_Filter_In_Excel_mini.jpg&quot; title=&quot;How to use Equal Filter in Excel&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;And the output will look like above.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;background-color: #f5f3a2; border-radius: 2px; border: 1px solid rgb(72, 117, 90); line-height: 25px; padding: 2px 4px; width: 250px;&quot;&gt;&lt;span style=&quot;color: #695f7a;&quot;&gt;&lt;span style=&quot;font-size: 17px;&quot;&gt;&lt;b&gt;Begins With Filter in Excel :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;If you want to show data that contain starting character then this filter is helpful.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;1.&lt;/b&gt;&amp;nbsp;Click on &quot;&lt;b&gt;Begins With...&lt;/b&gt;&quot; option from &quot;&lt;b&gt;Text Filters&lt;/b&gt;&quot;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;2.&lt;/b&gt; Then once again Input some part or the beginning of string in TextBox which is in the side of Type Combobox with &quot;&lt;b&gt;begins with&lt;/b&gt;&quot; option.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwsWwjT5UAp2Zld87BaKS61aks6OwkwQM9h0zOs4fRQaRh1XLLvFRRPodsQ8GBuOvV5APcxtMsflxXI9tCy0UwwgzzMo88iUy9CAM98WMnx_BkGgRyjHrZrwxD-NgJQhMFgMVYAkong_KCu4Gjs1nnJ6JrTLc75rTDHIGFZ-4yEkOfatS8JglriGJ1Cg/s580/Begin_With_Filter_Mini.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Begins With Filter in Excel&quot; border=&quot;0&quot; data-original-height=&quot;354&quot; data-original-width=&quot;580&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwsWwjT5UAp2Zld87BaKS61aks6OwkwQM9h0zOs4fRQaRh1XLLvFRRPodsQ8GBuOvV5APcxtMsflxXI9tCy0UwwgzzMo88iUy9CAM98WMnx_BkGgRyjHrZrwxD-NgJQhMFgMVYAkong_KCu4Gjs1nnJ6JrTLc75rTDHIGFZ-4yEkOfatS8JglriGJ1Cg/s16000/Begin_With_Filter_Mini.jpg&quot; title=&quot;How to use Begins With Filter in Excel&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

&lt;br /&gt;&lt;br /&gt;
&lt;div style=&quot;background-color: #f5f3a2; border-radius: 2px; border: 1px solid rgb(72, 117, 90); line-height: 25px; padding: 2px 4px; width: 250px;&quot;&gt;&lt;span style=&quot;color: #695f7a;&quot;&gt;&lt;span style=&quot;font-size: 17px;&quot;&gt;&lt;b&gt;Ends With Filter in Excel :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;If you want to show records according to containing last character. Then this filter will help.
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;1.&lt;/b&gt;&amp;nbsp;Click on &quot;&lt;b&gt;Ends With...&lt;/b&gt;&quot; option from &quot;&lt;b&gt;Text Filters&lt;/b&gt;&quot;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;2.&lt;/b&gt;&amp;nbsp;Then once again Input some character that end with that string which you want to filter in TextBox which is in the side of &lt;b&gt;Type &lt;/b&gt;Combobox with &quot;&lt;b&gt;Ends with&lt;/b&gt;&quot; option.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQ49HNw3gdLfLGoJciSQJKYRa8zXMzLi9zHwUVlmoxi3IgmXy287qb8Mlov06MGk8a1h-eSO_XjGsWde3mHj4aT_HmraJEZP--jVyEsqo_dl9XkDinv-f-1xCI_GY2ccvg6v07T4fLLhYTxvV8uUBdnA8un_ik_7zF6DqbH2pltMoS97MKdIfeGllF2A/s581/End_With_Filter_Mini.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;323&quot; data-original-width=&quot;581&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQ49HNw3gdLfLGoJciSQJKYRa8zXMzLi9zHwUVlmoxi3IgmXy287qb8Mlov06MGk8a1h-eSO_XjGsWde3mHj4aT_HmraJEZP--jVyEsqo_dl9XkDinv-f-1xCI_GY2ccvg6v07T4fLLhYTxvV8uUBdnA8un_ik_7zF6DqbH2pltMoS97MKdIfeGllF2A/s16000/End_With_Filter_Mini.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;background-color: #f5f3a2; border-radius: 2px; border: 1px solid rgb(72, 117, 90); line-height: 25px; padding: 2px 4px; width: 250px;&quot;&gt;&lt;span style=&quot;color: #695f7a;&quot;&gt;&lt;span style=&quot;font-size: 17px;&quot;&gt;&lt;b&gt;Contains Filter in Excel :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;This is the most used filter in business area. If you want to search records or list of all record that have match any character of that particular cell&#39;s then this will help.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;b&gt;1.&lt;/b&gt;&amp;nbsp;Click on &quot;&lt;b&gt;Contains..&lt;/b&gt;&quot; option from &quot;&lt;b&gt;Text Filters&lt;/b&gt;&quot;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;2.&lt;/b&gt;&amp;nbsp;Then once again Input some character that will be exist in string which you want to filter in TextBox which is in the side of&amp;nbsp;&lt;b&gt;Type&amp;nbsp;&lt;/b&gt;Combobox with &quot;&lt;b&gt;contains&lt;/b&gt;&quot; option.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_iJog2xVmQr-s4GPUhRAhsblzWMUyHtg2ucEb_GHjefE2TaMbjXB_jNRdg05C5mHsOYJ_MjvbGPuX1fmDrZQw6aiGwty6o4Q244ruX0XVRwBrTf4181Uo5Pxz0Bzwu5EmcZ15F9WxOUL_eQwhlHjpg6UAZ7j1ysHoEZJkfhq0JEpvdrcVLewtntSUAQ/s544/Contains_Filter_Excel_mini2.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Contains Filter in Excel&quot; border=&quot;0&quot; data-original-height=&quot;318&quot; data-original-width=&quot;544&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_iJog2xVmQr-s4GPUhRAhsblzWMUyHtg2ucEb_GHjefE2TaMbjXB_jNRdg05C5mHsOYJ_MjvbGPuX1fmDrZQw6aiGwty6o4Q244ruX0XVRwBrTf4181Uo5Pxz0Bzwu5EmcZ15F9WxOUL_eQwhlHjpg6UAZ7j1ysHoEZJkfhq0JEpvdrcVLewtntSUAQ/s16000/Contains_Filter_Excel_mini2.jpg&quot; title=&quot;How To use Contains Filter in Excel&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 17px;&quot;&gt;&lt;b&gt;(3). Numbers Filters :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;In this filter we will learn some filters which is mostly used. This filter will apply on That Column which have a list of Number or Numeric values.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;background-color: #ebffeb; border-radius: 2px; border: 1px solid rgb(72, 117, 90); line-height: 25px; padding: 2px 4px; width: 280px;&quot;&gt;&lt;span style=&quot;color: #bf115d;&quot;&gt;&lt;span style=&quot;font-size: 17px;&quot;&gt;&lt;b&gt;Greater Than Filter in Excel :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
Suppose, there is a list of Numbers, in which you want to find Greater Numbers list with given filter number. Then this filter will help.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;b&gt;1.&lt;/b&gt;&amp;nbsp;Click on &quot;&lt;b&gt;&lt;u&gt;G&lt;/u&gt;reater Than...&lt;/b&gt;&quot; option from &quot;&lt;b&gt;Number &lt;u&gt;F&lt;/u&gt;ilters...&lt;/b&gt;&quot;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;2.&lt;/b&gt;&amp;nbsp;Then input number in &quot;&lt;b&gt;Custom AutoFilter&lt;/b&gt;&quot; dialog, which will filter greater number.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQkIwf5qT4Vur9fdY-j6i71YpRPMhU0AAwgFxpxUflIQR36Xv0zjXsW5P_AP2D14qFq1PdCsFkJFJs6wD1iCOCrBwJAiX6hNZhTiiy0ZqN4mhk32TbA3ZZ6TEj0aZ4e3myUT1S1aTcDODHqloZnFe6WrFMylribbt5hnRMEz6TTASwW6qPQgJXRPw95w/s576/Greater_Than_Filter_Mini2.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Greater Than Filter in Excel&quot; border=&quot;0&quot; data-original-height=&quot;325&quot; data-original-width=&quot;576&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQkIwf5qT4Vur9fdY-j6i71YpRPMhU0AAwgFxpxUflIQR36Xv0zjXsW5P_AP2D14qFq1PdCsFkJFJs6wD1iCOCrBwJAiX6hNZhTiiy0ZqN4mhk32TbA3ZZ6TEj0aZ4e3myUT1S1aTcDODHqloZnFe6WrFMylribbt5hnRMEz6TTASwW6qPQgJXRPw95w/s16000/Greater_Than_Filter_Mini2.jpg&quot; title=&quot;Find Greater than Numbers in Excel&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div style=&quot;background-color: #ebffeb; border-radius: 2px; border: 1px solid rgb(72, 117, 90); line-height: 25px; padding: 2px 4px; width: 280px;&quot;&gt;&lt;span style=&quot;color: #bf115d;&quot;&gt;&lt;span style=&quot;font-size: 17px;&quot;&gt;&lt;b&gt;Less Than Filter in Excel :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
Suppose, there is a list of Numbers, in which you want to find Less Numbers list with given filter number. Then this filter will help.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;b&gt;1.&lt;/b&gt;&amp;nbsp;Click on &quot;&lt;u&gt;&lt;b&gt;L&lt;/b&gt;&lt;/u&gt;&lt;b&gt;ess Than...&lt;/b&gt;&quot; option from &quot;&lt;b&gt;Number&amp;nbsp;&lt;u&gt;F&lt;/u&gt;ilters...&lt;/b&gt;&quot;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;2.&lt;/b&gt;&amp;nbsp;Then input number in &quot;&lt;b&gt;Custom AutoFilter&lt;/b&gt;&quot; dialog, which will filter Less number.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhvXKdxk0HhsubEpN0v-I0z42brslFzHc1hBVlE-aTr5eRtmew6uz4brAkRx1XdGtSeIDk2wSBMOyi0gfuPvGcrZbh2xLLDAbQk-aI6xH5vztSr7nru9nbAHYWr8itrl44YisAA2SyOE7tQTXZUcbjm7oYX9VMK3Ke4hpQnngShqH_MgdBCL1dGaslvA/s606/Less_Than_Filter_Excel_Mini2.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Less than filter in Excel&quot; border=&quot;0&quot; data-original-height=&quot;334&quot; data-original-width=&quot;606&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhvXKdxk0HhsubEpN0v-I0z42brslFzHc1hBVlE-aTr5eRtmew6uz4brAkRx1XdGtSeIDk2wSBMOyi0gfuPvGcrZbh2xLLDAbQk-aI6xH5vztSr7nru9nbAHYWr8itrl44YisAA2SyOE7tQTXZUcbjm7oYX9VMK3Ke4hpQnngShqH_MgdBCL1dGaslvA/s16000/Less_Than_Filter_Excel_Mini2.jpg&quot; title=&quot;How to Filter Less Number in Excel&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

&lt;br /&gt;&lt;br /&gt;
&lt;div style=&quot;background-color: #ebffeb; border-radius: 2px; border: 1px solid rgb(72, 117, 90); line-height: 25px; padding: 2px 4px; width: 280px;&quot;&gt;&lt;span style=&quot;color: #bf115d;&quot;&gt;&lt;span style=&quot;font-size: 17px;&quot;&gt;&lt;b&gt;Between Filter in Excel :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
Between filter will apply when you input Greater Than value and Less Than Value in filter like below. This will show the Between Filter Output describe in image.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;b&gt;1.&lt;/b&gt;&amp;nbsp;Click on &quot;&lt;b&gt;Bet&lt;u&gt;w&lt;/u&gt;een...&lt;/b&gt;&quot; option from &quot;&lt;b&gt;Number&amp;nbsp;&lt;u&gt;F&lt;/u&gt;ilters...&lt;/b&gt;&quot;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;2.&lt;/b&gt;&amp;nbsp;Then input number in &quot;&lt;b&gt;Custom AutoFilter&lt;/b&gt;&quot; dialog, which will between the greater than or equal And less than or equal number of given input value.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOrFYzRRhZuBOAxCZmZ2etrwugD_kkDfMps8QBtahihLoVO6FB9Hc6NooL9s9xBcDDMqKHeazzKY1bfR9y9V8gjsl13jMV3jw0uFhuRHl2YGNao_Mop50yBWdhMVX4uPmppgugqHIceWhLLb6AqKOdh3dHrHwsfo0RWSgAoSRVt8pAsJNUzj_X8W96qg/s609/Between_Filter_Excel_mini2.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Between Filter in Excel&quot; border=&quot;0&quot; data-original-height=&quot;390&quot; data-original-width=&quot;609&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOrFYzRRhZuBOAxCZmZ2etrwugD_kkDfMps8QBtahihLoVO6FB9Hc6NooL9s9xBcDDMqKHeazzKY1bfR9y9V8gjsl13jMV3jw0uFhuRHl2YGNao_Mop50yBWdhMVX4uPmppgugqHIceWhLLb6AqKOdh3dHrHwsfo0RWSgAoSRVt8pAsJNUzj_X8W96qg/s16000/Between_Filter_Excel_mini2.jpg&quot; title=&quot;How to use Between Filter in Excel&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

&lt;br /&gt;&lt;br /&gt;

&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 17px;&quot;&gt;&lt;b&gt;(4). Filter by Color in Excel:&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;Here we can filter records by particular color selection. Following Image will describe how it will work?&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span style=&quot;background-color: #f7f9d9; color: #0b5394; font-size: medium;&quot;&gt;&lt;b&gt;Note:&lt;/b&gt; This filter will work only when cells contain background color on particular column&#39;s rows.&lt;/span&gt;&lt;br /&gt;&lt;/i&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;b&gt;1.&lt;/b&gt;&amp;nbsp;For this filter you have to click on &quot;&lt;b&gt;F&lt;u&gt;i&lt;/u&gt;lter by Color&lt;/b&gt;&quot; option.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;2.&lt;/b&gt;&amp;nbsp;Choose whatever color&#39;s record want to show like below.&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYEqVYmepDhmHN122mRLh20JiQAXoha79FrocHT1yGW1skF7epv8rNdUM95NvfWjIQRLoJSpLnsPUUpV7ObaBMuPB0oX6C5OCOTmq1Km8p7wNIs4naEuWbcRgFcWOMeID7wWrznFGqZg8pte5vvqt4UepIaTKLPQYi379utWQdaQbRJJe8Y_s5R6OhFA/s499/Filter_By_Color_Excel_Mini.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Filter by Color in Excel&quot; border=&quot;0&quot; data-original-height=&quot;238&quot; data-original-width=&quot;499&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYEqVYmepDhmHN122mRLh20JiQAXoha79FrocHT1yGW1skF7epv8rNdUM95NvfWjIQRLoJSpLnsPUUpV7ObaBMuPB0oX6C5OCOTmq1Km8p7wNIs4naEuWbcRgFcWOMeID7wWrznFGqZg8pte5vvqt4UepIaTKLPQYi379utWQdaQbRJJe8Y_s5R6OhFA/s16000/Filter_By_Color_Excel_Mini.jpg&quot; title=&quot;Show record of particular row color in excel&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;Show Records from particular Column&#39;s rows color in Excel.&lt;/span&gt;&lt;/h4&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
So, these are the &lt;b&gt;Types Of Filter in Excel&lt;/b&gt; and &lt;b&gt;How to Use Excel Filter&lt;/b&gt; with step by step process.&lt;/div&gt;</description><link>https://www.skotechlearn.com/2022/06/excel-filter-types-and-use-filter-in-excel.html</link><author>noreply@blogger.com (SKOTechLearn)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3cLWj3mKADWYuYFwkQRVqJx4RES6k9PHIzEMzkjsLaKwOpMo0RV5PztloYPHy2U6v8j19W7ToSonO2GsHIozNZmSEQMSLEUGi1zFKqdvEhAN0fAszGWFb_LXb-SMtw1iv-cgKeZIsG1sKJeXj3rQoTymgS9V5sELON4lyuEPBAd8M4zyeVMKJ3e-iuQ/s72-c/02_Text_And_Number_Filters_In_Excel%20-%20Mini2.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2258844867892945003.post-6874373206421134050</guid><pubDate>Sun, 19 Jun 2022 08:32:00 +0000</pubDate><atom:updated>2022-06-21T15:09:26.443-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Python</category><title>How to Add Columns and Items in TreeView in Python Tkinter</title><description>&lt;p&gt;&amp;nbsp;If you want to show items in rows and columns like table, tkinter provide &lt;b&gt;Treeview widgets in python&lt;/b&gt;. This widget is use as Listview for display records. So here we learn &lt;b&gt;Listview in Python&lt;/b&gt; or How to &lt;b&gt;add Column Hearder in Treeview in Python Tkinter&lt;/b&gt; or How to add items in &lt;b&gt;Treeview in Tkinter python&lt;/b&gt;?&amp;nbsp;&lt;/p&gt;&lt;p&gt;Now, we will cover following points that will solve all given questions.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;
  
  &lt;ol style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Add Column in TreeView in Tkinter Python&lt;/li&gt;
&lt;/b&gt;  &lt;b&gt;
&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Set Column width in TreeView in Tkinter&lt;/li&gt;
 &lt;/b&gt;  &lt;b&gt;
&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Set Treeview Column color in tkinter&lt;/li&gt;
  &lt;/b&gt;  &lt;b&gt;
&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Add Items in Treeview in Tkinter&lt;/li&gt;
&lt;/b&gt;
&lt;b&gt;
&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Tkintter Treeview Row Color in Python&lt;/li&gt;
&lt;/b&gt;&lt;/ol&gt;

&lt;br /&gt;
&lt;br /&gt;
  
  So, here we use Treeview as Listview in Tkinter with following way:&lt;br /&gt;&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 17px;&quot;&gt;&lt;b&gt;(1). Add Column in TreeView in Tkinter Python :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;
Now, let’s see how we add columns with names with different ways in python.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #741b47; color: #f3f3f3; font-weight: bold;&quot;&gt;Fist Way:
&lt;/span&gt;&lt;br /&gt;

&lt;pre style=&quot;background-color: #fcfbfb; border-bottom: 1px solid #D0D9EA; border-color: rgb(208, 217, 234) rgb(208, 217, 234) rgb(208, 217, 234) rgb(126, 139, 187); border-left: 3px solid #7E8BBB; border-radius: 5px; border-right: 1px solid #D0D9EA; border-style: solid; border-top: 1px solid #D0D9EA; border-width: 1px 1px 1px 3px; box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana; font-size: 13px; line-height: 22px; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: #800180;&quot;&gt;from&lt;/span&gt; tkinter &lt;span style=&quot;color: #800180;&quot;&gt;import &lt;/span&gt;*
&lt;span style=&quot;color: #800180;&quot;&gt;from &lt;/span&gt;tkinter &lt;span style=&quot;color: #800180;&quot;&gt;import&lt;/span&gt; ttk

TrvFrm = &lt;span style=&quot;color: #0b5394;&quot;&gt;Tk&lt;/span&gt;()

MyTrv = &lt;span style=&quot;color: #0b5394;&quot;&gt;ttk.Treeview&lt;/span&gt;(TrvFrm, columns=(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;Column1&#39;&lt;/span&gt;, &lt;span style=&quot;color: #990000;&quot;&gt;&#39;Column2&#39;&lt;/span&gt;, &lt;span style=&quot;color: #990000;&quot;&gt;&#39;Column3&#39;&lt;/span&gt;), show=&lt;span style=&quot;color: #990000;&quot;&gt;&#39;headings&#39;&lt;/span&gt;)

MyTrv.&lt;span style=&quot;color: #783f04;&quot;&gt;heading&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;MyCl1&#39;&lt;/span&gt;, text=&lt;span style=&quot;color: #990000;&quot;&gt;&#39;SKID&#39;&lt;/span&gt;)
MyTrv.&lt;span style=&quot;color: #783f04;&quot;&gt;heading&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;MyCl2&#39;&lt;/span&gt;, text=&lt;span style=&quot;color: #990000;&quot;&gt;&#39;SKName&#39;&lt;/span&gt;)
MyTrv.&lt;span style=&quot;color: #783f04;&quot;&gt;heading&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;MyCl3&#39;&lt;/span&gt;, text=&lt;span style=&quot;color: #990000;&quot;&gt;&#39;SKFName&#39;&lt;/span&gt;)

&lt;/pre&gt;
&lt;br /&gt;&lt;b style=&quot;background-color: #741b47;&quot;&gt;&lt;span style=&quot;color: #f3f3f3;&quot;&gt; Second Way:&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;

&lt;pre style=&quot;background-color: #fcfbfb; border-bottom: 1px solid #D0D9EA; border-color: rgb(208, 217, 234) rgb(208, 217, 234) rgb(208, 217, 234) rgb(126, 139, 187); border-left: 3px solid #7E8BBB; border-radius: 5px; border-right: 1px solid #D0D9EA; border-style: solid; border-top: 1px solid #D0D9EA; border-width: 1px 1px 1px 3px; box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana; font-size: 13px; line-height: 22px; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: #800180;&quot;&gt;from&lt;/span&gt; tkinter &lt;span style=&quot;color: #800180;&quot;&gt;import &lt;/span&gt;*
&lt;span style=&quot;color: #800180;&quot;&gt;from &lt;/span&gt;tkinter &lt;span style=&quot;color: #800180;&quot;&gt;import&lt;/span&gt; ttk

TrvFrm = &lt;span style=&quot;color: #0b5394;&quot;&gt;Tk&lt;/span&gt;()

MyTrv = &lt;span style=&quot;color: #0b5394;&quot;&gt;ttk.Treeview&lt;/span&gt;(TrvFrm, show=&lt;span style=&quot;color: #990000;&quot;&gt;&#39;headings&#39;&lt;/span&gt;)
MyTrv[&lt;span style=&quot;color: #990000;&quot;&gt;&#39;columns&#39;&lt;/span&gt;]=(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;MyCl1&#39;&lt;/span&gt;, &lt;span style=&quot;color: #990000;&quot;&gt;&#39;MyCl2&#39;&lt;/span&gt;, &lt;span style=&quot;color: #990000;&quot;&gt;&#39;MyCl3&#39;&lt;/span&gt;)

MyTrv.&lt;span style=&quot;color: #783f04;&quot;&gt;heading&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;MyCl1&#39;&lt;/span&gt;, text=&lt;span style=&quot;color: #990000;&quot;&gt;&#39;SKID&#39;&lt;/span&gt;)
MyTrv.&lt;span style=&quot;color: #783f04;&quot;&gt;heading&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;MyCl2&#39;&lt;/span&gt;, text=&lt;span style=&quot;color: #990000;&quot;&gt;&#39;SKName&#39;&lt;/span&gt;)
MyTrv.&lt;span style=&quot;color: #783f04;&quot;&gt;heading&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;MyCl3&#39;&lt;/span&gt;, text=&lt;span style=&quot;color: #990000;&quot;&gt;&#39;SKFName&#39;&lt;/span&gt;)

&lt;/pre&gt;

You can choose any one of them and proceed for further Process, So, Let’s see what will happen?
&lt;br /&gt;&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;b&gt;Show Columns in TreeView in Tkinter&lt;/b&gt;&lt;/h3&gt;
&lt;br /&gt;

Now, here we will put complete code with output as follows:
&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-bottom: 1px solid #D0D9EA; border-color: rgb(208, 217, 234) rgb(208, 217, 234) rgb(208, 217, 234) rgb(126, 139, 187); border-left: 3px solid #7E8BBB; border-radius: 5px; border-right: 1px solid #D0D9EA; border-style: solid; border-top: 1px solid #D0D9EA; border-width: 1px 1px 1px 3px; box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana; font-size: 13px; line-height: 22px; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: #800180;&quot;&gt;from&lt;/span&gt; tkinter &lt;span style=&quot;color: #800180;&quot;&gt;import &lt;/span&gt;*
&lt;span style=&quot;color: #800180;&quot;&gt;from &lt;/span&gt;tkinter &lt;span style=&quot;color: #800180;&quot;&gt;import&lt;/span&gt; ttk

TrvFrm = &lt;span style=&quot;color: #0b5394;&quot;&gt;Tk&lt;/span&gt;()
TrvFrm.&lt;span style=&quot;color: #351c75;&quot;&gt;title&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;TreeView Column Header&#39;&lt;/span&gt;)
TrvFrm.&lt;span style=&quot;color: #351c75;&quot;&gt;geometry&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;305x110&#39;&lt;/span&gt;)

MyTrv = &lt;span style=&quot;color: #0b5394;&quot;&gt;ttk.Treeview&lt;/span&gt;(TrvFrm, columns=(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;MyCl1&#39;&lt;/span&gt;, &lt;span style=&quot;color: #990000;&quot;&gt;&#39;MyCl2&#39;&lt;/span&gt;, &lt;span style=&quot;color: #990000;&quot;&gt;&#39;MyCl3&#39;&lt;/span&gt;), show=&lt;span style=&quot;color: #990000;&quot;&gt;&#39;headings&#39;&lt;/span&gt;)

MyTrv.&lt;span style=&quot;color: #783f04;&quot;&gt;heading&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;MyCl1&#39;&lt;/span&gt;, text=&lt;span style=&quot;color: #990000;&quot;&gt;&#39;SKID&#39;&lt;/span&gt;)
MyTrv.&lt;span style=&quot;color: #783f04;&quot;&gt;heading&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;MyCl2&#39;&lt;/span&gt;, text=&lt;span style=&quot;color: #990000;&quot;&gt;&#39;SKName&#39;&lt;/span&gt;)
MyTrv.&lt;span style=&quot;color: #783f04;&quot;&gt;heading&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;MyCl3&#39;&lt;/span&gt;, text=&lt;span style=&quot;color: #990000;&quot;&gt;&#39;SKFName&#39;&lt;/span&gt;)

MyTrv.pack(side=&lt;span style=&quot;color: #0b5394;&quot;&gt;TOP&lt;/span&gt;, fill=&lt;span style=&quot;color: #990000;&quot;&gt;&quot;both&quot;&lt;/span&gt;, expand=&lt;span style=&quot;color: #2b00fe;&quot;&gt;True&lt;/span&gt;)

TrvFrm.mainloop()

&lt;/pre&gt;
&lt;br /&gt;
When you run this code, it will show Form including &lt;b&gt;Treeview with columns in python&lt;/b&gt;.
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6lFRdqoWzG8Zyzqifj_FNUGGxe3osVdq5gb3nk-48jNrC1vt2o9OfKdWeQsCgkZXPMukp6FKKUNeRI2OteOQmCFzuxdU7JS1yxgRPxGJDB6a3XPiIqnjPqKMUmc_Ob7znbfqhLAjwiELLV5BEktxw1dLi6V68H0ew4upOZr_mB4dt_TdUIcD-efAzHA/s460/1_Add_Column_Header_in_TreeView_Tkinter.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Add_Column_Header_in_TreeView_Tkinter&quot; border=&quot;0&quot; data-original-height=&quot;191&quot; data-original-width=&quot;460&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6lFRdqoWzG8Zyzqifj_FNUGGxe3osVdq5gb3nk-48jNrC1vt2o9OfKdWeQsCgkZXPMukp6FKKUNeRI2OteOQmCFzuxdU7JS1yxgRPxGJDB6a3XPiIqnjPqKMUmc_Ob7znbfqhLAjwiELLV5BEktxw1dLi6V68H0ew4upOZr_mB4dt_TdUIcD-efAzHA/s16000/1_Add_Column_Header_in_TreeView_Tkinter.jpg&quot; title=&quot;Add Column Header in TreeView Tkinter Python&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;

&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 17px;&quot;&gt;&lt;b&gt;(2). Set Column width in TreeView in Tkinter :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;
If you want to set or fix Column width at run time then you have to write code like:&lt;div&gt;&lt;br /&gt;&amp;nbsp;

&lt;pre style=&quot;background-color: #fcfbfb; border-bottom: 1px solid #D0D9EA; border-color: rgb(208, 217, 234) rgb(208, 217, 234) rgb(208, 217, 234) rgb(126, 139, 187); border-left: 3px solid #7E8BBB; border-radius: 5px; border-right: 1px solid #D0D9EA; border-style: solid; border-top: 1px solid #D0D9EA; border-width: 1px 1px 1px 3px; box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana; font-size: 13px; line-height: 22px; overflow: scroll; padding: 10px 6px;&quot;&gt;MyTrv.&lt;span style=&quot;color: #783f04;&quot;&gt;column&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;MyCl1&#39;&lt;/span&gt;, &lt;span style=&quot;color: #073763;&quot;&gt;width&lt;/span&gt;=40)
MyTrv.&lt;span style=&quot;color: #783f04;&quot;&gt;column&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;MyCl2&#39;&lt;/span&gt;, &lt;span style=&quot;color: #073763;&quot;&gt;width&lt;/span&gt;=50)
MyTrv.&lt;span style=&quot;color: #783f04;&quot;&gt;column&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;MyCl3&#39;&lt;/span&gt;, &lt;span style=&quot;color: #073763;&quot;&gt;width&lt;/span&gt;=70)
&lt;/pre&gt;
&lt;br /&gt;
&lt;/div&gt;
&lt;br /&gt;
Ok, we will insert this code in our existing above code.&lt;div&gt;&amp;nbsp;
&lt;br /&gt;

&lt;pre style=&quot;background-color: #fcfbfb; border-bottom: 1px solid #D0D9EA; border-color: rgb(208, 217, 234) rgb(208, 217, 234) rgb(208, 217, 234) rgb(126, 139, 187); border-left: 3px solid #7E8BBB; border-radius: 5px; border-right: 1px solid #D0D9EA; border-style: solid; border-top: 1px solid #D0D9EA; border-width: 1px 1px 1px 3px; box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana; font-size: 13px; line-height: 22px; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: #741b47;&quot;&gt;from &lt;/span&gt;tkinter &lt;span style=&quot;color: #741b47;&quot;&gt;import &lt;/span&gt;*
&lt;span style=&quot;color: #741b47;&quot;&gt;from &lt;/span&gt;tkinter &lt;span style=&quot;color: #741b47;&quot;&gt;import &lt;/span&gt;ttk

TrvFrm  = &lt;span style=&quot;color: #0b5394;&quot;&gt;Tk&lt;/span&gt;()
TrvFrm .&lt;span style=&quot;color: #351c75;&quot;&gt;title&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;TreeView Column Header&#39;&lt;/span&gt;)
TrvFrm .&lt;span style=&quot;color: #351c75;&quot;&gt;geometry&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;300x100&#39;&lt;/span&gt;)

MyTrv = &lt;span style=&quot;color: #351c75;&quot;&gt;ttk.Treeview&lt;/span&gt;(TrvFrm, show=&lt;span style=&quot;color: #990000;&quot;&gt;&#39;headings&#39;&lt;/span&gt;)

&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;i&gt;#Create Column&lt;/i&gt;&lt;/span&gt;
MyTrv[&lt;span style=&quot;color: #990000;&quot;&gt;&#39;columns&#39;&lt;/span&gt;]=(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;MyCl1&#39;&lt;/span&gt;, &lt;span style=&quot;color: #990000;&quot;&gt;&#39;MyCl2&#39;&lt;/span&gt;, &lt;span style=&quot;color: #990000;&quot;&gt;&#39;MyCl3&#39;&lt;/span&gt;)

&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;i&gt;#Set Column Name&lt;/i&gt;&lt;/span&gt;
MyTrv.&lt;span style=&quot;color: #783f04;&quot;&gt;heading&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;MyCl1&#39;&lt;/span&gt;, text=&lt;span style=&quot;color: #990000;&quot;&gt;&#39;SKID&#39;&lt;/span&gt;)
MyTrv.&lt;span style=&quot;color: #783f04;&quot;&gt;heading&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;MyCl2&#39;&lt;/span&gt;, text=&lt;span style=&quot;color: #990000;&quot;&gt;&#39;SKName&#39;&lt;/span&gt;)
MyTrv.&lt;span style=&quot;color: #783f04;&quot;&gt;heading&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;MyCl3&#39;&lt;/span&gt;, text=&lt;span style=&quot;color: #990000;&quot;&gt;&#39;SKFName&#39;&lt;/span&gt;)

&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;i&gt;#Set Column Width&lt;/i&gt;&lt;/span&gt;
MyTrv.&lt;span style=&quot;color: #783f04;&quot;&gt;column&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;MyCl1&#39;&lt;/span&gt;, width=&lt;span style=&quot;color: #274e13;&quot;&gt;40&lt;/span&gt;)
MyTrv.&lt;span style=&quot;color: #783f04;&quot;&gt;column&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;MyCl2&#39;&lt;/span&gt;, width=&lt;span style=&quot;color: #274e13;&quot;&gt;50&lt;/span&gt;)
MyTrv.&lt;span style=&quot;color: #783f04;&quot;&gt;column&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;MyCl3&#39;&lt;/span&gt;, width=&lt;span style=&quot;color: #783f04;&quot;&gt;70&lt;/span&gt;)

MyTrv.&lt;span style=&quot;color: #783f04;&quot;&gt;pack&lt;/span&gt;(side=&lt;span style=&quot;color: #2b00fe;&quot;&gt;TOP&lt;/span&gt;, fill=&lt;span style=&quot;color: #990000;&quot;&gt;&quot;both&quot;&lt;/span&gt;, expand=&lt;span style=&quot;color: #2b00fe;&quot;&gt;True&lt;/span&gt;)

TrvFrm.mainloop()

&lt;/pre&gt;
&lt;br /&gt;
After running this code her we find output:&lt;br /&gt;

&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSxGsxz6biUyXbpQBNN0pwKE_d4eAtKJNFfbqhu1POrAiuX1ETX8LjuSa_GjFJzGR6K-ws6E7FNO_HacJhZK0kawCflGKNe_whMv9VUA4g7ZOdv68_COFDvcTD6tOJUUr-B9pllOyA1PxkEB42w9SSSCHfSVE1AKLd7vAdInLtMQ9FrgyRm8V3g2eESA/s312/2_Set_Column_Width_in_Treeview_in_Tkinter.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Set_Column_Width_in_Treeview_in_Tkinter&quot; border=&quot;0&quot; data-original-height=&quot;135&quot; data-original-width=&quot;312&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSxGsxz6biUyXbpQBNN0pwKE_d4eAtKJNFfbqhu1POrAiuX1ETX8LjuSa_GjFJzGR6K-ws6E7FNO_HacJhZK0kawCflGKNe_whMv9VUA4g7ZOdv68_COFDvcTD6tOJUUr-B9pllOyA1PxkEB42w9SSSCHfSVE1AKLd7vAdInLtMQ9FrgyRm8V3g2eESA/s16000/2_Set_Column_Width_in_Treeview_in_Tkinter.jpg&quot; title=&quot;Set Column Width in Treeview in Tkinter Python&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;As you can see, we adjust the &lt;b&gt;treeview Column width in tkinter &lt;/b&gt;according to need.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 17px;&quot;&gt;&lt;b&gt;(3). Set Treeview Column color in Tkinter :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;If you want to change &lt;b&gt;Tkinter Treeview column color&lt;/b&gt; like Background color or foreground color and also want to change &lt;b&gt;Treeview Column Font size in Tkinter&lt;/b&gt; or&amp;nbsp;&lt;b&gt;Treeview&amp;nbsp;Column Font Name in Tkinter&lt;/b&gt;. Then just add &lt;b&gt;Tkinter ttk style&lt;/b&gt; on your code.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

&lt;pre style=&quot;background-color: #fcfbfb; border-bottom: 1px solid #D0D9EA; border-color: rgb(208, 217, 234) rgb(208, 217, 234) rgb(208, 217, 234) rgb(126, 139, 187); border-left: 3px solid #7E8BBB; border-radius: 5px; border-right: 1px solid #D0D9EA; border-style: solid; border-top: 1px solid #D0D9EA; border-width: 1px 1px 1px 3px; box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana; font-size: 13px; line-height: 22px; overflow: scroll; padding: 10px 6px;&quot;&gt;mytkstyle = &lt;span style=&quot;color: #0b5394;&quot;&gt;ttk.Style()&lt;/span&gt;
&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;#Treeview Style in tkinter with Column Color with Font Size and Font Name&lt;/span&gt;&lt;/i&gt;
mytkstyle.&lt;span style=&quot;color: #783f04;&quot;&gt;configure&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;Trstyle.Treeview.Heading&quot;&lt;/span&gt;, background=&lt;span style=&quot;color: #990000;&quot;&gt;&#39;#ffedd4&#39;&lt;/span&gt;, foreground=&lt;span style=&quot;color: #990000;&quot;&gt;&#39;#f38755&#39;&lt;/span&gt;, font=(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;Georgia&#39;&lt;/span&gt;, &lt;span style=&quot;color: #274e13;&quot;&gt;10&lt;/span&gt;,&lt;span style=&quot;color: #990000;&quot;&gt;&#39;bold&#39;&lt;/span&gt;))

&lt;i&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;#Add ttk style on treeview&lt;/span&gt;&lt;/i&gt;
MyTrv = &lt;span style=&quot;color: #0b5394;&quot;&gt;ttk.Treeview&lt;/span&gt;(TrvFrm, show=&lt;span style=&quot;color: #990000;&quot;&gt;&#39;headings&#39;&lt;/span&gt;, style=&lt;span style=&quot;color: #990000;&quot;&gt;&quot;Trstyle.Treeview&quot;&lt;/span&gt;)

&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, just add above given code and implement code like bellow given example:&lt;div&gt;&amp;nbsp;
&lt;br /&gt;

&lt;pre style=&quot;background-color: #fcfbfb; border-bottom: 1px solid #D0D9EA; border-color: rgb(208, 217, 234) rgb(208, 217, 234) rgb(208, 217, 234) rgb(126, 139, 187); border-left: 3px solid #7E8BBB; border-radius: 5px; border-right: 1px solid #D0D9EA; border-style: solid; border-top: 1px solid #D0D9EA; border-width: 1px 1px 1px 3px; box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana; font-size: 13px; line-height: 22px; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: #741b47;&quot;&gt;from &lt;/span&gt;tkinter &lt;span style=&quot;color: #741b47;&quot;&gt;import &lt;/span&gt;*
&lt;span style=&quot;color: #741b47;&quot;&gt;from &lt;/span&gt;tkinter &lt;span style=&quot;color: #741b47;&quot;&gt;import &lt;/span&gt;ttk

TrRoot = &lt;span style=&quot;color: #0b5394;&quot;&gt;Tk()&lt;/span&gt;
TrRoot.&lt;span style=&quot;color: #783f04;&quot;&gt;title&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;TreeView Column Header&#39;&lt;/span&gt;)
TrRoot.&lt;span style=&quot;color: #783f04;&quot;&gt;geometry&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;300x100&#39;&lt;/span&gt;)

mytkstyle = &lt;span style=&quot;color: #0b5394;&quot;&gt;ttk.Style()&lt;/span&gt;

mytkstyle.&lt;span style=&quot;color: #783f04;&quot;&gt;configure&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;Trstyle.Treeview.Heading&quot;&lt;/span&gt;, background=&lt;span style=&quot;color: #990000;&quot;&gt;&#39;#ffedd4&#39;&lt;/span&gt;, foreground=&lt;span style=&quot;color: #990000;&quot;&gt;&#39;#f38755&#39;&lt;/span&gt;, font=(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;Georgia&#39;&lt;/span&gt;, &lt;span style=&quot;color: #274e13;&quot;&gt;10&lt;/span&gt;,&lt;span style=&quot;color: #990000;&quot;&gt;&#39;bold&#39;&lt;/span&gt;))

TkTree = &lt;span style=&quot;color: #0b5394;&quot;&gt;ttk.Treeview&lt;/span&gt;(TrRoot, show=&lt;span style=&quot;color: #990000;&quot;&gt;&#39;headings&#39;&lt;/span&gt;, style=&lt;span style=&quot;color: #990000;&quot;&gt;&quot;Trstyle.Treeview&quot;&lt;/span&gt;)
TkTree[&lt;span style=&quot;color: #990000;&quot;&gt;&#39;columns&#39;&lt;/span&gt;]=(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;MyCl1&#39;&lt;/span&gt;, &lt;span style=&quot;color: #990000;&quot;&gt;&#39;MyCl2&#39;&lt;/span&gt;, &lt;span style=&quot;color: #990000;&quot;&gt;&#39;MyCl3&#39;&lt;/span&gt;)

TkTree.&lt;span style=&quot;color: #783f04;&quot;&gt;heading&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;MyCl1&#39;&lt;/span&gt;, text=&#39;SKID&#39;)
TkTree.&lt;span style=&quot;color: #783f04;&quot;&gt;heading&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;MyCl2&#39;&lt;/span&gt;, text=&lt;span style=&quot;color: #990000;&quot;&gt;&#39;SKName&#39;&lt;/span&gt;)
TkTree.&lt;span style=&quot;color: #783f04;&quot;&gt;heading&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;MyCl3&#39;&lt;/span&gt;, text=&lt;span style=&quot;color: #990000;&quot;&gt;&#39;SKFName&#39;&lt;/span&gt;)

TkTree.&lt;span style=&quot;color: #783f04;&quot;&gt;pack&lt;/span&gt;(side=&lt;span style=&quot;color: #2b00fe;&quot;&gt;TOP&lt;/span&gt;, fill=&lt;span style=&quot;color: #990000;&quot;&gt;&quot;both&quot;&lt;/span&gt;, expand=&lt;span style=&quot;color: #2b00fe;&quot;&gt;True&lt;/span&gt;)

TrRoot.mainloop()

&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Now the above code is ready for display following output with different color of width of column after executing code: 
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4Mxvgel23Lb-7FBpI9Y268xxkoJu4lzZvQ1LPOaqPb4TZFyv4yg2eU8becVLHxUt62i2C0d6ZLs2CGdzN-b02o0OMcn5Ol1DqqQXEV6nvudLtbmEd76XRMwk6XTbO0WjsAK1hsLEm3B7zIdDWZ9NqTj61SWdpdHQjCqFukWAZ48Icz40NO2HmMz1f-A/s312/3_Set_Column_Color%20and%20Font_in_Treeview_in_Tkinter.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Set_Column_Color in_Treeview and Font_in_Treeview_in_Tkinter&quot; border=&quot;0&quot; data-original-height=&quot;135&quot; data-original-width=&quot;312&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4Mxvgel23Lb-7FBpI9Y268xxkoJu4lzZvQ1LPOaqPb4TZFyv4yg2eU8becVLHxUt62i2C0d6ZLs2CGdzN-b02o0OMcn5Ol1DqqQXEV6nvudLtbmEd76XRMwk6XTbO0WjsAK1hsLEm3B7zIdDWZ9NqTj61SWdpdHQjCqFukWAZ48Icz40NO2HmMz1f-A/s16000/3_Set_Column_Color%20and%20Font_in_Treeview_in_Tkinter.jpg&quot; title=&quot;Ser Column Color and Font in Tkinter Treeview&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;Add items in Treeview in Tkinter Python&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;Add items in Listview in Tkinter

&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;

&lt;br /&gt;
&lt;br /&gt;

&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 17px;&quot;&gt;&lt;b&gt;(4). Add Items in Treeview in Tkinter :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;
Here we add some items or records in Treeview as &lt;b&gt;Listview in Tkinter&lt;/b&gt; using ‘insert’ command. You can add items manually or through Loop as describe bellow:
&lt;br /&gt;
&lt;br /&gt;&lt;b&gt;&lt;span style=&quot;background-color: #38761d; color: white; font-size: medium;&quot;&gt;
(a)	Add Items in Treeview in Tkinter manually :

&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-bottom: 1px solid #D0D9EA; border-color: rgb(208, 217, 234) rgb(208, 217, 234) rgb(208, 217, 234) rgb(126, 139, 187); border-left: 3px solid #7E8BBB; border-radius: 5px; border-right: 1px solid #D0D9EA; border-style: solid; border-top: 1px solid #D0D9EA; border-width: 1px 1px 1px 3px; box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana; font-size: 13px; line-height: 22px; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: #741b47;&quot;&gt;from &lt;/span&gt;tkinter &lt;span style=&quot;color: #741b47;&quot;&gt;import &lt;/span&gt;*
&lt;span style=&quot;color: #741b47;&quot;&gt;from &lt;/span&gt;tkinter &lt;span style=&quot;color: #741b47;&quot;&gt;import &lt;/span&gt;ttk

TrvFrm  = &lt;span style=&quot;color: #0b5394;&quot;&gt;Tk()&lt;/span&gt;
TrvFrm .&lt;span style=&quot;color: #783f04;&quot;&gt;title&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;TreeView Column Header&#39;&lt;/span&gt;)
Trv = &lt;span style=&quot;color: #0b5394;&quot;&gt;ttk.Treeview&lt;/span&gt;(TrvFrm, show=&lt;span style=&quot;color: #990000;&quot;&gt;&#39;headings&#39;&lt;/span&gt;)
Trv[&lt;span style=&quot;color: #990000;&quot;&gt;&#39;columns&#39;&lt;/span&gt;]=(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;Clm1&#39;&lt;/span&gt;, &lt;span style=&quot;color: #990000;&quot;&gt;&#39;Clm2&#39;&lt;/span&gt;, &lt;span style=&quot;color: #990000;&quot;&gt;&#39;Clm3&#39;&lt;/span&gt;)

Trv.&lt;span style=&quot;color: #783f04;&quot;&gt;heading&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;Clm1&#39;&lt;/span&gt;, text=&lt;span style=&quot;color: #990000;&quot;&gt;&#39;SKID&#39;&lt;/span&gt;)
Trv.&lt;span style=&quot;color: #783f04;&quot;&gt;heading&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;Clm2&#39;&lt;/span&gt;, text=&lt;span style=&quot;color: #990000;&quot;&gt;&#39;SKName&#39;&lt;/span&gt;)
Trv.&lt;span style=&quot;color: #783f04;&quot;&gt;heading&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;Clm3&#39;&lt;/span&gt;, text=&lt;span style=&quot;color: #990000;&quot;&gt;&#39;SKFName&#39;&lt;/span&gt;)

Trv.&lt;span style=&quot;color: #783f04;&quot;&gt;insert&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;&#39;&lt;/span&gt;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;END&lt;/span&gt;, values=(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;1&#39;&lt;/span&gt;, &lt;span style=&quot;color: #990000;&quot;&gt;&#39;SKO&#39;&lt;/span&gt;, &lt;span style=&quot;color: #990000;&quot;&gt;&#39;AAAAAAA&#39;&lt;/span&gt;))
Trv.&lt;span style=&quot;color: #783f04;&quot;&gt;insert&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;&#39;&lt;/span&gt;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;END&lt;/span&gt;, values=(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;2&#39;&lt;/span&gt;, &lt;span style=&quot;color: #990000;&quot;&gt;&#39;Tech&#39;&lt;/span&gt;, &lt;span style=&quot;color: #990000;&quot;&gt;&#39;BBBBBB&#39;&lt;/span&gt;))
Trv.&lt;span style=&quot;color: #783f04;&quot;&gt;insert&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;&#39;&lt;/span&gt;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;END&lt;/span&gt;, values=(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;3&#39;&lt;/span&gt;, &lt;span style=&quot;color: #990000;&quot;&gt;&#39;Learn&#39;&lt;/span&gt;, &lt;span style=&quot;color: #990000;&quot;&gt;&#39;CCCCCCCC&#39;&lt;/span&gt;))


Trv.&lt;span style=&quot;color: #783f04;&quot;&gt;pack&lt;/span&gt;(side=&lt;span style=&quot;color: #2b00fe;&quot;&gt;TOP&lt;/span&gt;, fill=&lt;span style=&quot;color: #990000;&quot;&gt;&quot;both&quot;&lt;/span&gt;, expand=&lt;span style=&quot;color: #2b00fe;&quot;&gt;True&lt;/span&gt;)

TrvFrm.mainloop()

&lt;/pre&gt;

&lt;br /&gt;
&lt;br /&gt;&lt;b&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;
Output:

&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2gAzHHunGPszMXIKYNM8E23g74aleZCH8KixmY7cx7-AZ1EcE7GpFgjKrmZg9tFiG7b3Gz06bA8_b3s9feErMz8z3siGyP6Rg7nS3ixHj1GbBFjLsMuiu1UlLuNspH9XXqYBgz-1zsJK7BZ9b4Ayv4_XIXbFWDygQvbqamAFpvGbjmJ5fmeoam_PblA/s250/4_Manualy_Add_Items_in_Treeview_in_Tkinter.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Manually_Add_Items_in_Treeview_in_Tkinter&quot; border=&quot;0&quot; data-original-height=&quot;125&quot; data-original-width=&quot;250&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2gAzHHunGPszMXIKYNM8E23g74aleZCH8KixmY7cx7-AZ1EcE7GpFgjKrmZg9tFiG7b3Gz06bA8_b3s9feErMz8z3siGyP6Rg7nS3ixHj1GbBFjLsMuiu1UlLuNspH9XXqYBgz-1zsJK7BZ9b4Ayv4_XIXbFWDygQvbqamAFpvGbjmJ5fmeoam_PblA/s16000/4_Manualy_Add_Items_in_Treeview_in_Tkinter.jpg&quot; title=&quot;Manually Add Items in Treeview in Tkinter Python&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;background-color: #38761d; color: white; font-size: medium;&quot;&gt;(b)&amp;nbsp; Add Items in Treeview in Tkinter through Loop :&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Suppose you want to add some items through loop in Treeview then here we use &#39;&lt;b&gt;for&#39;&lt;/b&gt; loop in python for &lt;b&gt;insert records in treeview tkinter&lt;/b&gt;.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;


&lt;pre style=&quot;background-color: #fcfbfb; border-bottom: 1px solid #D0D9EA; border-color: rgb(208, 217, 234) rgb(208, 217, 234) rgb(208, 217, 234) rgb(126, 139, 187); border-left: 3px solid #7E8BBB; border-radius: 5px; border-right: 1px solid #D0D9EA; border-style: solid; border-top: 1px solid #D0D9EA; border-width: 1px 1px 1px 3px; box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana; font-size: 13px; line-height: 22px; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: #741b47;&quot;&gt;from &lt;/span&gt;tkinter &lt;span style=&quot;color: #741b47;&quot;&gt;import &lt;/span&gt;*
&lt;span style=&quot;color: #741b47;&quot;&gt;from &lt;/span&gt;tkinter &lt;span style=&quot;color: #741b47;&quot;&gt;import &lt;/span&gt;ttk

TrvFrm  = &lt;span style=&quot;color: #0b5394;&quot;&gt;Tk()&lt;/span&gt;
TrvFrm .&lt;span style=&quot;color: #783f04;&quot;&gt;title&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;TreeView Add Itmes through Loop&#39;&lt;/span&gt;)

MyTrv = &lt;span style=&quot;color: #0b5394;&quot;&gt;ttk.Treeview&lt;/span&gt;(TrvFrm, columns=(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;MyCl1&#39;&lt;/span&gt;, &lt;span style=&quot;color: #990000;&quot;&gt;&#39;MyCl2&#39;&lt;/span&gt;, &lt;span style=&quot;color: #990000;&quot;&gt;&#39;MyCl3&#39;&lt;/span&gt;), show=&lt;span style=&quot;color: #990000;&quot;&gt;&#39;headings&#39;&lt;/span&gt;)

MyTrv.heading(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;MyCl1&#39;&lt;/span&gt;, text=&lt;span style=&quot;color: #990000;&quot;&gt;&#39;CLID&#39;&lt;/span&gt;)
MyTrv.heading(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;MyCl2&#39;&lt;/span&gt;, text=&lt;span style=&quot;color: #990000;&quot;&gt;&#39;CLName&#39;&lt;/span&gt;)
MyTrv.heading(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;MyCl3&#39;&lt;/span&gt;, text=&lt;span style=&quot;color: #990000;&quot;&gt;&#39;CLFName&#39;&lt;/span&gt;)

&lt;span style=&quot;color: #741b47;&quot;&gt;for &lt;/span&gt;sn &lt;span style=&quot;color: #741b47;&quot;&gt;in &lt;/span&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #38761d;&quot;&gt;1&lt;/span&gt;, &lt;span style=&quot;color: #38761d;&quot;&gt;6&lt;/span&gt;):
    MyTrv.&lt;span style=&quot;color: #783f04;&quot;&gt;insert&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;&#39;&lt;/span&gt;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;END&lt;/span&gt;, values=(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;MyIDs&#39;&lt;/span&gt;+ &lt;span style=&quot;color: #134f5c;&quot;&gt;str&lt;/span&gt;(sn), &lt;span style=&quot;color: #990000;&quot;&gt;&#39;MyName&#39;&lt;/span&gt;+ &lt;span style=&quot;color: #134f5c;&quot;&gt;str&lt;/span&gt;(sn), &lt;span style=&quot;color: #990000;&quot;&gt;&#39;FName&#39;&lt;/span&gt;+ str(sn)))

MyTrv.&lt;span style=&quot;color: #783f04;&quot;&gt;pack&lt;/span&gt;(side=&lt;span style=&quot;color: #2b00fe;&quot;&gt;TOP&lt;/span&gt;, fill=&lt;span style=&quot;color: #990000;&quot;&gt;&quot;both&quot;&lt;/span&gt;, expand=&lt;span style=&quot;color: #2b00fe;&quot;&gt;True&lt;/span&gt;)

TrvFrm.mainloop()

&lt;/pre&gt;
&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;
Output:
&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHUt_zE5732Uop_ExwI8MHt6GvvusP3QcQX5wbXnKLQoADlgzSTiUUqa6ksJUFv0y6qm50A5MEj0EWbZROsQ7aanGxNoTFrOawPusN36wnNnyGl9Sd10N8AWlvMmcOr6pt5wdwxsX7CZu8DX3Wd0tFQrmj-YREOI_qdFtAZlcJOEd8aTTTggY9P0_rjg/s335/5_Loop_To_Add_Items_in_Treeview_in_Tkinter.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Loop_To_Add_Items_in_Treeview_in_Tkinter&quot; border=&quot;0&quot; data-original-height=&quot;174&quot; data-original-width=&quot;335&quot; height=&quot;166&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHUt_zE5732Uop_ExwI8MHt6GvvusP3QcQX5wbXnKLQoADlgzSTiUUqa6ksJUFv0y6qm50A5MEj0EWbZROsQ7aanGxNoTFrOawPusN36wnNnyGl9Sd10N8AWlvMmcOr6pt5wdwxsX7CZu8DX3Wd0tFQrmj-YREOI_qdFtAZlcJOEd8aTTTggY9P0_rjg/w320-h166/5_Loop_To_Add_Items_in_Treeview_in_Tkinter.jpg&quot; title=&quot;Loop To Add Items in Treeview in Tkinter Python&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;

&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 17px;&quot;&gt;&lt;b&gt;(5). Tkinter Treeview Row Color in Python :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;

&lt;div&gt;Now, the next step to add color in rows according to desire. For it, we will use, &#39;&lt;b&gt;ttk.Style&lt;/b&gt;&#39; for color and &#39;&lt;b&gt;tag_configure&lt;/b&gt;&#39; for treeview widget for apply color. Now here we use following code for better look of treeview as Table in tkinter.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;ttk style in Treeview in tkinter&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;/div&gt;&lt;div&gt;
  
&lt;pre style=&quot;background-color: #fcfbfb; border-bottom: 1px solid #D0D9EA; border-color: rgb(208, 217, 234) rgb(208, 217, 234) rgb(208, 217, 234) rgb(126, 139, 187); border-left: 3px solid #7E8BBB; border-radius: 5px; border-right: 1px solid #D0D9EA; border-style: solid; border-top: 1px solid #D0D9EA; border-width: 1px 1px 1px 3px; box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana; font-size: 13px; line-height: 22px; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: #741b47;&quot;&gt;from&lt;/span&gt; tkinter &lt;span style=&quot;color: #741b47;&quot;&gt;import&lt;/span&gt; *
&lt;span style=&quot;color: #741b47;&quot;&gt;from&lt;/span&gt; tkinter &lt;span style=&quot;color: #741b47;&quot;&gt;import&lt;/span&gt; ttk

TrvFrm = &lt;span style=&quot;color: #0b5394;&quot;&gt;Tk()&lt;/span&gt;
TrvFrm.&lt;span style=&quot;color: #783f04;&quot;&gt;title&lt;/span&gt;(&#39;&lt;span style=&quot;color: #990000;&quot;&gt;TreeView Row Color&lt;/span&gt;&#39;)
TrvFrm.&lt;span style=&quot;color: #783f04;&quot;&gt;geometry&lt;/span&gt;(&#39;&lt;span style=&quot;color: #990000;&quot;&gt;300x150&lt;/span&gt;&#39;)

style = &lt;span style=&quot;color: #0b5394;&quot;&gt;ttk.Style&lt;/span&gt;(TrvFrm)

&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;i&gt;# ttk Style theme&lt;/i&gt;&lt;/span&gt;
style.&lt;span style=&quot;color: #0b5394;&quot;&gt;theme_use&lt;/span&gt;(&quot;&lt;span style=&quot;color: #990000;&quot;&gt;default&lt;/span&gt;&quot;)

&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;i&gt;# Set treeview Row Colomn Color&lt;/i&gt;&lt;/span&gt;
style.&lt;span style=&quot;color: #0b5394;&quot;&gt;map&lt;/span&gt;(&#39;&lt;span style=&quot;color: #990000;&quot;&gt;Treeview&lt;/span&gt;&#39;, background=[(&#39;&lt;span style=&quot;color: #990000;&quot;&gt;selected&lt;/span&gt;&#39;, &#39;&lt;span style=&quot;color: #990000;&quot;&gt;#BFBFBF&lt;/span&gt;&#39;)])

MyTrv = &lt;span style=&quot;color: #0b5394;&quot;&gt;ttk.Treeview&lt;/span&gt;(TrvFrm, columns=(&#39;&lt;span style=&quot;color: #990000;&quot;&gt;MyCl1&lt;/span&gt;&#39;, &#39;&lt;span style=&quot;color: #990000;&quot;&gt;MyCl2&lt;/span&gt;&#39;, &#39;&lt;span style=&quot;color: #990000;&quot;&gt;MyCl3&lt;/span&gt;&#39;), show=&#39;&lt;span style=&quot;color: #990000;&quot;&gt;headings&lt;/span&gt;&#39;, selectmode = &#39;&lt;span style=&quot;color: #990000;&quot;&gt;browse&lt;/span&gt;&#39;)
MyTrv.&lt;span style=&quot;color: #783f04;&quot;&gt;column&lt;/span&gt;(&quot;&lt;span style=&quot;color: #990000;&quot;&gt;#0&lt;/span&gt;&quot;, width=&lt;span style=&quot;color: #274e13;&quot;&gt;60&lt;/span&gt;, minwidth=&lt;span style=&quot;color: #274e13;&quot;&gt;30&lt;/span&gt;, stretch=&lt;span style=&quot;color: #2b00fe;&quot;&gt;NO&lt;/span&gt;)
MyTrv.&lt;span style=&quot;color: #783f04;&quot;&gt;column&lt;/span&gt;(&quot;&lt;span style=&quot;color: #990000;&quot;&gt;MyCl1&lt;/span&gt;&quot;, width=&lt;span style=&quot;color: #274e13;&quot;&gt;80&lt;/span&gt;, minwidth=&lt;span style=&quot;color: #274e13;&quot;&gt;20&lt;/span&gt;, stretch=&lt;span style=&quot;color: #2b00fe;&quot;&gt;NO&lt;/span&gt;)
MyTrv.&lt;span style=&quot;color: #783f04;&quot;&gt;column&lt;/span&gt;(&quot;&lt;span style=&quot;color: #990000;&quot;&gt;MyCl2&lt;/span&gt;&quot;, width=&lt;span style=&quot;color: #274e13;&quot;&gt;100&lt;/span&gt;, minwidth=&lt;span style=&quot;color: #274e13;&quot;&gt;30&lt;/span&gt;, stretch=&lt;span style=&quot;color: #2b00fe;&quot;&gt;NO&lt;/span&gt;)
MyTrv.&lt;span style=&quot;color: #783f04;&quot;&gt;column&lt;/span&gt;(&quot;&lt;span style=&quot;color: #990000;&quot;&gt;MyCl3&lt;/span&gt;&quot;, width=&lt;span style=&quot;color: #274e13;&quot;&gt;100&lt;/span&gt;, minwidth=&lt;span style=&quot;color: #274e13;&quot;&gt;30&lt;/span&gt;, stretch=&lt;span style=&quot;color: #2b00fe;&quot;&gt;NO&lt;/span&gt;)

MyTrv.&lt;span style=&quot;color: #783f04;&quot;&gt;heading&lt;/span&gt;(&#39;&lt;span style=&quot;color: #990000;&quot;&gt;MyCl1&lt;/span&gt;&#39;, text=&#39;&lt;span style=&quot;color: #990000;&quot;&gt;CLID&lt;/span&gt;&#39;)
MyTrv.&lt;span style=&quot;color: #783f04;&quot;&gt;heading&lt;/span&gt;(&#39;&lt;span style=&quot;color: #990000;&quot;&gt;MyCl2&lt;/span&gt;&#39;, text=&#39;&lt;span style=&quot;color: #990000;&quot;&gt;CLName&lt;/span&gt;&#39;)
MyTrv.&lt;span style=&quot;color: #783f04;&quot;&gt;heading&lt;/span&gt;(&#39;&lt;span style=&quot;color: #990000;&quot;&gt;MyCl3&lt;/span&gt;&#39;, text=&#39;&lt;span style=&quot;color: #990000;&quot;&gt;CLFName&lt;/span&gt;&#39;)

&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;i&gt;# Set treeview row font color or foreground color&lt;/i&gt;&lt;/span&gt;
MyTrv.&lt;span style=&quot;color: #0b5394;&quot;&gt;tag_configure&lt;/span&gt;(&#39;&lt;span style=&quot;color: #990000;&quot;&gt;Cl1&lt;/span&gt;&#39;, background = &#39;&lt;span style=&quot;color: #990000;&quot;&gt;#f9fbdb&lt;/span&gt;&#39;, foreground = &#39;&lt;span style=&quot;color: #990000;&quot;&gt;#c26981&lt;/span&gt;&#39;)
MyTrv.&lt;span style=&quot;color: #0b5394;&quot;&gt;tag_configure&lt;/span&gt;(&#39;&lt;span style=&quot;color: #990000;&quot;&gt;Cl2&lt;/span&gt;&#39;, background = &#39;&lt;span style=&quot;color: #990000;&quot;&gt;#fbdbf1&lt;/span&gt;&#39;, foreground = &#39;&lt;span style=&quot;color: #990000;&quot;&gt;#6f9594&lt;/span&gt;&#39;)

&lt;span style=&quot;color: #741b47;&quot;&gt;for&lt;/span&gt; sn &lt;span style=&quot;color: #741b47;&quot;&gt;in&lt;/span&gt; &lt;span style=&quot;color: #0b5394;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #274e13;&quot;&gt;1, 6&lt;/span&gt;):
    &lt;span style=&quot;color: #741b47;&quot;&gt;if&lt;/span&gt; (sn &lt;span style=&quot;color: #2b00fe;&quot;&gt;%&lt;/span&gt; &lt;span style=&quot;color: #274e13;&quot;&gt;2&lt;/span&gt;) == &lt;span style=&quot;color: #274e13;&quot;&gt;0&lt;/span&gt;:  
        MyTrv.&lt;span style=&quot;color: #783f04;&quot;&gt;insert&lt;/span&gt;(&#39;&#39;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;END&lt;/span&gt;, values=(&#39;&lt;span style=&quot;color: #990000;&quot;&gt;MyIDs&lt;/span&gt;&#39; + &lt;span style=&quot;color: #0b5394;&quot;&gt;str&lt;/span&gt;(sn), &#39;&lt;span style=&quot;color: #990000;&quot;&gt;MyName&lt;/span&gt;&#39; + &lt;span style=&quot;color: #0b5394;&quot;&gt;str&lt;/span&gt;(sn), &#39;&lt;span style=&quot;color: #990000;&quot;&gt;FName&lt;/span&gt;&#39; + &lt;span style=&quot;color: #0b5394;&quot;&gt;str&lt;/span&gt;(sn)), tags = &#39;&lt;span style=&quot;color: #990000;&quot;&gt;Cl1&lt;/span&gt;&#39;)
    &lt;span style=&quot;color: #741b47;&quot;&gt;else&lt;/span&gt;:  
        MyTrv.&lt;span style=&quot;color: #783f04;&quot;&gt;insert&lt;/span&gt;(&#39;&#39;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;END&lt;/span&gt;, values=(&#39;&lt;span style=&quot;color: #990000;&quot;&gt;MyIDs&lt;/span&gt;&#39; + &lt;span style=&quot;color: #0b5394;&quot;&gt;str&lt;/span&gt;(sn), &#39;&lt;span style=&quot;color: #990000;&quot;&gt;MyName&lt;/span&gt;&#39; + &lt;span style=&quot;color: #0b5394;&quot;&gt;str&lt;/span&gt;(sn), &#39;&lt;span style=&quot;color: #990000;&quot;&gt;FName&lt;/span&gt;&#39; + &lt;span style=&quot;color: #0b5394;&quot;&gt;str&lt;/span&gt;(sn)), tags = &#39;&lt;span style=&quot;color: #990000;&quot;&gt;Cl2&lt;/span&gt;&#39;)

MyTrv.&lt;span style=&quot;color: #783f04;&quot;&gt;pack&lt;/span&gt;(side=&lt;span style=&quot;color: #2b00fe;&quot;&gt;TOP&lt;/span&gt;, fill=&quot;&lt;span style=&quot;color: #990000;&quot;&gt;both&lt;/span&gt;&quot;, expand=&lt;span style=&quot;color: #2b00fe;&quot;&gt;True&lt;/span&gt;)

TrvFrm.mainloop()

&lt;/pre&gt;After that, we will find a colorful listview or treeview as given in following output:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1LG_xKR5-q5bfDx3YYsMOT1NPqy81npMNlym4ITdvE_yhUAcLdoCyxVXYnI3xR9hVKLieOd1tOMaQRnkBXK-tl2csabZ6kx16Eiel9tam-T9slcBaTeRDkroZnoxP-zR2N3wGuhGnzpYZktbNc8s1E7snL7OEB44Vd2kgxgN012e8SnzvOTaO6BOidQ/s316/Set%20Treeview%20Row%20Color.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;tkinter Treeview Row Color&quot; border=&quot;0&quot; data-original-height=&quot;188&quot; data-original-width=&quot;316&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1LG_xKR5-q5bfDx3YYsMOT1NPqy81npMNlym4ITdvE_yhUAcLdoCyxVXYnI3xR9hVKLieOd1tOMaQRnkBXK-tl2csabZ6kx16Eiel9tam-T9slcBaTeRDkroZnoxP-zR2N3wGuhGnzpYZktbNc8s1E7snL7OEB44Vd2kgxgN012e8SnzvOTaO6BOidQ/s16000/Set%20Treeview%20Row%20Color.jpg&quot; title=&quot;Treeview Row Color in tkinter python&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt; 
  
These are the tips and way to &lt;b&gt;show data in treeview in tkinter&lt;/b&gt;. And you can choose &lt;b&gt;color of tkinter treeview&lt;/b&gt; according to need for your project. If you follow above given point then you can create an application with showing data in table model with desire color. So, this is the way to &lt;b&gt;Add Columns in treeview tkinter&lt;/b&gt; or &lt;b&gt;Add items in Treeview in Tkinter&lt;/b&gt; or &lt;b&gt;Style treeview in tkinter&lt;/b&gt;.&lt;/div&gt;</description><link>https://www.skotechlearn.com/2022/06/tkinter-treeview-columns-items-style-in-python.html</link><author>noreply@blogger.com (SKOTechLearn)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6lFRdqoWzG8Zyzqifj_FNUGGxe3osVdq5gb3nk-48jNrC1vt2o9OfKdWeQsCgkZXPMukp6FKKUNeRI2OteOQmCFzuxdU7JS1yxgRPxGJDB6a3XPiIqnjPqKMUmc_Ob7znbfqhLAjwiELLV5BEktxw1dLi6V68H0ew4upOZr_mB4dt_TdUIcD-efAzHA/s72-c/1_Add_Column_Header_in_TreeView_Tkinter.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2258844867892945003.post-998510185804275408</guid><pubDate>Sun, 18 Jul 2021 07:05:00 +0000</pubDate><atom:updated>2022-06-21T14:12:52.226-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Python</category><title>Style and Use Entry Box in tkinter and TextBox in tkinter</title><description>If you want to use &lt;b&gt;Entry Box in tkinter&lt;/b&gt; and &lt;b&gt;TextBox in tkinter &lt;/b&gt;or you can say that &lt;b&gt;tkinter Entry Widget&lt;/b&gt; and &lt;b&gt;tkinter Text Widget&lt;/b&gt;. So, here we describe following way to use or &lt;b&gt;Style EntryBox&lt;/b&gt; or &lt;b&gt;Style TextBox in tkinter&lt;/b&gt;. The Text or Entry widget Style will be defined in following points.&lt;div&gt;&amp;nbsp; &lt;br /&gt;

&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Create and Set Location and Size of Entry or Text Widget in tkinter&lt;/li&gt;
&lt;/b&gt;  &lt;b&gt;
&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Set Color of Entry or Text in tkinter&lt;/li&gt;
 &lt;/b&gt;  &lt;b&gt;
&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Set Selection Background and Foreground Color of Entry or Text in tkinter&lt;/li&gt;
 &lt;/b&gt;  &lt;b&gt;
&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Text or Entry Box Font Setting in tkinter&lt;/li&gt;
  &lt;/b&gt;  &lt;b&gt;
&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Text or Entry Border Style in tkinter&lt;/li&gt;
&lt;/b&gt; &lt;/ol&gt;

&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisD2lwva2_5o1B49w6rLQEkwpeHEjte3IzG9VUeYGst1isOBxTopU1ehF0eTP3MR54BIHZRIaiVk1wAGxaMl55pT8ObKt0jkMMAKxt_L9tCeAXlCNKFYGcG4QbmQj6DxwjXF8bn3vsECXp/s704/Entry_Or_text_Widget_Style_in_Tkinter.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Tkinter Entry Widget Style in Python&quot; border=&quot;0&quot; data-original-height=&quot;417&quot; data-original-width=&quot;704&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisD2lwva2_5o1B49w6rLQEkwpeHEjte3IzG9VUeYGst1isOBxTopU1ehF0eTP3MR54BIHZRIaiVk1wAGxaMl55pT8ObKt0jkMMAKxt_L9tCeAXlCNKFYGcG4QbmQj6DxwjXF8bn3vsECXp/s16000/Entry_Or_text_Widget_Style_in_Tkinter.jpg&quot; title=&quot;Tkinter Text Widget Style in Python&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Now, here we learn interesting way to style widget in tkiter.&lt;div&gt;&lt;br /&gt;&lt;br /&gt;

&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 17px;&quot;&gt;&lt;b&gt;(1). Create and Set Location and Size of Entry or Text Widget in tkinter :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;
Now, if you want to set particular control or widget in desire location of window and want to set Entry box Height and Width in tkinter then we use “&lt;b&gt;place&lt;/b&gt;” method in following way:
&lt;br /&gt;&lt;br /&gt;


&lt;pre style=&quot;background-color: #fcfbfb; border-bottom: 1px solid #D0D9EA; border-color: rgb(208, 217, 234) rgb(208, 217, 234) rgb(208, 217, 234) rgb(126, 139, 187); border-left: 3px solid #7E8BBB; border-radius: 5px; border-right: 1px solid #D0D9EA; border-style: solid; border-top: 1px solid #D0D9EA; border-width: 1px 1px 1px 3px; box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana; font-size: 13px; line-height: 22px; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: #800180;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #134f5c;&quot;&gt;tkinter&lt;/span&gt; &lt;span style=&quot;color: #800180;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #134f5c;&quot;&gt;*&lt;/span&gt;  

TkFrm = &lt;span style=&quot;color: #0b5394;&quot;&gt;Tk&lt;/span&gt;()
TkFrm.&lt;span style=&quot;color: #783f04;&quot;&gt;geometry&lt;/span&gt;(&quot;&lt;span style=&quot;color: #990000;&quot;&gt;250x200+500+400&lt;/span&gt;&quot;)
TkFrm.&lt;span style=&quot;color: #783f04;&quot;&gt;title&lt;/span&gt;(&#39;&lt;span style=&quot;color: #990000;&quot;&gt;Entry Box or Text Box Location And Size in Tkinter&lt;/span&gt;&#39;)
&lt;span style=&quot;color: #38761d;&quot;&gt;#Create Entry Box&lt;/span&gt;
MyEntryBox1 = &lt;span style=&quot;color: #0b5394;&quot;&gt;Entry&lt;/span&gt;(TkFrm)
&lt;span style=&quot;color: #38761d;&quot;&gt;#Set Entry Widget Location and Size in Form&lt;/span&gt;
MyEntryBox1.&lt;span style=&quot;color: #783f04;&quot;&gt;place&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;x&lt;/span&gt;=&lt;span style=&quot;color: #274e13;&quot;&gt;14&lt;/span&gt;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;y&lt;/span&gt;=&lt;span style=&quot;color: #274e13;&quot;&gt;30&lt;/span&gt;,  &lt;span style=&quot;color: #2b00fe;&quot;&gt;width&lt;/span&gt;=&lt;span style=&quot;color: #274e13;&quot;&gt;256&lt;/span&gt;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;height&lt;/span&gt;= &lt;span style=&quot;color: #274e13;&quot;&gt;35&lt;/span&gt;)
&lt;span style=&quot;color: #38761d;&quot;&gt;#Add Text to Entry Widget in Python&lt;/span&gt;
MyEntryBox1.&lt;span style=&quot;color: #783f04;&quot;&gt;insert&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;END&lt;/span&gt;, &#39;&lt;span style=&quot;color: #990000;&quot;&gt;SKOTechLearn&lt;/span&gt;&#39;)

&lt;span style=&quot;color: #38761d;&quot;&gt;#Create Entry Box&lt;/span&gt;
MyTxtBox = &lt;span style=&quot;color: #073763;&quot;&gt;Text&lt;/span&gt;(TkFrm)
&lt;span style=&quot;color: #38761d;&quot;&gt;#Set Text Widget Location and Size in Form&lt;/span&gt;
MyTxtBox.&lt;span style=&quot;color: #783f04;&quot;&gt;place&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;x&lt;/span&gt;=&lt;span style=&quot;color: #274e13;&quot;&gt;14&lt;/span&gt;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;y&lt;/span&gt;=&lt;span style=&quot;color: #274e13;&quot;&gt;90&lt;/span&gt;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;width&lt;/span&gt;=&lt;span style=&quot;color: #274e13;&quot;&gt;256&lt;/span&gt;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;height&lt;/span&gt;=&lt;span style=&quot;color: #274e13;&quot;&gt;50&lt;/span&gt;)
&lt;span style=&quot;color: #38761d;&quot;&gt;#Add Text to Text Widget in Python&lt;/span&gt;
MyTxtBox.&lt;span style=&quot;color: #783f04;&quot;&gt;insert&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;END&lt;/span&gt;, &#39;&lt;span style=&quot;color: #990000;&quot;&gt;SKOTechLearn&lt;/span&gt;&#39;)

TkFrm.&lt;span style=&quot;color: #783f04;&quot;&gt;mainloop&lt;/span&gt;()

&lt;/pre&gt;
&lt;br /&gt; &lt;br /&gt;
Here we add some text in both widgets in python tkinter. And after running it will show output:&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgU6u3JLEFpQoQa-ggrm6Q5bQkCFpSqmi-CbNxkUh2y_Hd-SbCLFzaL2lsGNrRB-5TplplVhkeQm1si95UVuSXNo8mWJF_2b1fS8a7wKYq8RO4RvaxzSjKkKDgHzrWaLZKsFVOaFVI-GjJY/s585/1_Entry_Or_text_Widget_Location_And_Size_in_Tkinter.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Tkinter Entry Size and Location&quot; border=&quot;0&quot; data-original-height=&quot;207&quot; data-original-width=&quot;585&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgU6u3JLEFpQoQa-ggrm6Q5bQkCFpSqmi-CbNxkUh2y_Hd-SbCLFzaL2lsGNrRB-5TplplVhkeQm1si95UVuSXNo8mWJF_2b1fS8a7wKYq8RO4RvaxzSjKkKDgHzrWaLZKsFVOaFVI-GjJY/s16000/1_Entry_Or_text_Widget_Location_And_Size_in_Tkinter.jpg&quot; title=&quot;Tkinter Text Size and Location&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
This way we can increase or decrease height and width of tkinter widgets.&lt;div&gt;&amp;nbsp;
&lt;br /&gt;&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 17px;&quot;&gt;&lt;b&gt;(2). Set Color of Entry or Text in tkinter :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;Here, we set Background, Foreground, Border Selection color or Entry Box or Text Box in Tkinter.&lt;div&gt;&lt;br /&gt;
Following method will use for &lt;b&gt;color setting in tkinter&lt;/b&gt;:
&lt;/div&gt;

&lt;table style=&quot;border-radius: 5px; border: 1px solid rgb(204, 204, 204); height: 114px;&quot;&gt;
  &lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;background-color: #898b91; border-radius: 5px; color: white; font-size: 15px; font-weight: bold; height: 18px; padding: 2px 4px;&quot;&gt;Method&lt;/td&gt;&lt;td style=&quot;background-color: #898b91; border-radius: 5px; color: white; font-size: 15px; font-weight: bold; height: 18px; padding: 2px 4px;&quot;&gt;Details&lt;/td&gt;&lt;/tr&gt;
 &lt;tr&gt;&lt;td style=&quot;background-color: #f7f9ff; border-radius: 5px; border: 1px solid rgb(204, 204, 204); font-size: 15px; font-weight: bold; margin: 3px; padding: 2px 4px;&quot;&gt;bg or background&lt;/td&gt;
   &lt;td style=&quot;background-color: #f7f9ff; border-radius: 5px; border: 1px solid rgb(204, 204, 204); font-size: 15px; margin: 3px; padding: 2px 4px;&quot;&gt;Use for Background color of Widgets&lt;/td&gt;&lt;/tr&gt;
 &lt;tr&gt;&lt;td style=&quot;background-color: #f7f9ff; border-radius: 5px; border: 1px solid rgb(204, 204, 204); font-size: 15px; font-weight: bold; margin: 3px; padding: 2px 4px;&quot;&gt;Fg or foreground&lt;/td&gt;
   &lt;td style=&quot;background-color: #f7f9ff; border-radius: 5px; border: 1px solid rgb(204, 204, 204); font-size: 15px; margin: 3px; padding: 2px 4px;&quot;&gt;Use for Font color of widgets&lt;/td&gt;&lt;/tr&gt;
 &lt;tr&gt;&lt;td style=&quot;background-color: #f7f9ff; border-radius: 5px; border: 1px solid rgb(204, 204, 204); font-size: 15px; font-weight: bold; margin: 3px; padding: 2px 4px;&quot;&gt;highlightbackground&lt;/td&gt;
   &lt;td style=&quot;background-color: #f7f9ff; border-radius: 5px; border: 1px solid rgb(204, 204, 204); font-size: 15px; margin: 3px; padding: 2px 4px;&quot;&gt;This method is use for Border color&lt;/td&gt;&lt;/tr&gt;
 &lt;tr&gt;&lt;td style=&quot;background-color: #f7f9ff; border-radius: 5px; border: 1px solid rgb(204, 204, 204); font-size: 15px; font-weight: bold; margin: 3px; padding: 2px 4px;&quot;&gt;highlightcolor&lt;/td&gt;
   &lt;td style=&quot;background-color: #f7f9ff; border-radius: 5px; border: 1px solid rgb(204, 204, 204); font-size: 15px; margin: 3px; padding: 2px 4px;&quot;&gt;This method is use for border color when focus on entry or text widget.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;

&lt;br /&gt;&lt;br /&gt;
&lt;div style=&quot;background-color: #660000; border-radius: 5px; border: 2px groove gray; color: white; font-size: 20px; padding: 2px 4px;&quot;&gt;&lt;b&gt;
Entry And Text Widget Color Setting in tkinter:&lt;/b&gt; &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;When you want to apply border color change when lost focus and got focus, and want to change font and back color, you have to apply and write following code:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

&lt;pre style=&quot;background-color: #fcfbfb; border-bottom: 1px solid #D0D9EA; border-color: rgb(208, 217, 234) rgb(208, 217, 234) rgb(208, 217, 234) rgb(126, 139, 187); border-left: 3px solid #7E8BBB; border-radius: 5px; border-right: 1px solid #D0D9EA; border-style: solid; border-top: 1px solid #D0D9EA; border-width: 1px 1px 1px 3px; box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana; font-size: 13px; line-height: 22px; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: #800180;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #134f5c;&quot;&gt;tkinter&lt;/span&gt; &lt;span style=&quot;color: #800180;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #134f5c;&quot;&gt;*&lt;/span&gt;  

TkFrm = &lt;span style=&quot;color: #0b5394;&quot;&gt;Tk&lt;/span&gt;()
TkFrm.&lt;span style=&quot;color: #783f04;&quot;&gt;geometry&lt;/span&gt;(&#39;&lt;span style=&quot;color: #990000;&quot;&gt;290x200+500+300&lt;/span&gt;&#39;)
TkFrm.&lt;span style=&quot;color: #783f04;&quot;&gt;title&lt;/span&gt;(&#39;&lt;span style=&quot;color: #990000;&quot;&gt;Entry Box or Text Box Color Setting in Tkinter&lt;/span&gt;&#39;)

&lt;span style=&quot;color: #38761d;&quot;&gt;#Set Entry Widget Color and Border Color&lt;/span&gt;
MyEntryBox1 = &lt;span style=&quot;color: #073763;&quot;&gt;Entry&lt;/span&gt;(TkFrm, &lt;span style=&quot;color: #2b00fe;&quot;&gt;highlightcolor&lt;/span&gt; = &#39;&lt;span style=&quot;color: #990000;&quot;&gt;green&lt;/span&gt;&#39;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;bg&lt;/span&gt;=&#39;&lt;span style=&quot;color: #990000;&quot;&gt;#F3FEFF&lt;/span&gt;&#39;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;fg&lt;/span&gt;=&#39;&lt;span style=&quot;color: #990000;&quot;&gt;red&lt;/span&gt;&#39;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;highlightbackground&lt;/span&gt;=&#39;&lt;span style=&quot;color: #990000;&quot;&gt;red&lt;/span&gt;&#39;)

&lt;span style=&quot;color: #38761d;&quot;&gt;#Set Widget Location and Size in Tkinter&lt;/span&gt;
MyEntryBox1.&lt;span style=&quot;color: #783f04;&quot;&gt;place&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;x&lt;/span&gt;=&lt;span style=&quot;color: #274e13;&quot;&gt;14&lt;/span&gt;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;y&lt;/span&gt;=&lt;span style=&quot;color: #274e13;&quot;&gt;30&lt;/span&gt;,  &lt;span style=&quot;color: #2b00fe;&quot;&gt;width&lt;/span&gt;=&lt;span style=&quot;color: #274e13;&quot;&gt;256&lt;/span&gt;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;height&lt;/span&gt;= &lt;span style=&quot;color: #274e13;&quot;&gt;35&lt;/span&gt;)
&lt;span style=&quot;color: #38761d;&quot;&gt;#Add Text to Entry Widget in Python&lt;/span&gt;
MyEntryBox1.&lt;span style=&quot;color: #783f04;&quot;&gt;insert&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;END&lt;/span&gt;, &#39;&lt;span style=&quot;color: #990000;&quot;&gt;SKOTechLearn&lt;/span&gt;&#39;)

&lt;span style=&quot;color: #38761d;&quot;&gt;# Text Widget Color and border Color in Tkinter&lt;/span&gt;
MyTxtBox = &lt;span style=&quot;color: #073763;&quot;&gt;Text&lt;/span&gt;(TkFrm, &lt;span style=&quot;color: #2b00fe;&quot;&gt;highlightcolor&lt;/span&gt; = &#39;&lt;span style=&quot;color: #990000;&quot;&gt;blue&lt;/span&gt;&#39;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;highlightbackground&lt;/span&gt;=&#39;&lt;span style=&quot;color: #990000;&quot;&gt;brown&lt;/span&gt;&#39;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;fg&lt;/span&gt;=&#39;&lt;span style=&quot;color: #990000;&quot;&gt;Navy&lt;/span&gt;&#39;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;bg&lt;/span&gt;=&#39;&lt;span style=&quot;color: #990000;&quot;&gt;#FFEFE7&lt;/span&gt;&#39;)
&lt;span style=&quot;color: #38761d;&quot;&gt;#Set Widget Location and Size in Form&lt;/span&gt;
MyTxtBox.&lt;span style=&quot;color: #783f04;&quot;&gt;place&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;x&lt;/span&gt;=&lt;span style=&quot;color: #274e13;&quot;&gt;14&lt;/span&gt;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;y&lt;/span&gt;=&lt;span style=&quot;color: #274e13;&quot;&gt;90&lt;/span&gt;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;width&lt;/span&gt;=&lt;span style=&quot;color: #274e13;&quot;&gt;256&lt;/span&gt;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;height&lt;/span&gt;=&lt;span style=&quot;color: #274e13;&quot;&gt;50&lt;/span&gt;)
&lt;span style=&quot;color: #38761d;&quot;&gt;#Add Text to Text Widget in Python&lt;/span&gt;
MyTxtBox.&lt;span style=&quot;color: #783f04;&quot;&gt;insert&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;END&lt;/span&gt;, &#39;&lt;span style=&quot;color: #990000;&quot;&gt;SKOTechLearn&lt;/span&gt;&#39;)

TkFrm.&lt;span style=&quot;color: #783f04;&quot;&gt;mainloop&lt;/span&gt;()

&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;When you execute this code, and when you focus on widget, it will change the border color as describe bellow image.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjw99rYKngv16ML_SXfuRZTSeNJgEK_sTN3QpwXRYoHK7nocDFClr7If2hWyqxb2aci5oTAfHpwwcHV9jTwIugE1hH5UzG-BD2q3dsXp4j8tJSw-ul6qdrkOgPx68mGuB_UaXq1jVk5qEte/s765/Entry_Or_text_Widget_Color_in_Tkinter.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Set Tkinter Entry widget Color in Python&quot; border=&quot;0&quot; data-original-height=&quot;408&quot; data-original-width=&quot;765&quot; height=&quot;341&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjw99rYKngv16ML_SXfuRZTSeNJgEK_sTN3QpwXRYoHK7nocDFClr7If2hWyqxb2aci5oTAfHpwwcHV9jTwIugE1hH5UzG-BD2q3dsXp4j8tJSw-ul6qdrkOgPx68mGuB_UaXq1jVk5qEte/w640-h341/Entry_Or_text_Widget_Color_in_Tkinter.jpg&quot; title=&quot;Set Tkinter Text widget Color in Python&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;

&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 17px;&quot;&gt;&lt;b&gt;(3). Set Selection Background and Selection Foreground Color of Entry or Text in tkinter :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;If you want to change Selection Color, when you select String or Value in Entry or Text Box, then you have to use ‘&lt;b&gt;selectbackground&lt;/b&gt;’ for selection back color and ‘&lt;b&gt;selectforeground&lt;/b&gt;’ for selection font color.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

&lt;pre style=&quot;background-color: #fcfbfb; border-bottom: 1px solid #D0D9EA; border-color: rgb(208, 217, 234) rgb(208, 217, 234) rgb(208, 217, 234) rgb(126, 139, 187); border-left: 3px solid #7E8BBB; border-radius: 5px; border-right: 1px solid #D0D9EA; border-style: solid; border-top: 1px solid #D0D9EA; border-width: 1px 1px 1px 3px; box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana; font-size: 13px; line-height: 22px; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: #800180;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #134f5c;&quot;&gt;tkinter&lt;/span&gt; &lt;span style=&quot;color: #800180;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #134f5c;&quot;&gt;* &lt;/span&gt; 

TkFrm = &lt;span style=&quot;color: #0b5394;&quot;&gt;Tk&lt;/span&gt;()
TkFrm.&lt;span style=&quot;color: #783f04;&quot;&gt;geometry&lt;/span&gt;(&#39;&lt;span style=&quot;color: #990000;&quot;&gt;290x200+500+300&lt;/span&gt;&#39;)
TkFrm.&lt;span style=&quot;color: #783f04;&quot;&gt;title&lt;/span&gt;(&#39;&lt;span style=&quot;color: #990000;&quot;&gt;Entry Box or Text Box Selection Color in Tkinter&lt;/span&gt;&#39;)

&lt;span style=&quot;color: #38761d;&quot;&gt;#Selection Color Setting in Tkinter Entry Widget&lt;/span&gt;
MyEntryBox1 = &lt;span style=&quot;color: #0b5394;&quot;&gt;Entry&lt;/span&gt;(TkFrm,  &lt;span style=&quot;color: #2b00fe;&quot;&gt;selectbackground&lt;/span&gt;=&#39;&lt;span style=&quot;color: #990000;&quot;&gt;yellow&lt;/span&gt;&#39;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;selectforeground&lt;/span&gt;=&#39;&lt;span style=&quot;color: #990000;&quot;&gt;green&lt;/span&gt;&#39;)
MyEntryBox1.&lt;span style=&quot;color: #783f04;&quot;&gt;place&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;x&lt;/span&gt;=&lt;span style=&quot;color: #274e13;&quot;&gt;14&lt;/span&gt;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;y&lt;/span&gt;=&lt;span style=&quot;color: #274e13;&quot;&gt;30&lt;/span&gt;,  &lt;span style=&quot;color: #2b00fe;&quot;&gt;width&lt;/span&gt;=&lt;span style=&quot;color: #274e13;&quot;&gt;256&lt;/span&gt;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;height&lt;/span&gt;= &lt;span style=&quot;color: #274e13;&quot;&gt;35&lt;/span&gt;)
MyEntryBox1.&lt;span style=&quot;color: #783f04;&quot;&gt;insert&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;END&lt;/span&gt;, &#39;&lt;span style=&quot;color: #990000;&quot;&gt;SKOTechLearn&lt;/span&gt;&#39;)

&lt;span style=&quot;color: #38761d;&quot;&gt;#Selection Color Setting in Tkinter Text Widget&lt;/span&gt;
MyTxtBox = &lt;span style=&quot;color: #0b5394;&quot;&gt;Text&lt;/span&gt;(TkFrm, &lt;span style=&quot;color: #2b00fe;&quot;&gt;selectforeground&lt;/span&gt;=&#39;&lt;span style=&quot;color: #990000;&quot;&gt;yellow&lt;/span&gt;&#39;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;selectbackground&lt;/span&gt;=&#39;&lt;span style=&quot;color: #990000;&quot;&gt;red&lt;/span&gt;&#39;)
MyTxtBox.&lt;span style=&quot;color: #783f04;&quot;&gt;place&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;x&lt;/span&gt;=&lt;span style=&quot;color: #274e13;&quot;&gt;14&lt;/span&gt;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;y&lt;/span&gt;=&lt;span style=&quot;color: #274e13;&quot;&gt;90&lt;/span&gt;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;width&lt;/span&gt;=&lt;span style=&quot;color: #274e13;&quot;&gt;256&lt;/span&gt;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;height&lt;/span&gt;=&lt;span style=&quot;color: #274e13;&quot;&gt;50&lt;/span&gt;)
MyTxtBox.&lt;span style=&quot;color: #783f04;&quot;&gt;insert&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;END&lt;/span&gt;, &#39;&lt;span style=&quot;color: #990000;&quot;&gt;SKOTechLearn&lt;/span&gt;&#39;)

TkFrm.&lt;span style=&quot;color: #783f04;&quot;&gt;mainloop&lt;/span&gt;()

&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;Output:&lt;/b&gt;&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVP4SQpfZ6VLsngIK_v82NfkDk3BY4mvfPztqLeDI-TwCOIf-AbnrvMXtcwoHSF35UoM-YMRFjabqX4F9ATf3wYuoYA2zIxkLWMizz73SUP3KasLX5luD6jB3cECLgnM5yqSeYO4HyJczN/s654/Entry_Or_text_Widget_Selection_Color_in_Tkinter.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Tkinter Entry Selection Color in Python&quot; border=&quot;0&quot; data-original-height=&quot;198&quot; data-original-width=&quot;654&quot; height=&quot;194&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVP4SQpfZ6VLsngIK_v82NfkDk3BY4mvfPztqLeDI-TwCOIf-AbnrvMXtcwoHSF35UoM-YMRFjabqX4F9ATf3wYuoYA2zIxkLWMizz73SUP3KasLX5luD6jB3cECLgnM5yqSeYO4HyJczN/w640-h194/Entry_Or_text_Widget_Selection_Color_in_Tkinter.jpg&quot; title=&quot;Tkinter Text Selection Color in Python&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); color: white; font-size: 17px; line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;b&gt;(4). Text or Entry Box Font Setting in tkinter :&lt;/b&gt;&lt;/h2&gt;
Now, lets see the code, how to change &lt;b&gt;font in Entry widget in tkinter&lt;/b&gt; or change &lt;b&gt;font in Text widget in tkinter&lt;/b&gt;. Or Change the &lt;b&gt;font size in tkinter&lt;/b&gt; widgets.&lt;br /&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-bottom: 1px solid #D0D9EA; border-color: rgb(208, 217, 234) rgb(208, 217, 234) rgb(208, 217, 234) rgb(126, 139, 187); border-left: 3px solid #7E8BBB; border-radius: 5px; border-right: 1px solid #D0D9EA; border-style: solid; border-top: 1px solid #D0D9EA; border-width: 1px 1px 1px 3px; box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana; font-size: 13px; line-height: 22px; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: #800180;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #134f5c;&quot;&gt;tkinter&lt;/span&gt; &lt;span style=&quot;color: #800180;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #134f5c;&quot;&gt;*&lt;/span&gt;  

TkFrm = &lt;span style=&quot;color: #0b5394;&quot;&gt;Tk&lt;/span&gt;()
TkFrm.&lt;span style=&quot;color: #783f04;&quot;&gt;geometry&lt;/span&gt;(&#39;&lt;span style=&quot;color: #990000;&quot;&gt;290x200+500+300&lt;/span&gt;&#39;)
TkFrm.&lt;span style=&quot;color: #783f04;&quot;&gt;title&lt;/span&gt;(&#39;&lt;span style=&quot;color: #990000;&quot;&gt;Entry Box or Text Box Font Setting in Tkinter&lt;/span&gt;&#39;)

&lt;span style=&quot;color: #38761d;&quot;&gt;#Font Settings in tkinter&lt;/span&gt;
MyEntryBox1 = &lt;span style=&quot;color: #0b5394;&quot;&gt;Entry&lt;/span&gt;(TkFrm,  &lt;span style=&quot;color: #2b00fe;&quot;&gt;font&lt;/span&gt;=&#39;&lt;span style=&quot;color: #990000;&quot;&gt;Verdana 12 bold&lt;/span&gt;&#39;)
MyEntryBox1.&lt;span style=&quot;color: #783f04;&quot;&gt;pack&lt;/span&gt;()
MyEntryBox1.&lt;span style=&quot;color: #783f04;&quot;&gt;insert&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;END&lt;/span&gt;, &#39;&lt;span style=&quot;color: #990000;&quot;&gt;SKOTechLearn&lt;/span&gt;&#39;)

&lt;span style=&quot;color: #38761d;&quot;&gt;#Font Settings in tkinter&lt;/span&gt;
MyTxtBox = &lt;span style=&quot;color: #0b5394;&quot;&gt;Text&lt;/span&gt;(TkFrm, &lt;span style=&quot;color: #2b00fe;&quot;&gt;font&lt;/span&gt;=&#39;&lt;span style=&quot;color: #990000;&quot;&gt;Georgia 13 italic bold&lt;/span&gt;&#39;)
MyTxtBox.&lt;span style=&quot;color: #783f04;&quot;&gt;pack&lt;/span&gt;()
MyTxtBox.&lt;span style=&quot;color: #783f04;&quot;&gt;insert&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;END&lt;/span&gt;, &#39;&lt;span style=&quot;color: #990000;&quot;&gt;SKOTechLearn&lt;/span&gt;&#39;)

TkFrm.&lt;span style=&quot;color: #783f04;&quot;&gt;mainloop&lt;/span&gt;()

&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;
Output:&lt;/b&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimrb81PKbb6X69JJqtlyDuZoTWsRQrq6FoH6lQjRhrdeYx8nkhBZwVwV4xFYd1klTvY5Kr9lZmBuULHf4bWEVEfb35yOYrsU_O-GhSYgHp_BhqgLvyWExXJrfpCYLVVvbVUgDqfrq1ACZl/s303/Entry_Or_text_Widget_Font_Setting_in_Tkinter.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Entry widget Font Setting in Tkinter&quot; border=&quot;0&quot; data-original-height=&quot;295&quot; data-original-width=&quot;303&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimrb81PKbb6X69JJqtlyDuZoTWsRQrq6FoH6lQjRhrdeYx8nkhBZwVwV4xFYd1klTvY5Kr9lZmBuULHf4bWEVEfb35yOYrsU_O-GhSYgHp_BhqgLvyWExXJrfpCYLVVvbVUgDqfrq1ACZl/s16000/Entry_Or_text_Widget_Font_Setting_in_Tkinter.jpg&quot; title=&quot;Text widget Font Setting in Tkinter&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 17px;&quot;&gt;&lt;b&gt;(5). Text or Entry Border Style in tkinter :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;Now, let’s find the last point to change &lt;b&gt;Border Style in tkinter widgets&lt;/b&gt;. Can use following method in you code. You can change style of &lt;b&gt;Text Widget Border in tkinter&lt;/b&gt; or&lt;b&gt; Entry Widget Border in Tkinter&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;

&lt;table style=&quot;border-radius: 5px; border: 1px solid rgb(204, 204, 204); height: 114px;&quot;&gt;
  &lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;background-color: #898b91; border-radius: 5px; color: white; font-size: 15px; font-weight: bold; height: 18px; padding: 2px 4px;&quot;&gt;Method&lt;/td&gt;&lt;td style=&quot;background-color: #898b91; border-radius: 5px; color: white; font-size: 15px; font-weight: bold; height: 18px; padding: 2px 4px;&quot;&gt;Details&lt;/td&gt;&lt;/tr&gt;
 &lt;tr&gt;&lt;td style=&quot;background-color: #f7f9ff; border-radius: 5px; border: 1px solid rgb(204, 204, 204); font-size: 15px; font-weight: bold; margin: 3px; padding: 2px 4px;&quot;&gt;relief&lt;/td&gt;
   &lt;td style=&quot;background-color: #f7f9ff; border-radius: 5px; border: 1px solid rgb(204, 204, 204); font-size: 15px; margin: 3px; padding: 2px 4px;&quot;&gt;Change Border Style (raised, sunken, solid, flat, ridge, groove)&lt;/td&gt;&lt;/tr&gt;
 &lt;tr&gt;&lt;td style=&quot;background-color: #f7f9ff; border-radius: 5px; border: 1px solid rgb(204, 204, 204); font-size: 15px; font-weight: bold; margin: 3px; padding: 2px 4px;&quot;&gt;highlightthickness&lt;/td&gt;
   &lt;td style=&quot;background-color: #f7f9ff; border-radius: 5px; border: 1px solid rgb(204, 204, 204); font-size: 15px; margin: 3px; padding: 2px 4px;&quot;&gt;Change Border width when widget gain focus &lt;/td&gt;&lt;/tr&gt;
 &lt;tr&gt;&lt;td style=&quot;background-color: #f7f9ff; border-radius: 5px; border: 1px solid rgb(204, 204, 204); font-size: 15px; font-weight: bold; margin: 3px; padding: 2px 4px;&quot;&gt;borderwidth&lt;/td&gt;
   &lt;td style=&quot;background-color: #f7f9ff; border-radius: 5px; border: 1px solid rgb(204, 204, 204); font-size: 15px; margin: 3px; padding: 2px 4px;&quot;&gt;Change Border Width&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;Lets find code:&lt;br /&gt;&lt;br /&gt;

&lt;pre style=&quot;background-color: #fcfbfb; border-bottom: 1px solid #D0D9EA; border-color: rgb(208, 217, 234) rgb(208, 217, 234) rgb(208, 217, 234) rgb(126, 139, 187); border-left: 3px solid #7E8BBB; border-radius: 5px; border-right: 1px solid #D0D9EA; border-style: solid; border-top: 1px solid #D0D9EA; border-width: 1px 1px 1px 3px; box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana; font-size: 13px; line-height: 22px; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: #800180;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #134f5c;&quot;&gt;tkinter&lt;/span&gt; &lt;span style=&quot;color: #800180;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #134f5c;&quot;&gt;*&lt;/span&gt;  

TkFrm = &lt;span style=&quot;color: #0b5394;&quot;&gt;Tk&lt;/span&gt;()
TkFrm.&lt;span style=&quot;color: #783f04;&quot;&gt;geometry&lt;/span&gt;(&#39;&lt;span style=&quot;color: #990000;&quot;&gt;290x200+500+300&lt;/span&gt;&#39;)
TkFrm.&lt;span style=&quot;color: #783f04;&quot;&gt;title&lt;/span&gt;(&#39;&lt;span style=&quot;color: #990000;&quot;&gt;Entry Box or Text Box Border Setting in Tkinter&lt;/span&gt;&#39;)

&lt;span style=&quot;color: #38761d;&quot;&gt;#Tkinter Widgets Border Setting&lt;/span&gt;
MyEntryBox1 = &lt;span style=&quot;color: #0b5394;&quot;&gt;Entry&lt;/span&gt;(TkFrm,  &lt;span style=&quot;color: #2b00fe;&quot;&gt;relief&lt;/span&gt;=&#39;&lt;span style=&quot;color: #990000;&quot;&gt;raised&lt;/span&gt;&#39;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;highlightthickness&lt;/span&gt;=&lt;span style=&quot;color: #274e13;&quot;&gt;1&lt;/span&gt;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;borderwidth&lt;/span&gt;=&lt;span style=&quot;color: #274e13;&quot;&gt;2&lt;/span&gt;)
MyEntryBox1.&lt;span style=&quot;color: #783f04;&quot;&gt;pack&lt;/span&gt;()
MyEntryBox1.&lt;span style=&quot;color: #783f04;&quot;&gt;insert&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;END&lt;/span&gt;, &#39;&lt;span style=&quot;color: #990000;&quot;&gt;SKOTechLearn&lt;/span&gt;&#39;)

&lt;span style=&quot;color: #38761d;&quot;&gt;#Tkinter Widgets Border Style&lt;/span&gt;
MyTxtBox = &lt;span style=&quot;color: #0b5394;&quot;&gt;Text&lt;/span&gt;(TkFrm, &lt;span style=&quot;color: #2b00fe;&quot;&gt;relief&lt;/span&gt;=&#39;&lt;span style=&quot;color: #990000;&quot;&gt;sunken&lt;/span&gt;&#39;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;highlightthickness&lt;/span&gt;=&lt;span style=&quot;color: #274e13;&quot;&gt;1&lt;/span&gt;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;borderwidth&lt;/span&gt;=&lt;span style=&quot;color: #274e13;&quot;&gt;2&lt;/span&gt;)
MyTxtBox.&lt;span style=&quot;color: #783f04;&quot;&gt;pack&lt;/span&gt;()
MyTxtBox.&lt;span style=&quot;color: #783f04;&quot;&gt;insert&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;END&lt;/span&gt;, &#39;&lt;span style=&quot;color: #990000;&quot;&gt;SKOTechLearn&lt;/span&gt;&#39;)

TkFrm.&lt;span style=&quot;color: #783f04;&quot;&gt;mainloop&lt;/span&gt;()

&lt;/pre&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;b&gt;Output:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVfGppjTrxzmnsezlhV7TMGafzn73-8pYWUnV70b1yfFCOon9bnZDG0HPJ4VWpGw9ZaFRYUbIdSr1COhA9r9gqN9s8TjwWeNrQFX4vlWCccHCgCm3EvvGRSF321nykabzoQAl2xD0jX16q/s303/Entry_Or_text_Widget_Border_Style_in_Tkinter.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Tkinter Entry Border Style&quot; border=&quot;0&quot; data-original-height=&quot;295&quot; data-original-width=&quot;303&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVfGppjTrxzmnsezlhV7TMGafzn73-8pYWUnV70b1yfFCOon9bnZDG0HPJ4VWpGw9ZaFRYUbIdSr1COhA9r9gqN9s8TjwWeNrQFX4vlWCccHCgCm3EvvGRSF321nykabzoQAl2xD0jX16q/s16000/Entry_Or_text_Widget_Border_Style_in_Tkinter.jpg&quot; title=&quot;Tkinter Text Border Style&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;So, this way you can change &lt;b&gt;Enty Widget Style in Tkinter&lt;/b&gt; or &lt;b&gt;Text Widget Style in Tkinter&lt;/b&gt;.</description><link>https://www.skotechlearn.com/2021/07/entry-or-text-widget-style-in-tkinter.html</link><author>noreply@blogger.com (SKOTechLearn)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisD2lwva2_5o1B49w6rLQEkwpeHEjte3IzG9VUeYGst1isOBxTopU1ehF0eTP3MR54BIHZRIaiVk1wAGxaMl55pT8ObKt0jkMMAKxt_L9tCeAXlCNKFYGcG4QbmQj6DxwjXF8bn3vsECXp/s72-c/Entry_Or_text_Widget_Style_in_Tkinter.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2258844867892945003.post-2925665341631460275</guid><pubDate>Mon, 05 Jul 2021 07:19:00 +0000</pubDate><atom:updated>2022-06-21T14:13:54.204-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Python</category><title>PySide Center Screen and Window State Maximized in PySide</title><description>As you know PySide provide stylish GUI comparing Tkinter and feature rich QT base application. So first, here we learn how to set &lt;b&gt;Center Screen window in Pyside in Python&lt;/b&gt;? And also we learn &lt;b&gt;Window State Maximize in Pyside in Python&lt;/b&gt;. Here we also include how to &lt;b&gt;Set window title in PySide&lt;/b&gt;?&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;
  
  Let’s find it in following points:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;b&gt;
&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Set window Size in PySide6 and Set Window Location in PySide6&lt;/li&gt;
&lt;/b&gt;  &lt;b&gt;
&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Python Center Screen Window in PySide6&lt;/li&gt;
 &lt;/b&gt;  &lt;b&gt;
&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Set Window State Maximized in PySide6&lt;/li&gt;
 &lt;/b&gt;  &lt;b&gt;
&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Set Window Title in PySide6&lt;/li&gt;
&lt;/b&gt; &lt;/ol&gt;

&lt;br /&gt;
&lt;br /&gt;

&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGQKVNx9dkMRte-PBg9_zNX97GJTkFi2YSDo8LiaHFppGfSigS7mFLqoqim8-j-_R1yWKm6z10XYhh8f4yOiXddsMkiAOZx20H0aC8Ph0yR8r34J39mgwBJY-YI0Qofrx7xXiLLxQcEwsl/s1265/PySIde_Window+State+and+Center+Screen+in+Python.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Window State Maximize in PySide&quot; border=&quot;0&quot; data-original-height=&quot;653&quot; data-original-width=&quot;1265&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGQKVNx9dkMRte-PBg9_zNX97GJTkFi2YSDo8LiaHFppGfSigS7mFLqoqim8-j-_R1yWKm6z10XYhh8f4yOiXddsMkiAOZx20H0aC8Ph0yR8r34J39mgwBJY-YI0Qofrx7xXiLLxQcEwsl/s16000/PySIde_Window+State+and+Center+Screen+in+Python.jpg&quot; title=&quot;Center Screen Window in PySide&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;u&gt;&lt;a href=&quot;https://www.skotechlearn.com/2020/06/tkinter-window-position-size-center-screen-in-python.html&quot; target=&quot;_blank&quot;&gt;How to Set Center Screen in Tkinter and Set window size in Tkinter?&lt;/a&gt;&lt;/u&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 17px;&quot;&gt;&lt;b&gt;(1). Set Window Size in PySide6 and Set Window Location in Pyside6 :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;
Suppose, you want to create a Form using PySide and want to display at run time with specific size with specific location on screen. Then here PySide provide ‘&lt;b&gt;setGeometry&lt;/b&gt;’ or ‘&lt;b&gt;move&lt;/b&gt;’ and ‘&lt;b&gt;resize&lt;/b&gt;’ function. The syntax is used in following way:&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

&lt;br /&gt;
&lt;div style=&quot;background: rgb(239, 242, 251); border-radius: 4px; border: 1px solid rgb(250, 250, 250); color: #2f0b3a; padding: 2px 4px; width: 200px;&quot;&gt;&lt;b&gt; ‘setGeometry’  Syntax:&lt;/b&gt;&lt;/div&gt;
&lt;pre&gt;MainForm.&lt;span style=&quot;color: #783f04;&quot;&gt;setGeometry&lt;/span&gt;(&lt;span style=&quot;color: #274e13;&quot;&gt;Form_Left&lt;/span&gt;, &lt;span style=&quot;color: #274e13;&quot;&gt;Form_Top&lt;/span&gt;, &lt;span style=&quot;color: #274e13;&quot;&gt;Form_Width&lt;/span&gt;, &lt;span style=&quot;color: #274e13;&quot;&gt;Form_Height&lt;/span&gt;)
&lt;/pre&gt;
&lt;br /&gt;&lt;div style=&quot;background: rgb(239, 242, 251); border-radius: 4px; color: #2f0b3a; padding: 2px 4px; width: 100px;&quot;&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;/div&gt;
&lt;pre&gt;&lt;span style=&quot;color: #800180;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #0b5394;&quot;&gt;PySide6.QtWidgets&lt;/span&gt; &lt;span style=&quot;color: #800180;&quot;&gt;import&lt;/span&gt; QMainWindow, QApplication

SKapp = &lt;span style=&quot;color: #2b00fe;&quot;&gt;QApplication&lt;/span&gt;()
MyPyForm = &lt;span style=&quot;color: #2b00fe;&quot;&gt;QMainWindow&lt;/span&gt;()

&lt;span style=&quot;color: #38761d;&quot;&gt;#Set Form&#39;s Location and Size&lt;/span&gt;
MyPyForm.&lt;span style=&quot;color: #783f04;&quot;&gt;setGeometry&lt;/span&gt;(&lt;span style=&quot;color: #274e13;&quot;&gt;150&lt;/span&gt;, &lt;span style=&quot;color: #274e13;&quot;&gt;100&lt;/span&gt;, &lt;span style=&quot;color: #274e13;&quot;&gt;330&lt;/span&gt;, &lt;span style=&quot;color: #274e13;&quot;&gt;250&lt;/span&gt;)

MyPyForm.&lt;span style=&quot;color: #783f04;&quot;&gt;show&lt;/span&gt;()

SKapp.&lt;span style=&quot;color: #783f04;&quot;&gt;exec&lt;/span&gt;()

&lt;/pre&gt;
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background: rgb(239, 242, 251); border-radius: 4px; border: 1px solid rgb(250, 250, 250); color: #2f0b3a; padding: 2px 4px; width: 200px;&quot;&gt;&lt;b&gt; ‘move’ Syntax:&lt;/b&gt;&lt;/div&gt;
&lt;pre&gt;MainForm.&lt;span style=&quot;color: #783f04;&quot;&gt;move&lt;/span&gt;(&lt;span style=&quot;color: #274e13;&quot;&gt;Left_Location&lt;/span&gt;, &lt;span style=&quot;color: #274e13;&quot;&gt;Top_Location&lt;/span&gt;)
&lt;/pre&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div style=&quot;background: rgb(239, 242, 251); border-radius: 4px; border: 1px solid rgb(250, 250, 250); color: #2f0b3a; padding: 2px 4px; width: 200px;&quot;&gt;&lt;b&gt; ‘resize’ Syntax:&lt;/b&gt;&lt;/div&gt;
&lt;pre&gt;MainForm.&lt;span style=&quot;color: #783f04;&quot;&gt;resize&lt;/span&gt;(&lt;span style=&quot;color: #274e13;&quot;&gt;Form_Width&lt;/span&gt;, &lt;span style=&quot;color: #274e13;&quot;&gt;Form_Height&lt;/span&gt;)
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we are using both function in given example:
&lt;br /&gt;
&lt;pre&gt;&lt;span style=&quot;color: #800180;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #0b5394;&quot;&gt;PySide6.QtWidgets&lt;/span&gt; &lt;span style=&quot;color: #800180;&quot;&gt;import&lt;/span&gt; QMainWindow, QApplication

SKapp = &lt;span style=&quot;color: #2b00fe;&quot;&gt;QApplication&lt;/span&gt;()
MyPyForm = &lt;span style=&quot;color: #2b00fe;&quot;&gt;QMainWindow&lt;/span&gt;()

&lt;span style=&quot;color: #38761d;&quot;&gt;#Set Location of Form in PySide&lt;/span&gt;
MyPyForm.&lt;span style=&quot;color: #783f04;&quot;&gt;move&lt;/span&gt;(&lt;span style=&quot;color: #274e13;&quot;&gt;150&lt;/span&gt;, &lt;span style=&quot;color: #274e13;&quot;&gt;100&lt;/span&gt;)
&lt;span style=&quot;color: #38761d;&quot;&gt;#Set Form Size in PySide&lt;/span&gt;
MyPyForm.&lt;span style=&quot;color: #783f04;&quot;&gt;resize&lt;/span&gt;(&lt;span style=&quot;color: #274e13;&quot;&gt;330&lt;/span&gt;, &lt;span style=&quot;color: #274e13;&quot;&gt;250&lt;/span&gt;)

MyPyForm.&lt;span style=&quot;color: #783f04;&quot;&gt;show&lt;/span&gt;()

SKapp.&lt;span style=&quot;color: #783f04;&quot;&gt;exec&lt;/span&gt;()

&lt;/pre&gt;
&lt;br /&gt;
Now, you will get same output when run application like bellow:&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5v8lWcEyS8g963VxAqYFZy_LCmwWpoqu9yMTYAWyUCZDCaWcAPRJPaMg5mtBzhTKt-td363LdWTCtNhciVRvGqR3jWk6c_HUf8EZi2yJWTzai41EeWXYKHU3JNXiEn9Zyd1TGvqdUKqcZ/s1022/1_PySide_Window_Size_and_Location.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Set Window Size and Location in Pyside&quot; border=&quot;0&quot; data-original-height=&quot;552&quot; data-original-width=&quot;1022&quot; height=&quot;346&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5v8lWcEyS8g963VxAqYFZy_LCmwWpoqu9yMTYAWyUCZDCaWcAPRJPaMg5mtBzhTKt-td363LdWTCtNhciVRvGqR3jWk6c_HUf8EZi2yJWTzai41EeWXYKHU3JNXiEn9Zyd1TGvqdUKqcZ/w640-h346/1_PySide_Window_Size_and_Location.jpg&quot; title=&quot;Pyside SetGeometry in Python&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 17px;&quot;&gt;&lt;b&gt;(2). Python Center Screen Window in PySide6 :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;
In this point, we learn how to set start position for form in center screen. For center screen form in Pyside we have to import following:
&lt;br /&gt;
&lt;pre&gt;&lt;span style=&quot;color: #800180;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #0b5394;&quot;&gt;PySide6.QtGui&lt;/span&gt; &lt;span style=&quot;color: #800180;&quot;&gt;import&lt;/span&gt; QScreen
&lt;/pre&gt;
&lt;br /&gt;

Here are following two ways from which you can set Center Screen in Python.

&lt;br /&gt;
&lt;br /&gt;&lt;i style=&quot;background-color: #fff2cc;&quot;&gt;&lt;span style=&quot;color: #800180; font-size: large;&quot;&gt;&lt;b&gt;
Note:&lt;/b&gt; Remember one thing before positioning form in center screen, you have to first define the form or dialog size then write center screen code.&lt;/span&gt;&lt;/i&gt;
&lt;br /&gt;
&lt;br /&gt;
First we use ‘&lt;b&gt;QScreen.availableGeometry(QApplication.primaryScreen())&lt;/b&gt;’. This will show screen available geometry.
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background: rgb(239, 242, 251); border-radius: 4px; border: 1px solid rgb(250, 250, 250); color: #2f0b3a; padding: 2px 4px; width: 300px;&quot;&gt;&lt;b&gt; PySide Center Screen Example 1:&lt;/b&gt;&lt;/div&gt;
&lt;pre&gt;&lt;span style=&quot;color: #800180;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #0b5394;&quot;&gt;PySide6.QtWidgets&lt;/span&gt; &lt;span style=&quot;color: #800180;&quot;&gt;import&lt;/span&gt; QMainWindow, QApplication
&lt;span style=&quot;color: #800180;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #0b5394;&quot;&gt;PySide6.QtGui&lt;/span&gt; &lt;span style=&quot;color: #800180;&quot;&gt;import&lt;/span&gt; QScreen

SKapp = &lt;span style=&quot;color: #2b00fe;&quot;&gt;QApplication&lt;/span&gt;()
MyPyForm = &lt;span style=&quot;color: #2b00fe;&quot;&gt;QMainWindow&lt;/span&gt;()

&lt;span style=&quot;color: #38761d;&quot;&gt;#Set Form Size&lt;/span&gt;
MyPyForm.&lt;span style=&quot;color: #783f04;&quot;&gt;resize&lt;/span&gt;(&lt;span style=&quot;color: #274e13;&quot;&gt;330&lt;/span&gt;, &lt;span style=&quot;color: #274e13;&quot;&gt;250&lt;/span&gt;)

&lt;span style=&quot;color: #38761d;&quot;&gt;#Get Screen geometry&lt;/span&gt;
SrcSize = QScreen.&lt;span style=&quot;color: #783f04;&quot;&gt;availableGeometry&lt;/span&gt;(QApplication.&lt;span style=&quot;color: #783f04;&quot;&gt;primaryScreen&lt;/span&gt;())
&lt;span style=&quot;color: #38761d;&quot;&gt;#Set X Position Center&lt;/span&gt;
frmX = (&lt;span style=&quot;color: #134f5c;&quot;&gt;SrcSize&lt;/span&gt;.&lt;span style=&quot;color: #783f04;&quot;&gt;width&lt;/span&gt;() - &lt;span style=&quot;color: #134f5c;&quot;&gt;MyPyForm&lt;/span&gt;.&lt;span style=&quot;color: #783f04;&quot;&gt;width&lt;/span&gt;())/2
&lt;span style=&quot;color: #38761d;&quot;&gt;#Set Y Position Center&lt;/span&gt;
frmY = (&lt;span style=&quot;color: #134f5c;&quot;&gt;SrcSize&lt;/span&gt;.&lt;span style=&quot;color: #783f04;&quot;&gt;height&lt;/span&gt;() - &lt;span style=&quot;color: #134f5c;&quot;&gt;MyPyForm&lt;/span&gt;.&lt;span style=&quot;color: #783f04;&quot;&gt;height&lt;/span&gt;())/2
&lt;span style=&quot;color: #38761d;&quot;&gt;#Set Form&#39;s Center Location&lt;/span&gt;
MyPyForm.&lt;span style=&quot;color: #783f04;&quot;&gt;move&lt;/span&gt;(&lt;span style=&quot;color: #274e13;&quot;&gt;frmX&lt;/span&gt;, &lt;span style=&quot;color: #274e13;&quot;&gt;frmY&lt;/span&gt;)

MyPyForm.&lt;span style=&quot;color: #783f04;&quot;&gt;show&lt;/span&gt;()

SKapp.&lt;span style=&quot;color: #783f04;&quot;&gt;exec&lt;/span&gt;()

&lt;/pre&gt;
&lt;br /&gt;


&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;u&gt;&lt;a href=&quot;https://www.skotechlearn.com/2020/08/get-tkinter-entry-or-text-value-in-python.html&quot; target=&quot;_blank&quot;&gt;Pass Value from Text To Label in Tkinter.&lt;/a&gt;&lt;/u&gt;&lt;/span&gt;&lt;/b&gt;&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background: rgb(239, 242, 251); border-radius: 4px; border: 1px solid rgb(250, 250, 250); color: #2f0b3a; padding: 2px 4px; width: 300px;&quot;&gt;&lt;b&gt; Pyside Center Screen Example 2:&lt;/b&gt;&lt;/div&gt;
&lt;pre&gt;&lt;span style=&quot;color: #800180;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #0b5394;&quot;&gt;PySide6.QtWidgets&lt;/span&gt; &lt;span style=&quot;color: #800180;&quot;&gt;import&lt;/span&gt; QMainWindow, QApplication
&lt;span style=&quot;color: #800180;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #0b5394;&quot;&gt;PySide6.QtGui&lt;/span&gt; &lt;span style=&quot;color: #800180;&quot;&gt;import&lt;/span&gt; QScreen

SKapp = &lt;span style=&quot;color: #2b00fe;&quot;&gt;QApplication&lt;/span&gt;()
MyPyForm = &lt;span style=&quot;color: #2b00fe;&quot;&gt;QMainWindow&lt;/span&gt;()

&lt;span style=&quot;color: #38761d;&quot;&gt;#Set Form&#39;s Location and Size&lt;/span&gt;
MyPyForm.&lt;span style=&quot;color: #783f04;&quot;&gt;resize&lt;/span&gt;(&lt;span style=&quot;color: #274e13;&quot;&gt;330&lt;/span&gt;, &lt;span style=&quot;color: #274e13;&quot;&gt;250&lt;/span&gt;)

&lt;span style=&quot;color: #38761d;&quot;&gt;#Get Screen Center Position&lt;/span&gt;
Fmcenter = QScreen.&lt;span style=&quot;color: #783f04;&quot;&gt;availableGeometry&lt;/span&gt;(QApplication.&lt;span style=&quot;color: #783f04;&quot;&gt;primaryScreen&lt;/span&gt;()).&lt;span style=&quot;color: #783f04;&quot;&gt;center&lt;/span&gt;()
Fmscr = MyPyForm.&lt;span style=&quot;color: #783f04;&quot;&gt;frameGeometry&lt;/span&gt;()

&lt;span style=&quot;color: #38761d;&quot;&gt;#Set Form in Center Position&lt;/span&gt;
Fmscr.&lt;span style=&quot;color: #783f04;&quot;&gt;moveCenter&lt;/span&gt;(&lt;span style=&quot;color: #134f5c;&quot;&gt;Fmcenter&lt;/span&gt;)

MyPyForm.&lt;span style=&quot;color: #783f04;&quot;&gt;show&lt;/span&gt;()

SKapp.&lt;span style=&quot;color: #783f04;&quot;&gt;exec&lt;/span&gt;()

&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Both codes will show same output:
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAa-R7J6DFnLqH5urf4xqzKcTrwIsfTdFYl1rnPNcP-DAWqz-XvyUh_3aAPeR8uagiym0XQjPmL9U6oPPLOJXINl57xs7mMqHpUxv6VI6HTwtB-OrXLN7m4EoUKvbvdyfskWGdJ3EwVekN/s780/2_PySide_Center_Sceen_Form.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Pyside Center Screen Window&quot; border=&quot;0&quot; data-original-height=&quot;489&quot; data-original-width=&quot;780&quot; height=&quot;402&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAa-R7J6DFnLqH5urf4xqzKcTrwIsfTdFYl1rnPNcP-DAWqz-XvyUh_3aAPeR8uagiym0XQjPmL9U6oPPLOJXINl57xs7mMqHpUxv6VI6HTwtB-OrXLN7m4EoUKvbvdyfskWGdJ3EwVekN/w640-h402/2_PySide_Center_Sceen_Form.jpg&quot; title=&quot;PySide6 Center Screen Form&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 17px;&quot;&gt;&lt;b&gt;(3). Set Window State Maximized in Pyside6 :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;Here SKOTechLearn describe two way to set window state maximized in PySide, and both will show same output as described bellow:
&lt;br /&gt;
&lt;br /&gt; 
&lt;div style=&quot;background: rgb(239, 242, 251); border-radius: 4px; border: 1px solid rgb(250, 250, 250); color: #2f0b3a; padding: 2px 4px; width: 350px;&quot;&gt;&lt;b&gt; PySide6 Maximized Form Example 1:&lt;/b&gt;&lt;/div&gt;&lt;br /&gt; 
&lt;pre&gt;&lt;span style=&quot;color: #800180;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #0b5394;&quot;&gt;PySide6.QtWidgets&lt;/span&gt; &lt;span style=&quot;color: #800180;&quot;&gt;import&lt;/span&gt; QMainWindow, QApplication
&lt;span style=&quot;color: #800180;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #0b5394;&quot;&gt;PySide6.QtGui&lt;/span&gt; &lt;span style=&quot;color: #800180;&quot;&gt;import&lt;/span&gt; QScreen

SKapp = &lt;span style=&quot;color: #2b00fe;&quot;&gt;QApplication&lt;/span&gt;()
MyPyForm = &lt;span style=&quot;color: #2b00fe;&quot;&gt;QMainWindow&lt;/span&gt;()

&lt;span style=&quot;color: #38761d;&quot;&gt;#Set Form&#39;s Location and Size&lt;/span&gt;
MyPyForm.&lt;span style=&quot;color: #783f04;&quot;&gt;resize&lt;/span&gt;(&lt;span style=&quot;color: #0c343d;&quot;&gt;330&lt;/span&gt;, &lt;span style=&quot;color: #0c343d;&quot;&gt;250&lt;/span&gt;)

SrcSize = QScreen.&lt;span style=&quot;color: #783f04;&quot;&gt;availableGeometry&lt;/span&gt;(QApplication.&lt;span style=&quot;color: #783f04;&quot;&gt;primaryScreen&lt;/span&gt;())

&lt;span style=&quot;color: #38761d;&quot;&gt;#Get Screen Width&lt;/span&gt;
frmX=SrcSize.&lt;span style=&quot;color: #783f04;&quot;&gt;width&lt;/span&gt;()

&lt;span style=&quot;color: #38761d;&quot;&gt;#Get Screen Height&lt;/span&gt;
frmY=SrcSize.&lt;span style=&quot;color: #783f04;&quot;&gt;height&lt;/span&gt;()

&lt;span style=&quot;color: #38761d;&quot;&gt;#Pyside Window State maximized&lt;/span&gt;
MyPyForm.&lt;span style=&quot;color: #783f04;&quot;&gt;setGeometry&lt;/span&gt;(&lt;span style=&quot;color: #0c343d;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #0c343d;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #0c343d;&quot;&gt;frmX&lt;/span&gt;, &lt;span style=&quot;color: #0c343d;&quot;&gt;frmY&lt;/span&gt;)

MyPyForm.&lt;span style=&quot;color: #783f04;&quot;&gt;show&lt;/span&gt;()

SKapp.&lt;span style=&quot;color: #783f04;&quot;&gt;exec&lt;/span&gt;()

&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt; 
&lt;div style=&quot;background: rgb(239, 242, 251); border-radius: 4px; border: 1px solid rgb(250, 250, 250); color: #2f0b3a; padding: 2px 4px; width: 350px;&quot;&gt;&lt;b&gt; PySide6 Maximize Form Example 2:&lt;/b&gt;&lt;/div&gt;&lt;br /&gt; 
&lt;pre&gt;&lt;span style=&quot;color: #800180;&quot;&gt;import&lt;/span&gt; sys
&lt;span style=&quot;color: #800180;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #0b5394;&quot;&gt;PySide6.QtWidgets&lt;/span&gt; &lt;span style=&quot;color: #800180;&quot;&gt;import&lt;/span&gt; QMainWindow, QApplication
&lt;span style=&quot;color: #800180;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #0b5394;&quot;&gt;PySide6.QtGui&lt;/span&gt; &lt;span style=&quot;color: #800180;&quot;&gt;import&lt;/span&gt; QScreen

&lt;span style=&quot;color: #2b00fe;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #0b5394;&quot;&gt;App&lt;/span&gt;(&lt;span style=&quot;color: #134f5c;&quot;&gt;QMainWindow&lt;/span&gt;):

    &lt;span style=&quot;color: #2b00fe;&quot;&gt;def &lt;/span&gt;&lt;span style=&quot;color: #783f04;&quot;&gt;__init__&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;self&lt;/span&gt;):
        &lt;span style=&quot;color: #0b5394;&quot;&gt;super&lt;/span&gt;().&lt;span style=&quot;color: #783f04;&quot;&gt;__init__&lt;/span&gt;()
        &lt;span style=&quot;color: #2b00fe;&quot;&gt;self&lt;/span&gt;.&lt;span style=&quot;color: #783f04;&quot;&gt;title&lt;/span&gt; = &#39;&lt;span style=&quot;color: #990000;&quot;&gt;PySide6 Maximize Window State&lt;/span&gt;&#39;
        
        &lt;span style=&quot;color: #38761d;&quot;&gt;#Pyside6 Maximize Form&lt;/span&gt;
        MyScn = &lt;span style=&quot;color: #134f5c;&quot;&gt;QScreen&lt;/span&gt;
        &lt;span style=&quot;color: #2b00fe;&quot;&gt;self&lt;/span&gt;.&lt;span style=&quot;color: #783f04;&quot;&gt;setGeometry&lt;/span&gt;(&lt;span style=&quot;color: #0c343d;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #0c343d;&quot;&gt;0&lt;/span&gt;, MyScn.&lt;span style=&quot;color: #783f04;&quot;&gt;availableGeometry&lt;/span&gt;(QApplication.&lt;span style=&quot;color: #783f04;&quot;&gt;primaryScreen&lt;/span&gt;()).&lt;span style=&quot;color: #783f04;&quot;&gt;width&lt;/span&gt;(), MyScn.&lt;span style=&quot;color: #783f04;&quot;&gt;availableGeometry&lt;/span&gt;(QApplication.&lt;span style=&quot;color: #783f04;&quot;&gt;primaryScreen&lt;/span&gt;()).&lt;span style=&quot;color: #783f04;&quot;&gt;height&lt;/span&gt;())  
    
        &lt;span style=&quot;color: #2b00fe;&quot;&gt;self&lt;/span&gt;.&lt;span style=&quot;color: #783f04;&quot;&gt;show&lt;/span&gt;()    
    
&lt;span style=&quot;color: #800180;&quot;&gt;if &lt;/span&gt;__name__ == &#39;&lt;span style=&quot;color: #990000;&quot;&gt;__main__&lt;/span&gt;&#39;:
    app = QApplication(&lt;span style=&quot;color: #0b5394;&quot;&gt;sys&lt;/span&gt;.&lt;span style=&quot;color: #2b00fe;&quot;&gt;argv&lt;/span&gt;)
    ex = &lt;span style=&quot;color: #073763;&quot;&gt;App&lt;/span&gt;()
    &lt;span style=&quot;color: #073763;&quot;&gt;sys&lt;/span&gt;.&lt;span style=&quot;color: #783f04;&quot;&gt;exit&lt;/span&gt;(app.exec())

&lt;/pre&gt;
&lt;br /&gt;
You will get maximized form:
&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUyFWBya3zehsJrfevQcf0RRfv5DflyiMlbYeNOrqG2pM7R_aiehGVGvPW9eLZQVXb9Q-FiafVE3UaY1pz6S5domavrcD0Pjn77Tbaa20HyNEawF9fr_VAxv5JbJKUdGv4iyGzWcTc8och/s716/3_PySide_Maximize_window_State.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;PySide Maximize Window State&quot; border=&quot;0&quot; data-original-height=&quot;464&quot; data-original-width=&quot;716&quot; height=&quot;414&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUyFWBya3zehsJrfevQcf0RRfv5DflyiMlbYeNOrqG2pM7R_aiehGVGvPW9eLZQVXb9Q-FiafVE3UaY1pz6S5domavrcD0Pjn77Tbaa20HyNEawF9fr_VAxv5JbJKUdGv4iyGzWcTc8och/w640-h414/3_PySide_Maximize_window_State.jpg&quot; title=&quot;Set Window State Maximize in PySide&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 17px;&quot;&gt;&lt;b&gt;(4). Set Window Title in PySide6 :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;
The simple way to set window title or form title in PySide using ‘&lt;b&gt;setWindowTitle&lt;/b&gt;’. Her we use it with two way at design time and change &lt;b&gt;Form title in PySide&lt;/b&gt; at run time.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b style=&quot;background-color: #990000;&quot;&gt;&lt;span style=&quot;color: #fff2cc; font-size: medium;&quot;&gt;(i). Set Window Title at design time :&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;pre&gt;&lt;span style=&quot;color: #800180;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #0b5394;&quot;&gt;sys&lt;/span&gt;
&lt;span style=&quot;color: #800180;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #0b5394;&quot;&gt;PySide6.QtWidgets&lt;/span&gt; &lt;span style=&quot;color: #800180;&quot;&gt;import&lt;/span&gt; QApplication, QMainWindow

app = &lt;span style=&quot;color: #2b00fe;&quot;&gt;QApplication&lt;/span&gt;(&lt;span style=&quot;color: #0b5394;&quot;&gt;sys&lt;/span&gt;.&lt;span style=&quot;color: #783f04;&quot;&gt;argv&lt;/span&gt;)
mainwindow = &lt;span style=&quot;color: #2b00fe;&quot;&gt;QMainWindow&lt;/span&gt;()

mainwindow.&lt;span style=&quot;color: #783f04;&quot;&gt;setGeometry&lt;/span&gt;(&lt;span style=&quot;color: #134f5c;&quot;&gt;300&lt;/span&gt;, &lt;span style=&quot;color: #134f5c;&quot;&gt;300&lt;/span&gt;, &lt;span style=&quot;color: #134f5c;&quot;&gt;300&lt;/span&gt;, &lt;span style=&quot;color: #134f5c;&quot;&gt;150&lt;/span&gt;)

&lt;span style=&quot;color: #38761d;&quot;&gt;#Set Window Title in PySide&lt;/span&gt;
mainwindow.&lt;span style=&quot;color: #783f04;&quot;&gt;setWindowTitle&lt;/span&gt;(&#39;&lt;span style=&quot;color: #990000;&quot;&gt;PySide Set Window Title&lt;/span&gt;&#39;)

mainwindow.&lt;span style=&quot;color: #783f04;&quot;&gt;show&lt;/span&gt;()

app.&lt;span style=&quot;color: #783f04;&quot;&gt;exec&lt;/span&gt;()   

&lt;/pre&gt;
&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #990000; color: #fff2cc; font-size: medium;&quot;&gt;&lt;b&gt;(ii). Set Window Title at run time :&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;Here we use ‘&lt;b&gt;QPushButton&lt;/b&gt;’ to change Title at run time when we click on button.
&lt;br /&gt;
&lt;pre&gt;&lt;span style=&quot;color: #800180;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #0b5394;&quot;&gt;sys&lt;/span&gt;
&lt;span style=&quot;color: #800180;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #0b5394;&quot;&gt;PySide6.QtWidgets&lt;/span&gt; &lt;span style=&quot;color: #800180;&quot;&gt;import&lt;/span&gt; QMainWindow, QPushButton, QApplication

&lt;span style=&quot;color: #2b00fe;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #0b5394;&quot;&gt;MyTitle&lt;/span&gt;(&lt;span style=&quot;color: #134f5c;&quot;&gt;QMainWindow&lt;/span&gt;):
    
    &lt;span style=&quot;color: #2b00fe;&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: #783f04;&quot;&gt; __init__&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;self&lt;/span&gt;):
        &lt;span style=&quot;color: #2b00fe;&quot;&gt;super&lt;/span&gt;().&lt;span style=&quot;color: #783f04;&quot;&gt;__init__&lt;/span&gt;()
        
        &lt;span style=&quot;color: #2b00fe;&quot;&gt;self&lt;/span&gt;.&lt;span style=&quot;color: #783f04;&quot;&gt;initUI&lt;/span&gt;()
        
    &lt;span style=&quot;color: #2b00fe;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;color: #783f04;&quot;&gt;initUI&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;self&lt;/span&gt;):      

        Pysbtn = &lt;span style=&quot;color: #134f5c;&quot;&gt;QPushButton&lt;/span&gt;(&#39;&lt;span style=&quot;color: #990000;&quot;&gt;Show title&lt;/span&gt;&#39;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;self&lt;/span&gt;)
        Pysbtn.&lt;span style=&quot;color: #783f04;&quot;&gt;move&lt;/span&gt;(&lt;span style=&quot;color: #0c343d;&quot;&gt;70&lt;/span&gt;, &lt;span style=&quot;color: #0c343d;&quot;&gt;40&lt;/span&gt;)
        
        &lt;span style=&quot;color: #38761d;&quot;&gt;#Call Click Event which is defined bellow&lt;/span&gt;
        Pysbtn.clicked.&lt;span style=&quot;color: #783f04;&quot;&gt;connect&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;self&lt;/span&gt;.&lt;span style=&quot;color: #783f04;&quot;&gt;ClickToChangeTitle&lt;/span&gt;)
        
        &lt;span style=&quot;color: #2b00fe;&quot;&gt;self&lt;/span&gt;.&lt;span style=&quot;color: #783f04;&quot;&gt;setGeometry&lt;/span&gt;(&lt;span style=&quot;color: #0c343d;&quot;&gt;300&lt;/span&gt;, &lt;span style=&quot;color: #0c343d;&quot;&gt;300&lt;/span&gt;, &lt;span style=&quot;color: #0c343d;&quot;&gt;300&lt;/span&gt;, &lt;span style=&quot;color: #0c343d;&quot;&gt;150&lt;/span&gt;)
        &lt;span style=&quot;color: #2b00fe;&quot;&gt;self&lt;/span&gt;.&lt;span style=&quot;color: #783f04;&quot;&gt;show&lt;/span&gt;()


    &lt;span style=&quot;color: #38761d;&quot;&gt;#QPushButton Click Event in PySide&lt;/span&gt;    
    &lt;span style=&quot;color: #2b00fe;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;color: #783f04;&quot;&gt;ClickToChangeTitle&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;self&lt;/span&gt;):
            &lt;span style=&quot;color: #2b00fe;&quot;&gt;self&lt;/span&gt;.&lt;span style=&quot;color: #783f04;&quot;&gt;setWindowTitle&lt;/span&gt;(&#39;&lt;span style=&quot;color: #990000;&quot;&gt;Click to Change Title in Pyside&lt;/span&gt;&#39;)
        
&lt;span style=&quot;color: #800180;&quot;&gt;if &lt;/span&gt;__name__ == &#39;&lt;span style=&quot;color: #990000;&quot;&gt;__main__&lt;/span&gt;&#39;:  
    app = QApplication(&lt;span style=&quot;color: #0b5394;&quot;&gt;sys&lt;/span&gt;.&lt;span style=&quot;color: #2b00fe;&quot;&gt;argv&lt;/span&gt;)
    ex = MyTitle()
    &lt;span style=&quot;color: #0b5394;&quot;&gt;sys&lt;/span&gt;.&lt;span style=&quot;color: #783f04;&quot;&gt;exit&lt;/span&gt;(app.exec())

&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;

Output:&lt;/b&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhR5zt5OD3HuZbsdWRPebePhLMKlv7tNVKaXioz3QaL152hB_QmWHim-p0syl2mM1Gc3qN89vlJSzZTg5Fn50-CzPv2de_-mF7i8bQ9AmuPr43-3w8kL_8fuDwHHL9JznyrOGsANqrRY09y/s712/4_PySide_Set_Window_Title_By_Click.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Set Window Title in PySide&quot; border=&quot;0&quot; data-original-height=&quot;258&quot; data-original-width=&quot;712&quot; height=&quot;232&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhR5zt5OD3HuZbsdWRPebePhLMKlv7tNVKaXioz3QaL152hB_QmWHim-p0syl2mM1Gc3qN89vlJSzZTg5Fn50-CzPv2de_-mF7i8bQ9AmuPr43-3w8kL_8fuDwHHL9JznyrOGsANqrRY09y/w640-h232/4_PySide_Set_Window_Title_By_Click.jpg&quot; title=&quot;Set Dialog Title in PySide&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;

Set Window Title in Python 

&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;br /&gt;

Now here are some Pyside windows tips, this way you can easily &lt;b&gt;Maximized Window in PySide&lt;/b&gt; and Also Set &lt;b&gt;Center Screen Window in PySide&lt;/b&gt; in Python. And Also Set &lt;b&gt;Window Title or Form Title in PySide&lt;/b&gt;.
&lt;/div&gt;</description><link>https://www.skotechlearn.com/2021/07/pyside-center-screen-and-window-state.html</link><author>noreply@blogger.com (SKOTechLearn)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGQKVNx9dkMRte-PBg9_zNX97GJTkFi2YSDo8LiaHFppGfSigS7mFLqoqim8-j-_R1yWKm6z10XYhh8f4yOiXddsMkiAOZx20H0aC8Ph0yR8r34J39mgwBJY-YI0Qofrx7xXiLLxQcEwsl/s72-c/PySIde_Window+State+and+Center+Screen+in+Python.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2258844867892945003.post-3796866200255045434</guid><pubDate>Wed, 30 Jun 2021 07:33:00 +0000</pubDate><atom:updated>2022-06-24T14:45:32.296-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Python</category><title>Use ScrollBar in Tkinter and Set ScrollBar in TextBox in Tkinter</title><description>If we are creating a project and want to start programming in python using tkinter and want to use scrolling in many widgets like- TextBox, Listbox, TreeView etc. Then we will use &lt;b&gt;ScrollBar widget in Tkinter &lt;/b&gt;python.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Here we learn How to use&amp;nbsp;&lt;b&gt;ScrolledText in Tkinter&lt;/b&gt; or how can we &lt;b&gt;Set Scrollbar in Textbox in Python Tkinter&lt;/b&gt; or How to use &lt;b&gt;Tkinter ScrollBar in Python&lt;/b&gt;?&lt;div&gt;&amp;nbsp;
&lt;br /&gt;So, Lets learn Following Point wise steps.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;b&gt;
&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Learn about Tkinter ScrollBar in Python&lt;/li&gt;
&lt;/b&gt;  &lt;b&gt;
&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Change Tkinter ScrollBar Color and Style&lt;/li&gt;
 &lt;/b&gt;  &lt;b&gt;
&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;How to Set ScrollBar in Textbox in Python Tkinter&lt;/li&gt;
&lt;/b&gt; &lt;/ol&gt;

&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWNdYQN0qmO13cjjwi7RDDL9v_nRgntu6rzAQ8H4L14eVAElTlxoxITsxLon5odqeIMhylVKNUAxpiTK0GhfzsA-klxrSUEcQeKU57sbsxp6eaCJEYUf72JpVZ9DKbsC12-kAvhbUS1cAW/s225/0_Tkinter_ScrollBar_in_TextBox.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Tkinter ScrollBar in Python&quot; border=&quot;0&quot; data-original-height=&quot;225&quot; data-original-width=&quot;193&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWNdYQN0qmO13cjjwi7RDDL9v_nRgntu6rzAQ8H4L14eVAElTlxoxITsxLon5odqeIMhylVKNUAxpiTK0GhfzsA-klxrSUEcQeKU57sbsxp6eaCJEYUf72JpVZ9DKbsC12-kAvhbUS1cAW/s16000/0_Tkinter_ScrollBar_in_TextBox.jpg&quot; title=&quot;ScrollBar in Tkinter&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
When you are start programming in python, you will find very useful widget, as you know &lt;b&gt;Scrollbar Widget in tkinter&lt;/b&gt;, you can use it in many widgets.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 17px;&quot;&gt;&lt;b&gt;(1). Learn About Tkinter ScrollBar in Python :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;
In Python you can find that, you can use scrollbar in vertical and horizontal way.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

&lt;div style=&quot;background-color: maroon; border-radius: 3px; border: 1px solid rgb(178, 154, 148); color: yellow; float: left; font-size: 17px; line-height: 18px; padding: 1px 2px;&quot;&gt;&lt;b&gt;Vertical ScrollBar in Tkinter: &lt;/b&gt;&lt;/div&gt;&amp;nbsp;This will scroll the details or information of a widget from up to down. You can scroll down or return to scroll up for getting information given inside a widget.&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-IpGA7vjwPSY2UNOlo0RzD6eAaDF_vRSrP9oNokLw4CmuTnvGgGNj5ZQ3BKG6Oex2sJ6TlFzqZMbmlPfcxfeB2DpFxWITvq1Tj1EditiUhcj9f6IGx_XZlDofrWYjCls0AiojPLn4Lmgl/s130/Vertical_ScrollBar%252Cjpg.jpeg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Vertical ScrollBar in Python&quot; border=&quot;0&quot; data-original-height=&quot;130&quot; data-original-width=&quot;15&quot; height=&quot;200&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-IpGA7vjwPSY2UNOlo0RzD6eAaDF_vRSrP9oNokLw4CmuTnvGgGNj5ZQ3BKG6Oex2sJ6TlFzqZMbmlPfcxfeB2DpFxWITvq1Tj1EditiUhcj9f6IGx_XZlDofrWYjCls0AiojPLn4Lmgl/w23-h200/Vertical_ScrollBar%252Cjpg.jpeg&quot; title=&quot;Vertical ScrollBar in Tkinter&quot; width=&quot;23&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

&lt;br /&gt;
&lt;div style=&quot;background-color: maroon; border-radius: 3px; border: 1px solid rgb(178, 154, 148); color: yellow; float: left; font-size: 17px; line-height: 18px; padding: 1px 2px;&quot;&gt;&lt;b&gt;Horizontal ScrollBar in Tkinter: &lt;/b&gt;&lt;/div&gt;&amp;nbsp; This will scroll the details of information of a widget from left to right. You can scroll left or return to right to get information given inside that particular widget.
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOggDt6WxuGpFXEqca_07npalqgGYrHw_xn6l2TSBhK2ZPafPcui4F0aYwyJe3_X8j5tw8SnSDiee-G_nEdz5qpbktXEJ0q2SEbPZBZRhCtZ_xWEyCyvMxEvh9IGfxzMwo2llDQFc9luUg/s140/Horizontal_ScrollBar.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Horizontal ScrollBar in Tkinter&quot; border=&quot;0&quot; data-original-height=&quot;15&quot; data-original-width=&quot;140&quot; height=&quot;21&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOggDt6WxuGpFXEqca_07npalqgGYrHw_xn6l2TSBhK2ZPafPcui4F0aYwyJe3_X8j5tw8SnSDiee-G_nEdz5qpbktXEJ0q2SEbPZBZRhCtZ_xWEyCyvMxEvh9IGfxzMwo2llDQFc9luUg/w200-h21/Horizontal_ScrollBar.jpg&quot; title=&quot;Horizontal ScrollBar in Python&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;
&lt;br /&gt;

&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 17px;&quot;&gt;&lt;b&gt;(2). Change Tkinter ScrollBar Color and Style :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;
For styling scrollbar, we use “&lt;b&gt;ttk.Style ()&lt;/b&gt;”. Using &lt;b&gt;Style&lt;/b&gt; will change the Background, DarkColor, LightColor, ArrowColor, TroughColor etc. Example is given bellow:
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

&lt;div style=&quot;background-color: #eff8fb; border-radius: 3px; border: 1px solid rgb(88, 172, 250); font-size: 17px; line-height: 35px; padding: 1px 2px;&quot;&gt;&lt;i&gt;&lt;span style=&quot;color: #741b47;&quot;&gt;&lt;b&gt;Note: &lt;/b&gt;For using style, you have to use &lt;b&gt;ttk.Scrollbar&lt;/b&gt; in your application.&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Syntax:&lt;/b&gt;&lt;/div&gt;

&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow: scroll; padding-left: 10px; padding: 10px 6px 10px 10px; border-left: 3px solid #7E8BBB&quot;&gt;style = &lt;span style=&quot;color: #3d85c6;&quot;&gt;ttk.Style&lt;/span&gt;()
&lt;span style=&quot;color: #6aa84f;&quot;&gt;#Set Style&lt;/span&gt;
style.&lt;span style=&quot;color: #b45f06;&quot;&gt;configure&lt;/span&gt;(&#39;&lt;span style=&quot;color: #990000;&quot;&gt;SetStyleName&lt;/span&gt;&#39;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;background&lt;/span&gt;=&#39;&lt;span style=&quot;color: #990000;&quot;&gt;Set Color&lt;/span&gt;&#39;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;troughcolor&lt;/span&gt;=&#39;&lt;span style=&quot;color: #990000;&quot;&gt;Set Color&lt;/span&gt;&#39;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;arrowcolor&lt;/span&gt;=&#39;&lt;span style=&quot;color: #990000;&quot;&gt;Set Color&lt;/span&gt;&#39;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;highlightcolor&lt;/span&gt;=&#39;&lt;span style=&quot;color: #990000;&quot;&gt;Set Color&lt;/span&gt;&#39;) 

Vsrl.&lt;span style=&quot;color: #b45f06;&quot;&gt;configure&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;style&lt;/span&gt; = &#39;&lt;span style=&quot;color: #990000;&quot;&gt;SetStyleName&lt;/span&gt;&#39;)

&lt;/pre&gt;
&lt;br /&gt;
&lt;div&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow: scroll; padding-left: 10px; padding: 10px 6px 10px 10px; border-left: 3px solid #7E8BBB&quot;&gt;&lt;span style=&quot;color: #800180;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #0b5394;&quot;&gt;tkinter&lt;/span&gt; &lt;span style=&quot;color: #800180;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #0b5394;&quot;&gt;*&lt;/span&gt;
&lt;span style=&quot;color: #800180;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #0b5394;&quot;&gt;tkinter&lt;/span&gt; &lt;span style=&quot;color: #800180;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #0b5394;&quot;&gt;ttk&lt;/span&gt;

SKForm = &lt;span style=&quot;color: #2b00fe;&quot;&gt;Tk&lt;/span&gt;()
SKForm.&lt;span style=&quot;color: #783f04;&quot;&gt;title&lt;/span&gt;(&#39;&lt;span style=&quot;color: #990000;&quot;&gt;Tkinter Scroll TextBox&lt;/span&gt;&#39;)

Vsrl = ttk.&lt;span style=&quot;color: #783f04;&quot;&gt;Scrollbar&lt;/span&gt;(SKForm)
Vsrl.&lt;span style=&quot;color: #783f04;&quot;&gt;pack&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;side&lt;/span&gt; = &lt;span style=&quot;color: #0b5394;&quot;&gt;RIGHT&lt;/span&gt;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;fill&lt;/span&gt; = &lt;span style=&quot;color: #0b5394;&quot;&gt;Y&lt;/span&gt;)

&lt;span style=&quot;color: #6aa84f;&quot;&gt;#Create Style For ScrollBar&lt;/span&gt;
style = ttk.&lt;span style=&quot;color: #783f04;&quot;&gt;Style&lt;/span&gt;()
&lt;span style=&quot;color: #6aa84f;&quot;&gt;#Set Style For ScrollBar&lt;/span&gt;
style.&lt;span style=&quot;color: #783f04;&quot;&gt;configure&lt;/span&gt;(&#39;&lt;span style=&quot;color: #990000;&quot;&gt;TScrollbar&lt;/span&gt;&#39;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;background&lt;/span&gt;=&#39;&lt;span style=&quot;color: #990000;&quot;&gt;#E66565&lt;/span&gt;&#39;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;troughcolor&lt;/span&gt;=&#39;&lt;span style=&quot;color: #990000;&quot;&gt;#E0F5DA&lt;/span&gt;&#39;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;arrowcolor&lt;/span&gt;=&#39;&lt;span style=&quot;color: #990000;&quot;&gt;#65E6A9&lt;/span&gt;&#39;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;highlightcolor&lt;/span&gt;=&#39;&lt;span style=&quot;color: #990000;&quot;&gt;#E0F5DA&lt;/span&gt;&#39;) 

Vsrl.&lt;span style=&quot;color: #783f04;&quot;&gt;configure&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;style&lt;/span&gt; = &#39;&lt;span style=&quot;color: #990000;&quot;&gt;TScrollbar&#39;&lt;/span&gt;)

MyTkTextBox = &lt;span style=&quot;color: #0b5394;&quot;&gt;Text&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;SKForm&lt;/span&gt;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;yscrollcommand&lt;/span&gt; = Vsrl.&lt;span style=&quot;color: #783f04;&quot;&gt;set&lt;/span&gt;)

MyTkTextBox.&lt;span style=&quot;color: #783f04;&quot;&gt;config&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;wrap&lt;/span&gt; = &lt;span style=&quot;color: #0b5394;&quot;&gt;NONE&lt;/span&gt;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;width&lt;/span&gt; = &lt;span style=&quot;color: #274e13;&quot;&gt;22&lt;/span&gt;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;height&lt;/span&gt; = &lt;span style=&quot;color: #274e13;&quot;&gt;12&lt;/span&gt;)

&lt;span style=&quot;color: #6aa84f;&quot;&gt;#Add Record in TextBox in Tkinter&lt;/span&gt;
&lt;span style=&quot;color: #a64d79;&quot;&gt;for&lt;/span&gt; ist &lt;span style=&quot;color: #a64d79;&quot;&gt;in&lt;/span&gt; &lt;span style=&quot;color: #0b5394;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #38761d;&quot;&gt;16&lt;/span&gt;):
    MyTkTextBox.&lt;span style=&quot;color: #783f04;&quot;&gt;insert&lt;/span&gt;(&lt;span style=&quot;color: #0b5394;&quot;&gt;END&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;str&lt;/span&gt;(ist) + &quot;&lt;span style=&quot;color: #990000;&quot;&gt; = Set Horizontal and Vertical Scroll Bar in TextBox&lt;/span&gt;&quot;+ &quot;&lt;span style=&quot;color: #cc0000;&quot;&gt;\n&lt;/span&gt;&quot;)

MyTkTextBox.&lt;span style=&quot;color: #783f04;&quot;&gt;pack&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;side &lt;/span&gt;= &lt;span style=&quot;color: #0b5394;&quot;&gt;TOP&lt;/span&gt;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;fill &lt;/span&gt;= &quot;&lt;span style=&quot;color: #990000;&quot;&gt;both&lt;/span&gt;&quot;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;expand &lt;/span&gt;= &lt;span style=&quot;color: #0b5394;&quot;&gt;True&lt;/span&gt;)

Vsrl.&lt;span style=&quot;color: #783f04;&quot;&gt;config&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;command&lt;/span&gt; = MyTkTextBox.&lt;span style=&quot;color: #783f04;&quot;&gt;yview&lt;/span&gt;)

SKForm.&lt;span style=&quot;color: #783f04;&quot;&gt;mainloop&lt;/span&gt;()

&lt;/pre&gt;&lt;br /&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;

Add Text in TextBox in Tkinter&lt;/span&gt;&lt;/h4&gt;

&lt;br /&gt;&lt;b&gt;Output:&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidJFuGUVEJvXmc6KUH-MYTAirkFJbEFbKb1f-hS6W34C-AQO8dKi92Cf1bceQq4X2hGFURMqGvNOxazr3wUiXt1NYjAHxKKo3WoOr2SmrBgjvKRr-F-ffpFyWbV1bnlye-_HjJdPkpvCXJ/s245/6_Tkinter_ScrollBar_Style_in_Tkinter.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Tkinter ScrollBar Style in Python&quot; border=&quot;0&quot; data-original-height=&quot;245&quot; data-original-width=&quot;209&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidJFuGUVEJvXmc6KUH-MYTAirkFJbEFbKb1f-hS6W34C-AQO8dKi92Cf1bceQq4X2hGFURMqGvNOxazr3wUiXt1NYjAHxKKo3WoOr2SmrBgjvKRr-F-ffpFyWbV1bnlye-_HjJdPkpvCXJ/s16000/6_Tkinter_ScrollBar_Style_in_Tkinter.jpg&quot; title=&quot;ScrollBar Style in Tkinter&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 17px;&quot;&gt;&lt;b&gt;(3). How to Set ScrollBar in Textbox in Python Tkinter :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt; If you want to set Scroll Bar in Text in Tkinter. Here we will write some sentences or &lt;b&gt;multi-line text in TextBox in Tkinter&lt;/b&gt;. And want to scroll then we use following code for scrolling.&lt;div&gt;&amp;nbsp;
&lt;br /&gt;
&lt;div style=&quot;background-color: maroon; border-bottom: 3px solid yellow; border-radius: 3px; color: white; font-size: 17px; line-height: 22px; padding: 3px 5px;&quot;&gt;&lt;b&gt;Set Vertical ScrollBar in TextBox in Tkinter: &lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;

&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow: scroll; padding-left: 10px; padding: 10px 6px 10px 10px; border-left: 3px solid #7E8BBB&quot;&gt;&lt;span style=&quot;color: #741b47;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #0b5394;&quot;&gt;tkinter&lt;/span&gt; &lt;span style=&quot;color: #741b47;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #0b5394;&quot;&gt;*&lt;/span&gt;

SKForm = &lt;span style=&quot;color: #0b5394;&quot;&gt;Tk&lt;/span&gt;()
SKForm.&lt;span style=&quot;color: #783f04;&quot;&gt;title&lt;/span&gt;(&#39;&lt;span style=&quot;color: #990000;&quot;&gt;Vertical Scroll TextBox&lt;/span&gt;&#39;)

Vsrl = &lt;span style=&quot;color: #783f04;&quot;&gt;Scrollbar&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;SKForm&lt;/span&gt;)
Vsrl.&lt;span style=&quot;color: #783f04;&quot;&gt;pack&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;side&lt;/span&gt; = &lt;span style=&quot;color: #0b5394;&quot;&gt;RIGHT&lt;/span&gt;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;fill&lt;/span&gt; = &lt;span style=&quot;color: #0b5394;&quot;&gt;Y&lt;/span&gt;)

MyTkTextBox = &lt;span style=&quot;color: #783f04;&quot;&gt;Text&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;SKForm&lt;/span&gt;,  &lt;span style=&quot;color: #2b00fe;&quot;&gt;yscrollcommand&lt;/span&gt; = Vsrl.&lt;span style=&quot;color: #783f04;&quot;&gt;set&lt;/span&gt;)
MyTkTextBox.&lt;span style=&quot;color: #783f04;&quot;&gt;config&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;wrap&lt;/span&gt; = &lt;span style=&quot;color: #0b5394;&quot;&gt;NONE&lt;/span&gt;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;width&lt;/span&gt; = &lt;span style=&quot;color: #38761d;&quot;&gt;22&lt;/span&gt;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;height&lt;/span&gt; = &lt;span style=&quot;color: #38761d;&quot;&gt;12&lt;/span&gt;)

&lt;span style=&quot;color: #741b47;&quot;&gt;for&lt;/span&gt; ist &lt;span style=&quot;color: #741b47;&quot;&gt;in&lt;/span&gt; &lt;span style=&quot;color: #0b5394;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #38761d;&quot;&gt;16&lt;/span&gt;):
    MyTkTextBox.&lt;span style=&quot;color: #783f04;&quot;&gt;insert&lt;/span&gt;(&lt;span style=&quot;color: #0b5394;&quot;&gt;END&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;str&lt;/span&gt;(ist) +&quot; &lt;span style=&quot;color: #990000;&quot;&gt;= Set Vertical Scroll Bar in TextBox&lt;/span&gt;&quot;+ &quot;&lt;span style=&quot;color: #990000;&quot;&gt;\n&lt;/span&gt;&quot;)

MyTkTextBox.&lt;span style=&quot;color: #783f04;&quot;&gt;pack&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;side&lt;/span&gt;=&lt;span style=&quot;color: #0b5394;&quot;&gt;TOP&lt;/span&gt;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;fill&lt;/span&gt;=&quot;&lt;span style=&quot;color: #990000;&quot;&gt;both&lt;/span&gt;&quot;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;expand&lt;/span&gt;=&lt;span style=&quot;color: #0b5394;&quot;&gt;True&lt;/span&gt;)

&lt;span style=&quot;color: #38761d;&quot;&gt;# Set Vertical Scroll Bar to configure Text Y View&lt;/span&gt;
Vsrl.&lt;span style=&quot;color: #783f04;&quot;&gt;config&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;command&lt;/span&gt; = MyTkTextBox.&lt;span style=&quot;color: #783f04;&quot;&gt;yview&lt;/span&gt;)

SKForm.&lt;span style=&quot;color: #783f04;&quot;&gt;mainloop&lt;/span&gt;()

&lt;/pre&gt;
&lt;br /&gt;
Now, you will get the given output.&lt;div&gt;&lt;br /&gt;&amp;nbsp;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgeEULYqD3MXcNaaxUALGdOLWbvrQTMy0pk5zr6IyeCiNCNjWqxjo5Hxjnjg6_E2duYjnbofbxok9LMIxMpvbbwo64Xx-n7O50NMd_UDGR_amgjO7YNt3NFt8yreKlgOxg-D6PCFx4djhiZ/s361/Vertical_Scroll_TextBox_in_Tkinter.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Set Vertical Scroll Bar in TextBox Tkinter&quot; border=&quot;0&quot; data-original-height=&quot;175&quot; data-original-width=&quot;361&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgeEULYqD3MXcNaaxUALGdOLWbvrQTMy0pk5zr6IyeCiNCNjWqxjo5Hxjnjg6_E2duYjnbofbxok9LMIxMpvbbwo64Xx-n7O50NMd_UDGR_amgjO7YNt3NFt8yreKlgOxg-D6PCFx4djhiZ/s16000/Vertical_Scroll_TextBox_in_Tkinter.jpg&quot; title=&quot;Set Vertical ScrollBar in Text Tkinter&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: maroon; border-bottom: 3px solid yellow; border-radius: 3px; color: white; font-size: 17px; line-height: 22px; padding: 3px 5px;&quot;&gt;&lt;b&gt;Using ScrolledText in Tkinter for Vertical Scrolling:&lt;/b&gt;&lt;/div&gt; &lt;br /&gt;When you will use &lt;b&gt;ScrolledText Widget in Tkinter&lt;/b&gt;, there is no need for add extra &lt;b&gt;Scroll widget in Tkinter&lt;/b&gt; for Vertical Scrolling. ScrolledText Widget has inbuilt Vertical Scrollbar as describe in bellow python code:

&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow: scroll; padding-left: 10px; padding: 10px 6px 10px 10px; border-left: 3px solid #7E8BBB&quot;&gt;&lt;span style=&quot;color: #741b47;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #0b5394;&quot;&gt;tkinter&lt;/span&gt; &lt;span style=&quot;color: #741b47;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #0b5394;&quot;&gt;*&lt;/span&gt;
&lt;span style=&quot;color: #741b47;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #0b5394;&quot;&gt;tkinter.scrolledtext&lt;/span&gt; &lt;span style=&quot;color: #741b47;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #0b5394;&quot;&gt;ScrolledText&lt;/span&gt;

SKForm = &lt;span style=&quot;color: #0b5394;&quot;&gt;Tk&lt;/span&gt;()
SKForm.&lt;span style=&quot;color: #783f04;&quot;&gt;title&lt;/span&gt;(&#39;&lt;span style=&quot;color: #990000;&quot;&gt;ScrolledText in Tkinter&lt;/span&gt;&#39;)

skt = &lt;span style=&quot;color: #0b5394;&quot;&gt;ScrolledText&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;SKForm&lt;/span&gt;)
skt.&lt;span style=&quot;color: #783f04;&quot;&gt;config&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;width &lt;/span&gt;= &lt;span style=&quot;color: #38761d;&quot;&gt;39&lt;/span&gt;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;height &lt;/span&gt;= &lt;span style=&quot;color: #38761d;&quot;&gt;6&lt;/span&gt;)

&lt;span style=&quot;color: #6aa84f;&quot;&gt;#Add Text in ScrolledText in Tkinter&lt;/span&gt;
&lt;span style=&quot;color: #741b47;&quot;&gt;for&lt;/span&gt; ist &lt;span style=&quot;color: #741b47;&quot;&gt;in&lt;/span&gt; &lt;span style=&quot;color: #0b5394;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #38761d;&quot;&gt;8&lt;/span&gt;):
    skt.&lt;span style=&quot;color: #783f04;&quot;&gt;insert&lt;/span&gt;(&lt;span style=&quot;color: #0b5394;&quot;&gt;END&lt;/span&gt;, &lt;span style=&quot;color: #783f04;&quot;&gt;str&lt;/span&gt;(ist) +&quot;&lt;span style=&quot;color: #990000;&quot;&gt; = Using ScrolledText Widget Scroll&lt;/span&gt; &quot;+ &quot;&lt;span style=&quot;color: #990000;&quot;&gt;\n&lt;/span&gt;&quot;)
    
skt.&lt;span style=&quot;color: #783f04;&quot;&gt;pack&lt;/span&gt;()

SKForm.&lt;span style=&quot;color: #783f04;&quot;&gt;mainloop&lt;/span&gt;()

&lt;/pre&gt;
&lt;br /&gt;
Now, let’s see the output:
&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgW7Tf_QZz79uZf77bpbIgVZrsRAMAZpA8tYPBc87WxTLy7MKICb0Yb9krE9gprwSU12BEzJxnrLOSJURn2BbRidm5kMMdql-yLkHmEUJkX1idL48wplI9o8rcTGfmLhg1O7yxjsAemWD11/s343/4_ScrolledText_in_Tkinter.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;ScrolledText in Tkinter&quot; border=&quot;0&quot; data-original-height=&quot;143&quot; data-original-width=&quot;343&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgW7Tf_QZz79uZf77bpbIgVZrsRAMAZpA8tYPBc87WxTLy7MKICb0Yb9krE9gprwSU12BEzJxnrLOSJURn2BbRidm5kMMdql-yLkHmEUJkX1idL48wplI9o8rcTGfmLhg1O7yxjsAemWD11/s16000/4_ScrolledText_in_Tkinter.jpg&quot; title=&quot;Add Text in ScrolledText in Tkinter&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: maroon; border-bottom: 3px solid yellow; border-radius: 3px; color: white; font-size: 17px; line-height: 22px; padding: 3px 5px;&quot;&gt;&lt;b&gt;(c)	Set Vertical and Horizontal ScrollBar in TextBox in Tkinter:&lt;/b&gt;&lt;/div&gt; &lt;br /&gt;
Here we use Both Vertical and Horizontal ScrollBar in Text widget in Tkinter. Or here we set &lt;b&gt;ScrollBar Orientation in Tkinter&lt;/b&gt;.&lt;div&gt;&amp;nbsp;
&lt;br /&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Horizontal ScrollBar in Text in Tkinter&lt;/span&gt;&lt;/h4&gt;&lt;/div&gt;&lt;div&gt;
&lt;br /&gt;Example:&lt;/div&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow: scroll; padding-left: 10px; padding: 10px 6px 10px 10px; border-left: 3px solid #7E8BBB;&quot;&gt;&lt;span style=&quot;color: #741b47;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #0b5394;&quot;&gt;tkinter&lt;/span&gt; &lt;span style=&quot;color: #741b47;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #0b5394;&quot;&gt;*&lt;/span&gt;

SKForm = &lt;span style=&quot;color: #0b5394;&quot;&gt;Tk&lt;/span&gt;()
SKForm.&lt;span style=&quot;color: #783f04;&quot;&gt;title&lt;/span&gt;(&#39;&lt;span style=&quot;color: #990000;&quot;&gt;Tkinter Scroll TextBox&lt;/span&gt;&#39;)

&lt;span style=&quot;color: #6aa84f;&quot;&gt;#Create Horizontal ScrollBar in Tkinter&lt;/span&gt;
Hsrl = &lt;span style=&quot;color: #0b5394;&quot;&gt;Scrollbar&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;SKForm&lt;/span&gt;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;orient&lt;/span&gt; = &#39;&lt;span style=&quot;color: #990000;&quot;&gt;horizontal&lt;/span&gt;&#39;)
Hsrl.&lt;span style=&quot;color: #783f04;&quot;&gt;pack&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;side&lt;/span&gt; = &lt;span style=&quot;color: #0b5394;&quot;&gt;BOTTOM&lt;/span&gt;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;fill&lt;/span&gt; = &lt;span style=&quot;color: #0b5394;&quot;&gt;X&lt;/span&gt;)

&lt;span style=&quot;color: #6aa84f;&quot;&gt;#Create Vertical ScrollBar in Tkinter&lt;/span&gt;
Vsrl = &lt;span style=&quot;color: #0b5394;&quot;&gt;Scrollbar&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;SKForm&lt;/span&gt;)
Vsrl.&lt;span style=&quot;color: #783f04;&quot;&gt;pack&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;side&lt;/span&gt; = &lt;span style=&quot;color: #0b5394;&quot;&gt;RIGHT&lt;/span&gt;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;fill&lt;/span&gt; = &lt;span style=&quot;color: #0b5394;&quot;&gt;Y&lt;/span&gt;)

&lt;span style=&quot;color: #6aa84f;&quot;&gt;#Create TextBox and Set Scroll Bar&lt;/span&gt;
MyTkTextBox = &lt;span style=&quot;color: #0b5394;&quot;&gt;Text&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;SKForm&lt;/span&gt;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;xscrollcommand&lt;/span&gt; = Hsrl.&lt;span style=&quot;color: #783f04;&quot;&gt;set&lt;/span&gt;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;yscrollcommand&lt;/span&gt; = Vsrl.&lt;span style=&quot;color: #783f04;&quot;&gt;set&lt;/span&gt;)

MyTkTextBox.&lt;span style=&quot;color: #783f04;&quot;&gt;config&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;wrap&lt;/span&gt; = &lt;span style=&quot;color: #0b5394;&quot;&gt;NONE&lt;/span&gt;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;width&lt;/span&gt; = &lt;span style=&quot;color: #38761d;&quot;&gt;22&lt;/span&gt;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;height&lt;/span&gt; = &lt;span style=&quot;color: #38761d;&quot;&gt;12&lt;/span&gt;)

&lt;span style=&quot;color: #741b47;&quot;&gt;for&lt;/span&gt; ist &lt;span style=&quot;color: #741b47;&quot;&gt;in&lt;/span&gt; &lt;span style=&quot;color: #0b5394;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #38761d;&quot;&gt;16&lt;/span&gt;):
    MyTkTextBox.&lt;span style=&quot;color: #783f04;&quot;&gt;insert&lt;/span&gt;(&lt;span style=&quot;color: #0b5394;&quot;&gt;END&lt;/span&gt;, &lt;span style=&quot;color: #783f04;&quot;&gt;str&lt;/span&gt;(ist) +&quot;&lt;span style=&quot;color: #990000;&quot;&gt; = Set Horizontal and Vertical Scroll Bar in TextBox&lt;/span&gt;&quot;+ &quot;&lt;span style=&quot;color: #990000;&quot;&gt;\n&lt;/span&gt;&quot;)

&lt;span style=&quot;color: #6aa84f;&quot;&gt;#Set TextBox widget to Form at top&lt;/span&gt;
MyTkTextBox.&lt;span style=&quot;color: #783f04;&quot;&gt;pack&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;side&lt;/span&gt;=&lt;span style=&quot;color: #3d85c6;&quot;&gt;TOP&lt;/span&gt;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;fill&lt;/span&gt;=&quot;&lt;span style=&quot;color: #990000;&quot;&gt;both&lt;/span&gt;&quot;, &lt;span style=&quot;color: #2b00fe;&quot;&gt;expand&lt;/span&gt;=&lt;span style=&quot;color: #0b5394;&quot;&gt;True&lt;/span&gt;)

&lt;span style=&quot;color: #6aa84f;&quot;&gt;# Set Horizontal Scroll Bar to configure Textox X View&lt;/span&gt;
Hsrl.&lt;span style=&quot;color: #783f04;&quot;&gt;config&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;command&lt;/span&gt; = MyTkTextBox.&lt;span style=&quot;color: #783f04;&quot;&gt;xview&lt;/span&gt;)

&lt;span style=&quot;color: #6aa84f;&quot;&gt;# Set Vertical Scroll Bar to configure Textox Y View&lt;/span&gt;
Vsrl.&lt;span style=&quot;color: #783f04;&quot;&gt;config&lt;/span&gt;(&lt;span style=&quot;color: #2b00fe;&quot;&gt;command&lt;/span&gt; = MyTkTextBox.&lt;span style=&quot;color: #783f04;&quot;&gt;yview&lt;/span&gt;)

SKForm.&lt;span style=&quot;color: #783f04;&quot;&gt;mainloop&lt;/span&gt;()

&lt;/pre&gt;
&lt;br /&gt;&lt;div&gt;&lt;b&gt;Output:&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVmQaBm-ju3BwemTKQjrhBWLH2CP0xjuxFtN4iDHoOuoE88bCqauemP8LBwgQa910ec6gQ2NuCdIxQ5a0jf5qHxJu-oUN5VrVgTC9rJGW9ANWizyZjJfaZkI61XN0MU2YtcS78J8nWvVJA/s303/5_Set_ScrollBar_in_TextBox_in_Tkinter.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Horizontal and Vertical Scrollbar in Tkinter&quot; border=&quot;0&quot; data-original-height=&quot;258&quot; data-original-width=&quot;303&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVmQaBm-ju3BwemTKQjrhBWLH2CP0xjuxFtN4iDHoOuoE88bCqauemP8LBwgQa910ec6gQ2NuCdIxQ5a0jf5qHxJu-oUN5VrVgTC9rJGW9ANWizyZjJfaZkI61XN0MU2YtcS78J8nWvVJA/s16000/5_Set_ScrollBar_in_TextBox_in_Tkinter.jpg&quot; title=&quot;Horizontal and Vertical Scrolling Text in Tkinter&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;After running application, this will show above given output, you can easily scroll your Textbox content left to right or Up and down.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So, this way SKOTechLearn describe the way to use &lt;b&gt;ScrollBar in Tkinter Python&lt;/b&gt; or you can set &lt;b&gt;ScrollBar in Text Widget in Tkinter&lt;/b&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;</description><link>https://www.skotechlearn.com/2021/06/Scrollbar-in-Text-in-tkinter.html</link><author>noreply@blogger.com (SKOTechLearn)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWNdYQN0qmO13cjjwi7RDDL9v_nRgntu6rzAQ8H4L14eVAElTlxoxITsxLon5odqeIMhylVKNUAxpiTK0GhfzsA-klxrSUEcQeKU57sbsxp6eaCJEYUf72JpVZ9DKbsC12-kAvhbUS1cAW/s72-c/0_Tkinter_ScrollBar_in_TextBox.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2258844867892945003.post-5118582321781929967</guid><pubDate>Tue, 22 Jun 2021 14:56:00 +0000</pubDate><atom:updated>2021-07-13T11:58:50.035-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">VB.Net</category><title>How to Connect or Show Data from SQLite in VB.Net or C#</title><description>&lt;p&gt;As you know that SQLite free to use in any platform. But here we will learn How to Use &lt;b&gt;SQlite Database in VB.net&lt;/b&gt; and we will also learn how to show &lt;b&gt;SQLite Data in VB.Net or C#&lt;/b&gt;.&amp;nbsp;&lt;/p&gt;&lt;p&gt;But In Vb.net if we want to call data from SQLite then we have to use &lt;b&gt;“System.Data.SQLite.dll”&lt;/b&gt; file or add as reference in VB.Net. Now when we insert this dll file, we have first import following class in your programming.
&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFHHA5CrGmohJEuiGe-w4qPKoyD5tcvvmg_i9PbRQda6SrjaFWWWFQxHtmnQrIAHU-6aX71BXUZzbX54o6mGc9NGIitBHhI74o-YPtAi8rMXJJcJEilnDTlbX2-FxhtLiG-7BLcWH9aZiA/s445/0_SQLIte_Connect_With_VBNet.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;SQLIte Connect With VB.Net&quot; border=&quot;0&quot; data-original-height=&quot;261&quot; data-original-width=&quot;445&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFHHA5CrGmohJEuiGe-w4qPKoyD5tcvvmg_i9PbRQda6SrjaFWWWFQxHtmnQrIAHU-6aX71BXUZzbX54o6mGc9NGIitBHhI74o-YPtAi8rMXJJcJEilnDTlbX2-FxhtLiG-7BLcWH9aZiA/s16000/0_SQLIte_Connect_With_VBNet.jpg&quot; title=&quot;SQLIte Connect With VB.Net&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;b&gt;VB.Net :&lt;/b&gt;&lt;/p&gt;

&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding-left: 10px; padding: 10px 6px 10px 10px;&quot;&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;Imports&lt;/span&gt; System.Data.SQLite
&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;C# :&lt;/b&gt;

&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding-left: 10px; padding: 10px 6px 10px 10px;&quot;&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;using&lt;/span&gt; System.Data.SQLite;
&lt;/pre&gt;
&lt;br /&gt;
After that we will proceed with following points:

&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;b&gt;
&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;How to Connect SQLite in VB.Net&lt;/li&gt;
&lt;/b&gt;  &lt;b&gt;
&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Show Data from SQLite in VB.Net through Query&lt;/li&gt;
 &lt;/b&gt;  &lt;b&gt;
&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Show SQlite  Data in ListBox in VB.Net&lt;/li&gt;
  &lt;/b&gt;  &lt;b&gt;
&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Show SQLite Data in Listview in VB.Net&lt;/li&gt;
&lt;/b&gt; &lt;/ol&gt;
&lt;br /&gt;&lt;/div&gt;

When you add this reference to your vb project then you have to first learn what is the &lt;b&gt;SQLite ConnectionString in VB.Net&lt;/b&gt;.&amp;nbsp;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;First, there is following table we created in &lt;b&gt;Sqlite3 Database&lt;/b&gt;.
&lt;br /&gt;

&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinDwZRN4mzEqWewPTIWESPfgR2VU7xBTfL27mE1A-Q_kBq_lyBKlyFnZwKjxyeclHPo1pDLn-V3l6c0xhcIyUgl7KzGHY-WUU7wIN0zn_P43rQ1ULR8Z8e4XUJfi5o34-J1_Vb9PZNGtVe/s407/1_MySqliteDatabase_And_Table_with_Records.jpg&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;Create Table in SQLite Database&quot; border=&quot;0&quot; data-original-height=&quot;133&quot; data-original-width=&quot;407&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinDwZRN4mzEqWewPTIWESPfgR2VU7xBTfL27mE1A-Q_kBq_lyBKlyFnZwKjxyeclHPo1pDLn-V3l6c0xhcIyUgl7KzGHY-WUU7wIN0zn_P43rQ1ULR8Z8e4XUJfi5o34-J1_Vb9PZNGtVe/s16000/1_MySqliteDatabase_And_Table_with_Records.jpg&quot; title=&quot;Create Table in SQLite Database&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;b&gt;&lt;i&gt;&lt;span style=&quot;color: #800180;&quot;&gt;SQLite Database with Tables&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

After that we will learn point wise described bellow.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 16px;&quot;&gt;&lt;b&gt;(1). How to Connect SQLite in VB.Net :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;
For any database connection in any programming language require ConnectionString, so first we will write code for connection String:&lt;div&gt;&lt;br /&gt;&lt;b&gt;
VB:&lt;/b&gt;&lt;br /&gt;
&lt;/div&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding-left: 10px; padding: 10px 6px 10px 10px;&quot;&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;Dim&lt;/span&gt; SQLiteConn &lt;span style=&quot;color: #0b5394;&quot;&gt;As New&lt;/span&gt; SQLiteConnection

SQLiteConn.ConnectionString = &lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;Data Source=MyPath\MysqliteFile.db; Integrated Security=true&quot;&lt;/span&gt;

SQLiteConn.Open()

&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;b&gt;
C#:&lt;/b&gt;&lt;br /&gt;

&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding-left: 10px; padding: 10px 6px 10px 10px;&quot;&gt;SQLiteConnection SQLiteConn = &lt;span style=&quot;color: #0b5394;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b00fe;&quot;&gt;SQLiteConnection&lt;/span&gt;();

SQLiteConn.ConnectionString = &lt;span style=&quot;color: #2b00fe;&quot;&gt;@&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;Data Source=MyPath\MysqliteFile.db; Integrated Security=true&quot;&lt;/span&gt;;

SQLiteConn.&lt;span style=&quot;color: #2b00fe;&quot;&gt;Open&lt;/span&gt;();

&lt;/pre&gt;
&lt;br /&gt;&lt;div&gt;This way you can connect SQLite with VB.Net.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 16px;&quot;&gt;&lt;b&gt;(2). Show Data from SQLite in VB.Net through Query :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;Now, Lets try to show data from Local SQLite Database’s Tables through query in VB.Net.  Suppose we want to show only single record of one field then we have to write following code:&lt;div&gt;&lt;br /&gt;&lt;b&gt;
VB:&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding-left: 10px; padding: 10px 6px 10px 10px;&quot;&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;Dim&lt;/span&gt; SQLitecnStr &lt;span style=&quot;color: #0b5394;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #741b47;&quot;&gt;String&lt;/span&gt; =&lt;span style=&quot;color: #990000;&quot;&gt;&quot;Data Source=C:\MYSQLiteDBForVB.db; Integrated Security=true&quot;&lt;/span&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;Dim&lt;/span&gt; SQLiteConn &lt;span style=&quot;color: #0b5394;&quot;&gt;As New&lt;/span&gt; &lt;span style=&quot;color: #741b47;&quot;&gt;SQLiteConnection&lt;/span&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;Dim&lt;/span&gt; SQLitecmd &lt;span style=&quot;color: #0b5394;&quot;&gt;As New&lt;/span&gt; &lt;span style=&quot;color: #741b47;&quot;&gt;SQLiteCommand&lt;/span&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;Dim&lt;/span&gt; SQLiteReader &lt;span style=&quot;color: #0b5394;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #741b47;&quot;&gt;SQLiteDataReader&lt;/span&gt;

SQLiteConn.ConnectionString = SQLitecnStr
SQLiteConn.&lt;span style=&quot;color: #2b00fe;&quot;&gt;Open&lt;/span&gt;()

SQLitecmd.Connection = SQLiteConn
SQLitecmd.CommandText =&lt;span style=&quot;color: #990000;&quot;&gt; &quot;SELECT * from MySQLiteTable LIMIT 1;&quot;&lt;/span&gt;
SQLiteReader = SQLitecmd.&lt;span style=&quot;color: #2b00fe;&quot;&gt;ExecuteReader&lt;/span&gt;()
	
Msgbox(SQLiteReader(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;MyName&quot;&lt;/span&gt;).&lt;span style=&quot;color: #2b00fe;&quot;&gt;ToString&lt;/span&gt;)

SQLiteReader.&lt;span style=&quot;color: #2b00fe;&quot;&gt;Close&lt;/span&gt;()
SQLiteConn.&lt;span style=&quot;color: #2b00fe;&quot;&gt;Close&lt;/span&gt;()

&lt;/pre&gt;&lt;/div&gt;
&lt;br /&gt;&lt;b&gt;
C#:&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding-left: 10px; padding: 10px 6px 10px 10px;&quot;&gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;string&lt;/span&gt; SQLitecnStr = &lt;span style=&quot;color: #2b00fe;&quot;&gt;@&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&quot;Data Source=C:\MYSQLiteDBForVB.db; Integrated Security=true&quot;&lt;/span&gt;;
SQLiteConnection SQLiteConn = &lt;span style=&quot;color: #0b5394;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b00fe;&quot;&gt;SQLiteConnection&lt;/span&gt;();
SQLiteCommand SQLitecmd = &lt;span style=&quot;color: #0b5394;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b00fe;&quot;&gt;SQLiteCommand&lt;/span&gt;();
SQLiteDataReader SQLiteReader;
	
SQLiteConn.ConnectionString = SQLitecnStr;
SQLiteConn.&lt;span style=&quot;color: #2b00fe;&quot;&gt;Open&lt;/span&gt;();
	
SQLitecmd.Connection = SQLiteConn;
SQLitecmd.CommandText = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;SELECT * from MySQLiteTable LIMIT 1;&quot;&lt;/span&gt;;
SQLiteReader = SQLitecmd.&lt;span style=&quot;color: #2b00fe;&quot;&gt;ExecuteReader&lt;/span&gt;();
	
MessageBox.&lt;span style=&quot;color: #2b00fe;&quot;&gt;Show&lt;/span&gt;(SQLiteReader[&lt;span style=&quot;color: #990000;&quot;&gt;&quot;MyName&quot;&lt;/span&gt;].&lt;span style=&quot;color: #2b00fe;&quot;&gt;ToString&lt;/span&gt;(), &lt;span style=&quot;color: #990000;&quot;&gt;&quot;SQLite Connection in VB.Net&quot;&lt;/span&gt;);
	          
SQLiteReader.&lt;span style=&quot;color: #2b00fe;&quot;&gt;Close&lt;/span&gt;();
SQLiteConn.&lt;span style=&quot;color: #2b00fe;&quot;&gt;Close&lt;/span&gt;();

&lt;/pre&gt;
&lt;br /&gt;
When we execute this code, the output will present in MessageBox.&lt;div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjV9VOVtYfCEnlrVMiWTTgjKGvdjci249I9_8PkAbS3XEoo_5o1XfPk_isxjDaXJG6UTcDHjYwWyPf04apSR4OQSMo-n_tvEVSyXgWBKoDu_T4JJPKfrlZ4nRUgz74AixJ0fwMJglhjd-N_/s209/2_SQLite_Record_in_MessageBox_VBNet.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Show MessageBox in VB.Net&quot; border=&quot;0&quot; data-original-height=&quot;154&quot; data-original-width=&quot;209&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjV9VOVtYfCEnlrVMiWTTgjKGvdjci249I9_8PkAbS3XEoo_5o1XfPk_isxjDaXJG6UTcDHjYwWyPf04apSR4OQSMo-n_tvEVSyXgWBKoDu_T4JJPKfrlZ4nRUgz74AixJ0fwMJglhjd-N_/s16000/2_SQLite_Record_in_MessageBox_VBNet.jpg&quot; title=&quot;SQLite Data in MessageBox in Vb.net&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 16px;&quot;&gt;&lt;b&gt;(3). Show SQLite  Data in ListBox in VB.Net :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;
Now, Suppose you want to show SQlite’s Table’s particular Fields records or &lt;b&gt;show Data in ListBox in VB.Net&lt;/b&gt; or Listing particular Field in List then here we use while loop without using ‘LIMIT’ in Query just same as bellow:&lt;br /&gt;&lt;br /&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;&lt;b&gt;SQLite Select Query Example&lt;/b&gt;&lt;/h4&gt;

&lt;br /&gt;&lt;b&gt;
VB:&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding-left: 10px; padding: 10px 6px 10px 10px;&quot;&gt;MyListbox1.items.&lt;span style=&quot;color: #2b00fe;&quot;&gt;clear&lt;/span&gt;()
&lt;span style=&quot;color: #0b5394;&quot;&gt;Dim&lt;/span&gt; SQLitecnStr &lt;span style=&quot;color: #0b5394;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #741b47;&quot;&gt;String&lt;/span&gt; =&lt;span style=&quot;color: #990000;&quot;&gt;&quot;Data Source=C:\MYSQLiteDBForVB.db; Integrated Security=true&quot;&lt;/span&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;Dim&lt;/span&gt; SQLiteConn &lt;span style=&quot;color: #0b5394;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #0b5394;&quot;&gt;New&lt;/span&gt; &lt;span style=&quot;color: #741b47;&quot;&gt;SQLiteConnection&lt;/span&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;Dim&lt;/span&gt; SQLitecmd &lt;span style=&quot;color: #0b5394;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #0b5394;&quot;&gt;New&lt;/span&gt; &lt;span style=&quot;color: #741b47;&quot;&gt;SQLiteCommand&lt;/span&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;Dim&lt;/span&gt; SQLiteReader &lt;span style=&quot;color: #0b5394;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #741b47;&quot;&gt;SQLiteDataReader&lt;/span&gt;
SQLiteConn.ConnectionString = SQLitecnStr
SQLiteConn.&lt;span style=&quot;color: #2b00fe;&quot;&gt;Open&lt;/span&gt;()

SQLitecmd.Connection = SQLiteConn
SQLitecmd.CommandText = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;SELECT * from MySQLiteTable;&quot;&lt;/span&gt;
SQLiteReader = SQLitecmd.&lt;span style=&quot;color: #2b00fe;&quot;&gt;ExecuteReader&lt;/span&gt;()
 
&lt;span style=&quot;color: #0b5394;&quot;&gt;While&lt;/span&gt; SQLiteReader.&lt;span style=&quot;color: #2b00fe;&quot;&gt;Read&lt;/span&gt;()
    MyListbox1.Items.&lt;span style=&quot;color: #2b00fe;&quot;&gt;Add&lt;/span&gt;(SQLiteReader(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;MyMono&quot;&lt;/span&gt;).&lt;span style=&quot;color: #2b00fe;&quot;&gt;ToString&lt;/span&gt;)
&lt;span style=&quot;color: #0b5394;&quot;&gt;End While&lt;/span&gt;

SQLiteReader.&lt;span style=&quot;color: #2b00fe;&quot;&gt;Close&lt;/span&gt;()
SQLiteConn.&lt;span style=&quot;color: #2b00fe;&quot;&gt;Close&lt;/span&gt;()

&lt;/pre&gt;
&lt;br /&gt;&lt;b&gt;
C#:&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding-left: 10px; padding: 10px 6px 10px 10px;&quot;&gt;MyListbox1.Items.&lt;span style=&quot;color: #2b00fe;&quot;&gt;Clear&lt;/span&gt;();
string SQLitecnStr = &lt;span style=&quot;color: #2b00fe;&quot;&gt;@&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&quot;Data Source=C:\MYSQLiteDBForVB.db; Integrated Security=true&quot;&lt;/span&gt;;
SQLiteConnection SQLiteConn = &lt;span style=&quot;color: #0b5394;&quot;&gt;new&lt;/span&gt; SQLiteConnection();
SQLiteCommand SQLitecmd = &lt;span style=&quot;color: #0b5394;&quot;&gt;new&lt;/span&gt; SQLiteCommand();
SQLiteDataReader SQLiteReader;

SQLiteConn.ConnectionString = SQLitecnStr;
SQLiteConn.&lt;span style=&quot;color: #2b00fe;&quot;&gt;Open&lt;/span&gt;();

SQLitecmd.Connection = SQLiteConn;
SQLitecmd.CommandText = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;SELECT * from MySQLiteTable;&quot;&lt;/span&gt;;
SQLiteReader = SQLitecmd.&lt;span style=&quot;color: #2b00fe;&quot;&gt;ExecuteReader&lt;/span&gt;();

&lt;span style=&quot;color: #0b5394;&quot;&gt;while&lt;/span&gt; (SQLiteReader.&lt;span style=&quot;color: #2b00fe;&quot;&gt;Read&lt;/span&gt;())
    &lt;span style=&quot;color: #0b5394;&quot;&gt;{&lt;/span&gt;
       MyListbox1.Items.&lt;span style=&quot;color: #2b00fe;&quot;&gt;Add&lt;/span&gt;(SQLiteReader[&lt;span style=&quot;color: #990000;&quot;&gt;&quot;MyMono&quot;&lt;/span&gt;].&lt;span style=&quot;color: #2b00fe;&quot;&gt;ToString&lt;/span&gt;());
   &lt;span style=&quot;color: #0b5394;&quot;&gt; }&lt;/span&gt;

 SQLiteReader.&lt;span style=&quot;color: #2b00fe;&quot;&gt;Close&lt;/span&gt;();
 SQLiteConn.&lt;span style=&quot;color: #2b00fe;&quot;&gt;Close&lt;/span&gt;();

&lt;/pre&gt;
&lt;br /&gt;
After executing this code, we will find following output.&lt;div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg84NZF_8LJp586kWTGfX14sYy6OFFKBwLZkwVIkz4cbHzOue4ErCrrCt1DELGiGaC0lrl1b9c-01F6gpbS7xd-VCAdpkPLQpIflmOXFi_f1GQAFQCH7AAKdLDxO-nfE4r6tJf0uRmq_T94/s196/3_Show_SQLite_Records_in_ListBox_in_VbNet.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Show SQLite Data in Listbox in VB.Net&quot; border=&quot;0&quot; data-original-height=&quot;196&quot; data-original-width=&quot;191&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg84NZF_8LJp586kWTGfX14sYy6OFFKBwLZkwVIkz4cbHzOue4ErCrrCt1DELGiGaC0lrl1b9c-01F6gpbS7xd-VCAdpkPLQpIflmOXFi_f1GQAFQCH7AAKdLDxO-nfE4r6tJf0uRmq_T94/s16000/3_Show_SQLite_Records_in_ListBox_in_VbNet.jpg&quot; title=&quot;Show SQLite Data in Listbox in C#&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 16px;&quot;&gt;&lt;b&gt;(4) Show SQLite Data in ListView in VB.Net :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;Now, Lets Learn about important point that we use in every simple programming process in vb.net or any other programming Languages. Here we will talk about ListView (Showing Multiple Rows with multiple columns) with containing &lt;b&gt;SQLite Records in VB.Net&lt;/b&gt;.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Here we learn how to Use&amp;nbsp;&lt;b&gt;SQLite in ListView in VB.Net&lt;/b&gt;. So we have to follow the code like:&lt;/div&gt;&lt;br /&gt;&lt;b&gt;VB:
&lt;/b&gt;

&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding-left: 10px; padding: 10px 6px 10px 10px;&quot;&gt;MyLstView.Items.&lt;span style=&quot;color: #2b00fe;&quot;&gt;Clear&lt;/span&gt;()
&lt;span style=&quot;color: #0b5394;&quot;&gt;Dim&lt;/span&gt; SQLitecnStr &lt;span style=&quot;color: #0b5394;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #a64d79;&quot;&gt;String&lt;/span&gt; =&lt;span style=&quot;color: #990000;&quot;&gt;&quot;Data Source=C:\MYSQLiteDBForVB.db; Integrated Security=true&quot;&lt;/span&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;Dim&lt;/span&gt; SQLiteConn &lt;span style=&quot;color: #0b5394;&quot;&gt;As New&lt;/span&gt; &lt;span style=&quot;color: #a64d79;&quot;&gt;SQLiteConnection&lt;/span&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;Dim&lt;/span&gt; SQLitecmd &lt;span style=&quot;color: #0b5394;&quot;&gt;As New&lt;/span&gt; &lt;span style=&quot;color: #a64d79;&quot;&gt;SQLiteCommand&lt;/span&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;Dim&lt;/span&gt; SQLiteReader &lt;span style=&quot;color: #0b5394;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #a64d79;&quot;&gt;SQLiteDataReader&lt;/span&gt;

SQLiteConn.ConnectionString = SQLitecnStr
SQLiteConn.&lt;span style=&quot;color: #2b00fe;&quot;&gt;Open&lt;/span&gt;()

SQLitecmd.Connection = SQLiteConn
SQLitecmd.CommandText = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;SELECT * from MySQLiteTable;&quot;&lt;/span&gt;
SQLiteReader = SQLitecmd.&lt;span style=&quot;color: #2b00fe;&quot;&gt;ExecuteReader&lt;/span&gt;()

&lt;span style=&quot;color: #0b5394;&quot;&gt;While&lt;/span&gt; SQLiteReader.&lt;span style=&quot;color: #2b00fe;&quot;&gt;Read&lt;/span&gt;()
    &lt;span style=&quot;color: #0b5394;&quot;&gt;Dim&lt;/span&gt; Lstv &lt;span style=&quot;color: #0b5394;&quot;&gt;As New&lt;/span&gt; &lt;span style=&quot;color: #a64d79;&quot;&gt;ListViewItem&lt;/span&gt;
    Lstv.Text = SQLiteReader(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;MySrno&quot;&lt;/span&gt;).&lt;span style=&quot;color: #2b00fe;&quot;&gt;ToString&lt;/span&gt;
    Lstv.SubItems.&lt;span style=&quot;color: #2b00fe;&quot;&gt;Add&lt;/span&gt;(SQLiteReader(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;MyName&quot;&lt;/span&gt;).&lt;span style=&quot;color: #2b00fe;&quot;&gt;ToString&lt;/span&gt;)
    Lstv.SubItems.&lt;span style=&quot;color: #2b00fe;&quot;&gt;Add&lt;/span&gt;(SQLiteReader(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;MyMono&quot;&lt;/span&gt;).&lt;span style=&quot;color: #2b00fe;&quot;&gt;ToString&lt;/span&gt;)
    MyLstView.Items.&lt;span style=&quot;color: #2b00fe;&quot;&gt;Add&lt;/span&gt;(Lstv)
&lt;span style=&quot;color: #0b5394;&quot;&gt;End While&lt;/span&gt;

SQLiteReader.&lt;span style=&quot;color: #2b00fe;&quot;&gt;Close&lt;/span&gt;()
SQLiteConn.&lt;span style=&quot;color: #2b00fe;&quot;&gt;Close&lt;/span&gt;()

&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;C#:
&lt;/b&gt;

&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding-left: 10px; padding: 10px 6px 10px 10px;&quot;&gt;MyLstView.Items.&lt;span style=&quot;color: #2b00fe;&quot;&gt;Clear&lt;/span&gt;();
&lt;span style=&quot;color: #0b5394;&quot;&gt;string&lt;/span&gt; SQLitecnStr = &lt;span style=&quot;color: #2b00fe;&quot;&gt;@&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&quot;Data Source=C:\MYSQLiteDBForVB.db; Integrated Security=true&quot;&lt;/span&gt;;
SQLiteConnection SQLiteConn = &lt;span style=&quot;color: #0b5394;&quot;&gt;new&lt;/span&gt; SQLiteConnection();
SQLiteCommand SQLitecmd = &lt;span style=&quot;color: #0b5394;&quot;&gt;new&lt;/span&gt; SQLiteCommand();
SQLiteDataReader SQLiteReader;

SQLiteConn.ConnectionString = SQLitecnStr;
SQLiteConn.&lt;span style=&quot;color: #2b00fe;&quot;&gt;Open&lt;/span&gt;();

SQLitecmd.Connection = SQLiteConn;
SQLitecmd.CommandText = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;SELECT * from MySQLiteTable;&quot;&lt;/span&gt;;
SQLiteReader = SQLitecmd.ExecuteReader();

&lt;span style=&quot;color: #0b5394;&quot;&gt;while&lt;/span&gt; (SQLiteReader.&lt;span style=&quot;color: #2b00fe;&quot;&gt;Read&lt;/span&gt;())
     {
        ListViewItem Lsvw = &lt;span style=&quot;color: #0b5394;&quot;&gt;new&lt;/span&gt; ListViewItem();
        Lsvw.Text = SQLiteReader[&lt;span style=&quot;color: #990000;&quot;&gt;&quot;MySrno&quot;&lt;/span&gt;].&lt;span style=&quot;color: #2b00fe;&quot;&gt;ToString&lt;/span&gt;();
        Lsvw.SubItems.&lt;span style=&quot;color: #2b00fe;&quot;&gt;Add&lt;/span&gt;(SQLiteReader[&lt;span style=&quot;color: #990000;&quot;&gt;&quot;MyName&quot;&lt;/span&gt;].&lt;span style=&quot;color: #2b00fe;&quot;&gt;ToString&lt;/span&gt;());
        Lsvw.SubItems.&lt;span style=&quot;color: #2b00fe;&quot;&gt;Add&lt;/span&gt;(SQLiteReader[&lt;span style=&quot;color: #990000;&quot;&gt;&quot;MyMono&quot;&lt;/span&gt;].&lt;span style=&quot;color: #2b00fe;&quot;&gt;ToString&lt;/span&gt;());
        MyLstView.Items.&lt;span style=&quot;color: #2b00fe;&quot;&gt;Add&lt;/span&gt;(Lsvw);
     }

SQLiteReader.&lt;span style=&quot;color: #2b00fe;&quot;&gt;Close&lt;/span&gt;();
SQLiteConn.&lt;span style=&quot;color: #2b00fe;&quot;&gt;Close&lt;/span&gt;();

&lt;/pre&gt;
&lt;br /&gt;
So, the output will displayed like below to showing SQLite Records in ListView in VB.Net.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQgeyhtQj3mn7hcKnvHZC3Nmy5sU99yRWwjoeqHgWU1ZyCS5us_HOwXdwqWVjqsjetmE-bvXUgnfcol80OgFSyqtpwLqRk-C5qfgaYoJ08dw0EZT4pSkdHxqx4BHgdA0i8zIAgnu7HB6UH/s288/4_Show_SQLite_Records_in_ListView_in_VB.Net.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;SQLite Record in Listview in VB.Net&quot; border=&quot;0&quot; data-original-height=&quot;226&quot; data-original-width=&quot;288&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQgeyhtQj3mn7hcKnvHZC3Nmy5sU99yRWwjoeqHgWU1ZyCS5us_HOwXdwqWVjqsjetmE-bvXUgnfcol80OgFSyqtpwLqRk-C5qfgaYoJ08dw0EZT4pSkdHxqx4BHgdA0i8zIAgnu7HB6UH/s16000/4_Show_SQLite_Records_in_ListView_in_VB.Net.jpg&quot; title=&quot;SQLite Record in Listview in C#&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;
&lt;br /&gt;
Here are the above given details with step by step points for Showing Data of &lt;b&gt;SQLite in VB.Net&lt;/b&gt;. Try to implement more your project with above given examples.</description><link>https://www.skotechlearn.com/2021/06/connect-SQLite-in-VB-Net.html</link><author>noreply@blogger.com (SKOTechLearn)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFHHA5CrGmohJEuiGe-w4qPKoyD5tcvvmg_i9PbRQda6SrjaFWWWFQxHtmnQrIAHU-6aX71BXUZzbX54o6mGc9NGIitBHhI74o-YPtAi8rMXJJcJEilnDTlbX2-FxhtLiG-7BLcWH9aZiA/s72-c/0_SQLIte_Connect_With_VBNet.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2258844867892945003.post-6040437137241782115</guid><pubDate>Tue, 20 Apr 2021 08:15:00 +0000</pubDate><atom:updated>2021-04-20T01:15:16.649-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Python</category><title>Login Form in Python GUI with MYSQL and MSSQL Connection</title><description>In python, if we want to Design Login Form with database authentication with MYSQL or MSSQL then we have to follow the following process with step by step guide.&amp;nbsp;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Here we will learn How to Design &lt;b&gt;Login Form in Python GUI &lt;/b&gt;with &lt;a href=&quot;https://www.skotechlearn.com/2021/04/mysql-connection-in-python.html&quot; target=&quot;_blank&quot;&gt;MYSQL connection in Python&lt;/a&gt; or &lt;b&gt;SQL Server Connection in Python&lt;/b&gt;.&amp;nbsp;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDtqskbmeCiR8HOhCg6TjyYeCIihJ6juFX1e7kBcUSfTZ0HTL7HWmrx5kf-eO53NfpCZxqFkYpwdaRU0POHoQYYpx7bRaeCnAk_4NRWVB3nUKEkV5NarPH1_v_lFtHL3eTjYi-XcV8pCLE/s428/1_Login_Form_in_Python_GUI.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Design Login Form in Python Tkinter&quot; border=&quot;0&quot; data-original-height=&quot;276&quot; data-original-width=&quot;428&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDtqskbmeCiR8HOhCg6TjyYeCIihJ6juFX1e7kBcUSfTZ0HTL7HWmrx5kf-eO53NfpCZxqFkYpwdaRU0POHoQYYpx7bRaeCnAk_4NRWVB3nUKEkV5NarPH1_v_lFtHL3eTjYi-XcV8pCLE/s16000/1_Login_Form_in_Python_GUI.jpg&quot; title=&quot;Login Form in Python GUI&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

First we have to Create table For authentication with following field Name:

&lt;table style=&quot;border-collapse: collapse; border-spacing: 0px; height: 18px; width: 90%;&quot;&gt;
&lt;thead&gt;
  &lt;tr&gt;
    &lt;th colspan=&quot;2&quot; style=&quot;background-color: #657b83; border: 1px solid rgb(220, 227, 218); color: #fdf6e3; font-family: Arial, sans-serif; font-size: 14px; font-weight: normal; height: 18px; padding: 3px; text-align: center; width: 250px;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Login_tbl&lt;/span&gt;&lt;/th&gt;
  &lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
  &lt;tr&gt;
    &lt;td style=&quot;background-color: #fdf6e3; border: 1px solid rgb(220, 227, 218); color: #002b36; font-family: Arial, sans-serif; font-size: 14px; padding: 3px; text-align: center;&quot;&gt;&lt;b&gt;usrname&lt;/b&gt;&lt;/td&gt;
    &lt;td style=&quot;background-color: #fdf6e3; border: 1px solid rgb(220, 227, 218); color: #002b36; font-family: Arial, sans-serif; font-size: 14px; padding: 3px; text-align: center;&quot;&gt;&lt;b&gt;passwrd&lt;/b&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td style=&quot;background-color: white; border: 1px solid rgb(220, 227, 218); padding: 3px; text-align: center; vertical-align: top;&quot;&gt;sko&lt;/td&gt;
    &lt;td style=&quot;background-color: white; border: 1px solid rgb(220, 227, 218); padding: 3px; text-align: center; vertical-align: top;&quot;&gt;tech&lt;/td&gt;
  &lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;br /&gt;

Same type of table we create in MSSQL.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;
After that we will use following tkinter widget:

&lt;br /&gt;
&lt;table style=&quot;height: 114px; width: 385px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;background-color: #657b83; border: 1px solid rgb(220, 227, 218); color: #fdf6e3; padding: 2px; text-align: center; width: 191px;&quot;&gt;&lt;strong&gt;Name&lt;/strong&gt;&lt;/td&gt;
&lt;td style=&quot;background-color: #657b83; border: 1px solid rgb(220, 227, 218); color: #fdf6e3; padding: 2px; text-align: center; width: 193px;&quot;&gt;&lt;strong&gt;Tkinter Wiidget&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;border: 1px solid rgb(220, 227, 218); font-family: Arial, sans-serif; font-size: 15px; padding: 2px; width: 191px;&quot;&gt;Bannerlabel&lt;/td&gt;
&lt;td style=&quot;border: 1px solid rgb(220, 227, 218); font-family: Arial, sans-serif; font-size: 15px; padding: 2px; width: 193px;&quot;&gt;&amp;nbsp;Label&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;border: 1px solid rgb(220, 227, 218); font-family: Arial, sans-serif; font-size: 15px; padding: 2px; width: 191px;&quot;&gt;UserLabel&lt;/td&gt;
&lt;td style=&quot;border: 1px solid rgb(220, 227, 218); font-family: Arial, sans-serif; font-size: 15px; padding: 2px; width: 193px;&quot;&gt;&amp;nbsp;Label&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;border: 1px solid rgb(220, 227, 218); font-family: Arial, sans-serif; font-size: 15px; padding: 2px; width: 191px;&quot;&gt;PassLabel&lt;/td&gt;
&lt;td style=&quot;border: 1px solid rgb(220, 227, 218); font-family: Arial, sans-serif; font-size: 15px; padding: 2px; width: 193px;&quot;&gt;&amp;nbsp;Label&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;border: 1px solid rgb(220, 227, 218); font-family: Arial, sans-serif; font-size: 15px; padding: 2px; width: 191px;&quot;&gt;UserTxt&lt;/td&gt;
&lt;td style=&quot;border: 1px solid rgb(220, 227, 218); font-family: Arial, sans-serif; font-size: 15px; padding: 2px; width: 193px;&quot;&gt;&amp;nbsp;Entry&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;border: 1px solid rgb(220, 227, 218); font-family: Arial, sans-serif; font-size: 15px; padding: 2px; width: 191px;&quot;&gt;PassTxt&lt;/td&gt;
&lt;td style=&quot;border: 1px solid rgb(220, 227, 218); font-family: Arial, sans-serif; font-size: 15px; padding: 2px; width: 193px;&quot;&gt;&amp;nbsp;Entry&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;border: 1px solid rgb(220, 227, 218); font-family: Arial, sans-serif; font-size: 15px; padding: 2px; width: 191px;&quot;&gt;LoginBtn&lt;/td&gt;
&lt;td style=&quot;border: 1px solid rgb(220, 227, 218); font-family: Arial, sans-serif; font-size: 15px; padding: 2px; width: 193px;&quot;&gt;&amp;nbsp;Button&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;

&lt;br /&gt;
After that we will proceed with following points:
&lt;br /&gt;
&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;b&gt;
&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Login Form Design in Python GUI with MYSQL Connection&lt;/li&gt;
&lt;/b&gt;  &lt;b&gt;
&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Login Form Design in Python GUI with MSSQL Connection&lt;/li&gt;
&lt;/b&gt; &lt;/ol&gt;
&lt;br /&gt;
Now we will first Start with MYSQL connection then MS SQL Server Connection.
&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 16px;&quot;&gt;&lt;b&gt;(1). Login Form Design in Python GUI with MYSQL Connection :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;

Now, first we will import ‘&lt;b&gt;mysql.connector&lt;/b&gt;’ for connection. Then write code for establish connection with MYSQl after that write code for query like following way:
&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding-left: 10px; padding: 10px 6px 10px 10px;&quot;&gt;&lt;span style=&quot;color: #741b47;&quot;&gt;import&lt;/span&gt; mysql.connector &lt;span style=&quot;color: #741b47;&quot;&gt;as&lt;/span&gt; mysqlconnector
&lt;span style=&quot;color: #741b47;&quot;&gt;import&lt;/span&gt; tkinter &lt;span style=&quot;color: #741b47;&quot;&gt;as&lt;/span&gt; mytk
&lt;span style=&quot;color: #741b47;&quot;&gt;from&lt;/span&gt; tkinter &lt;span style=&quot;color: #741b47;&quot;&gt;import&lt;/span&gt; *
&lt;span style=&quot;color: #741b47;&quot;&gt;import&lt;/span&gt; tkinter.messagebox &lt;span style=&quot;color: #741b47;&quot;&gt;as&lt;/span&gt; mymessagebox

MyLoginForm = mytk.Tk()
MyLoginForm.title(&lt;span style=&quot;color: #cc0000;&quot;&gt;&#39;Login Form with MYSQL Connection&#39;&lt;/span&gt;)
&lt;span style=&quot;color: #38761d;&quot;&gt;#Set Form Size&lt;/span&gt;
MyLoginForm.geometry(&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;380x200&quot;&lt;/span&gt;)

&lt;span style=&quot;color: #0b5394;&quot;&gt;def&lt;/span&gt; ClicktoLogin():
    &lt;span style=&quot;color: #38761d;&quot;&gt;#MYSQL ConnectionString&lt;/span&gt;
    mydb = mysqlconnector.connect(&lt;span style=&quot;color: #134f5c;&quot;&gt;host&lt;/span&gt;=&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;xxx.xxx.xxx.xx&quot;&lt;/span&gt;, &lt;span style=&quot;color: #134f5c;&quot;&gt;user&lt;/span&gt;=&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;sko&quot;&lt;/span&gt;, &lt;span style=&quot;color: #134f5c;&quot;&gt;password&lt;/span&gt;=&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;mypassword&quot;&lt;/span&gt;, &lt;span style=&quot;color: #134f5c;&quot;&gt;database&lt;/span&gt;=&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;skotechlearn&quot;&lt;/span&gt;)
    mycursor = mydb.cursor(&lt;span style=&quot;color: #134f5c;&quot;&gt;dictionary&lt;/span&gt;=&lt;span style=&quot;color: #0b5394;&quot;&gt;True&lt;/span&gt;)
    mycursor.execute(&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;SELECT * FROM login_tbl where usrname = &#39;&quot;&lt;/span&gt;+ UserTxt.get() +&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;&#39; and passwrd = &#39;&quot;&lt;/span&gt;+ PassTxt.get() +&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;&#39;;&quot;&lt;/span&gt;)
    myresult = mycursor.fetchone()
    &lt;span style=&quot;color: #a64d79;&quot;&gt;if&lt;/span&gt; myresult==&lt;span style=&quot;color: #0b5394;&quot;&gt;None&lt;/span&gt;:
       mymessagebox.showerror(&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;Error&quot;&lt;/span&gt;, &lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;Invalid User Name And Password&quot;&lt;/span&gt;)

    &lt;span style=&quot;color: #a64d79;&quot;&gt;else&lt;/span&gt;:
       mymessagebox.showinfo(&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;Success&quot;&lt;/span&gt;, &lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;Successfully Login&quot;&lt;/span&gt;)
            
    mydb.close()
    mycursor.close()

&lt;span style=&quot;color: #38761d;&quot;&gt;# Set Tkinter Widget Size Location and Style&lt;/span&gt;
Bannerlabel = Label(MyLoginForm, &lt;span style=&quot;color: #0b5394;&quot;&gt;text&lt;/span&gt; = &lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;Login Form......&quot;&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;width&lt;/span&gt;=&lt;span style=&quot;color: #38761d;&quot;&gt;40&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;bg&lt;/span&gt;= &lt;span style=&quot;color: #cc0000;&quot;&gt;&#39;yellow&#39;&lt;/span&gt;)
Bannerlabel.place(&lt;span style=&quot;color: #0b5394;&quot;&gt;x&lt;/span&gt;=&lt;span style=&quot;color: #38761d;&quot;&gt;20&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;y&lt;/span&gt;=&lt;span style=&quot;color: #38761d;&quot;&gt;20&lt;/span&gt;)

UserLabel = Label(MyLoginForm, &lt;span style=&quot;color: #0b5394;&quot;&gt;text&lt;/span&gt; = &lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;User Name:&quot;&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;width&lt;/span&gt;=&lt;span style=&quot;color: #38761d;&quot;&gt;10&lt;/span&gt;)
UserLabel.place(&lt;span style=&quot;color: #0b5394;&quot;&gt;x&lt;/span&gt;=&lt;span style=&quot;color: #38761d;&quot;&gt;20&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;y&lt;/span&gt;=&lt;span style=&quot;color: #38761d;&quot;&gt;60&lt;/span&gt;)

UserTxt = Entry(MyLoginForm,  &lt;span style=&quot;color: #0b5394;&quot;&gt;width&lt;/span&gt;=&lt;span style=&quot;color: #38761d;&quot;&gt;27&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;relief&lt;/span&gt;=&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;flat&quot;&lt;/span&gt;)
UserTxt.place(&lt;span style=&quot;color: #0b5394;&quot;&gt;x&lt;/span&gt;=&lt;span style=&quot;color: #38761d;&quot;&gt;120&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;y&lt;/span&gt;=&lt;span style=&quot;color: #38761d;&quot;&gt;60&lt;/span&gt;)

&lt;span style=&quot;color: #38761d;&quot;&gt;#Set Focus on User Entrybox in Tkinter&lt;/span&gt;
UserTxt.focus()

PassLabel = Label(MyLoginForm, &lt;span style=&quot;color: #0b5394;&quot;&gt;text&lt;/span&gt; = &lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;Password :&quot;&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;width&lt;/span&gt;=&lt;span style=&quot;color: #38761d;&quot;&gt;10&lt;/span&gt;)
PassLabel.place(&lt;span style=&quot;color: #0b5394;&quot;&gt;x&lt;/span&gt;=&lt;span style=&quot;color: #38761d;&quot;&gt;20&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;y&lt;/span&gt;=&lt;span style=&quot;color: #38761d;&quot;&gt;90&lt;/span&gt;)

PassTxt = Entry(MyLoginForm,  &lt;span style=&quot;color: #0b5394;&quot;&gt;width&lt;/span&gt;=&lt;span style=&quot;color: #38761d;&quot;&gt;27&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;relief&lt;/span&gt;=&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;flat&quot;&lt;/span&gt;)
PassTxt.place(&lt;span style=&quot;color: #0b5394;&quot;&gt;x&lt;/span&gt;=&lt;span style=&quot;color: #38761d;&quot;&gt;120&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;y&lt;/span&gt;=&lt;span style=&quot;color: #38761d;&quot;&gt;90&lt;/span&gt;)

&lt;span style=&quot;color: #38761d;&quot;&gt;#Set Password Char in Entry Widget&lt;/span&gt;
PassTxt.config(&lt;span style=&quot;color: #0b5394;&quot;&gt;show&lt;/span&gt;=&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;*&quot;&lt;/span&gt;);

LoginBtn = Button(MyLoginForm, &lt;span style=&quot;color: #0b5394;&quot;&gt;text&lt;/span&gt; =&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;Login&quot;&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;command&lt;/span&gt; = ClicktoLogin, &lt;span style=&quot;color: #0b5394;&quot;&gt;relief&lt;/span&gt;=&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;groove&quot;&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;fg&lt;/span&gt;=&lt;span style=&quot;color: #cc0000;&quot;&gt;&#39;blue&#39;&lt;/span&gt;)
LoginBtn.place(&lt;span style=&quot;color: #0b5394;&quot;&gt;x&lt;/span&gt;=&lt;span style=&quot;color: #38761d;&quot;&gt;280&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;y&lt;/span&gt;=&lt;span style=&quot;color: #38761d;&quot;&gt;140&lt;/span&gt;)

MyLoginForm.configure(&lt;span style=&quot;color: #0b5394;&quot;&gt;background&lt;/span&gt;=&lt;span style=&quot;color: #cc0000;&quot;&gt;&#39;#54596d&#39;&lt;/span&gt;)
MyLoginForm.mainloop()
&lt;/pre&gt;

&lt;br /&gt;
When we execute this code. We will see the output looks like bellow.&lt;div&gt;&amp;nbsp;
&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnk8p2ihlXdCbOwpxFnLAeO7hAY8u_lmMd1ogWzhhOzSiaCLsTi0yE0bMSt2_5iyEkfoCxc2Ycaxd9dA0rYw85fDLfVnJaem4i3xpJ0GZwkSX77UnhZH6waTzw9VBxoU4Fn01OBO46yNev/s767/2_Login_Form_with_MYSQL_Connection_in_Python.jpeg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Login Form MYSQL Connection in Python&quot; border=&quot;0&quot; data-original-height=&quot;284&quot; data-original-width=&quot;767&quot; height=&quot;237&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnk8p2ihlXdCbOwpxFnLAeO7hAY8u_lmMd1ogWzhhOzSiaCLsTi0yE0bMSt2_5iyEkfoCxc2Ycaxd9dA0rYw85fDLfVnJaem4i3xpJ0GZwkSX77UnhZH6waTzw9VBxoU4Fn01OBO46yNev/w640-h237/2_Login_Form_with_MYSQL_Connection_in_Python.jpeg&quot; title=&quot;Login Form in Python with MYSQL Connection&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;
&lt;br /&gt;
As you can see we have changed Form, Label color for better look. After successful Login there will be a message displayed like above figure.
&lt;br /&gt;Now, Lets come to another point with &lt;b&gt;MSSQL Connection in Python&lt;/b&gt;.
&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 16px;&quot;&gt;&lt;b&gt;(2). Login Form Design in Python GUI with MSSQL Connection :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;
For MSSQL Connection first we install &lt;b&gt;pymssql&lt;/b&gt;. 
&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding-left: 10px; padding: 10px 6px 10px 10px;&quot;&gt;pip install pymssql
&lt;/pre&gt;
&lt;br /&gt;&lt;b&gt;
or
&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding-left: 10px; padding: 10px 6px 10px 10px;&quot;&gt;pip3 install pymssql
&lt;/pre&gt;
&lt;br /&gt;
After that we will &lt;b&gt;import pymssql in python&lt;/b&gt; code.&lt;div&gt;&amp;nbsp;
&lt;br /&gt;For Import and for MSSQL Connection String in Python, we will write following code.&lt;/div&gt;&lt;div&gt;&amp;nbsp;
&lt;br /&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;MSSQL Server Connection in Python
&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Connection String Code:
&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding-left: 10px; padding: 10px 6px 10px 10px;&quot;&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;# pymssql.connect(MSSQLServerIP, UserName, Password, Database)&lt;/span&gt;
pymssql.connect(&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;xxx.xxx.xxx.xx&quot;&lt;/span&gt;,&lt;span style=&quot;color: #cc0000;&quot;&gt; &quot;myusername&quot;&lt;/span&gt;, &lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;myPassword&quot;&lt;/span&gt;, &lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;MyDatabase&quot;&lt;/span&gt;)
&lt;/pre&gt;
&lt;br /&gt;&lt;br /&gt;
Let’s see how can we connect MSSQL Server with Python Tkinter Login Form?
&lt;br /&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding-left: 10px; padding: 10px 6px 10px 10px;&quot;&gt;&lt;span style=&quot;color: #741b47;&quot;&gt;import&lt;/span&gt; pymssql &lt;span style=&quot;color: #741b47;&quot;&gt;as&lt;/span&gt; MSSQLCnn
&lt;span style=&quot;color: #741b47;&quot;&gt;import&lt;/span&gt; tkinter &lt;span style=&quot;color: #741b47;&quot;&gt;as&lt;/span&gt; mytk
&lt;span style=&quot;color: #741b47;&quot;&gt;from&lt;/span&gt; tkinter &lt;span style=&quot;color: #741b47;&quot;&gt;import&lt;/span&gt; *
&lt;span style=&quot;color: #741b47;&quot;&gt;import&lt;/span&gt; tkinter.messagebox &lt;span style=&quot;color: #741b47;&quot;&gt;as&lt;/span&gt; mymessagebox

MyLoginForm = mytk.Tk()
MyLoginForm.title(&lt;span style=&quot;color: #cc0000;&quot;&gt;&#39;Login Form with MSSQL Server Connection&#39;&lt;/span&gt;)
MyLoginForm.geometry(&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;380x200&quot;&lt;/span&gt;)

&lt;span style=&quot;color: #0b5394;&quot;&gt;def&lt;/span&gt; ClicktoLogin():
    &lt;span style=&quot;color: #38761d;&quot;&gt;#MSSQL Server ConnectionString&lt;/span&gt;
    MSSQLdb = MSSQLCnn.connect(&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;xxx.xxx.xxx.xx&quot;&lt;/span&gt;, &lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;SQLServerUser&quot;&lt;/span&gt;, &lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;SQlServerPassword&quot;&lt;/span&gt;, &lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;SQLServerDatabase&quot;&lt;/span&gt;)
    mySQLcursor = MSSQLdb.cursor()
    mySQLcursor.execute(&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;SELECT * FROM login_tbl where usrname = &#39;&quot;&lt;/span&gt;+ UserTxt.get() +&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;&#39; and passwrd = &#39;&quot;&lt;/span&gt;+ PassTxt.get() +&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;&#39;;&quot;&lt;/span&gt;)
    mySQLresult = mySQLcursor.fetchone()
    &lt;span style=&quot;color: #741b47;&quot;&gt;if&lt;/span&gt; mySQLresult==&lt;span style=&quot;color: #0b5394;&quot;&gt;None&lt;/span&gt;:
       mymessagebox.showerror(&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;Error&quot;&lt;/span&gt;, &lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;Invalid User Name And Password&quot;&lt;/span&gt;)

    &lt;span style=&quot;color: #741b47;&quot;&gt;else&lt;/span&gt;:
       mymessagebox.showinfo(&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;Success&quot;&lt;/span&gt;, &lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;Successfully Login&quot;&lt;/span&gt;)
            
    MSSQLdb.close()
    mySQLcursor.close()

Bannerlabel = Label(MyLoginForm, &lt;span style=&quot;color: #0b5394;&quot;&gt;text&lt;/span&gt; =&lt;span style=&quot;color: #cc0000;&quot;&gt; &quot;MSSQL Server Login Form......&quot;&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;width&lt;/span&gt;=&lt;span style=&quot;color: #38761d;&quot;&gt;40&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;bg&lt;/span&gt;= &lt;span style=&quot;color: #cc0000;&quot;&gt;&#39;#81907E&#39;&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;fg&lt;/span&gt;=&lt;span style=&quot;color: #cc0000;&quot;&gt;&#39;white&#39;&lt;/span&gt;)
Bannerlabel.place(&lt;span style=&quot;color: #0b5394;&quot;&gt;x&lt;/span&gt;=&lt;span style=&quot;color: #38761d;&quot;&gt;20&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;y&lt;/span&gt;=&lt;span style=&quot;color: #38761d;&quot;&gt;20&lt;/span&gt;)

UserLabel = Label(MyLoginForm, &lt;span style=&quot;color: #0b5394;&quot;&gt;text&lt;/span&gt; = &lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;User Name:&quot;&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;width&lt;/span&gt;=&lt;span style=&quot;color: #38761d;&quot;&gt;10&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;bg&lt;/span&gt;=&lt;span style=&quot;color: #cc0000;&quot;&gt;&#39;#FFE6D8&#39;&lt;/span&gt;)
UserLabel.place(&lt;span style=&quot;color: #0b5394;&quot;&gt;x&lt;/span&gt;=&lt;span style=&quot;color: #38761d;&quot;&gt;20&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;y&lt;/span&gt;=&lt;span style=&quot;color: #38761d;&quot;&gt;60&lt;/span&gt;)

UserTxt = Entry(MyLoginForm,  &lt;span style=&quot;color: #0b5394;&quot;&gt;width&lt;/span&gt;=&lt;span style=&quot;color: #38761d;&quot;&gt;27&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;relief&lt;/span&gt;=&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;flat&quot;&lt;/span&gt;)
UserTxt.place(&lt;span style=&quot;color: #0b5394;&quot;&gt;x&lt;/span&gt;=&lt;span style=&quot;color: #38761d;&quot;&gt;120&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;y&lt;/span&gt;=&lt;span style=&quot;color: #38761d;&quot;&gt;60&lt;/span&gt;)

&lt;span style=&quot;color: #38761d;&quot;&gt;#Focus of User Entrybox in Tkinter&lt;/span&gt;
UserTxt.focus()

PassLabel = Label(MyLoginForm, &lt;span style=&quot;color: #0b5394;&quot;&gt;text&lt;/span&gt; = &lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;Password :&quot;&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;width&lt;/span&gt;=&lt;span style=&quot;color: #38761d;&quot;&gt;10&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;bg&lt;/span&gt;=&lt;span style=&quot;color: #cc0000;&quot;&gt;&#39;#FFE6D8&#39;&lt;/span&gt;)
PassLabel.place(&lt;span style=&quot;color: #0b5394;&quot;&gt;x&lt;/span&gt;=&lt;span style=&quot;color: #38761d;&quot;&gt;20&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;y&lt;/span&gt;=&lt;span style=&quot;color: #38761d;&quot;&gt;90&lt;/span&gt;)

PassTxt = Entry(MyLoginForm,  &lt;span style=&quot;color: #0b5394;&quot;&gt;width&lt;/span&gt;=&lt;span style=&quot;color: #38761d;&quot;&gt;27&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;relief&lt;/span&gt;=&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;flat&quot;&lt;/span&gt;)
PassTxt.place(&lt;span style=&quot;color: #0b5394;&quot;&gt;x&lt;/span&gt;=&lt;span style=&quot;color: #38761d;&quot;&gt;120&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;y&lt;/span&gt;=&lt;span style=&quot;color: #38761d;&quot;&gt;90&lt;/span&gt;)

&lt;span style=&quot;color: #38761d;&quot;&gt;#Set Entry box Password Char in Tkinter&lt;/span&gt;
PassTxt.config(&lt;span style=&quot;color: #0b5394;&quot;&gt;show&lt;/span&gt;=&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;*&quot;&lt;/span&gt;);

LoginBtn = Button(MyLoginForm, &lt;span style=&quot;color: #0b5394;&quot;&gt;text&lt;/span&gt; =&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;Login&quot;&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;command&lt;/span&gt; = ClicktoLogin, &lt;span style=&quot;color: #0b5394;&quot;&gt;relief&lt;/span&gt;=&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;groove&quot;&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;fg&lt;/span&gt;=&lt;span style=&quot;color: #cc0000;&quot;&gt;&#39;blue&#39;&lt;/span&gt;)
LoginBtn.place(&lt;span style=&quot;color: #0b5394;&quot;&gt;x&lt;/span&gt;=&lt;span style=&quot;color: #38761d;&quot;&gt;280&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;y&lt;/span&gt;=&lt;span style=&quot;color: #38761d;&quot;&gt;140&lt;/span&gt;)

MyLoginForm.configure(&lt;span style=&quot;color: #0b5394;&quot;&gt;background&lt;/span&gt;=&lt;span style=&quot;color: #cc0000;&quot;&gt;&#39;#FFE6D8&#39;&lt;/span&gt;)
MyLoginForm.mainloop()
&lt;/pre&gt;
&lt;br /&gt;&lt;br /&gt;
After the execution of this code in python, the following output will present.
&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2OU2yedca6rmeEDywo7Ye6lniU4EbdtlE6ldXl076KtpRh5UcsSTwwetW5kcQuzjOOueGt2bsPHUPsO0-QQLHb0_pE_5n2zPgsDlDQ68AW9zSv89WVxy0U95jclfrRekJ9EgcJvete3Sh/s704/3_Login_Form_with_MSSQL_Connection_in_Python.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Login Form MSSQL Connection in Python&quot; border=&quot;0&quot; data-original-height=&quot;284&quot; data-original-width=&quot;704&quot; height=&quot;258&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2OU2yedca6rmeEDywo7Ye6lniU4EbdtlE6ldXl076KtpRh5UcsSTwwetW5kcQuzjOOueGt2bsPHUPsO0-QQLHb0_pE_5n2zPgsDlDQ68AW9zSv89WVxy0U95jclfrRekJ9EgcJvete3Sh/w640-h258/3_Login_Form_with_MSSQL_Connection_in_Python.jpg&quot; title=&quot;Login Form in Python with MSSQL Connection&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
This way you can easily Create or &lt;b&gt;Design Login Form in Python GUI &lt;/b&gt;with Tkinter and &lt;b&gt;Connect Login Form with MSSQL in Python&lt;/b&gt; Or &lt;b&gt;Connect Login Form with MYSQL in Python&lt;/b&gt;.&lt;/div&gt;</description><link>https://www.skotechlearn.com/2021/04/login-form-in-python--with-mysql-mssql-connection.html</link><author>noreply@blogger.com (SKOTechLearn)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDtqskbmeCiR8HOhCg6TjyYeCIihJ6juFX1e7kBcUSfTZ0HTL7HWmrx5kf-eO53NfpCZxqFkYpwdaRU0POHoQYYpx7bRaeCnAk_4NRWVB3nUKEkV5NarPH1_v_lFtHL3eTjYi-XcV8pCLE/s72-c/1_Login_Form_in_Python_GUI.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2258844867892945003.post-5642284821281534751</guid><pubDate>Mon, 05 Apr 2021 06:00:00 +0000</pubDate><atom:updated>2021-04-04T23:00:16.453-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Python</category><title>MySQL Connection in Python with MYSQL Select Query in Python</title><description>When we want to connect MYSQL Database with application then we have to first consider about &lt;b&gt;MYSQL Connection Driver&lt;/b&gt; and &lt;b&gt;MySQL ConnectionString&lt;/b&gt;. So here we will describe &lt;b&gt;MYSQL Database Connection in Python&lt;/b&gt; or &lt;b&gt;MYSQL connection in Python&lt;/b&gt; with database in three ways.&amp;nbsp;&lt;div&gt;&lt;br /&gt; 
&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;b&gt;
&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Using Pyodbc in MYSQL Connection&lt;/li&gt;
&lt;/b&gt;  &lt;b&gt;
&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Using  mysql.connector for MYSQL Connection&lt;/li&gt;
 &lt;/b&gt;  &lt;b&gt;
&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Using pymysql for MYSQL Connection&lt;/li&gt;
&lt;/b&gt; &lt;/ol&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

Fist thing we have to know that if we want to connect any type of Database organization, then we have to use Driver from particular database organization like MYSQL.

So, Lets Start from &lt;b&gt;pyodbc in python&lt;/b&gt;.&lt;div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;
  
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 16px;&quot;&gt;&lt;b&gt;(1). Using Pyodbc in MYSQL Connection :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;

For using pyodbc, you have to &lt;a href=&quot;https://pypi.org/project/pyodbc/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;install pyodbc through pip&lt;/a&gt;.  Now, lets know the following connection string of pyodbc.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding-left: 10px; padding: 10px 6px 10px 10px;&quot;&gt;pyodbc.connect(&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;DRIVER={Driver_Name}; User=Server_User; Password=server_Password; Server=localhost/server IP; Database=DatabaseName;&quot;&lt;/span&gt;)
&lt;/pre&gt;
&lt;br /&gt;
So, Write following code to show database table’s record in following way:
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding-left: 10px; padding: 10px 6px 10px 10px;&quot;&gt;&lt;span style=&quot;color: #a64d79;&quot;&gt;import&lt;/span&gt; pyodbc 

mysqlcn = pyodbc.connect(&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;DRIVER={MySQL ODBC 8.0 ANSI Driver}; User=sko; Password=xxxxxx; Server=xxx.xxx.xxx.xx; Database=mydatabase; &quot;&lt;/span&gt;)
dbcursor = mysqlcn.cursor() 
dbcursor.execute(&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;SELECT * FROM TestTable&quot;&lt;/span&gt;) 
myfield = dbcursor.fetchone() 
&lt;span style=&quot;color: #6aa84f;&quot;&gt;# Loop to fetch one by one data.&lt;/span&gt;
&lt;span style=&quot;color: #a64d79;&quot;&gt;while&lt;/span&gt; myfield:
      &lt;span style=&quot;color: #6aa84f;&quot;&gt;# Print partuculat column data from table&lt;/span&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;print&lt;/span&gt; (myfield[&lt;span style=&quot;color: #6aa84f;&quot;&gt;0&lt;/span&gt;]) 
myfield = dbcursor.fetchone()

&lt;span style=&quot;color: #6aa84f;&quot;&gt;#Now Close cursor and connection&lt;/span&gt;
dbcursor.close()
mysqlcn.close() 
&lt;/pre&gt;
&lt;br /&gt;
In this code we use “&lt;b&gt;&lt;a href=&quot;https://dev.mysql.com/downloads/connector/odbc/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;MySQL ODBC 8.0 ANSI Driver&lt;/a&gt;&lt;/b&gt;” in pyodbc.&amp;nbsp;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This will show following output:
&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqPvbEIMm9OQFyI6fNFCMTVhgXlgeUHA9ngouJ6IeoJ0zXTVailXDvwm7ppy8cKDbStFBEmt5r_eYnbMTKSXmaQGBWx7ZeCrG9PrSi9_3BLekLf2W2E1wEl7_OSLRxqRPaQ5g5KzPCIVYz/s335/1_MySQL_connect_To_Pyodbc_With_Output.jpeg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;MySQL Connect using Pyodbc Output&quot; border=&quot;0&quot; data-original-height=&quot;154&quot; data-original-width=&quot;335&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqPvbEIMm9OQFyI6fNFCMTVhgXlgeUHA9ngouJ6IeoJ0zXTVailXDvwm7ppy8cKDbStFBEmt5r_eYnbMTKSXmaQGBWx7ZeCrG9PrSi9_3BLekLf2W2E1wEl7_OSLRxqRPaQ5g5KzPCIVYz/s16000/1_MySQL_connect_To_Pyodbc_With_Output.jpeg&quot; title=&quot;MySQL Connect using Pyodbc in Python&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;h3 style=&quot;font-size: 22px; text-align: left;&quot;&gt;&lt;b&gt;
Show MySQL Data in Listbox in Python
&lt;/b&gt;&lt;/h3&gt;
&lt;br /&gt;
If you want to show data or you can use &lt;b&gt;MYSQL Select Query in Python&lt;/b&gt; to show data in Listbox then following code will be help in you coding.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Show Database Record in Listbox:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding-left: 10px; padding: 10px 6px 10px 10px;&quot;&gt;&lt;span style=&quot;color: #a64d79;&quot;&gt;import&lt;/span&gt; tkinter &lt;span style=&quot;color: #a64d79;&quot;&gt;as&lt;/span&gt; mytk
&lt;span style=&quot;color: #a64d79;&quot;&gt;from&lt;/span&gt; tkinter &lt;span style=&quot;color: #a64d79;&quot;&gt;import&lt;/span&gt; *
&lt;span style=&quot;color: #a64d79;&quot;&gt;import&lt;/span&gt; pyodbc 

MytkForm = mytk.Tk()&lt;br /&gt;MytkForm.title(&lt;span style=&quot;color: #cc0000;&quot;&gt;&#39;MySQL with pyodbc&#39;&lt;/span&gt;)
MytkForm.geometry(&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;250x100&quot;&lt;/span&gt;)

&lt;span style=&quot;color: #6aa84f;&quot;&gt;# Create Listbox&lt;/span&gt;
MyTklist = mytk.Listbox(MytkForm)&lt;br /&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;#Clear Listbox&lt;/span&gt;
MyTklist.delete(&lt;span style=&quot;color: #6aa84f;&quot;&gt;0&lt;/span&gt;,END)
mysqlcn = pyodbc.connect(&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;DRIVER={MySQL ODBC 8.0 ANSI Driver}; User=sko; Password=xxxxxx; Server=xxx.xxx.xxx.xx; Database=mydatabase;&quot;&lt;/span&gt;)
dbcursor = mysqlcn.cursor() 
&lt;span style=&quot;color: #6aa84f;&quot;&gt;#MySQL Select Query in Python&lt;/span&gt;
dbcursor.execute(&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;SELECT * FROM TestTable&quot;&lt;/span&gt;) 
myfield = dbcursor.fetchone() 
&lt;span style=&quot;color: #a64d79;&quot;&gt;while&lt;/span&gt; myfield:
    &lt;span style=&quot;color: #6aa84f;&quot;&gt;# Add Field data in Listbox&lt;/span&gt;
    MyTklist.insert(END,myfield[&lt;span style=&quot;color: #6aa84f;&quot;&gt;0&lt;/span&gt;]) 
    myfield = dbcursor.fetchone()

dbcursor.close()
mysqlcn.close()
MyTklist.pack()

MytkForm.mainloop()
&lt;/pre&gt;
&lt;br /&gt;&lt;b&gt;&lt;u&gt;
OUTPUT:&lt;/u&gt;&amp;nbsp;&lt;/b&gt;&lt;div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_dQzzIx9nmSqQ4kMSf3BuAlik_zgfoXiALLeQCzQ-K0hSmqahf4cUYoUQ08YH4K1PhimqFKvA05tiNQTfONnBeMcn129YwunSzOxhZCqirtL2Z99kIFgYgoctPuvpNHoH6BrJdPwDVbPo/s262/2_MySQL_data_show+in+Listbox+in+Python+with+pyodbc.jpeg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;MySQL Data Show in Listbox in Python&quot; border=&quot;0&quot; data-original-height=&quot;135&quot; data-original-width=&quot;262&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_dQzzIx9nmSqQ4kMSf3BuAlik_zgfoXiALLeQCzQ-K0hSmqahf4cUYoUQ08YH4K1PhimqFKvA05tiNQTfONnBeMcn129YwunSzOxhZCqirtL2Z99kIFgYgoctPuvpNHoH6BrJdPwDVbPo/s16000/2_MySQL_data_show+in+Listbox+in+Python+with+pyodbc.jpeg&quot; title=&quot;MySQL Data Show in Listbox in Python&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 16px;&quot;&gt;&lt;b&gt;(2). Using  mysql.connector for MYSQL Connection&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;In this point we will learn how to use&lt;a href=&quot;https://pypi.org/project/mysql-connector/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt; mysql.connector for database&lt;/a&gt; connection and also learn how to List MYSQL data through column name in python.&amp;nbsp;&lt;div&gt;&lt;br /&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;&lt;b&gt;

Mysql.connector ConnectionString in Python
&lt;/b&gt;&lt;/h4&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding-left: 10px; padding: 10px 6px 10px 10px;&quot;&gt;mysql.connector.connect(&lt;span style=&quot;color: #0b5394;&quot;&gt;host=&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;XXX.XXX.XXX.XX&quot;&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;user=&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;Database_User&quot;&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;password=&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;Database_Password&quot;&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;database=&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;DatabaseName&quot;&lt;/span&gt;)
&lt;/pre&gt;
&lt;br /&gt;
Now Lets, see how to show data?
&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding-left: 10px; padding: 10px 6px 10px 10px;&quot;&gt;&lt;span style=&quot;color: #a64d79;&quot;&gt;import&lt;/span&gt; mysql.connector
&lt;span style=&quot;color: #6aa84f;&quot;&gt;#ConnectionString&lt;/span&gt;
mydb = mysql.connector.connect(&lt;span style=&quot;color: #0b5394;&quot;&gt;host=&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;XXX.XXX.XXX.XX&quot;&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;user=&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;sko&quot;&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;password=&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;mypassword&quot;&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;database=&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;mydatabase&quot;&lt;/span&gt;)
mycursor = mydb.cursor()
mycursor.execute(&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;SELECT * FROM TestTable&quot;&lt;/span&gt;)
myresult = mycursor.fetchall()
&lt;span style=&quot;color: #a64d79;&quot;&gt;for&lt;/span&gt; mycol &lt;span style=&quot;color: #a64d79;&quot;&gt;in&lt;/span&gt; myresult:
   &lt;span style=&quot;color: #6aa84f;&quot;&gt;# Get Second Column&#39;s row List&lt;/span&gt;
   &lt;span style=&quot;color: #b45f06;&quot;&gt;print&lt;/span&gt;(mycol[&lt;span style=&quot;color: #6aa84f;&quot;&gt;1&lt;/span&gt;])

mydb.close()
mycursor.close() 
&lt;/pre&gt;&lt;br /&gt;
&lt;div&gt;&lt;b&gt;&lt;u&gt;OUTPUT:&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZIwQAi99__laKvmSiK2s-OeqQok23rMqy6XgrDn7jVmoPzMe9vxkPPUF9r2lNOZ36yiG1CHYtCLakRLpkzPMkwbhohh_nx3VPb8Yk8UAxWQilqDo2eLyxb2N7hq3408yGKjSSyiMrmvwL/s431/3_MySQL_connect_with_mysql.connector_Output.jpeg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;MySQL Connect using mysql.connector&quot; border=&quot;0&quot; data-original-height=&quot;132&quot; data-original-width=&quot;431&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZIwQAi99__laKvmSiK2s-OeqQok23rMqy6XgrDn7jVmoPzMe9vxkPPUF9r2lNOZ36yiG1CHYtCLakRLpkzPMkwbhohh_nx3VPb8Yk8UAxWQilqDo2eLyxb2N7hq3408yGKjSSyiMrmvwL/s16000/3_MySQL_connect_with_mysql.connector_Output.jpeg&quot; title=&quot;Using mysql.connector in Python&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;&lt;div&gt;
In this given output, you can see, we show only second column data through “&lt;b&gt;mycol[1]&lt;/b&gt;” this code.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;&lt;b&gt;MySQL Column Value show through Column Name in Python in Listbox:&amp;nbsp;&lt;/b&gt;&lt;/h4&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;As you saw before, we are showing data through Column Number, but if we have more columns and want to show particular column value then we have to determine &lt;b&gt;Column Name&lt;/b&gt;.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So, through following way you can use to show column value through Column Name.
You have to add following code in cursor method.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding-left: 10px; padding: 10px 6px 10px 10px;&quot;&gt;mycursor = mydb.cursor(dictionary&lt;span style=&quot;color: #3d85c6;&quot;&gt;=True&lt;/span&gt;)
&lt;/pre&gt;
&lt;br /&gt;
Lets see with full details:
&lt;br /&gt;

&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding-left: 10px; padding: 10px 6px 10px 10px;&quot;&gt;&lt;span style=&quot;color: #a64d79;&quot;&gt;import&lt;/span&gt; mysql.connector
&lt;span style=&quot;color: #a64d79;&quot;&gt;import&lt;/span&gt; tkinter &lt;span style=&quot;color: #a64d79;&quot;&gt;as&lt;/span&gt; mytk
&lt;span style=&quot;color: #a64d79;&quot;&gt;from&lt;/span&gt; tkinter &lt;span style=&quot;color: #a64d79;&quot;&gt;import&lt;/span&gt; *

MytkForm2 = mytk.Tk()&lt;br /&gt;MytkForm2.title(&lt;span style=&quot;color: #cc0000;&quot;&gt;&#39;MySQL with mysql.connector&#39;&lt;/span&gt;)
MytkForm2.geometry(&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;270x120&quot;&lt;/span&gt;)

MyListData= mytk.Listbox(MytkForm2)&lt;br /&gt;mydb = mysql.connector.connect(&lt;span style=&quot;color: #0b5394;&quot;&gt;host=&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;XXX.XXX.XXX.XX&quot;&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;user=&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;sko&quot;&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;password=&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;mypassword&lt;/span&gt;&quot;, &lt;span style=&quot;color: #0b5394;&quot;&gt;database=&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;mydatabase&quot;&lt;/span&gt;)

&lt;span style=&quot;color: #6aa84f;&quot;&gt;#Fetch Particular Column Value through Column name with using dictionary&lt;/span&gt;
mycursor = mydb.cursor(dictionary&lt;span style=&quot;color: #0b5394;&quot;&gt;=True&lt;/span&gt;)

mycursor.execute(&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;SELECT * FROM TestTable&quot;&lt;/span&gt;)
myresult = mycursor.fetchall()
&lt;span style=&quot;color: #a64d79;&quot;&gt;for&lt;/span&gt; MyColName &lt;span style=&quot;color: #a64d79;&quot;&gt;in&lt;/span&gt; myresult:
    MyListData.insert(END, MyColName [&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;MyDetails&quot;&lt;/span&gt;]) 
mydb.close()
mycursor.close() 
MyListData.pack()

MytkForm2.mainloop()
&lt;/pre&gt;
&lt;br /&gt;
Now, This will Show output according to Column Name.
&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZW4ITFNYIhQHfCDglcQ6cPR4Ah4Z_-r-25Xbsx_K2GM2ARWVxyu4G6fPP6KgIILwVkyb_UsjLSebHSNRTNDPuic-ZMf0sFj8DLJ8IZcP97PNKWSujizSZ6j4_6NQ538a7X9QSujige_5Q/s622/4_MySQL_Data_in+ListBox+using+column+name+in+python.jpeg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;MySQL Data in ListBox using column name in python&quot; border=&quot;0&quot; data-original-height=&quot;141&quot; data-original-width=&quot;622&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZW4ITFNYIhQHfCDglcQ6cPR4Ah4Z_-r-25Xbsx_K2GM2ARWVxyu4G6fPP6KgIILwVkyb_UsjLSebHSNRTNDPuic-ZMf0sFj8DLJ8IZcP97PNKWSujizSZ6j4_6NQ538a7X9QSujige_5Q/s16000/4_MySQL_Data_in+ListBox+using+column+name+in+python.jpeg&quot; title=&quot;Database record through Column name in python&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 16px;&quot;&gt;&lt;b&gt;(3). Using Pymysql for MYSQL Connection&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;
You can use another connector in python that&#39;s call &lt;b&gt;pymysql&lt;/b&gt;. First you have to &lt;a href=&quot;https://pypi.org/project/PyMySQL/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;install pymysql&lt;/a&gt;. After that you have to use following connection string.
&lt;br /&gt;

&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding-left: 10px; padding: 10px 6px 10px 10px;&quot;&gt;pymysql.connect(&lt;span style=&quot;color: #0b5394;&quot;&gt;host=&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;XXX.XXX.XXX.XX&quot;&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;user=&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;MySQLUsername&quot;&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;password=&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;MYSQLPassword&quot;&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;database=&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;MYSQLDatabase&quot;&lt;/span&gt;)
&lt;/pre&gt;
&lt;br /&gt;
Then write following code to show data in Python.
&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding-left: 10px; padding: 10px 6px 10px 10px;&quot;&gt;&lt;span style=&quot;color: #a64d79;&quot;&gt;import&lt;/span&gt; pymysql

&lt;span style=&quot;color: #6aa84f;&quot;&gt;# database connectionstring&lt;/span&gt;
connmysql = pymysql.connect(&lt;span style=&quot;color: #0b5394;&quot;&gt;host=&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;XXX.XXX.XXX.XX&quot;&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;user=&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;sko&quot;&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;password=&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;mypassword&quot;&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;database=&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;mydatabase&quot;&lt;/span&gt;)
cursordb = connmysql.cursor()

&lt;span style=&quot;color: #6aa84f;&quot;&gt;# execute your query through execute().&lt;/span&gt;
cursordb.execute(&lt;span style=&quot;color: #cc0000;&quot;&gt;&quot;SELECT * FROM TestTable&quot;&lt;/span&gt;)

&lt;span style=&quot;color: #6aa84f;&quot;&gt;# get all row through fetchall().&lt;/span&gt;
data = cursordb.fetchall()
&lt;span style=&quot;color: #a64d79;&quot;&gt;for&lt;/span&gt; colnm &lt;span style=&quot;color: #a64d79;&quot;&gt;in&lt;/span&gt; data:
    print(colnm[&lt;span style=&quot;color: #6aa84f;&quot;&gt;0&lt;/span&gt;])

&lt;span style=&quot;color: #6aa84f;&quot;&gt;# close connection&lt;/span&gt;
connmysql.close()
&lt;/pre&gt;
&lt;br /&gt;&lt;div&gt;&lt;b&gt;&lt;u&gt;OUTPUT:&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9NGuJiW6QmM_tTaCI-NaZEe-xQnyF_7mfk6I4zTBmL3addEQ5aMMgkLtfUn-aT5L_fwhnZzxpvRxt6lbhDJwPO9cHaRLJRRewGkWRSmKTatKgtIjfmpuZ84hcacz5t_M3CXb_d2yRikyC/s119/5_MySQL_connect_To_Pymysql_With_Output.jpeg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;119&quot; data-original-width=&quot;104&quot; height=&quot;200&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9NGuJiW6QmM_tTaCI-NaZEe-xQnyF_7mfk6I4zTBmL3addEQ5aMMgkLtfUn-aT5L_fwhnZzxpvRxt6lbhDJwPO9cHaRLJRRewGkWRSmKTatKgtIjfmpuZ84hcacz5t_M3CXb_d2yRikyC/w175-h200/5_MySQL_connect_To_Pymysql_With_Output.jpeg&quot; width=&quot;175&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;border-radius: 10px; border: 1px solid rgb(255, 245, 238); box-shadow: rgb(253, 238, 244) 3px 3px; padding: 8px;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;b&gt;
Conclusion:&lt;/b&gt; &lt;/span&gt;You can use any one of these method. You will find some performance differences. But you will find exact result using any connector in python.&lt;/div&gt;
&lt;br /&gt;
So, this way you can&lt;b&gt; Connect MYSQL in Python &lt;/b&gt;with step by step process.</description><link>https://www.skotechlearn.com/2021/04/mysql-connection-in-python.html</link><author>noreply@blogger.com (SKOTechLearn)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqPvbEIMm9OQFyI6fNFCMTVhgXlgeUHA9ngouJ6IeoJ0zXTVailXDvwm7ppy8cKDbStFBEmt5r_eYnbMTKSXmaQGBWx7ZeCrG9PrSi9_3BLekLf2W2E1wEl7_OSLRxqRPaQ5g5KzPCIVYz/s72-c/1_MySQL_connect_To_Pyodbc_With_Output.jpeg" height="72" width="72"/><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2258844867892945003.post-8373049960948712251</guid><pubDate>Sat, 27 Mar 2021 20:29:00 +0000</pubDate><atom:updated>2021-03-27T13:29:02.464-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Tips And Tricks</category><title>How to Make Image Selected Area Transparent in Gimp</title><description>&lt;p&gt;In this post SKOTechLearn will describe How to Make Image &lt;b&gt;Selected Area Transparent in GIMP&lt;/b&gt; or &lt;b&gt;Image Selected Area Transparent in GIMP&lt;/b&gt;. As you know GIMP provide image processing of all kind of image formats. You can modify, beautify and change format of image through this application.&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyXCyWH_tc35MyEKaGH7kD5is_ymZJphNN4mW_eLllxbCNtjZnetYu8wGot_vsykK1_ZBRyZq7wZhpyzZUg0dzIbutv2ZXo-7nCzzaGRFTVnMXsdaxuxsD8Y7P7vnmghbUHj4PuLaQzvXB/s433/1_Selected_Area_transparent_in_Gimp_mini.jpeg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Selected Area Transparent in Gimp&quot; border=&quot;0&quot; data-original-height=&quot;346&quot; data-original-width=&quot;433&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyXCyWH_tc35MyEKaGH7kD5is_ymZJphNN4mW_eLllxbCNtjZnetYu8wGot_vsykK1_ZBRyZq7wZhpyzZUg0dzIbutv2ZXo-7nCzzaGRFTVnMXsdaxuxsD8Y7P7vnmghbUHj4PuLaQzvXB/s16000/1_Selected_Area_transparent_in_Gimp_mini.jpeg&quot; title=&quot;Image Selected Area Transparent in Gimp&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;Here, we will describe three way to make area transparent in &lt;b&gt;GIMP&lt;/b&gt;. You just follow the steps described bellow with following points:&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;b&gt;
&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Use ‘Rectangle Select Tool’&amp;nbsp;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhty-1MKjXPvGJY4eaMGwPyEnrd2ycLefA0FsCsRVYvf48qp1xlmiiA813U-bPKZNQwyvASBzbSkQeCJCuw9OgKOCfZk1tik7_h5VYAeYShZdPyFkC1vuCHm4_T4JDZ1a9NVx2ks9WS6x5O/s34/Rectangle+Select+Tool.jpeg&quot; style=&quot;clear: left; display: inline; margin-bottom: 0em; margin-right: 0em; text-align: center;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;26&quot; data-original-width=&quot;34&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhty-1MKjXPvGJY4eaMGwPyEnrd2ycLefA0FsCsRVYvf48qp1xlmiiA813U-bPKZNQwyvASBzbSkQeCJCuw9OgKOCfZk1tik7_h5VYAeYShZdPyFkC1vuCHm4_T4JDZ1a9NVx2ks9WS6x5O/s0/Rectangle+Select+Tool.jpeg&quot; /&gt;&lt;/a&gt;To Make Selected Area Transparent&lt;/li&gt;
&lt;/b&gt;  &lt;b&gt;
&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Use ‘Free Select Tool’&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDg_zDHdbpo3a5-ufDH9nnNNDXnj6OW_3o_k82SJ3GFRqRkb7xtVph82ma5ao0oZ9qPCvX8XzMqv_MN0MVs_EhK34WxpOTBBJrB5VnYJg8KPtk_0yz7F0qc-XpeN0vhpJQiafDsQeF4mDF/s34/Free+Select+Tool.jpeg&quot; style=&quot;margin-left: 0em; margin-right: 0em; text-align: center;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;26&quot; data-original-width=&quot;34&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDg_zDHdbpo3a5-ufDH9nnNNDXnj6OW_3o_k82SJ3GFRqRkb7xtVph82ma5ao0oZ9qPCvX8XzMqv_MN0MVs_EhK34WxpOTBBJrB5VnYJg8KPtk_0yz7F0qc-XpeN0vhpJQiafDsQeF4mDF/s0/Free+Select+Tool.jpeg&quot; /&gt;&lt;/a&gt;To Make Selected Area Transparent&lt;/li&gt;
  &lt;/b&gt;  &lt;b&gt;
&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Use ‘Eraser Tool’&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNJD_eKzzQQtes4CxKHZszzYnqGGCgeaWQVGlVUCCnJtfQi3zAuGg70irKGnwQSBakovfa96e-jQMQrZqGwcyZnGmRqTnTM0ZQcTCRllv6ulj9utX2a4MrLcVtBZaLS-FZMaY3VVFB1auj/s34/Eraser+Tool.jpeg&quot; style=&quot;clear: left; display: inline; margin-bottom: 0em; margin-right: 0em; text-align: center;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;26&quot; data-original-width=&quot;34&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNJD_eKzzQQtes4CxKHZszzYnqGGCgeaWQVGlVUCCnJtfQi3zAuGg70irKGnwQSBakovfa96e-jQMQrZqGwcyZnGmRqTnTM0ZQcTCRllv6ulj9utX2a4MrLcVtBZaLS-FZMaY3VVFB1auj/s0/Eraser+Tool.jpeg&quot; /&gt;&lt;/a&gt;To Make Selected Area Transparent&lt;/li&gt;
&lt;/b&gt; &lt;/ol&gt;&lt;div&gt;&lt;br /&gt;

So, First Open your Image in Gimp. Then proceed with following way:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); line-height: 25px; padding: 2px 4px;&quot;&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 16px;&quot;&gt;&lt;b&gt;(1). Use ‘Rectangle Select Tool’ To Make Selected Area Transparent :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;
If you want to use ‘&lt;b&gt;Rectangle Select Tool&lt;/b&gt;’, you have to follow the steps in GIMP.
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: paleturquoise; border-radius: 3px; border: 2px solid rgb(204, 204, 204); float: left; width: 21px;&quot;&gt;&amp;nbsp;&lt;b&gt;1.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;Right click on Image in Gimp.&lt;br /&gt;&lt;br /&gt;
&lt;div style=&quot;background-color: paleturquoise; border-radius: 3px; border: 2px solid rgb(204, 204, 204); float: left; width: 21px;&quot;&gt;&amp;nbsp;&lt;b&gt;2.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;A drop down menu will appear, Go to ‘&lt;b&gt;Layer&lt;/b&gt;’ option.&lt;br /&gt;&lt;br /&gt;
&lt;div style=&quot;background-color: paleturquoise; border-radius: 3px; border: 2px solid rgb(204, 204, 204); float: left; width: 21px;&quot;&gt;&amp;nbsp;&lt;b&gt;3.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;In ‘&lt;b&gt;Layer&lt;/b&gt;’, go to ‘&lt;b&gt;Transparency&lt;/b&gt;’ option.&lt;br /&gt;&lt;br /&gt;
&lt;div style=&quot;background-color: paleturquoise; border-radius: 3px; border: 2px solid rgb(204, 204, 204); float: left; width: 21px;&quot;&gt;&amp;nbsp;&lt;b&gt;4.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;Then Select ‘&lt;b&gt;Add Alpha Channel&lt;/b&gt;’.&lt;br /&gt;&lt;br /&gt; 

Let&#39;s see the instruction given in following figure.&lt;div&gt;&lt;br /&gt;&amp;nbsp;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh35rNdvaQInYes3LAu7P4VbVO41iRWCm6b9vrbs2JmUhHBuWkqXbMhoMWb04q9wJeDCCdsQVeVVnyRiB3O94PCSksnRn6l9PfZdq-VNbwWCpt0lmmXT2Flf44QvpvGsXZETVEnMUhBkcGJ/s630/2_Add_Alpha_Chanel_In_Gimp_Mini.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Add Alpha Chanel In Gimp&quot; border=&quot;0&quot; data-original-height=&quot;310&quot; data-original-width=&quot;630&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh35rNdvaQInYes3LAu7P4VbVO41iRWCm6b9vrbs2JmUhHBuWkqXbMhoMWb04q9wJeDCCdsQVeVVnyRiB3O94PCSksnRn6l9PfZdq-VNbwWCpt0lmmXT2Flf44QvpvGsXZETVEnMUhBkcGJ/s16000/2_Add_Alpha_Chanel_In_Gimp_Mini.jpg&quot; title=&quot;Add Alpha Chanel In Gimp for Transparency&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div style=&quot;background-color: paleturquoise; border-radius: 3px; border: 2px solid rgb(204, 204, 204); float: left; width: 21px;&quot;&gt;&amp;nbsp;&lt;b&gt;5.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;After that select ‘&lt;b&gt;Rectangle Select Tool&lt;/b&gt;’ from ‘&lt;b&gt;Tools&lt;/b&gt;’.&lt;br /&gt;&lt;br /&gt;
&lt;div style=&quot;background-color: paleturquoise; border-radius: 3px; border: 2px solid rgb(204, 204, 204); float: left; width: 21px;&quot;&gt;&amp;nbsp;&lt;b&gt;6.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;Now, select area where you want to make selection transparent.&lt;br /&gt;&lt;br /&gt;
&lt;div style=&quot;background-color: paleturquoise; border-radius: 3px; border: 2px solid rgb(204, 204, 204); float: left; width: 21px;&quot;&gt;&amp;nbsp;&lt;b&gt;7.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;And Press ‘&lt;b&gt;Delete&lt;/b&gt;’ from Keyboard.&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWlQB9encyf_FbuE2LViUAIoFjO7WeOyOUC6FpvTRcBEPQSQeJn7tg-1SzmlljDJ4UNSJ__MHmZNUcLIY0svQ5jR1tg9CwctePNQBIhf0y9rXhsGCBlu26SNMnVEcnvKZWjNa9NunjZayQ/s539/3_Select_Tool_For_Selection_Transparent_in_Gimp.jpeg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Select Tool For Selection Transparent in Gimp&quot; border=&quot;0&quot; data-original-height=&quot;261&quot; data-original-width=&quot;539&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWlQB9encyf_FbuE2LViUAIoFjO7WeOyOUC6FpvTRcBEPQSQeJn7tg-1SzmlljDJ4UNSJ__MHmZNUcLIY0svQ5jR1tg9CwctePNQBIhf0y9rXhsGCBlu26SNMnVEcnvKZWjNa9NunjZayQ/s16000/3_Select_Tool_For_Selection_Transparent_in_Gimp.jpeg&quot; title=&quot;Select Tool For Selection Transparent in Gimp&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt; 


Now, let&#39;s proceed to second process.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&amp;nbsp;

&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); line-height: 25px; padding: 2px 4px;&quot;&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 16px;&quot;&gt;&lt;b&gt;(2). Use ‘Free Select Tool’ To Make Selected Area Transparent :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;/div&gt;
Like above given Points for ‘&lt;b&gt;Add Alpha Channel&lt;/b&gt;’. You have to do same in this process.&amp;nbsp;&lt;div&gt;&lt;br /&gt;&lt;div&gt;&lt;b&gt;&amp;nbsp;(Right Click) Image &lt;span style=&quot;background-color: #fce5cd;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; “Layer” &lt;span style=&quot;background-color: #fce5cd;&quot;&gt;&amp;gt;&amp;gt; &lt;/span&gt;“Transparency” &lt;span style=&quot;background-color: #fce5cd;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; “Add Alpha Channel”&amp;nbsp;&lt;/b&gt;&lt;div&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: #e7e7fb; border-radius: 3px; border: 2px solid rgb(204, 204, 204); float: left; width: 21px;&quot;&gt;&amp;nbsp;&lt;b&gt;1.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;After this Process, you have to go to ‘&lt;b&gt;Tools&lt;/b&gt;’ window and select ‘&lt;b&gt;Free Select Tool&lt;/b&gt;’.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: #e7e7fb; border-radius: 3px; border: 2px solid rgb(204, 204, 204); float: left; width: 21px;&quot;&gt;&amp;nbsp;&lt;b&gt;2.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;Then point on area which you want to make transparent.&lt;br /&gt;&lt;br /&gt;
&lt;div style=&quot;background-color: #e7e7fb; border-radius: 3px; border: 2px solid rgb(204, 204, 204); float: left; width: 21px;&quot;&gt;&amp;nbsp;&lt;b&gt;3.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;And then join start and end point of ‘&lt;b&gt;Free Select Tool&lt;/b&gt;’ then Press ‘&lt;b&gt;Delete&lt;/b&gt;’ Button from Keyboard.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiq1sHzcJ_5hbZbXdFjdXikxziSskWwbcWPVAXlAaNlZjvQWd1he4g1nnWdr1lly3HKd-XxmTLWK71TYzPWWQKa8KIHo83Gxi_FUljDsAehmIf9TAvRw7K5ymfUyDyQOELJ1P4ZIR-tezb8/s522/4_Free_Select_Tool_For_Selection_Transparent_in_Gimp.jpeg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;274&quot; data-original-width=&quot;522&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiq1sHzcJ_5hbZbXdFjdXikxziSskWwbcWPVAXlAaNlZjvQWd1he4g1nnWdr1lly3HKd-XxmTLWK71TYzPWWQKa8KIHo83Gxi_FUljDsAehmIf9TAvRw7K5ymfUyDyQOELJ1P4ZIR-tezb8/s16000/4_Free_Select_Tool_For_Selection_Transparent_in_Gimp.jpeg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;
&lt;br /&gt;
This will make desire area transparent.&lt;div&gt;&lt;br /&gt;&amp;nbsp;

&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); line-height: 25px; padding: 2px 4px;&quot;&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 16px;&quot;&gt;&lt;b&gt;(3). Use ‘Eraser Tool’  To Make Selected Area Transparent :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;
Same way you have to select ‘&lt;b&gt;Add Alpha Channel&lt;/b&gt;’ like first process.&lt;div&gt;&lt;br /&gt;&lt;b&gt;
(Right Click) Image&lt;span style=&quot;background-color: #fce5cd;&quot;&gt; &amp;gt;&amp;gt;&lt;/span&gt; “Layer” &lt;span style=&quot;background-color: #fce5cd;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; “Transparency” &lt;span style=&quot;background-color: #fce5cd;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; “Add Alpha Channel”&amp;nbsp;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;div style=&quot;background-color: #e5c4e3; border-radius: 3px; border: 2px solid rgb(204, 204, 204); float: left; width: 21px;&quot;&gt;&amp;nbsp;&lt;b&gt;1.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;After that Select ‘&lt;b&gt;Eraser Tool&lt;/b&gt;’.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: #e5c4e3; border-radius: 3px; border: 2px solid rgb(204, 204, 204); float: left; width: 21px;&quot;&gt;&amp;nbsp;&lt;b&gt;2.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;Then go to ‘&lt;b&gt;Eraser Tool&lt;/b&gt;’ &lt;b&gt;Properties&lt;/b&gt; and Increase or decrease &lt;b&gt;Eraser&lt;/b&gt; ‘&lt;b&gt;Size&lt;/b&gt;’ according to area selection.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: #e5c4e3; border-radius: 3px; border: 2px solid rgb(204, 204, 204); float: left; width: 21px;&quot;&gt;&amp;nbsp;&lt;b&gt;3.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;Then click on area of Image.&lt;br /&gt;
&lt;br /&gt;
 
This will make eraser area transparent.

&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjKPvrseCymzS3n4b2JuKEbi0FZdF0uxll-YXzAWPPqw0n8teTp4OZPVjKPCW-UuHB727sOGbuTtLCOPpRnH9tMP-8TxchDp3qmlEn654O0fQv-OPj_YP84GrNJetoNTDaSikQzgAykzpG/s550/5_Eraser_Tool_For_Selection_Transparent_in_Gimp.jpeg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Eraser Tool For Selection Transparent in Gimp&quot; border=&quot;0&quot; data-original-height=&quot;348&quot; data-original-width=&quot;550&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjKPvrseCymzS3n4b2JuKEbi0FZdF0uxll-YXzAWPPqw0n8teTp4OZPVjKPCW-UuHB727sOGbuTtLCOPpRnH9tMP-8TxchDp3qmlEn654O0fQv-OPj_YP84GrNJetoNTDaSikQzgAykzpG/s16000/5_Eraser_Tool_For_Selection_Transparent_in_Gimp.jpeg&quot; title=&quot;Eraser Tool For Selection Transparent in Gimp&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

&lt;div style=&quot;background-color: #f9ffec; border-radius: 3px; border: 2px solid rgb(178, 154, 148); line-height: 25px; padding: 3px 4px;&quot;&gt;
&lt;span style=&quot;color: #a64d79; font-size: 16px;&quot;&gt;&lt;i&gt;&lt;b&gt;Note:&lt;/b&gt; If you want to increase or decrease transparency level, you have  to simply go to ‘&lt;b&gt;Eraser&lt;/b&gt;’ tool’s Properties window and Increase or decrease ‘Opacity’ from 0 to 100%.&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;


This is the simplest and easy way to manually select area and make it transparent.&amp;nbsp;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In Gimp, you will find many other tools that provide facility to&lt;b&gt; transparent selected part in GIMP&lt;/b&gt;.

So, this way you can make &lt;b&gt;Image Selected Area transparent in GIMP&lt;/b&gt; with SKOTechLearn easy tips.
&lt;/div&gt;</description><link>https://www.skotechlearn.com/2021/03/image-selected-area-transparent-gimp.html</link><author>noreply@blogger.com (SKOTechLearn)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyXCyWH_tc35MyEKaGH7kD5is_ymZJphNN4mW_eLllxbCNtjZnetYu8wGot_vsykK1_ZBRyZq7wZhpyzZUg0dzIbutv2ZXo-7nCzzaGRFTVnMXsdaxuxsD8Y7P7vnmghbUHj4PuLaQzvXB/s72-c/1_Selected_Area_transparent_in_Gimp_mini.jpeg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2258844867892945003.post-2873396235186933081</guid><pubDate>Thu, 25 Mar 2021 07:29:00 +0000</pubDate><atom:updated>2022-06-21T14:16:27.947-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Python</category><title>Add Itmes in ComboBox in Tkinter Python with Loop Example</title><description>&lt;p&gt;Here, we will discuss and Learn about &lt;b&gt;Tkinter Combobox in Python&lt;/b&gt;. Here we will learn how to Add &lt;b&gt;Items in Combobox in Tkinter &lt;/b&gt;or &lt;b&gt;Add Items in ComboBox in Tkinter through Loop in Python&lt;/b&gt;. So, we will proceed with step by step Process with following points.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;


&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;b&gt;
&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Manually Add Items in ComboBox Tkinter in python&lt;/li&gt;
&lt;/b&gt;  &lt;b&gt;
&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Add Items in ComboBox Tkinter in python through Loop&lt;/li&gt;
&lt;/b&gt; &lt;/ol&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

Now, lets Learn point wise given bellow.&lt;div&gt;&lt;br /&gt;&lt;b&gt;&lt;a href=&quot;https://www.skotechlearn.com/2020/08/get-tkinter-entry-or-text-value-in-python.html&quot; target=&quot;_blank&quot;&gt;&amp;nbsp;How To Get value From Textbox to Label in Tkinter in Python?&lt;/a&gt;&lt;/b&gt;&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); line-height: 25px; padding: 2px 4px;&quot;&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 16px;&quot;&gt;&lt;b&gt;(1). Manually Add Items in ComboBox Tkinter in python :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;/div&gt;
If you want to add items in design time or manually then you have to write following code in Python. Tkinter provide ttk class to show combobox and its attributes. 
So, Manually add items process code in tkinter described in following way:

&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding-left: 10px; padding: 10px 6px 10px 10px;&quot;&gt;&lt;span style=&quot;color: #a64d79;&quot;&gt;import&lt;/span&gt; tkinter &lt;span style=&quot;color: #a64d79;&quot;&gt;as&lt;/span&gt; tk
&lt;span style=&quot;color: #a64d79;&quot;&gt;from&lt;/span&gt; tkinter &lt;span style=&quot;color: #a64d79;&quot;&gt;import&lt;/span&gt; *
&lt;span style=&quot;color: #a64d79;&quot;&gt;from&lt;/span&gt; tkinter &lt;span style=&quot;color: #a64d79;&quot;&gt;import&lt;/span&gt; ttk

MyrootDialog = tk.Tk(&lt;span style=&quot;color: #3d85c6;&quot;&gt;className&lt;/span&gt;=&lt;span style=&quot;color: #e06666;&quot;&gt;&quot;Add Items in Tkinter Combobox&quot;&lt;/span&gt;)
&lt;span style=&quot;color: #38761d;&quot;&gt;#Set Tkinter window Size&lt;/span&gt;
MyrootDialog.geometry(&lt;span style=&quot;color: #e06666;&quot;&gt;&quot;300x100&quot;&lt;/span&gt;)

mytkcombo = ttk.Combobox(MyrootDialog, &lt;span style=&quot;color: #3d85c6;&quot;&gt;values&lt;/span&gt;=[&lt;span style=&quot;color: #e06666;&quot;&gt;&#39;SKO&#39;&lt;/span&gt;, &lt;span style=&quot;color: #e06666;&quot;&gt;&#39;Tech&#39;&lt;/span&gt;, &lt;span style=&quot;color: #e06666;&quot;&gt;&#39;Learn&#39;&lt;/span&gt;])
&lt;span style=&quot;color: #38761d;&quot;&gt;#Set Combobox Position in Python&lt;/span&gt;
mytkcombo.place(&lt;span style=&quot;color: #3d85c6;&quot;&gt;relx&lt;/span&gt;=0.5, &lt;span style=&quot;color: #3d85c6;&quot;&gt;rely&lt;/span&gt;=0.3, &lt;span style=&quot;color: #3d85c6;&quot;&gt;anchor&lt;/span&gt;=&lt;span style=&quot;color: #e06666;&quot;&gt;&#39;center&#39;&lt;/span&gt;)
mytkcombo[&lt;span style=&quot;color: #e06666;&quot;&gt;&#39;state&#39;&lt;/span&gt;] = &lt;span style=&quot;color: #e06666;&quot;&gt;&#39;readonly&#39;&lt;/span&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;#mycombo.pack()&lt;/span&gt;

MyrootDialog.mainloop()
&lt;/pre&gt;

When you run this code, this will show you following output.
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGtQaFG8MuGPeUl_vM-xdEEpxdyKdolvXVCPKSlOvESTBlY2DGUvPCyp3HKx3mC8SPMRIG0Yud9d8zwNn8Di5aRbuP_T2xscypinOoSzfS_N5qWgYLlOJUpAVs97VA2EpDpIRS-FCjiuTc/s733/1_Static+way+to+show+items+in+combobox_In_Tkinter.jpeg&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;Manually Show items in Combobox Tkinter&quot; border=&quot;0&quot; data-original-height=&quot;173&quot; data-original-width=&quot;733&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGtQaFG8MuGPeUl_vM-xdEEpxdyKdolvXVCPKSlOvESTBlY2DGUvPCyp3HKx3mC8SPMRIG0Yud9d8zwNn8Di5aRbuP_T2xscypinOoSzfS_N5qWgYLlOJUpAVs97VA2EpDpIRS-FCjiuTc/s16000/1_Static+way+to+show+items+in+combobox_In_Tkinter.jpeg&quot; title=&quot;Show items in Combobox Tkinter Python&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;i&gt;&lt;span style=&quot;color: #741b47;&quot;&gt;Items in Tkinter ComboBox in Python&lt;/span&gt;&lt;/i&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

So, In this way you can add items in ComboBox tkinter in Python through static way. Now let’s Learn about dynamic way at run time.&lt;div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&amp;nbsp;&lt;b&gt;&lt;a href=&quot;https://www.skotechlearn.com/2020/08/string-in-python-and-concatenate-format-python.html&quot; target=&quot;_blank&quot;&gt;How to Use String and How to Concatenate String in Python with Example?&lt;/a&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); line-height: 25px; padding: 2px 4px;&quot;&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 16px;&quot;&gt;&lt;b&gt;(2). Add Items in ComboBox Tkinter in python through Loop :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;

Now, if You want to add itmes in tkinter combobox at runtime with loop or loop to add items in tkinter combobox in python, you have to implement some code in python like bellow:&amp;nbsp;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;u&gt;Example 1:

&lt;/u&gt;&lt;/b&gt;&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding-left: 10px; padding: 10px 6px 10px 10px;&quot;&gt;&lt;span style=&quot;color: #a64d79;&quot;&gt;import&lt;/span&gt; tkinter &lt;span style=&quot;color: #a64d79;&quot;&gt;as&lt;/span&gt; tk
&lt;span style=&quot;color: #a64d79;&quot;&gt;from&lt;/span&gt; tkinter &lt;span style=&quot;color: #a64d79;&quot;&gt;import&lt;/span&gt; *
&lt;span style=&quot;color: #a64d79;&quot;&gt;from&lt;/span&gt; tkinter &lt;span style=&quot;color: #a64d79;&quot;&gt;import&lt;/span&gt; ttk

MyrootDialog = tk.Tk(&lt;span style=&quot;color: #3d85c6;&quot;&gt;className&lt;/span&gt;=&lt;span style=&quot;color: #e06666;&quot;&gt;&quot;Add Items in Tkinter Combobox&quot;&lt;/span&gt;)
&lt;span style=&quot;color: #6aa84f;&quot;&gt;#Set Tkinter window Size&lt;/span&gt;
MyrootDialog.geometry(&lt;span style=&quot;color: #e06666;&quot;&gt;&quot;300x100&quot;&lt;/span&gt;)

mytkcombo = ttk.Combobox(MyrootDialog)
&lt;span style=&quot;color: #6aa84f;&quot;&gt;# For Loop&lt;/span&gt;
&lt;span style=&quot;color: #a64d79;&quot;&gt;for&lt;/span&gt; x &lt;span style=&quot;color: #a64d79;&quot;&gt;in&lt;/span&gt; &lt;span style=&quot;color: #b45f06;&quot;&gt;range&lt;/span&gt;(5):
  &lt;span style=&quot;color: #6aa84f;&quot;&gt; # Add itmes in combobox through Loop code&lt;/span&gt;
   mytkcombo[&lt;span style=&quot;color: #e06666;&quot;&gt;&#39;values&#39;&lt;/span&gt;]= &lt;span style=&quot;color: #3d85c6;&quot;&gt;tuple&lt;/span&gt;(&lt;span style=&quot;color: #3d85c6;&quot;&gt;list&lt;/span&gt;(mytkcombo[&lt;span style=&quot;color: #e06666;&quot;&gt;&#39;values&#39;&lt;/span&gt;]) + [&lt;span style=&quot;color: #3d85c6;&quot;&gt;str&lt;/span&gt;(x)])
mytkcombo.place(&lt;span style=&quot;color: #3d85c6;&quot;&gt;relx&lt;/span&gt;=&lt;span style=&quot;color: #6aa84f;&quot;&gt;0.5&lt;/span&gt;, &lt;span style=&quot;color: #3d85c6;&quot;&gt;rely&lt;/span&gt;=&lt;span style=&quot;color: #6aa84f;&quot;&gt;0.3&lt;/span&gt;, &lt;span style=&quot;color: #3d85c6;&quot;&gt;anchor&lt;/span&gt;=&lt;span style=&quot;color: #e06666;&quot;&gt;&#39;center&#39;&lt;/span&gt;)

MyrootDialog.mainloop()

&lt;/pre&gt;&lt;/div&gt;


This is the dynamic way to show items in combobox at run time through loop. This will show following output:&lt;/div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbiwI4vUttcS9iukpXfg_mUw-5USYnR5s2JSwRUgm9IeK7BiZTZMZCG6PBgfs594uYuWDuCStctG2UOYDoIN4B_Ki5piu_zFBO8epJnqoFglxf0QPyQk2eowv6Ld3akqjUC-BB3Kjyc8ZF/s312/1_1_Show+Items+Through+Loop+In+ComboBox+in+Tkinter.jpg&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;Loop Items in ComboBox Tkinter&quot; border=&quot;0&quot; data-original-height=&quot;168&quot; data-original-width=&quot;312&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbiwI4vUttcS9iukpXfg_mUw-5USYnR5s2JSwRUgm9IeK7BiZTZMZCG6PBgfs594uYuWDuCStctG2UOYDoIN4B_Ki5piu_zFBO8epJnqoFglxf0QPyQk2eowv6Ld3akqjUC-BB3Kjyc8ZF/s16000/1_1_Show+Items+Through+Loop+In+ComboBox+in+Tkinter.jpg&quot; title=&quot;Add Items in Loop in ComboBox in Python&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;i&gt;&lt;span style=&quot;color: #a64d79;&quot;&gt;Loop Items in ComboBox&lt;/span&gt;&lt;/i&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Show Month in Combobox Tkinter through Loop&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;

&lt;b&gt;&lt;u&gt;Example 2:&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

Now, lets See another Example to showing month name in ComboBox through Loop . In this example we use array list to &lt;b&gt;add items in ComboBox Python&lt;/b&gt;.

&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding-left: 10px; padding: 10px 6px 10px 10px;&quot;&gt;&lt;span style=&quot;color: #a64d79;&quot;&gt;import&lt;/span&gt; tkinter &lt;span style=&quot;color: #a64d79;&quot;&gt;as&lt;/span&gt; tk
&lt;span style=&quot;color: #a64d79;&quot;&gt;from&lt;/span&gt; tkinter &lt;span style=&quot;color: #a64d79;&quot;&gt;import&lt;/span&gt; *
&lt;span style=&quot;color: #a64d79;&quot;&gt;from&lt;/span&gt; tkinter &lt;span style=&quot;color: #a64d79;&quot;&gt;import&lt;/span&gt; ttk
&lt;span style=&quot;color: #a64d79;&quot;&gt;import&lt;/span&gt; calendar

MyrootDialog = tk.Tk(&lt;span style=&quot;color: #3d85c6;&quot;&gt;className&lt;/span&gt;=&lt;span style=&quot;color: #e06666;&quot;&gt;&quot;Add Items in Tkinter Combobox&quot;&lt;/span&gt;)
&lt;span style=&quot;color: #6aa84f;&quot;&gt;#Set Tkinter window Size&lt;/span&gt;
MyrootDialog.geometry(&lt;span style=&quot;color: #e06666;&quot;&gt;&quot;300x100&quot;&lt;/span&gt;)

mytkcombo = ttk.Combobox(MyrootDialog)
&lt;span style=&quot;color: #6aa84f;&quot;&gt;# Define Array List&lt;/span&gt;
strList=[&lt;span style=&quot;color: #e06666;&quot;&gt;&#39;&#39;&lt;/span&gt;]
&lt;span style=&quot;color: #a64d79;&quot;&gt;for&lt;/span&gt; mnt &lt;span style=&quot;color: #a64d79;&quot;&gt;in&lt;/span&gt; &lt;span style=&quot;color: #b45f06;&quot;&gt;range&lt;/span&gt;(1, 13):
   &lt;span style=&quot;color: #6aa84f;&quot;&gt;#Add Month Name through Loop&lt;/span&gt;
   strList.append(calendar.month_name[mnt])
&lt;span style=&quot;color: #6aa84f;&quot;&gt;#Add Items in Tkinter Combobox through Array&lt;/span&gt;
mytkcombo[&lt;span style=&quot;color: #e06666;&quot;&gt;&#39;values&#39;&lt;/span&gt;] = strList
mytkcombo.place(&lt;span style=&quot;color: #3d85c6;&quot;&gt;relx&lt;/span&gt;=&lt;span style=&quot;color: #6aa84f;&quot;&gt;0.5&lt;/span&gt;, &lt;span style=&quot;color: #3d85c6;&quot;&gt;rely&lt;/span&gt;=&lt;span style=&quot;color: #6aa84f;&quot;&gt;0.3&lt;/span&gt;, &lt;span style=&quot;color: #3d85c6;&quot;&gt;anchor&lt;/span&gt;=&lt;span style=&quot;color: #e06666;&quot;&gt;&#39;center&#39;&lt;/span&gt;)

MyrootDialog.mainloop()

&lt;/pre&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;a href=&quot;https://www.skotechlearn.com/2020/05/if-else-statement-in-python.html&quot;&gt;Using If Else Statement in Python.&lt;/a&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

After running this code you will see the output like following way:

&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlmia79K42UY8kRy3PXkayDzNdAcxsFJtI_QfxhnCFW1ShSRewBHiaUpIvSfUOn2uNq-lbF8o1qmBJ4NZdTBi9sO8v2RB_GkpW3emwOvK9oW2ruiJPxI0GN63cTtKZiuuK-TT79dE2Tlac/s329/2_Show+Month+In+ComboBox+in+Tkinter.jpg&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;Show Month In ComboBox in Tkinter&quot; border=&quot;0&quot; data-original-height=&quot;274&quot; data-original-width=&quot;329&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlmia79K42UY8kRy3PXkayDzNdAcxsFJtI_QfxhnCFW1ShSRewBHiaUpIvSfUOn2uNq-lbF8o1qmBJ4NZdTBi9sO8v2RB_GkpW3emwOvK9oW2ruiJPxI0GN63cTtKZiuuK-TT79dE2Tlac/s16000/2_Show+Month+In+ComboBox+in+Tkinter.jpg&quot; title=&quot;Show Month In ComboBox in Tkinter Python&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;i&gt;&lt;span style=&quot;color: #741b47;&quot;&gt;Show Month Name in Tkinter ComboBox in Python&lt;/span&gt;&lt;/i&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;

So, these are the three way to show or &lt;b&gt;Add Items in Combobox in tkinter in Python&lt;/b&gt;, you can choose anyone according to your application or software requirement.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;a href=&quot;https://www.skotechlearn.com/2020/06/use-label-in-python-using-tkinter.html&quot; target=&quot;_blank&quot;&gt;Tkinter Label Features and Use Of Label in Python.&lt;/a&gt;&lt;/b&gt;&lt;/div&gt;</description><link>https://www.skotechlearn.com/2021/03/add-itmes-in-combobox-tkinter-python.html</link><author>noreply@blogger.com (SKOTechLearn)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGtQaFG8MuGPeUl_vM-xdEEpxdyKdolvXVCPKSlOvESTBlY2DGUvPCyp3HKx3mC8SPMRIG0Yud9d8zwNn8Di5aRbuP_T2xscypinOoSzfS_N5qWgYLlOJUpAVs97VA2EpDpIRS-FCjiuTc/s72-c/1_Static+way+to+show+items+in+combobox_In_Tkinter.jpeg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2258844867892945003.post-1589978030586970075</guid><pubDate>Wed, 19 Aug 2020 10:43:00 +0000</pubDate><atom:updated>2021-03-25T01:00:40.569-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Tips And Tricks</category><title>Steps to Change Dark Theme to Light Theme in Visual Studio Code</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
If you like &lt;b&gt;Light Theme in Code Editor in Visual Studio Code&lt;/b&gt; then here SKOTechLearn will describe the steps to Change &lt;b&gt;Dark Theme to Light Them in Visual Studio Code&lt;/b&gt;. And Here we will also describe the steps to &lt;b&gt;Customize Color or Theme in Visual Studio Code&lt;/b&gt;. &lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh98aqegFUAVE_8XGN3srYipZMksNxSVutTLlKGdGM__PptvvonR_SHDc9EpWWFw_Lr6ZC_xotQOeOIL5dvUOyXdhHxQrCYLs7S0Vj1BH2HL6hepBDWwlAL_Av7DIJNnJ9hjoJmKv0s7AY3/s1600/0.Dark+theme+to+Light+theme+in+visual+studio+code_Output_mini.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Dark theme to Light Theme in Visual Studio Code&quot; border=&quot;0&quot; data-original-height=&quot;290&quot; data-original-width=&quot;927&quot; height=&quot;200&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh98aqegFUAVE_8XGN3srYipZMksNxSVutTLlKGdGM__PptvvonR_SHDc9EpWWFw_Lr6ZC_xotQOeOIL5dvUOyXdhHxQrCYLs7S0Vj1BH2HL6hepBDWwlAL_Av7DIJNnJ9hjoJmKv0s7AY3/s640/0.Dark+theme+to+Light+theme+in+visual+studio+code_Output_mini.jpg&quot; title=&quot;Dark theme to Light Theme in Visual Studio Code&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
By default VS Code contain Dark theme. You know that Visual Studio is highly customized code editor compare to all other code editor. And you can find many feature to &lt;b&gt;change Look and Feel in Visual Studio Code&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Change visual studio code background color&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Now, we can choose any one process for &lt;b&gt;Change Code Editor Color in Visual Studio Code&lt;/b&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;b&gt;
&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Change Theme of Visual Studio Code through Shortcut Key&lt;/li&gt;
&lt;/b&gt;  &lt;b&gt;
&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Change Theme of Visual Studio Code through Settings&lt;/li&gt;
&lt;/b&gt;  &lt;b&gt;
&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Change Color Theme of Visual Studio Code through Code&lt;/li&gt;
&lt;/b&gt; &lt;/ol&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;
&lt;b&gt;(1). Change Theme of Visual Studio Code through Shortcut Key:&lt;/b&gt;&lt;/h2&gt;
When you open VSCode, and want to change theme, then simply you have to press two different shortcut Key one by one same time.&lt;br /&gt;
&lt;br /&gt;
Press First Shortcut Key:&amp;nbsp;&lt;b style=&quot;background-color: #0b5394;&quot;&gt;&lt;span style=&quot;color: yellow;&quot;&gt;&amp;nbsp;CTRL + K&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
After that Press second Shortcut Key: &lt;b style=&quot;background-color: #0b5394;&quot;&gt;&lt;span style=&quot;color: yellow;&quot;&gt;&amp;nbsp;CTRL + T&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Now, you will see a drop down Option Box “&lt;b&gt;Select Color Theme (Up/Down Keys To Preview)&lt;/b&gt;” will appear containing list of existing theme like bellow:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKtt3gMr5DOe_Kw3RP5nRuMDtu3ks5Z9Lpak9xKRWRyNvXPQMU33Zi-BGP2oWXCgKSv4LRMsjEnQvYiai33nnCUPOaO5ngBv1wLEmP9amJNc8WGVOsWSrdBJfIi8_9Bvmj-9pc8Tum0iQS/s1600/1.+Change+Visual+Studio+Theme+through+Shortcut+Key_Mini.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Change Theme in Visual Studio Code through Shortcut Key&quot; border=&quot;0&quot; data-original-height=&quot;321&quot; data-original-width=&quot;846&quot; height=&quot;242&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKtt3gMr5DOe_Kw3RP5nRuMDtu3ks5Z9Lpak9xKRWRyNvXPQMU33Zi-BGP2oWXCgKSv4LRMsjEnQvYiai33nnCUPOaO5ngBv1wLEmP9amJNc8WGVOsWSrdBJfIi8_9Bvmj-9pc8Tum0iQS/s640/1.+Change+Visual+Studio+Theme+through+Shortcut+Key_Mini.jpg&quot; title=&quot;Change Theme in Visual Studio Code through Shortcut Key&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
This Option Box contain two types of Theme Category first is “&lt;b&gt;light themes&lt;/b&gt;” and second is “&lt;b&gt;dark themes&lt;/b&gt;”. If you want to &lt;b&gt;change VSCode in light theme&lt;/b&gt;, then choose first category.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;
&lt;b&gt;(2). Change Color Theme of Visual Studio Code through Settings:&lt;/b&gt;&lt;/h2&gt;
If you want to proceed for color change through VSCode settings, then you have to follow the steps:&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: #8d3f88; border-radius: 12px; border: 1.4px solid rgb(98, 62, 96); color: white; float: left; font-family: verdana; font-size: 14px; margin: 0px 3px; text-align: center; width: 25px;&quot;&gt;
&lt;b&gt;1.&lt;/b&gt; &lt;/div&gt;
First Go to “&lt;b&gt;File&lt;/b&gt;” menu.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: #8d3f88; border-radius: 12px; border: 1.4px solid rgb(98, 62, 96); color: white; float: left; font-family: verdana; font-size: 14px; margin: 0px 3px; text-align: center; width: 25px;&quot;&gt;
&lt;b&gt;2.&lt;/b&gt; &lt;/div&gt;
Find “&lt;b&gt;Preferences&lt;/b&gt;” and select it.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: #8d3f88; border-radius: 12px; border: 1.4px solid rgb(98, 62, 96); color: white; float: left; font-family: verdana; font-size: 14px; margin: 0px 3px; text-align: center; width: 25px;&quot;&gt;
&lt;b&gt;3.&lt;/b&gt; &lt;/div&gt;
And then select “&lt;b&gt;Color Theme[Ctrl+K Ctrl+T]&lt;/b&gt;” option from it.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: #8d3f88; border-radius: 12px; border: 1.4px solid rgb(98, 62, 96); color: white; float: left; font-family: verdana; font-size: 14px; margin: 0px 3px; text-align: center; width: 25px;&quot;&gt;
&lt;b&gt;4.&lt;/b&gt; &lt;/div&gt;
Now, a drop down list will appear containing themes options. Choose anyone which you like.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgeEWhtsI_9BBw23ebXwYxV9t1weh1nxefxUfU3mPT-xoITTv8fhvzwZEuW-nG6odkxntxs8LJZAKkPA0gPdMhTYqhCpTuEyVWLoe4-bA2Pr_aiyCwbVAMJFAevprVtHkI7xQIdyqYB6CH/s1600/2.+Change+Color+Theme+of+Visual+Studio+Code+through+Settings_Min.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Settings to change Theme color in Visual Studio&quot; border=&quot;0&quot; data-original-height=&quot;521&quot; data-original-width=&quot;762&quot; height=&quot;436&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgeEWhtsI_9BBw23ebXwYxV9t1weh1nxefxUfU3mPT-xoITTv8fhvzwZEuW-nG6odkxntxs8LJZAKkPA0gPdMhTYqhCpTuEyVWLoe4-bA2Pr_aiyCwbVAMJFAevprVtHkI7xQIdyqYB6CH/s640/2.+Change+Color+Theme+of+Visual+Studio+Code+through+Settings_Min.jpg&quot; title=&quot;Change Theme Color of Visual Studio Code through Settings&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
As you can see, in this way you can &lt;b&gt;change Dark Theme to Light Theme in VSCode&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;
&lt;b&gt;(3). Change Color Theme of Visual Studio Code through Code:&lt;/b&gt;&lt;/h2&gt;
This is very interesting process to &lt;b&gt;Change Look and Feel Of Visual Studio Code&lt;/b&gt;. In this Process you can change every Part of VSCode Tool&#39;s color according to your desire. You have to Simply proceed with following way:&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: #335b4e; border-radius: 12px; border: 1.4px solid rgb(98, 62, 96); color: white; float: left; font-family: verdana; font-size: 14px; margin: 0px 3px; text-align: center; width: 25px;&quot;&gt;
&lt;b&gt;1.&lt;/b&gt; &lt;/div&gt;
Same as above given steps, you have to first go to “&lt;b&gt;File&lt;/b&gt;” menu then “&lt;b&gt;Preferences&lt;/b&gt;” then “&lt;b&gt;Settings&lt;/b&gt;”.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: #335b4e; border-radius: 12px; border: 1.4px solid rgb(98, 62, 96); color: white; float: left; font-family: verdana; font-size: 14px; margin: 0px 3px; text-align: center; width: 25px;&quot;&gt;
&lt;b&gt;2.&lt;/b&gt; &lt;/div&gt;
You will find “&lt;b&gt;Settings&lt;/b&gt;” Tab will appear. Go to &lt;b&gt;Search Bar&lt;/b&gt; and search for “&lt;b&gt;.json&lt;/b&gt;”.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: #335b4e; border-radius: 12px; border: 1.4px solid rgb(98, 62, 96); color: white; float: left; font-family: verdana; font-size: 14px; margin: 0px 3px; text-align: center; width: 25px;&quot;&gt;
&lt;b&gt;3.&lt;/b&gt; &lt;/div&gt;
You will get “&lt;b&gt;Edit in Settings.json&lt;/b&gt;” option. Just click on it.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: #335b4e; border-radius: 12px; border: 1.4px solid rgb(98, 62, 96); color: white; float: left; font-family: verdana; font-size: 14px; margin: 0px 3px; text-align: center; width: 25px;&quot;&gt;
&lt;b&gt;4.&lt;/b&gt; &lt;/div&gt;
Now “&lt;b&gt;Settings.json&lt;/b&gt;” file will display. Add color code like bellow:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;{
     &lt;span style=&quot;color: #990000;&quot;&gt;&quot;workbench.colorCustomizations&quot;: &lt;/span&gt;{
     &lt;span style=&quot;color: #38761d;&quot;&gt;//For Code editor Color Change&lt;/span&gt;
     &lt;span style=&quot;color: #0b5394;&quot;&gt;&quot;editor.background&quot;:&lt;/span&gt; &lt;span style=&quot;color: #990000;&quot;&gt;&quot;#edeafa&quot;&lt;/span&gt;,
     &lt;span style=&quot;color: #0b5394;&quot;&gt;&quot;editor.foreground&quot;:&lt;/span&gt; &lt;span style=&quot;color: #990000;&quot;&gt;&quot;#4b4548&quot;&lt;/span&gt;,

     &lt;span style=&quot;color: #38761d;&quot;&gt;//For Sidebar Color Change&lt;/span&gt;
     &lt;span style=&quot;color: #0b5394;&quot;&gt;&quot;sideBar.background&quot;:&lt;/span&gt; &lt;span style=&quot;color: #990000;&quot;&gt;&quot;#fddcaa&quot;&lt;/span&gt;,
     &lt;span style=&quot;color: #0b5394;&quot;&gt;&quot;sideBar.foreground&quot;:&lt;/span&gt; &lt;span style=&quot;color: #990000;&quot;&gt;&quot;#612144&quot;&lt;/span&gt;, 

     &lt;span style=&quot;color: #38761d;&quot;&gt;//Change Activity Bar Color&lt;/span&gt;
     &lt;span style=&quot;color: #0b5394;&quot;&gt;&quot;activityBar.background&quot;:&lt;/span&gt; &lt;span style=&quot;color: #990000;&quot;&gt;&quot;#7f61a7&quot;&lt;/span&gt;,
     &lt;span style=&quot;color: #0b5394;&quot;&gt;&quot;activityBar.foreground&quot;:&lt;/span&gt; &lt;span style=&quot;color: #990000;&quot;&gt;&quot;#c5ff3e&quot;&lt;/span&gt;,
     &lt;span style=&quot;color: #0b5394;&quot;&gt;&quot;activityBar.inactiveForeground&quot;:&lt;/span&gt; &lt;span style=&quot;color: #990000;&quot;&gt;&quot;#6dc58f&quot;&lt;/span&gt;
     }
} &lt;/pre&gt;
&lt;br /&gt;
After writing this code, save it and see what happen:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9OuQqlCSaT0WRRJHMVtiv3pBdllPCepG6pyTpFj6_vw_PymiEuudxTHBU6mylk9xDlu6lpDtdWIbfirSOcY1NObrsYZXOqpTkURZa2qutwKAjpcCq1Omqclu-f0YzxooqEyJzJBTZptJT/s1600/3.+Customize+Theme+Color+in+Visual+Studio+Code_Mini.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Customise Theme Color in Visual Studio Code&quot; border=&quot;0&quot; data-original-height=&quot;345&quot; data-original-width=&quot;910&quot; height=&quot;242&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9OuQqlCSaT0WRRJHMVtiv3pBdllPCepG6pyTpFj6_vw_PymiEuudxTHBU6mylk9xDlu6lpDtdWIbfirSOcY1NObrsYZXOqpTkURZa2qutwKAjpcCq1Omqclu-f0YzxooqEyJzJBTZptJT/s640/3.+Customize+Theme+Color+in+Visual+Studio+Code_Mini.jpg&quot; title=&quot;Customise Theme Color in Visual Studio Code&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
As you can see you can manually&amp;nbsp;&lt;b&gt;create theme in VSCode&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
So, this way you can easily &lt;b&gt;Customize Theme Color of Visual Studio Code&lt;/b&gt;. And also set &lt;b&gt;Light theme in VSCode.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</description><link>https://www.skotechlearn.com/2020/08/change-theme-and-color-in-visual-studio-code.html</link><author>noreply@blogger.com (SKOTechLearn)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh98aqegFUAVE_8XGN3srYipZMksNxSVutTLlKGdGM__PptvvonR_SHDc9EpWWFw_Lr6ZC_xotQOeOIL5dvUOyXdhHxQrCYLs7S0Vj1BH2HL6hepBDWwlAL_Av7DIJNnJ9hjoJmKv0s7AY3/s72-c/0.Dark+theme+to+Light+theme+in+visual+studio+code_Output_mini.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2258844867892945003.post-1353422771778430146</guid><pubDate>Tue, 18 Aug 2020 04:45:00 +0000</pubDate><atom:updated>2021-03-25T00:49:54.795-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Python</category><title>Steps to Get Entry Or Text Value in Label in Python Tkinter</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
In python using Tkinter, there are two types of Input Box first is &lt;b&gt;Tkinter Entry&lt;/b&gt; Box and Second is &lt;b&gt;Tkinter Text&lt;/b&gt;. And if you want to get String or &lt;b&gt;Get Value from Entry in Tkinter &lt;/b&gt;or &lt;b&gt;Get Tkinter Text Value in Python&lt;/b&gt; then here you will find detailed process to consider how to use it in your Project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;&lt;a href=&quot;https://www.skotechlearn.com/2020/06/use-label-in-python-using-tkinter.html&quot; target=&quot;_blank&quot;&gt;How to use Tkinter Label in Python with features&lt;/a&gt;&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background: rgb(255, 254, 246); border: 1px solid rgb(243, 238, 211); line-height: 30px; padding: 4px;&quot;&gt;
&lt;b&gt;Important Note:&lt;/b&gt; We Find that Text widget can not work in Tab Order. You have to write more code effort to perform &lt;b&gt;Tab order in Text in Tkinter&lt;/b&gt;. But if you use &lt;b&gt;Entry widget in python&lt;/b&gt;. There will no problem in tab order.&lt;/div&gt;
&lt;br /&gt;
Now Let’s Learn How to &lt;b&gt;Get Value from Entry in Python Tkinter &lt;/b&gt;or &lt;b&gt;Get Value from Text&lt;/b&gt; with following way:&lt;br /&gt;
&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;b&gt;
&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Get Entry Value in Label in Python Tkinter&lt;/li&gt;
&lt;/b&gt; &lt;b&gt;
&lt;li style=&quot;color: #094a66; font-family: arial, sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Get Text Value in Label in Python Tkinter&lt;/li&gt;
&lt;/b&gt;&lt;/ol&gt;
&lt;br /&gt;
So, Let’s Start.&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;
&lt;b&gt;(1). Get Entry Value in Label in Python Tkinter :&lt;/b&gt;&lt;/h2&gt;
As you know that for perform any action in Python you have to define Function. So for getting value you have to define function as bellow and Get Entry Value.&lt;br /&gt;
&lt;br /&gt;
Python Code:&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: purple;&quot;&gt;from&lt;/span&gt; tkinter &lt;span style=&quot;color: purple;&quot;&gt;import&lt;/span&gt; *

MyRootDialog=Tk()
&lt;span style=&quot;color: #6aa84f;&quot;&gt;#Set Tkinter Size And Location&lt;/span&gt;
MyRootDialog.geometry(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;200x150+100+100&quot;&lt;/span&gt;)

&lt;span style=&quot;color: #6aa84f;&quot;&gt;#Set Tkinter Title&lt;/span&gt;
MyRootDialog.title(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;Get Input Value in Label&quot;&lt;/span&gt;)

&lt;span style=&quot;color: #6aa84f;&quot;&gt;# Define Function for get Value&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;color: #b45f06;&quot;&gt;Get_MyInputValue&lt;/span&gt;():
     getresult = MyEntryBox.get()
     myTKlabel[&lt;span style=&quot;color: #990000;&quot;&gt;&#39;text&#39;&lt;/span&gt;] = getresult

&lt;span style=&quot;color: #6aa84f;&quot;&gt;# Create Tkinter Entry Widget&lt;/span&gt;
MyEntryBox = Entry(MyRootDialog, &lt;span style=&quot;color: blue;&quot;&gt;width&lt;/span&gt;=20)
MyEntryBox.place(&lt;span style=&quot;color: blue;&quot;&gt;x&lt;/span&gt;=5, &lt;span style=&quot;color: blue;&quot;&gt;y&lt;/span&gt;=6)

myTKlabel = Label(MyRootDialog, &lt;span style=&quot;color: blue;&quot;&gt;borderwidth&lt;/span&gt;=1, &lt;span style=&quot;color: blue;&quot;&gt;relief&lt;/span&gt;=&lt;span style=&quot;color: #990000;&quot;&gt;&quot;ridge&quot;&lt;/span&gt;, &lt;span style=&quot;color: blue;&quot;&gt;height&lt;/span&gt;=3, &lt;span style=&quot;color: blue;&quot;&gt;width&lt;/span&gt;=25)
myTKlabel.place(&lt;span style=&quot;color: blue;&quot;&gt;x&lt;/span&gt;=4, &lt;span style=&quot;color: blue;&quot;&gt;y&lt;/span&gt;=42)

&lt;span style=&quot;color: #6aa84f;&quot;&gt;#command will call the defined function&lt;/span&gt;
MyTkButton = Button(MyRootDialog, &lt;span style=&quot;color: blue;&quot;&gt;height&lt;/span&gt;=1, &lt;span style=&quot;color: blue;&quot;&gt;width&lt;/span&gt;=10, &lt;span style=&quot;color: blue;&quot;&gt;text&lt;/span&gt;=&lt;span style=&quot;color: #990000;&quot;&gt;&quot;Get text&quot;&lt;/span&gt;, &lt;span style=&quot;color: blue;&quot;&gt;command&lt;/span&gt;= Get_MyInputValue)
MyTkButton.place(&lt;span style=&quot;color: blue;&quot;&gt;x&lt;/span&gt;=4, &lt;span style=&quot;color: blue;&quot;&gt;y&lt;/span&gt;=112)

mainloop()&lt;/pre&gt;
&lt;br /&gt;
One more thing here you can use get value in Label through following two way:&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background: rgb(250, 247, 222); border: 1px solid rgb(230, 226, 198); font-family: verdana; font-size: 13px; padding: 4px; width: 250px;&quot;&gt;
myTKlabel[&lt;span style=&quot;color: #990000;&quot;&gt;&#39;text&#39;&lt;/span&gt;] = getresult&lt;/div&gt;
&lt;br /&gt;
or &lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background: rgb(250, 247, 222); border: 1px solid rgb(230, 226, 198); font-family: verdana; font-size: 13px; padding: 4px; width: 250px;&quot;&gt;
myTKlabel.config(&lt;span style=&quot;color: blue;&quot;&gt;text&amp;nbsp;&lt;/span&gt;= getresult)&lt;/div&gt;
&lt;br /&gt;
You can use it according to your desire. Both will present same result.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Output:&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQsl5ZzVxA9nNbXD3JKIE653fY47olYf_qqCn_YzVRMRxrURQRSrQW_1E2Pe-Ogt2BaJE_wJbx2UV4zFC1DZl0vEHpl0eTp42iRJuv_jVSkCXOIynHAXL_C0T8AHXdd7xVYP2EGaDnTx-W/s1600/1.+Get+Tkinter+Entry+Value+in+Label.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Get Entry value in Tkinter in Python&quot; border=&quot;0&quot; data-original-height=&quot;234&quot; data-original-width=&quot;447&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQsl5ZzVxA9nNbXD3JKIE653fY47olYf_qqCn_YzVRMRxrURQRSrQW_1E2Pe-Ogt2BaJE_wJbx2UV4zFC1DZl0vEHpl0eTp42iRJuv_jVSkCXOIynHAXL_C0T8AHXdd7xVYP2EGaDnTx-W/s1600/1.+Get+Tkinter+Entry+Value+in+Label.jpg&quot; title=&quot;Get Tkinter Entry Value in Label in Python&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
You can also &lt;b&gt;&lt;u&gt;&lt;a href=&quot;https://www.skotechlearn.com/2020/06/tkinter-window-position-size-center-screen-in-python.html&quot; target=&quot;_blank&quot;&gt;Set Tkinter window in Center Location&lt;/a&gt;&lt;/u&gt;&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;
&lt;b&gt;(2). Get Text Value in Label in Python Tkinter :&lt;/b&gt;&lt;/h2&gt;
Now if you use Tkinter Text widget in python then you have to write following code to get Tkinter text in python.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background: rgb(243, 253, 242); border: 1px solid rgb(180, 203, 188); line-height: 30px; padding: 4px;&quot;&gt;
&lt;b&gt;&lt;i&gt;&lt;span style=&quot;color: purple;&quot;&gt;Note:&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; Get Value from Tkinter Entry Widget code: &lt;span style=&quot;background: rgb(250, 247, 222); border: 1px solid rgb(230, 226, 198); font-family: &amp;quot;verdana&amp;quot;; font-size: 13px; padding: 2px;&quot;&gt; MyEntryBox.get()&lt;/span&gt;&lt;br /&gt;
And for get Value from Tkinter Text Widget code: &lt;span style=&quot;background: rgb(250, 247, 222); border: 1px solid rgb(230, 226, 198); font-family: &amp;quot;verdana&amp;quot;; font-size: 13px; padding: 2px;&quot;&gt;MyTktextBox.get(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;1.0&quot;&lt;/span&gt;, &lt;span style=&quot;color: #990000;&quot;&gt;&#39;end-1c&#39;&lt;/span&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
In Text Widget you have to pass Index inside &lt;b&gt;Get() &lt;/b&gt;function:&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
Code:&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: purple;&quot;&gt;from&lt;/span&gt; tkinter &lt;span style=&quot;color: purple;&quot;&gt;import&lt;/span&gt; *

MyRootDialog=Tk()
&lt;span style=&quot;color: #6aa84f;&quot;&gt;#Set Tkinter Size And Location&lt;/span&gt;
MyRootDialog.geometry(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;200x150+100+100&quot;&lt;/span&gt;)

&lt;span style=&quot;color: #6aa84f;&quot;&gt;#Set Tkinter Title&lt;/span&gt;
MyRootDialog.title(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;Get Input Value in Label&quot;&lt;/span&gt;)

&lt;span style=&quot;color: #6aa84f;&quot;&gt;# Define Function for get Text Value&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;color: #b45f06;&quot;&gt;Get_TKTextValue&lt;/span&gt;():
      myTxtresult = MyTktextBox.get(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;1.0&quot;&lt;/span&gt;, &lt;span style=&quot;color: #990000;&quot;&gt;&#39;end-1c&#39;&lt;/span&gt;)
      myTKlabel.config(&lt;span style=&quot;color: blue;&quot;&gt;text&lt;/span&gt; = myTxtresult)

&lt;span style=&quot;color: #6aa84f;&quot;&gt;# Create Tkinter Text Widget&lt;/span&gt;
MyTktextBox=Text(MyRootDialog, &lt;span style=&quot;color: blue;&quot;&gt;height&lt;/span&gt;=1, &lt;span style=&quot;color: blue;&quot;&gt;width&lt;/span&gt;=20)
MyTktextBox.place(&lt;span style=&quot;color: blue;&quot;&gt;x&lt;/span&gt;=5, &lt;span style=&quot;color: blue;&quot;&gt;y&lt;/span&gt;=6)


myTKlabel = Label(MyRootDialog, &lt;span style=&quot;color: blue;&quot;&gt;borderwidth&lt;/span&gt;=1, &lt;span style=&quot;color: blue;&quot;&gt;relief&lt;/span&gt;=&lt;span style=&quot;color: #990000;&quot;&gt;&quot;ridge&quot;&lt;/span&gt;, &lt;span style=&quot;color: blue;&quot;&gt;height&lt;/span&gt;=2, &lt;span style=&quot;color: blue;&quot;&gt;width&lt;/span&gt;=25)
myTKlabel.place(&lt;span style=&quot;color: blue;&quot;&gt;x&lt;/span&gt;=4, &lt;span style=&quot;color: blue;&quot;&gt;y&lt;/span&gt;=42)

&lt;span style=&quot;color: #6aa84f;&quot;&gt;#command will call the defined function&lt;/span&gt;
MyButton = Button(MyRootDialog, &lt;span style=&quot;color: blue;&quot;&gt;height&lt;/span&gt;=1, &lt;span style=&quot;color: blue;&quot;&gt;width&lt;/span&gt;=10, &lt;span style=&quot;color: blue;&quot;&gt;text&lt;/span&gt;=&lt;span style=&quot;color: #990000;&quot;&gt;&quot;Get text&quot;&lt;/span&gt;, &lt;span style=&quot;color: blue;&quot;&gt;command&lt;/span&gt;= Get_TKTextValue)
MyButton.place(&lt;span style=&quot;color: blue;&quot;&gt;x&lt;/span&gt;=4, &lt;span style=&quot;color: blue;&quot;&gt;y&lt;/span&gt;=92)

mainloop()&lt;/pre&gt;
&lt;br /&gt;
Now, when you run you code, this will present following output.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;&lt;a href=&quot;https://www.skotechlearn.com/2020/08/string-in-python-and-concatenate-format-python.html&quot; target=&quot;_blank&quot;&gt;Different types of Multi Line String process in Python&lt;/a&gt;&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Output:&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgm3DIm-Vx90WAquIW5E_tFjQGBygckMHBLMRUl4c5QmBHMewlntviZZCkj0OO4cwdKqnpNt6AkSovg7C0QvP_DZT3j1giJ1etX3bxpj2DYrrGDkDjOxgZvCbaTCTRrsD1uD9lPB0msrJe_/s1600/2.+Get+Tkinter+Text+Value+in+Label.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Get Text Value in Python&quot; border=&quot;0&quot; data-original-height=&quot;241&quot; data-original-width=&quot;561&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgm3DIm-Vx90WAquIW5E_tFjQGBygckMHBLMRUl4c5QmBHMewlntviZZCkj0OO4cwdKqnpNt6AkSovg7C0QvP_DZT3j1giJ1etX3bxpj2DYrrGDkDjOxgZvCbaTCTRrsD1uD9lPB0msrJe_/s1600/2.+Get+Tkinter+Text+Value+in+Label.jpg&quot; title=&quot;Get Tkinter Text Value in Label&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
So, these above given code process is use to &lt;b&gt;Get Tkinter Text Value in Label&lt;/b&gt; or &lt;b&gt;Get Entry Value in Python&lt;/b&gt;.&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;&lt;a href=&quot;https://www.skotechlearn.com/2021/03/add-itmes-in-combobox-tkinter-python.html&quot; target=&quot;_blank&quot;&gt;Simply Add Items in Tkinter ComboBox in Python with Example&lt;/a&gt;&lt;/b&gt;&lt;/div&gt;
</description><link>https://www.skotechlearn.com/2020/08/get-tkinter-entry-or-text-value-in-python.html</link><author>noreply@blogger.com (SKOTechLearn)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQsl5ZzVxA9nNbXD3JKIE653fY47olYf_qqCn_YzVRMRxrURQRSrQW_1E2Pe-Ogt2BaJE_wJbx2UV4zFC1DZl0vEHpl0eTp42iRJuv_jVSkCXOIynHAXL_C0T8AHXdd7xVYP2EGaDnTx-W/s72-c/1.+Get+Tkinter+Entry+Value+in+Label.jpg" height="72" width="72"/><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2258844867892945003.post-2094194525469583900</guid><pubDate>Thu, 13 Aug 2020 06:28:00 +0000</pubDate><atom:updated>2020-08-12T23:39:59.813-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Python</category><title>String in Python with Single, Multi-Line, Concatenate in Python</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;First of all you have to understand about &lt;b&gt;String in Python&lt;/b&gt;. Basically a String is a collection of characters which is used to define a word or sentence or paragraph with single or multiple lines. And here we also describe some basic Format of String or Integer &lt;b&gt;Concatenation in Python&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQ6D0VBeoUK_-pcsIlpv4cAndkjgYJl59AKJ31f1B2XLbKBX8Y883pDIZhtn2bSkzqXN1McdDIVNHyYbk61GaEJjR_sNaTI6gh1eTYECZZ_6FhrgazkwvPNky-TSLk4M87miJZTkYs5di5/s1600/Houw_To_Use_String_In_Python.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Use String in Python&quot; border=&quot;0&quot; data-original-height=&quot;472&quot; data-original-width=&quot;663&quot; height=&quot;454&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQ6D0VBeoUK_-pcsIlpv4cAndkjgYJl59AKJ31f1B2XLbKBX8Y883pDIZhtn2bSkzqXN1McdDIVNHyYbk61GaEJjR_sNaTI6gh1eTYECZZ_6FhrgazkwvPNky-TSLk4M87miJZTkYs5di5/s640/Houw_To_Use_String_In_Python.jpg&quot; title=&quot;How To Use String in Python&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
In Python, when we define a string, it will be define either &lt;b&gt;Single (‘ ’) Quote&lt;/b&gt; or &lt;b&gt;Double Quote ( “ ”)&lt;/b&gt;.&lt;br /&gt;
For simple example you can use &lt;b&gt;print()&lt;/b&gt; function for display simple word or sentence as form of string as given bellow:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;print&lt;/span&gt;( &lt;span style=&quot;color: #990000;&quot;&gt;&quot;SKOTechLearn&quot;&lt;/span&gt; )
&lt;span style=&quot;color: blue;&quot;&gt;print&lt;/span&gt;( &lt;span style=&quot;color: #990000;&quot;&gt;&#39;SKOTechLearn&#39;&lt;/span&gt; )
&lt;/pre&gt;&lt;b&gt;Output:&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;background: #F5F9FC; border: 1px solid #cdd6d8; line-height: 23px; padding: 2px 4px;&quot;&gt;&lt;div style=&quot;color: #3d4b72; font-family: verdana; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: #859900;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;
SKOTechLearn&lt;br /&gt;
SKOTechLearn&lt;br /&gt;
&lt;span style=&quot;color: #859900;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
So, let’s see the types and use of String with following way:&lt;br /&gt;
&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;b&gt;&lt;span style=&quot;color: #094a66; font-family: &amp;quot;oswald&amp;quot; , sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Single Line String using Variable&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;&lt;span style=&quot;color: #094a66; font-family: &amp;quot;oswald&amp;quot; , sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Use String to Passing value in Function&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;&lt;span style=&quot;color: #094a66; font-family: &amp;quot;oswald&amp;quot; , sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Multi-Line Sting using Variable&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;&lt;span style=&quot;color: #094a66; font-family: &amp;quot;oswald&amp;quot; , sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Concatenate Strings in Python&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;&lt;span style=&quot;color: #094a66; font-family: &amp;quot;oswald&amp;quot; , sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Concatenate integer or number with String&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #3d5d72; background: #3D5D72; border-radius: 6px; border: 2px solid #b4bdc4; color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;b&gt; (1). Single Line String in Python using Variable :&lt;/b&gt;&lt;/h2&gt;Suppose you want to store your word or sentence and show during process then we simply assign a Variable.&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;mystrng = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;Hello SKOTechLearn&quot;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;print&lt;/span&gt;(mystrng)
&lt;/pre&gt;&lt;b&gt;Output:&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;background: #F5F9FC; border: 1px solid #cdd6d8; line-height: 23px; padding: 2px 4px;&quot;&gt;&lt;div style=&quot;color: #3d4b72; font-family: verdana; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: #859900;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;color: #3d4b72; font-family: &amp;quot;verdana&amp;quot;; font-size: 13px;&quot;&gt;Hello SKOTechLearn&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: #3d4b72; font-family: verdana; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: #859900;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #3d5d72; background: #3D5D72; border-radius: 6px; border: 2px solid #b4bdc4; color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;b&gt;(2). Use String to Passing value in Function in Python:&lt;/b&gt;&lt;/h2&gt;This is very important point which is used in every programming process. Here you can use string for passing in other function or references.&lt;br /&gt;
&lt;br /&gt;
You can simply cover following points:&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;line-height: 20px;&quot;&gt;➤ Python pass function as argument with parameters&lt;br /&gt;
➤ How to pass string as parameter in python function?&lt;br /&gt;
➤ Python pass function name as argument&lt;br /&gt;
➤ Python call function from string with arguments&lt;/div&gt;&lt;br /&gt;
You have to simply learn following process:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;Myfstr = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;skotechlearn&quot;&lt;/span&gt;
MyPFunc( Myfstr )

&lt;span style=&quot;color: blue;&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: blue; font-weight: bold;&quot;&gt; &lt;/span&gt;MyPFunc&lt;b&gt; &lt;/b&gt;( Myfstr ):
    &lt;span style=&quot;color: #b45f06;&quot;&gt;# upper() method is use to show Characters in Capital Letters&lt;/span&gt;
    skstr = Myfstr.&lt;span style=&quot;color: #073763;&quot;&gt;upper&lt;/span&gt;()
    &lt;span style=&quot;color: blue;&quot;&gt;print&lt;b&gt; &lt;/b&gt;&lt;/span&gt;(skstr)
&lt;/pre&gt;&lt;b&gt;Output:&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;background: #F5F9FC; border: 1px solid #cdd6d8; line-height: 23px; padding: 2px 4px;&quot;&gt;&lt;div style=&quot;color: #3d4b72; font-family: verdana; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: #859900;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;
SKOTECHLEARN&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #859900;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;
You can simply use this process with many ways according to your application requirement process.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #3d5d72; background: #3D5D72; border-radius: 6px; border: 2px solid #b4bdc4; color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;b&gt;(3). Multi-Line Sting in Python using Variable :&lt;/b&gt;&lt;/h2&gt;As you can understand how to store or show string in python, but when you want to store multiline sentence or paragraph on your application, what is the code process we apply?&lt;br /&gt;
&lt;br /&gt;
You have to simply write word or sentence in start and end with &lt;b&gt;Triple Quotes (&quot;&quot;&quot; &quot;&quot;&quot;)  or  You can simply use “\n”&lt;/b&gt; between you sentence with following way:&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background: #fff1ef; border-radius: 8px; border: 2px solid #ee9c92; padding: 3px 3px;&quot;&gt;&lt;b&gt;Multi-line String using Triple Quotes (&quot;&quot;&quot; &quot;&quot;&quot;)  :&lt;/b&gt;&lt;/div&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;MyMultilineStr = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;&quot;&quot;This is Triple Quote multiline Sentence
Using Python Code
With Simple output&quot;&quot;&quot;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;print &lt;/span&gt;(MyMultilineStr)
&lt;/pre&gt;&lt;b&gt;Output:&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;background: #F5F9FC; border: 1px solid #cdd6d8; line-height: 23px; padding: 2px 4px;&quot;&gt;&lt;div style=&quot;color: #3d4b72; font-family: verdana; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: #859900;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;
This is Triple Quote multiline Sentence&lt;br /&gt;
Using Python Code&lt;br /&gt;
With Simple output&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;color: #859900;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background: #fff1ef; border-radius: 8px; border: 2px solid #ee9c92; padding: 3px 3px;&quot;&gt;&lt;b&gt;Multi-line using “\n” &lt;/b&gt;&lt;b&gt;:&lt;/b&gt;&lt;/div&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;MyNextLineStr = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;This is multiline Sentence &lt;b&gt;\n&lt;/b&gt; Python Code &lt;b&gt;\n&lt;/b&gt; With Next Line Process &quot;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;print&lt;b&gt; &lt;/b&gt;&lt;/span&gt;(MyNextLineStr)
&lt;/pre&gt;&lt;b&gt;Output:&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;background: #F5F9FC; border: 1px solid #cdd6d8; line-height: 23px; padding: 2px 4px;&quot;&gt;&lt;div style=&quot;color: #3d4b72; font-family: verdana; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: #859900;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;
This is multiline Sentence&lt;br /&gt;
Python Code&lt;br /&gt;
With Next Line Process&lt;br /&gt;
&lt;span style=&quot;color: #859900;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #3d5d72; background: #3D5D72; border-radius: 6px; border: 2px solid #b4bdc4; color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;b&gt;(4). Concatenate Strings in Python :&lt;/b&gt;&lt;/h2&gt;There are 4 ways for &lt;b&gt;concatenating string in Python. &lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background: #fff1ef; border-radius: 8px; border: 2px solid #ee9c92; float: left; padding: 3px 3px;&quot;&gt;&lt;b&gt;First Process:&lt;/b&gt; &lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
You can simply use &lt;b&gt;“+” Sign&lt;/b&gt; for concatenate word or sentence.&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;FstStr = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;SKO&quot;&lt;/span&gt;
SecStr = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;Tech&quot;&lt;/span&gt;
ThirdStr = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;Learn&quot;&lt;/span&gt;

FinalStr = FstStr  + &lt;span style=&quot;color: #990000;&quot;&gt;&quot; &quot;&lt;/span&gt; + SecStr + &lt;span style=&quot;color: #990000;&quot;&gt;&quot; &quot;&lt;/span&gt; + ThirdStr
&lt;span style=&quot;color: blue;&quot;&gt;print &lt;/span&gt;(FinalStr)
&lt;/pre&gt;&lt;b&gt;Output:&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;background: #F5F9FC; border: 1px solid #cdd6d8; line-height: 23px; padding: 2px 4px;&quot;&gt;&lt;div style=&quot;color: #3d4b72; font-family: verdana; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: #859900;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;
SKO Tech Learn&lt;br /&gt;
&lt;span style=&quot;color: #859900;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background: #fff1ef; border-radius: 8px; border: 2px solid #ee9c92; float: left; padding: 3px 3px;&quot;&gt;&lt;b&gt;Second Process:&lt;/b&gt; &lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
You can simply use &lt;b&gt;“{}{}{}”.format(StrVar1, StrVar2, StrVar3)&lt;/b&gt; function.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;background-color: #fff2cc; color: #741b47;&quot;&gt;Tips1:&lt;/span&gt;&lt;/b&gt;&amp;nbsp;&quot;{}{}{}&quot;.format(StrVar1, StrVar2, StrVar3): if you don’t need space between string.&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;background-color: #fff2cc; color: #741b47;&quot;&gt;Tips2:&lt;/span&gt;&lt;/b&gt;&amp;nbsp;&quot;{} {} {}&quot;.format(StrVar1, StrVar2, StrVar3) : if you need to add space between string.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: #d9ead3;&quot;&gt;&lt;i&gt;&lt;b&gt;Note:&lt;/b&gt; Input  Number of “{}” Curly Brace according to the number of string variable.&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;PStr1= &lt;span style=&quot;color: #990000;&quot;&gt;&quot;SKO&quot;&lt;/span&gt;
PStr2 = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;Tech&quot;&lt;/span&gt;
PStr3 = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;Learn&quot;&lt;/span&gt;
PStr4 = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;Tips&quot;&lt;/span&gt;

&lt;span style=&quot;color: #b45f06;&quot;&gt;#concatenate String without space&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;{}{}{}{}&quot;&lt;/span&gt;.format(PStr1, PStr2, PStr3, PStr4)) 

&lt;span style=&quot;color: #b45f06;&quot;&gt;# concatenate String with space&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;{} {} {} {}&quot;&lt;/span&gt;.format(PStr1, PStr2, PStr3, PStr4))
&lt;/pre&gt;&lt;b&gt;Output:&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;background: #F5F9FC; border: 1px solid #cdd6d8; line-height: 23px; padding: 2px 4px;&quot;&gt;&lt;div style=&quot;color: #3d4b72; font-family: verdana; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: #859900;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;
SKOTechLearnTips&lt;br /&gt;
SKO Tech Learn Tips&lt;br /&gt;
&lt;span style=&quot;color: #859900;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background: #fff1ef; border-radius: 8px; border: 2px solid #ee9c92; float: left; padding: 3px 3px;&quot;&gt;&lt;b&gt;Third Process:&lt;/b&gt; &lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
In this process you can use &lt;b&gt;&quot;% s % s % s&quot; % (StrVr1, StrVr2, StrVr3)&lt;/b&gt;. Here you can add number of &lt;b&gt;“% s”&lt;/b&gt; according to number of string value or variable.&lt;br /&gt;
&lt;br /&gt;
&lt;b style=&quot;background-color: #fff2cc;&quot;&gt;&quot;% s % s % s&quot; :&lt;/b&gt; if you want to add space during concatenating variable. This will show sentence with space.&lt;br /&gt;
&lt;b style=&quot;background-color: #fff2cc;&quot;&gt;&quot;% s% s% s&quot; : &lt;/b&gt;This will show Concatenate variable without space.&lt;br /&gt;
&lt;br /&gt;
For Example:&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;myVr1 = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;This&quot;&lt;/span&gt;
myVr2 = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;is&quot;&lt;/span&gt;
myVr3 = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;Concatenate&quot;&lt;/span&gt;
myVr4 = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;Code&quot;&lt;/span&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;#Sentance without space&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;%s%s%s%s&quot;&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;%&lt;/span&gt; (myVr1, myVr2, myVr3, myVr4)) 

&lt;span style=&quot;color: #b45f06;&quot;&gt;# Add space between word or sentence&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;%s %s %s %s&quot;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt; % &lt;/span&gt;(myVr1, myVr2, myVr3, myVr4))
&lt;/pre&gt;&lt;b&gt;Output:&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;background: #F5F9FC; border: 1px solid #cdd6d8; line-height: 23px; padding: 2px 4px;&quot;&gt;&lt;div style=&quot;color: #3d4b72; font-family: verdana; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: #859900;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;
ThisisConcatenateCode&lt;br /&gt;
This is Concatenate Code&lt;br /&gt;
&lt;span style=&quot;color: #859900;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background: #fff1ef; border-radius: 8px; border: 2px solid #ee9c92; float: left; padding: 3px 3px;&quot;&gt;&lt;b&gt;Forth Process:&lt;/b&gt; &lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Use &lt;b&gt;.join&lt;/b&gt; for &lt;b&gt;concatenate in python&lt;/b&gt;. For Simply you have to follow following syntax:&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;background-color: #fff2cc;&quot;&gt;Concatenate Without Space:&lt;/span&gt; &lt;/i&gt;&quot;&quot;.join([SkVr1, SkVr2, SkVr3])&lt;br /&gt;
&lt;i style=&quot;background-color: #fff2cc;&quot;&gt;Concatenate With Space:&lt;/i&gt; &quot;&quot;.join([SkVr1, SkVr2, SkVr3])&lt;br /&gt;
&lt;br /&gt;
For Example:&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;SkVr1 = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;Learn&quot;&lt;/span&gt;
SkVr2 = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;Concatenate&quot;&lt;/span&gt;
SkVr3 = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;process&quot;&lt;/span&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;# Concatenate process without space&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;&quot;&lt;/span&gt;.join([SkVr1, SkVr2, SkVr3])) 
&lt;span style=&quot;color: #b45f06;&quot;&gt;# Concatenate process with space &lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&quot; &quot;&lt;/span&gt;.join([SkVr1, SkVr2, SkVr3]))
&lt;/pre&gt;&lt;b&gt;Output:&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;background: #F5F9FC; border: 1px solid #cdd6d8; line-height: 23px; padding: 2px 4px;&quot;&gt;&lt;div style=&quot;color: #3d4b72; font-family: verdana; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: #859900;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;color: #3d4b72; font-family: &amp;quot;verdana&amp;quot;; font-size: 13px;&quot;&gt;LearnConcatenateprocess&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #3d4b72; font-family: &amp;quot;verdana&amp;quot;; font-size: 13px;&quot;&gt;Learn Concatenate process&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: #3d4b72; font-family: verdana; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: #859900;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #3d5d72; background: #3D5D72; border-radius: 6px; border: 2px solid #b4bdc4; color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;b&gt;(5). Concatenate integer or number in Python with String:&lt;/b&gt;&lt;/h2&gt;When you will try to concatenate integer in Python with alphabet or sentence, you will get the following error with normal process like bellow:&lt;br /&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;border: solid #828687 1.0pt; line-height: 23px; padding: 4px 4px;&quot;&gt;&lt;div style=&quot;font-family: verdana; font-size: 13px; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;print&lt;/span&gt;(1 + &lt;span style=&quot;color: #990000;&quot;&gt;&quot;This is Alphabet&quot;&lt;/span&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr&gt;   &lt;td style=&quot;background: #F5F9FC; border: solid #CDD6D8 1.0pt; line-height: 20px;&quot;&gt;&lt;div style=&quot;font-family: verdana; font-size: 13px; line-height: 20px;&quot;&gt;&lt;span style=&quot;color: #859900;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #975252;&quot;&gt;Traceback (most recent call   last):&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: red;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #975252;&quot;&gt;print(1+&quot;This is Alphabet&quot;)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #975252;&quot;&gt;TypeError: unsupported operand type(s) for +: &#39;int&#39; and &#39;str&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #859900;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
As you can see the above error will display. So, we try following way to solve this problem. There are four process for &lt;b&gt;Concatenating Integer with String&lt;/b&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background: #fff1ef; border-radius: 8px; border: 2px solid #ee9c92; float: left; padding: 2px 2px;&quot;&gt;&lt;b&gt;Process 1:&lt;/b&gt; &lt;/div&gt;&amp;nbsp;Simply input number inside &lt;b&gt;Double Quote(“ ”)&lt;/b&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;print(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;2&quot;&lt;/span&gt;+ &lt;span style=&quot;color: #990000;&quot;&gt;&quot;. &lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;This is Alphabet&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&quot;&lt;/span&gt;)&lt;/pre&gt;&lt;/div&gt;&lt;b&gt;Output:&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;background: #F5F9FC; border: 1px solid #cdd6d8; line-height: 23px; padding: 2px 4px;&quot;&gt;&lt;div style=&quot;color: #3d4b72; font-family: verdana; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: #859900;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;color: #3d4b72; font-family: &amp;quot;verdana&amp;quot;; font-size: 13px;&quot;&gt;2. This is Alphabet&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: #3d4b72; font-family: verdana; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: #859900;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background: #fff1ef; border-radius: 8px; border: 2px solid #ee9c92; float: left; padding: 2px 2px;&quot;&gt;&lt;b&gt;Process 2:&lt;/b&gt; &lt;/div&gt;&amp;nbsp;Using &lt;b&gt;str() &lt;/b&gt;for converting Integer :&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;mynum = 2
combstr = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;This is Alphabet&quot;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: blue;&quot;&gt;str&lt;/span&gt;(mynum) + &lt;span style=&quot;color: #990000;&quot;&gt;&quot;=  &quot; &lt;/span&gt;+ combstr)&lt;/pre&gt;&lt;/div&gt;&lt;b&gt;Output:&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;background: #F5F9FC; border: 1px solid #cdd6d8; line-height: 23px; padding: 2px 4px;&quot;&gt;&lt;div style=&quot;color: #3d4b72; font-family: verdana; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: #859900;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;color: #3d4b72; font-family: &amp;quot;verdana&amp;quot;; font-size: 13px;&quot;&gt;2= This is Alphabet&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: #3d4b72; font-family: verdana; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: #859900;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background: #fff1ef; border-radius: 8px; border: 2px solid #ee9c92; float: left; padding: 2px 2px;&quot;&gt;&lt;b&gt;Process 3:&lt;/b&gt; &lt;/div&gt;&amp;nbsp;Using &lt;b&gt;.format&lt;/b&gt; method for concatenate of integer :&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;mynum = 2
combstr = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;This is Alphabet&quot;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;print &lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&quot;Point No. {} is - {} for concatenate with Integer&quot;&lt;/span&gt;.&lt;span style=&quot;color: blue;&quot;&gt;format&lt;/span&gt;(mynum, combstr)
&lt;/pre&gt;&lt;b&gt;Output:&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;background: #F5F9FC; border: 1px solid #cdd6d8; line-height: 23px; padding: 2px 4px;&quot;&gt;&lt;div style=&quot;color: #3d4b72; font-family: verdana; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: #859900;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;color: #3d4b72; font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;span style=&quot;font-size: 13px;&quot;&gt;Point No. 2 is - This is Alphabet for concatenate with Integer&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: #3d4b72; font-family: verdana; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: #859900;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background: #fff1ef; border-radius: 8px; border: 2px solid #ee9c92; float: left; padding: 2px 2px;&quot;&gt;&lt;b&gt;Process 4:&lt;/b&gt; &lt;/div&gt;&amp;nbsp;Using &lt;b&gt;“% s”&lt;/b&gt; for Concatenate integer :&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;mynum = 2
combstr = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;This is Alphabet&quot;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;No. % s % s&quot;&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;%&lt;/span&gt; (mynum, combstr))
&lt;/pre&gt;&lt;b&gt;Output:&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;background: #F5F9FC; border: 1px solid #cdd6d8; line-height: 23px; padding: 2px 4px;&quot;&gt;&lt;div style=&quot;color: #3d4b72; font-family: verdana; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: #859900;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;color: #3d4b72; font-family: &amp;quot;verdana&amp;quot;;&quot;&gt;&lt;span style=&quot;font-size: 13px;&quot;&gt;No. 2 This is Alphabet&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: #3d4b72; font-family: verdana; font-size: 13px;&quot;&gt;&lt;span style=&quot;color: #859900;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
So Friends, these are the process for Using &lt;b&gt;String in Python&lt;/b&gt;, easily show &lt;b&gt;Multi-line String in python&lt;/b&gt;, &lt;b&gt;Passing String in function in Python&lt;/b&gt;, &lt;b&gt;Concatenate String in Python&lt;/b&gt;, &lt;b&gt;Concatenate Integer in Python&lt;/b&gt;.&lt;/div&gt;</description><link>https://www.skotechlearn.com/2020/08/string-in-python-and-concatenate-format-python.html</link><author>noreply@blogger.com (SKOTechLearn)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQ6D0VBeoUK_-pcsIlpv4cAndkjgYJl59AKJ31f1B2XLbKBX8Y883pDIZhtn2bSkzqXN1McdDIVNHyYbk61GaEJjR_sNaTI6gh1eTYECZZ_6FhrgazkwvPNky-TSLk4M87miJZTkYs5di5/s72-c/Houw_To_Use_String_In_Python.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2258844867892945003.post-2673385472672544087</guid><pubDate>Tue, 21 Jul 2020 19:18:00 +0000</pubDate><atom:updated>2021-06-30T12:08:22.409-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">NetBeans</category><title>Static or Dynamic Way to Display Image in jFrame in Java Swing</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
In this post, SKOTechLearn describe the static and dynamic way to &lt;b&gt;Display Image in jFrame in Java Swing&lt;/b&gt; with Netbeans through &lt;b&gt;jLabel&lt;/b&gt;. Simply we can add image through Properties Settings or using Code which is described bellow.&lt;br /&gt;
&lt;br /&gt;
Why we use &lt;b&gt;jLabel for displaying image&lt;/b&gt;? Because, This is the simple way to handle any files like: jpeg, png etc using jLable pallet.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;
&lt;u&gt;&lt;a href=&quot;https://www.skotechlearn.com/2019/04/open-another-existing-jframe-in-java-netbeans.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;Open jFrame through Another jFrame in Java Swing&lt;/b&gt;&lt;/a&gt;&lt;/u&gt;&lt;br /&gt;
&lt;br /&gt;
If you want to show external image or use it as internal way like add as logo or banner, then here we will describe as dynamic and static way. So lets learn with following two process:&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;background: rgb(235, 241, 245); border-radius: 4px; border: 0.5px solid rgb(200, 213, 206); font-size: 16px; line-height: 28px; padding: 2px 6px; text-align: justify;&quot;&gt;
&lt;span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;(1) Display Image in jLabel in Java Swing Static way&lt;/b&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background: rgb(235, 241, 245); border-radius: 4px; border: 0.5px solid rgb(200, 213, 206); font-size: 16px; line-height: 28px; padding: 2px 6px; text-align: justify;&quot;&gt;
&lt;span&gt;&lt;b&gt;&lt;span style=&quot;color: #444444;&quot;&gt;&amp;nbsp;&lt;/span&gt;(2) Display Image in jLabel in Java Swing Dynamic way&lt;/b&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
Come to the point by point description.&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;b&gt;(1) Display Image in jLabel in Java Swing Static way :&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;
In this process just create an image file or use your existing file and copy that file in your particular package. For this step by step process let&#39;s find following.&lt;br /&gt;
&lt;br /&gt;
Suppose if you create a picture file and want to show. Then first copy that particular file and paste it on your project&#39;s package, or you can access through external path.&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;img alt=&quot;Drag_Image_File_In_Java_Package&quot; border=&quot;0&quot; data-original-height=&quot;437&quot; data-original-width=&quot;550&quot; height=&quot;317&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgldsaZof5jESliUV84QbqhI5UzuUGfrleYQTKjfMNpbA9JpP8E2ldK1lwN_fCD7kuXIUbrQMVRGPtvRs-g0YM8cM6HJ1XK7bkhBlGcLgV13tJNk8JobRayBV8Jz7JGKZOTH88h6VnLbSTG/s400/1_copy_paste_image_in_Package_web.jpg&quot; title=&quot;Drag_Image_File_In_Java_Package&quot; width=&quot;400&quot; /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;i&gt;&lt;span style=&quot;color: purple;&quot;&gt;&lt;b&gt;Drag Image File In Package&lt;/b&gt;&lt;/span&gt;&lt;/i&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;&lt;a href=&quot;https://www.skotechlearn.com/2019/04/auto-resize-control-change-control-name-in-java.html&quot; target=&quot;_blank&quot;&gt;Tips to Auto Resize Control Setting in Java Netbeans&lt;/a&gt;&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
As you can see, I simply copy my particular file and paste on my package. After that simply drag a jLabel from palette and adjust it&#39;s height width and location according to desire and after that follow the steps:&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background: rgb(215, 235, 240); border-radius: 50%; border: 2px solid rgb(136, 109, 154); float: left; font-family: verdana; font-size: 16px; margin: 0px 10px; padding: 0px 0px 2px 2px; text-align: center; width: 25px;&quot;&gt;
&lt;b&gt;1.&lt;/b&gt; &lt;/div&gt;
Right click on jLabel.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background: rgb(215, 235, 240); border-radius: 50%; border: 2px solid rgb(136, 109, 154); float: left; font-family: verdana; font-size: 16px; margin: 0px 10px; padding: 0px 0px 2px 2px; text-align: center; width: 25px;&quot;&gt;
&lt;b&gt;2.&lt;/b&gt; &lt;/div&gt;
Select &#39;&lt;b&gt;Properties&lt;/b&gt;&#39; option or go to directly on &#39;&lt;b&gt;Properties&lt;/b&gt;&#39; window.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background: rgb(215, 235, 240); border-radius: 50%; border: 2px solid rgb(136, 109, 154); float: left; font-family: verdana; font-size: 16px; margin: 0px 10px; padding: 0px 0px 2px 2px; text-align: center; width: 25px;&quot;&gt;
&lt;b&gt;3.&lt;/b&gt; &lt;/div&gt;
Find “&lt;b&gt;icon&lt;/b&gt;” option. And select your particular file.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background: rgb(215, 235, 240); border-radius: 50%; border: 2px solid rgb(136, 109, 154); float: left; font-family: verdana; font-size: 16px; margin: 0px 10px; padding: 0px 0px 2px 2px; text-align: center; width: 25px;&quot;&gt;
&lt;b&gt;4.&lt;/b&gt; &lt;/div&gt;
If it not show any file just click on &#39;&lt;b&gt;Custom editor&lt;/b&gt;&#39; button&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhoMsevQJFPe_HBjR2xaK8UXCqLrMa81mO8NEGXMPT-iFPFU17YqoOlTrVKm6ctlShgPdjcPCv7kiWKxjo7_WR1NkoIx_QtoCEpC-NgW_8NqCqh-6EjvgCDHmLSIq9ljlKAID8ezxlRqD9r/s1600/CustomEditorbutton.jpg&quot; style=&quot;margin-left: 0em; margin-right: 0em;&quot;&gt;&lt;img alt=&quot;Custom_Editor_Buton_in_Java&quot; border=&quot;0&quot; data-original-height=&quot;17&quot; data-original-width=&quot;16&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhoMsevQJFPe_HBjR2xaK8UXCqLrMa81mO8NEGXMPT-iFPFU17YqoOlTrVKm6ctlShgPdjcPCv7kiWKxjo7_WR1NkoIx_QtoCEpC-NgW_8NqCqh-6EjvgCDHmLSIq9ljlKAID8ezxlRqD9r/s1600/CustomEditorbutton.jpg&quot; title=&quot;Custom_Editor_Buton_in_Java&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background: rgb(215, 235, 240); border-radius: 50%; border: 2px solid rgb(136, 109, 154); float: left; font-family: verdana; font-size: 16px; margin: 0px 10px; padding: 0px 0px 2px 2px; text-align: center; width: 25px;&quot;&gt;
&lt;b&gt;5.&lt;/b&gt; &lt;/div&gt;
And select file from there.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For &#39;&lt;b&gt;Custom editor&lt;/b&gt;&#39; button, you can see that it will contain with icon&#39;s option of Properties windows. For easily understanding process follow the image.&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;img alt=&quot;Set_Icon_in_jLabel&quot; border=&quot;0&quot; data-original-height=&quot;624&quot; data-original-width=&quot;800&quot; height=&quot;499&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAVjz5FYBv6tIgqdxZ7euNxyxJp7CTwqVDlVSZ_JLkh-sbRQv9i1ZEfUEEJg7Wp1wf8jeo3otY0NjG81OtVSRebZRe7YM6Lkw-5olWzSMbbbcWqySfgQHJyM0ww_b6auUniJdRXNwBDIzC/s640/2_Show_image_in_jLabel_web.jpg&quot; style=&quot;margin-left: auto; margin-right: auto;&quot; title=&quot;Set_Icon_in_jLabel&quot; width=&quot;640&quot; /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;i&gt;&lt;span style=&quot;color: purple;&quot;&gt;&lt;b&gt;jLabel icon setting&lt;/b&gt;&lt;/span&gt;&lt;/i&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
When you done all this process. It will display picture like shown in above figure.&lt;br /&gt;
So, this is the way of showing picture in static way.&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;a href=&quot;https://www.skotechlearn.com/2019/04/change-jlabel-style-design-color-java-netbeans.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;How to Design or Change Look of jLabel in Java in Netbeans&lt;/b&gt;&lt;/a&gt;&lt;/u&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2 class=&quot;DynamicWay&quot; style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;b&gt;(2) Display Image in jLabel in Java Swing Dynamic way:&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;
If you want to show image in dynamic way, you have to write code for it, Suppose you want to show picture during jFrame&#39;s open or activate. So write code as we describe bellow.&lt;br /&gt;
&lt;br /&gt;
But first, you have to import some class inside your java &lt;b&gt;Package&lt;/b&gt;:&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;package &lt;/span&gt;simple_java; 

&lt;span style=&quot;color: blue;&quot;&gt;  import &lt;/span&gt;java.awt.image.BufferedImage;
&lt;span style=&quot;color: blue;&quot;&gt;  import &lt;/span&gt;java.io.IOException;
&lt;span style=&quot;color: blue;&quot;&gt;  import &lt;/span&gt;javax.imageio.ImageIO;
&lt;span style=&quot;color: blue;&quot;&gt;  import &lt;/span&gt;javax.swing.ImageIcon;
&lt;/pre&gt;
&lt;br /&gt;
Now lets write show picture code on WindowsOpened evets:&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;private void&lt;/span&gt; formWindowOpened(java.awt.event.WindowEvent evt) { 
   &lt;span style=&quot;color: blue;&quot;&gt;try&lt;/span&gt;{
       BufferedImage image1 = ImageIO.read(getClass().getResource(&lt;span style=&quot;color: #b45f06;&quot;&gt;&quot;skotechlearn.png&quot;&lt;/span&gt;));
       &lt;span style=&quot;color: #09c009;&quot;&gt;jLabel1&lt;/span&gt;.setIcon(&lt;span style=&quot;color: blue;&quot;&gt;new &lt;/span&gt;ImageIcon(image1));
   }&lt;span style=&quot;color: blue;&quot;&gt;catch&lt;/span&gt;(IOException imgl){}

 }   
&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;How to show external image in jLabel?&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
If you want to show picture from external url or path, then write code like:&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;String myimgpath; 
myimgpath= &lt;span style=&quot;color: #b45f06;&quot;&gt;&quot;your exteral file path&quot;&lt;/span&gt;;
Icon myimgicon = &lt;span style=&quot;color: blue;&quot;&gt;new &lt;/span&gt;ImageIcon(myimgpath);
&lt;span style=&quot;color: #09c009;&quot;&gt;jLabel1&lt;/span&gt;.setIcon(myimgicon);
&lt;/pre&gt;
&lt;br /&gt;
When you run application then it will load picture during runtime and display it on jLabel.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: #ecf9f2; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; padding: 4px;&quot;&gt;
&lt;i&gt;&lt;span style=&quot;color: purple;&quot;&gt;&lt;b&gt;Note:- &lt;/b&gt;You can also set jLabel as background image by setting the height width of jLabel according to jFrame.&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;br /&gt;
So, this is the way of displaying image on jFrame in java Netbeans with static and dynamic process which is easily described in above given step by step process in SKOTechlearn post.&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;a href=&quot;https://www.skotechlearn.com/2019/05/create-swing-gui-project-with-jframe-design-java-netbeans.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;Simple Tips to Creating Swing GUI Application in Java&lt;/b&gt;&lt;/a&gt;&lt;/u&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
For further learning of coding, programming&amp;nbsp; or simple tips and trick related to OS, follow SKOTechlearn and learn things as simple as possible.&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;a href=&quot;https://www.skotechlearn.com/2019/05/design-jlist-show-items-in-jlist-java-netbeans.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;Tips to Use of jList for Showing Data in Java Swing&lt;/b&gt;&lt;/a&gt;&lt;/u&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>https://www.skotechlearn.com/2020/07/display-show-image-in-jframe-java-netbeans.html</link><author>noreply@blogger.com (SKOTechLearn)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgldsaZof5jESliUV84QbqhI5UzuUGfrleYQTKjfMNpbA9JpP8E2ldK1lwN_fCD7kuXIUbrQMVRGPtvRs-g0YM8cM6HJ1XK7bkhBlGcLgV13tJNk8JobRayBV8Jz7JGKZOTH88h6VnLbSTG/s72-c/1_copy_paste_image_in_Package_web.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2258844867892945003.post-4134269488057320306</guid><pubDate>Wed, 08 Jul 2020 11:33:00 +0000</pubDate><atom:updated>2020-08-06T01:05:04.604-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">VB.Net</category><title>Show Drives With Folders and Files in TreeView in VB.Net, C#</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;If you are trying to show Drives, Folders, Sub-Folders and Files without using &lt;b&gt;FolderBrowserDialog &lt;/b&gt;or &lt;b&gt;OpenFileDialog &lt;/b&gt;through VB.Net Code. Then you can try &lt;b&gt;TreeView control&lt;/b&gt; for this process. To use &lt;b&gt;TreeView as File Explorer or Folder Explorer,&lt;/b&gt; there are some simple and easy coding and setting tips you have to apply.&lt;br /&gt;
&lt;br /&gt;
So, here we try to &lt;b&gt;Show Drives with Folders and Files in TreeView in VB.Net, C#&lt;/b&gt; coding. &lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;&lt;a href=&quot;https://www.skotechlearn.com/2020/06/show-files-icons-in-listview-using-imagelist-vb6.html&quot; target=&quot;_blank&quot;&gt;(File&#39;s Icons in ListView) Show List of Files with Files&#39; Icons in Listview&lt;/a&gt;&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
But, first we understand why we need &lt;b&gt;TreeView as FileExplorer?&lt;/b&gt;&amp;nbsp;The answer is very simple, whenever we develop1 an application and want to show files, folders or drives in static way then we use many controls like ListBox, ListView or &lt;b&gt;TreeView as File browser or Folder browser&lt;/b&gt;. &lt;br /&gt;
&lt;br /&gt;
Now, Lets proceed with following point: &lt;br /&gt;
&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;b&gt;&lt;span style=&quot;color: #094a66; font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Show Drives with Folders and File in TreeView in VB.Net (VB, C#) &lt;/span&gt;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;&lt;span style=&quot;color: #094a66; font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: 16px; line-height: 35px;&quot;&gt;Get TreeView Selected Node Path in Label VB.Net (VB, C#)&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;br /&gt;
Now, let&#39;s start with point wise.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;&lt;a href=&quot;https://www.skotechlearn.com/2019/01/search-files-from-folders-or-directories-through-string-VB-Dot-Net.html&quot; target=&quot;_blank&quot;&gt;Searching Files from Folders or Sub-Folders through code using VB.Net&lt;/a&gt;&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid #b29a94; color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;b style=&quot;color: white;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;(1). Show Drives with Folders and File in TreeView in VB.Net (VB , C#) :&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;First we have to add some controls like Button, Label, Treeview. Now here we use these controls with following &lt;b&gt;Names&lt;/b&gt;. &lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;background-color: #fff2cc;&quot;&gt;ExplorerBtn &lt;/span&gt;:&lt;/b&gt; &lt;span style=&quot;background-color: #d9ead3;&quot;&gt;Button &lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;background-color: #fff2cc;&quot;&gt;MytrView1&lt;/span&gt; :&lt;/b&gt; &lt;span style=&quot;background-color: #d9ead3;&quot;&gt;Treeview &lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;background-color: #fff2cc;&quot;&gt;MyPathLabel&lt;/span&gt; :&lt;/b&gt; &lt;span style=&quot;background-color: #d9ead3;&quot;&gt;Label &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
First, we write code inside Button for calling Drives. &lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Button’s Click Event for Showing Drives in TreeView. &lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;VB.Net :&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt; Private Sub&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; ExplorerBtn_Click(sender &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;As &lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;Object&lt;/span&gt;, e &lt;span style=&quot;color: blue;&quot;&gt;As &lt;/span&gt;EventArgs)
  &lt;span style=&quot;color: #93c47d;&quot;&gt;&#39;Clear TreeView&lt;/span&gt;
  MytrView1.Nodes.&lt;span style=&quot;color: #351c75;&quot;&gt;Clear()&lt;/span&gt;

  &lt;span style=&quot;color: #93c47d;&quot;&gt;&#39;Loop For Get Drives&lt;/span&gt;
  &lt;span style=&quot;color: blue;&quot;&gt;For Each&lt;/span&gt; myDrives &lt;span style=&quot;color: blue;&quot;&gt;As &lt;/span&gt;&lt;span style=&quot;color: #674ea7;&quot;&gt;System.IO.DriveInfo&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;In &lt;/span&gt;&lt;span style=&quot;color: #674ea7;&quot;&gt;System.IO.DriveInfo.&lt;span style=&quot;color: #351c75;&quot;&gt;GetDrives()&lt;/span&gt;&lt;/span&gt;
     &lt;span style=&quot;color: blue;&quot;&gt;Dim &lt;/span&gt;myDrivesNode &lt;span style=&quot;color: blue;&quot;&gt;As &lt;/span&gt;TreeNode = MytrView1.Nodes.&lt;span style=&quot;color: #351c75;&quot;&gt;Add&lt;/span&gt;(mydrives.Name)
     &lt;span style=&quot;color: #93c47d;&quot;&gt;&#39;Adding &quot;Expand&quot; string is use for Add Expand &quot;[+]&quot; option on Drives&lt;/span&gt;
     myDrivesNode.Nodes.&lt;span style=&quot;color: #351c75;&quot;&gt;Add&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;Expand&quot;&lt;/span&gt;)
  &lt;span style=&quot;color: blue;&quot;&gt;Next&lt;/span&gt;

&lt;span style=&quot;color: blue;&quot;&gt; End Sub&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;b&gt;C# :&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt; private void&lt;/span&gt; ExplorerBtn_Click(&lt;span style=&quot;color: #cc0000;&quot;&gt;object &lt;/span&gt;sender, &lt;span style=&quot;color: #cc0000;&quot;&gt;EventArgs &lt;/span&gt;e)
 {
    &lt;span style=&quot;color: #93c47d;&quot;&gt;//Clear TreeView&lt;/span&gt;
    MytrView1.Nodes.&lt;span style=&quot;color: #351c75;&quot;&gt;Clear()&lt;/span&gt;;

    &lt;span style=&quot;color: #93c47d;&quot;&gt;//Loop For Get Drives&lt;/span&gt;
    &lt;span style=&quot;color: blue;&quot;&gt;foreach &lt;/span&gt;(&lt;span style=&quot;color: #351c75;&quot;&gt;System.IO.DriveInfo&lt;/span&gt; myDrives &lt;span style=&quot;color: blue;&quot;&gt;in &lt;/span&gt;&lt;span style=&quot;color: #351c75;&quot;&gt;System.IO.DriveInfo&lt;/span&gt;.&lt;span style=&quot;color: #351c75;&quot;&gt;GetDrives()&lt;/span&gt;)
    {
       TreeNode myDrivesNode = MytrView1.Nodes.&lt;span style=&quot;color: #351c75;&quot;&gt;Add&lt;/span&gt;(myDrives.Name);
       &lt;span style=&quot;color: #93c47d;&quot;&gt;//Adding &quot;Expand&quot; string is use for Add Expand &quot;[+]&quot; option on Drives&lt;/span&gt;
       myDrivesNode.Nodes.&lt;span style=&quot;color: #351c75;&quot;&gt;Add&lt;/span&gt;(&lt;span style=&quot;color: blue;&quot;&gt;&quot;Expand&quot;&lt;/span&gt;);
    }

  }
&lt;/pre&gt;&lt;br /&gt;
So, this code will present output in following way: &lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgw880RkrgCEIX-rvR_JJE5sPxDx56zEr1Ua53fGFiPxJ7AIw3Xi7HLhMbKHbFPd0Im7Z-kW-utBnMelHmWp_SY6PeDed9PVPnEW_S1Sys2XNajdMv02KjbMjwcBTIAIVTuvo1LKMQiOal9/s1600/Show_Drives_in_Treeview_web.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Show Drives in Treeview VB.Net&quot; border=&quot;0&quot; data-original-height=&quot;417&quot; data-original-width=&quot;428&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgw880RkrgCEIX-rvR_JJE5sPxDx56zEr1Ua53fGFiPxJ7AIw3Xi7HLhMbKHbFPd0Im7Z-kW-utBnMelHmWp_SY6PeDed9PVPnEW_S1Sys2XNajdMv02KjbMjwcBTIAIVTuvo1LKMQiOal9/s1600/Show_Drives_in_Treeview_web.jpg&quot; title=&quot;Show Drives in Treeview&quot; /&gt;&lt;/a&gt;&lt;/div&gt;After that, we use &#39;&lt;b&gt;BeforeExpand&lt;/b&gt;&#39; event of &lt;b&gt;Treeview &lt;/b&gt;for getting Folders and Files List on particular Drives.&lt;/div&gt;&lt;br /&gt;
&lt;b&gt;VB.Net : &lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt; Private Sub&lt;/span&gt; MytrView1_BeforeExpand(sender &lt;span style=&quot;color: blue;&quot;&gt;As&lt;/span&gt; Object, e &lt;span style=&quot;color: blue;&quot;&gt;As&lt;/span&gt; TreeViewCancelEventArgs)
   &lt;span style=&quot;color: blue;&quot;&gt;Dim&lt;/span&gt; MyExistNode &lt;span style=&quot;color: blue;&quot;&gt;As&lt;/span&gt; TreeNode = e.Node
   &lt;span style=&quot;color: #93c47d;&quot;&gt;&#39;Clear TreeNode&lt;/span&gt;
   MyExistNode.Nodes.&lt;span style=&quot;color: #351c75;&quot;&gt;Clear()&lt;/span&gt;

   &lt;span style=&quot;color: blue;&quot;&gt;Try&lt;/span&gt;
     &lt;span style=&quot;color: #93c47d;&quot;&gt;&#39;Loop For Get Folders&lt;/span&gt;
     &lt;span style=&quot;color: blue;&quot;&gt;Dim&lt;/span&gt; mypath &lt;span style=&quot;color: blue;&quot;&gt;As&lt;/span&gt; String = MyExistNode.FullPath

     &lt;span style=&quot;color: #93c47d;&quot;&gt;&#39;Loop For Get Folders&lt;/span&gt;
     &lt;span style=&quot;color: blue;&quot;&gt;For Each&lt;/span&gt; myFolders &lt;span style=&quot;color: blue;&quot;&gt;As&lt;/span&gt; String &lt;span style=&quot;color: blue;&quot;&gt;In&lt;/span&gt; System.IO.Directory.&lt;span style=&quot;color: #351c75;&quot;&gt;GetDirectories&lt;/span&gt;(mypath)
        &lt;span style=&quot;color: blue;&quot;&gt;Dim&lt;/span&gt; FldrNode &lt;span style=&quot;color: blue;&quot;&gt;As&lt;/span&gt; TreeNode = MyExistNode.Nodes.&lt;span style=&quot;color: #351c75;&quot;&gt;Add&lt;/span&gt;(System.IO.Path.&lt;span style=&quot;color: #351c75;&quot;&gt;GetFileName&lt;/span&gt;(myFolders))
        &lt;span style=&quot;color: #93c47d;&quot;&gt;&#39;Here, Expand is use for add Expanding option &quot;[+]&quot; on folder&lt;/span&gt;
        FldrNode.Nodes.&lt;span style=&quot;color: #351c75;&quot;&gt;Add&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;Expand&quot;&lt;/span&gt;)
     &lt;span style=&quot;color: blue;&quot;&gt;Next&lt;/span&gt;

     &lt;span style=&quot;color: #93c47d;&quot;&gt;&#39;Loop For Get Files&lt;/span&gt;
     &lt;span style=&quot;color: blue;&quot;&gt;For Each&lt;/span&gt; MyFiles &lt;span style=&quot;color: blue;&quot;&gt;As&lt;/span&gt; String &lt;span style=&quot;color: blue;&quot;&gt;In&lt;/span&gt; System.IO.Directory.&lt;span style=&quot;color: #351c75;&quot;&gt;GetFiles&lt;/span&gt;(mypath)
        &lt;span style=&quot;color: blue;&quot;&gt;Dim &lt;/span&gt;FLNode &lt;span style=&quot;color: blue;&quot;&gt;As&lt;/span&gt; TreeNode = MyExistNode.Nodes.&lt;span style=&quot;color: #351c75;&quot;&gt;Add&lt;/span&gt;(System.IO.Path.&lt;span style=&quot;color: #351c75;&quot;&gt;GetFileName&lt;/span&gt;(MyFiles))
     &lt;span style=&quot;color: blue;&quot;&gt;Next&lt;/span&gt;

    &lt;span style=&quot;color: blue;&quot;&gt;Catch&lt;/span&gt; ex &lt;span style=&quot;color: blue;&quot;&gt;As&lt;/span&gt; Exception

    &lt;span style=&quot;color: blue;&quot;&gt;End Try&lt;/span&gt;
  
 &lt;span style=&quot;color: blue;&quot;&gt;End Sub&lt;/span&gt;
&lt;/pre&gt;&lt;br /&gt;
&lt;b&gt;C# :&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;private void&lt;/span&gt; MytrView1_BeforeExpand(&lt;span style=&quot;color: #990000;&quot;&gt;object&lt;/span&gt; sender, &lt;span style=&quot;color: #990000;&quot;&gt;TreeViewCancelEventArgs&lt;/span&gt; e)
  {
     TreeNode MyExistNode = e.Node;
     &lt;span style=&quot;color: #93c47d;&quot;&gt;//Clear TreeNode&lt;/span&gt;
     MyExistNode.Nodes.&lt;span style=&quot;color: #351c75;&quot;&gt;Clear()&lt;/span&gt;;

     &lt;span style=&quot;color: #073763;&quot;&gt;try&lt;/span&gt;
      {
        &lt;span style=&quot;color: #990000;&quot;&gt;string &lt;/span&gt;mypath = MyExistNode.FullPath;

        &lt;span style=&quot;color: #93c47d;&quot;&gt;//Loop For Get Folders&lt;/span&gt;
        &lt;span style=&quot;color: blue;&quot;&gt;foreach &lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;string&lt;/span&gt; myFolders &lt;span style=&quot;color: blue;&quot;&gt;in&lt;/span&gt; System.IO.Directory.&lt;span style=&quot;color: #351c75;&quot;&gt;GetDirectories&lt;/span&gt;(mypath))
        {
           TreeNode FldrNode = MyExistNode.Nodes.&lt;span style=&quot;color: #351c75;&quot;&gt;Add&lt;/span&gt;(System.IO.Path.&lt;span style=&quot;color: #351c75;&quot;&gt;GetFileName&lt;/span&gt;(myFolders));
           &lt;span style=&quot;color: #93c47d;&quot;&gt;//Here, Expand is use for add Expanding option &quot;[+]&quot; on folder&lt;/span&gt;
           FldrNode.Nodes.&lt;span style=&quot;color: #351c75;&quot;&gt;Add&lt;/span&gt;(&lt;span style=&quot;color: blue;&quot;&gt;&quot;Expand&quot;&lt;/span&gt;);
         }

        &lt;span style=&quot;color: #93c47d;&quot;&gt;//Loop For Get Files&lt;/span&gt;
        &lt;span style=&quot;color: blue;&quot;&gt;foreach&lt;/span&gt; (&lt;span style=&quot;color: #990000;&quot;&gt;string&lt;/span&gt; MyFiles &lt;span style=&quot;color: blue;&quot;&gt;in&lt;/span&gt; System.IO.Directory.&lt;span style=&quot;color: #351c75;&quot;&gt;GetFiles&lt;/span&gt;(mypath))
         {
                
            TreeNode FLNode = MyExistNode.Nodes.&lt;span style=&quot;color: #351c75;&quot;&gt;Add&lt;/span&gt;(System.IO.Path.&lt;span style=&quot;color: #351c75;&quot;&gt;GetFileName&lt;/span&gt;(MyFiles));
               
          }

       }
        &lt;span style=&quot;color: #073763;&quot;&gt;catch&lt;/span&gt; (Exception FlErr)
       {
          MessageBox.&lt;span style=&quot;color: #351c75;&quot;&gt;Show&lt;/span&gt;(FlErr.&lt;span style=&quot;color: #351c75;&quot;&gt;ToString&lt;/span&gt;());
       }

   }
&lt;/pre&gt;&lt;br /&gt;
OK, when you run your application this will show following output: &lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjk5AcX1e0FwkCDTbsPjFddrQPWkgD_WHsN5vHt20k5JGbm-0ojSgJmqf6d43uBevjh1ee7_tOaoDakTqq9fzd3ZCGCUMNNiyFi119oc0a7KN4_jL00gxXiuM7VaOmHQHwjXaIgeUiYxqYG/s1600/Show_Drive_Folders_File_in_TreeView_VBDotNet_web.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Show Drives Folders Files in Treeview VB.Net&quot; border=&quot;0&quot; data-original-height=&quot;386&quot; data-original-width=&quot;397&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjk5AcX1e0FwkCDTbsPjFddrQPWkgD_WHsN5vHt20k5JGbm-0ojSgJmqf6d43uBevjh1ee7_tOaoDakTqq9fzd3ZCGCUMNNiyFi119oc0a7KN4_jL00gxXiuM7VaOmHQHwjXaIgeUiYxqYG/s1600/Show_Drive_Folders_File_in_TreeView_VBDotNet_web.jpg&quot; title=&quot;Show Drives Folders Files in Treeview&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
As you can see, when you click on any drive this will expand with containing Folders and files and when you expand any folder this will show your list of sub-folders and files in Treeview.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;&lt;a href=&quot;https://www.skotechlearn.com/2019/02/change-progressbar-color-style-use-in-vb.html&quot; target=&quot;_blank&quot;&gt;Styling ProgressBar in VB.Net&lt;/a&gt;&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid #b29a94; color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;b style=&quot;color: white;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;(2). Get Treeview Selected Node Path in Label VB.Net (VB, C#) :&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;Now, let’s try to get selected Node path in Label from Treeview. So, here we go through code process.&lt;br /&gt;
&lt;br /&gt;
You have to first go to &lt;b&gt;“AfterSelect”&lt;/b&gt; &lt;b&gt;event &lt;/b&gt;of &lt;b&gt;Treeview &lt;/b&gt;and write following code:&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;VB.Net:&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt; Private Sub&lt;/span&gt; MytrView1_AfterSelect(sender &lt;span style=&quot;color: blue;&quot;&gt;As&lt;/span&gt; &lt;span style=&quot;color: #990000;&quot;&gt;Object&lt;/span&gt;, e &lt;span style=&quot;color: blue;&quot;&gt;As&lt;/span&gt; TreeViewEventArgs)
    
  &lt;span style=&quot;color: blue;&quot;&gt;Dim&lt;/span&gt; MySelectedNode &lt;span style=&quot;color: blue;&quot;&gt;As&lt;/span&gt; TreeNode = e.Node
  &lt;span style=&quot;color: #93c47d;&quot;&gt;&#39;Get Selected Node Path&lt;/span&gt;
  MyPathLabel.Text = MySelectedNode.FullPath
    
 &lt;span style=&quot;color: blue;&quot;&gt;End Sub&lt;/span&gt;
&lt;/pre&gt;&lt;br /&gt;
&lt;b&gt;C# :&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;private void&lt;/span&gt; MytrView1_AfterSelect(&lt;span style=&quot;color: #990000;&quot;&gt;object&lt;/span&gt; sender, TreeViewEventArgs e)
  {
     TreeNode MySelectedNode = e.Node;
     &lt;span style=&quot;color: #93c47d;&quot;&gt;//Get Selected Node Path&lt;/span&gt;
     MyPathLabel.Text = MySelectedNode.FullPath;
    
  }
&lt;/pre&gt;&lt;br /&gt;
This will work like following way:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRbrswPvghZoASiuwMIueq0zYOojp00zOQoYx5CVoJfnY31ETywz5OhWWBoMLxIc7L-MwykPnKH7Th9HIs8WAFOOq7_SbNW0nF0DE_brZdmCB71SQ6qdr3ge5D3cBR9UFxkGIxC7EqsOpQ/s1600/Get+Treeview+Selected+Node_Path_web.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Get TreeView Selected Node Path in Label VB.Net&quot; border=&quot;0&quot; data-original-height=&quot;445&quot; data-original-width=&quot;394&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRbrswPvghZoASiuwMIueq0zYOojp00zOQoYx5CVoJfnY31ETywz5OhWWBoMLxIc7L-MwykPnKH7Th9HIs8WAFOOq7_SbNW0nF0DE_brZdmCB71SQ6qdr3ge5D3cBR9UFxkGIxC7EqsOpQ/s1600/Get+Treeview+Selected+Node_Path_web.jpg&quot; title=&quot;Get TreeView Selected Node Path in Label&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Okay, now we have learned how to &lt;b&gt;Show Drives with Folders and Files in TreeView in VB.Net&lt;/b&gt; using VB and C# code. You can also try and ask any question related to this topic describe in SKOTechLearn Tips.&lt;/div&gt;</description><link>https://www.skotechlearn.com/2020/07/show-drives-folders-files-in-treeview-vbnet.html</link><author>noreply@blogger.com (SKOTechLearn)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgw880RkrgCEIX-rvR_JJE5sPxDx56zEr1Ua53fGFiPxJ7AIw3Xi7HLhMbKHbFPd0Im7Z-kW-utBnMelHmWp_SY6PeDed9PVPnEW_S1Sys2XNajdMv02KjbMjwcBTIAIVTuvo1LKMQiOal9/s72-c/Show_Drives_in_Treeview_web.jpg" height="72" width="72"/><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2258844867892945003.post-501808795389288391</guid><pubDate>Fri, 03 Jul 2020 10:12:00 +0000</pubDate><atom:updated>2020-08-06T00:34:14.472-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">NetBeans</category><title>Change jTable Column Header and Rows Color in Java NetBeans Easily</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;In this post, SKOTechLearn will explain how to &lt;b&gt;Change Color of jTable&lt;/b&gt;&amp;nbsp;&lt;b&gt;in Java&lt;/b&gt; like Column Header Color, grid Color, Rows Color, Selection Color. When I was started programming in java and using jTable, I faced problem of &lt;b&gt;jTable background color foreground color&lt;/b&gt; of particular cells or rows and columns. &lt;br /&gt;
&lt;br /&gt;
So here are the simple and easy tips to &lt;b&gt;Change jTable Column Header and Rows Color in Java &lt;/b&gt;Netbeans Easily.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;&lt;a href=&quot;https://www.skotechlearn.com/2020/06/add-column-header-in-jtable-grid-setting-java-netbeans.html&quot; target=&quot;_blank&quot;&gt;Easily Add Column Header in jTable with Grid Settings in Java&lt;/a&gt;&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
So here SKOTechLearn will described, how to &lt;b&gt;Change jTable Column Header and Rows Color in Java NetBeans&lt;/b&gt;&amp;nbsp;in simple way?&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQShwZ3M2DZW_XetZO9V_j2n3S45UI_vEAoFupDMs8KwQlKb2DjlKJ2t3sPgklCC_r-9NFLL5fR3T9j3kDQS7em6-RQxOPZBj94GzL-jjhftXmKDDvN-Wsou-xY1L6W7LrzuWGBYS6x0mG/s1600/1_jTable-Color_Settings_web.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;jTable background and foreground color in Java&quot; border=&quot;0&quot; data-original-height=&quot;240&quot; data-original-width=&quot;534&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQShwZ3M2DZW_XetZO9V_j2n3S45UI_vEAoFupDMs8KwQlKb2DjlKJ2t3sPgklCC_r-9NFLL5fR3T9j3kDQS7em6-RQxOPZBj94GzL-jjhftXmKDDvN-Wsou-xY1L6W7LrzuWGBYS6x0mG/s1600/1_jTable-Color_Settings_web.jpg&quot; title=&quot;jTable background and foreground color&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;/div&gt;&lt;br /&gt;
So, Let’s take a look of Following Color changing point.&lt;br /&gt;
&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li style=&quot;color: #094a66; font-family: &amp;quot;oswald&amp;quot; , sans-serif; font-size: 15px; line-height: 40px;&quot;&gt;&lt;b&gt;jTable Column Header Background Color and Foreground or Font Color&amp;nbsp;&lt;/b&gt;&lt;/li&gt;
&lt;li style=&quot;color: #094a66; font-family: &amp;quot;oswald&amp;quot; , sans-serif; font-size: 15px; line-height: 40px;&quot;&gt;&lt;b&gt;jTable Column Header Background Color and Foreground Color in NetBeans&lt;/b&gt;&lt;/li&gt;
&lt;li style=&quot;color: #094a66; font-family: &amp;quot;oswald&amp;quot; , sans-serif; font-size: 15px; line-height: 40px;&quot;&gt;&lt;b&gt;jTable Rows Background and Foreground Color&lt;/b&gt;&lt;/li&gt;
&lt;li style=&quot;color: #094a66; font-family: &amp;quot;oswald&amp;quot; , sans-serif; font-size: 15px; line-height: 40px;&quot;&gt;&lt;b&gt;Change Background and Foreground Color of Particular Column&#39;s Rows in jTable&lt;/b&gt;&lt;/li&gt;
&lt;li style=&quot;color: #094a66; font-family: &amp;quot;oswald&amp;quot; , sans-serif; font-size: 15px; line-height: 40px;&quot;&gt;&lt;b&gt;jTable Selection background and Foreground Color&lt;/b&gt;&lt;/li&gt;
&lt;li style=&quot;color: #094a66; font-family: &amp;quot;oswald&amp;quot; , sans-serif; font-size: 15px; line-height: 40px;&quot;&gt;&lt;b&gt;jTable Selection Background and Foreground Setting in NetBeans&lt;/b&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;br /&gt;
First you have to import &lt;a href=&quot;https://docs.oracle.com/javase/7/docs/api/java/awt/Color.html&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;Color Class&lt;/b&gt;&lt;/a&gt;:&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt; import&lt;/span&gt; java.awt.Color;
&lt;/pre&gt;&lt;br /&gt;
Now, Let&#39;s Proceed with above given point.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid #b29a94; color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b style=&quot;color: white;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;(1). jTable Column Header Background Color and Foreground or Font Color :&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;There are many ways to change Header’s back color. You can change it through predefined system color or you can use custom color.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;background-color: #fff5e9; color: purple;&quot;&gt;Column Header background with default system Color&lt;/span&gt;:&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: #0baf31;&quot;&gt; MyTblView&lt;/span&gt;.getTableHeader().setBackground(Color.&lt;span style=&quot;color: #19a56d;&quot;&gt;&lt;i&gt;MAGENTA&lt;/i&gt;&lt;/span&gt;);
&lt;/pre&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;background-color: #fff5e9; color: purple;&quot;&gt;Column Header background with Custom Color :&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: #19a56d;&quot;&gt; MyTblView&lt;/span&gt;.getTableHeader().setBackground(Color.&lt;i&gt;decode&lt;/i&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;#696B9E&quot;&lt;/span&gt;));
&lt;/pre&gt;&lt;br /&gt;
&lt;b&gt;Or&lt;/b&gt; you can use &lt;b&gt;JTableHeader&lt;/b&gt; class.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;&lt;a href=&quot;https://www.skotechlearn.com/2020/06/jtable-sorting-in-java-netbeans.html&quot; target=&quot;_blank&quot;&gt;Enable or Show jTable Sorting Option in Java&lt;/a&gt;&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
First import this class:&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt; import&lt;/span&gt; javax.swing.table.JTableHeader;
&lt;/pre&gt;&lt;br /&gt;
Then use this class with following way:&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span&gt;&lt;span&gt; JTableHeader TblHeader = &lt;span style=&quot;color: #19a56d;&quot;&gt;MyTblView&lt;/span&gt;.getTableHeader();
 TblHeader.setBackground(Color.&lt;i&gt;&lt;span style=&quot;color: #19a56d;&quot;&gt;GREEN&lt;/span&gt;&lt;/i&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;Same above code process will apply here; we can set Foreground color with system default and custom color setting.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;background-color: #fff5e9; color: purple;&quot;&gt;Column Header Foreground with default system Color :&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: #19a56d;&quot;&gt; MyTblView&lt;/span&gt;.getTableHeader().setForeground(Color.&lt;span style=&quot;color: #19a56d;&quot;&gt;&lt;i&gt;BLUE&lt;/i&gt;&lt;/span&gt;);
&lt;/pre&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;background-color: #fff5e9; color: purple;&quot;&gt;Column Header Foreground with Custom Color :&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span&gt;&lt;span style=&quot;color: #19a56d;&quot;&gt; MyTblView&lt;/span&gt;.getTableHeader().setForeground(Color.&lt;i&gt;decode&lt;/i&gt;(&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&quot;#FCE7FC&quot;&lt;/span&gt;));
&lt;/pre&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;background-color: #fff5e9; color: purple;&quot;&gt;JTableHeader class for Foreground color code:&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;JTableHeader TblHeader = &lt;span style=&quot;color: #0baf31;&quot;&gt;MyTbleView&lt;/span&gt;.getTableHeader();
 TblHeader.setForeground(Color.&lt;i&gt;&lt;span style=&quot;color: #19a56d;&quot;&gt;RED&lt;/span&gt;&lt;/i&gt;);
&lt;/pre&gt;&lt;br /&gt;
When you run any code the output will show in following way:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhy0q0dm6W-wnNqwClv6gLyo19jf-qEGiQJ3VX7MJi3f4PTh8K2A0hbfj6tgDac4Hso48EzCJiTVoAIjgfONDIZffzHJ9BGZRISp8xXZsYxB-P2nzffioRX2HaiD2kGpw_ggWk11KPPVAOo/s1600/jTable_ColumnHeader_Background_and_Foreground_Color_web.jpg&quot; imageanchor=&quot;1&quot;&gt;&lt;img alt=&quot;jTable_ColumnHeader_Background_and_Foreground_Color_Java&quot; border=&quot;0&quot; data-original-height=&quot;105&quot; data-original-width=&quot;264&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhy0q0dm6W-wnNqwClv6gLyo19jf-qEGiQJ3VX7MJi3f4PTh8K2A0hbfj6tgDac4Hso48EzCJiTVoAIjgfONDIZffzHJ9BGZRISp8xXZsYxB-P2nzffioRX2HaiD2kGpw_ggWk11KPPVAOo/s1600/jTable_ColumnHeader_Background_and_Foreground_Color_web.jpg&quot; title=&quot;jTable_ColumnHeader_Background_and_Foreground_Color&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid #b29a94; color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b style=&quot;color: white;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;(2). jTable Column Header Background Color and Foreground Color in NetBeans :&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;If you are using NetBeans for swing GUI project using jTable, the column header color will apply in different coding way. You have to use &lt;b&gt;DefaultTableCellRenderer&lt;/b&gt; class in NetBeans Code.&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;DefaultTableCellRenderer MyHeaderRender = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; DefaultTableCellRenderer();
MyHeaderRender.setBackground(Color.&lt;i&gt;decode&lt;/i&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;#696B9E&quot;&lt;/span&gt;));
MyHeaderRender.setForeground(Color.&lt;i&gt;decode&lt;/i&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;#FCE7FC&quot;&lt;/span&gt;));

&lt;span style=&quot;color: #19a56d;&quot;&gt;MyTblView&lt;/span&gt;.getTableHeader().getColumnModel().getColumn(0).setHeaderRenderer(MyHeaderRender);
&lt;span style=&quot;color: #19a56d;&quot;&gt;MyTblView&lt;/span&gt;.getTableHeader().getColumnModel().getColumn(1).setHeaderRenderer(MyHeaderRender);
&lt;span style=&quot;color: #19a56d;&quot;&gt;MyTblView&lt;/span&gt;.getTableHeader().getColumnModel().getColumn(2).setHeaderRenderer(MyHeaderRender); 
&lt;/pre&gt;&lt;br /&gt;
After that this will show given output:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjC1HgqQIaMb9eOzwQXGLBrXBV9lx9lr1hES0i7zZrWM1jXb3rAYpVcGkrMcQn4miZ8kgzLcCFsCbwW3QKY_2lbyzRm7kCQPk3yYerrltdOxoZIG2IjgCi5UR10rTqEAJzgP7T_TPza4isT/s1600/Netbeans_jTable_Header_Color_output_web.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Netbeans_jTable_Header_Color&quot; border=&quot;0&quot; data-original-height=&quot;154&quot; data-original-width=&quot;305&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjC1HgqQIaMb9eOzwQXGLBrXBV9lx9lr1hES0i7zZrWM1jXb3rAYpVcGkrMcQn4miZ8kgzLcCFsCbwW3QKY_2lbyzRm7kCQPk3yYerrltdOxoZIG2IjgCi5UR10rTqEAJzgP7T_TPza4isT/s1600/Netbeans_jTable_Header_Color_output_web.jpg&quot; title=&quot;Netbeans_jTable_Header_Color_output&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid #b29a94; color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b style=&quot;color: white;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;(3). jTable Rows Background and Foreground Color :&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;There is simple code for doing this. But remember one thing; it can change color of all rows. The simple and easy codes are as follows:&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span&gt;&lt;span style=&quot;color: #24983f;&quot;&gt; MyTblView&lt;/span&gt;.setBackground(Color.&lt;i&gt;&lt;span style=&quot;color: #19a56d;&quot;&gt;LIGHT_GRAY&lt;/span&gt;&lt;/i&gt;);
&lt;span style=&quot;color: #24983f;&quot;&gt; MyTblView&lt;/span&gt;.setForeground(Color.&lt;i&gt;&lt;span style=&quot;color: #19a56d;&quot;&gt;BLUE&lt;/span&gt;&lt;/i&gt;);
&lt;/span&gt;&lt;/pre&gt;This code will not be use for particular rows settings.&lt;br /&gt;
&lt;br /&gt;
This will show the following output.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAt3RVmvrAubN3K7ZuARc1CC0ShjKUpfg0mliVHoRTnPXBqggDUR9mBQXEXNV1VXEE3ZsRrHx1NH1T5ryM8LU6jC7r5aAcjt6XPi1y9Ryz_s0kmmDWjt1knYpEblKoSCY9VEeFMfV9485I/s1600/jTable_Rows_Background_and_ForeGround_Color_Change_web.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;jTable_Rows_Background_and_ForeGround_Color&quot; border=&quot;0&quot; data-original-height=&quot;111&quot; data-original-width=&quot;262&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAt3RVmvrAubN3K7ZuARc1CC0ShjKUpfg0mliVHoRTnPXBqggDUR9mBQXEXNV1VXEE3ZsRrHx1NH1T5ryM8LU6jC7r5aAcjt6XPi1y9Ryz_s0kmmDWjt1knYpEblKoSCY9VEeFMfV9485I/s1600/jTable_Rows_Background_and_ForeGround_Color_Change_web.jpg&quot; title=&quot;jTable_Rows_Background_and_ForeGround_Color_output&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid #b29a94; color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b style=&quot;color: white;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;(4). Change Background and Foreground Color of Particular Column&#39;s Rows in jTable :&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;Now, this is the very interesting point, because I have searched this point in many web-page and not find any suitable way to do this.&lt;br /&gt;
&lt;br /&gt;
But, SKOTechLearn will explain simple tips to &lt;b&gt;change Particular Column color of jTable&lt;/b&gt; in Java it, write or copy given code and see what happen.&lt;br /&gt;
&lt;br /&gt;
First you have to import &lt;b&gt;&lt;a href=&quot;https://docs.oracle.com/javase/7/docs/api/javax/swing/table/DefaultTableCellRenderer.html&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;DefaultTableCellRenderer&lt;/a&gt;&lt;/b&gt; class:&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;import&lt;/span&gt; javax.swing.table.DefaultTableCellRenderer;
&lt;/pre&gt;&lt;br /&gt;
After that write given code:&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span&gt; DefaultTableCellRenderer MyCellrendar = &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; DefaultTableCellRenderer();
 
 MyCellrendar.setBackground(Color.&lt;i&gt;&lt;span style=&quot;color: #19a56d;&quot;&gt;yellow&lt;/span&gt;&lt;/i&gt;);
 MyCellrendar.setForeground(Color.&lt;span style=&quot;color: #19a56d;&quot;&gt;RED&lt;/span&gt;);

 &lt;span style=&quot;color: #19a56d;&quot;&gt;MyTblView&lt;/span&gt;.getColumnModel().getColumn(1).setCellRenderer(MyCellrendar);
&lt;/pre&gt;&lt;br /&gt;
The output will be display like:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRzcuUqEv7nFSBu7zS5E7bejMVurDLbG8E7U4rDkf3dx8Uwn1p68XItSkAXy5CSerVnPwRSeF-5fdAwoFZn5I3xhbJoR71GLk9ZlOm8iEyhEN5_EItQg8nkvMlj_7ASnA7ypzq7xYZKLoz/s1600/jTable_Particuluar_Column_color_change_web.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;jTable_Particuluar_Column_and_cell_color_java&quot; border=&quot;0&quot; data-original-height=&quot;116&quot; data-original-width=&quot;258&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRzcuUqEv7nFSBu7zS5E7bejMVurDLbG8E7U4rDkf3dx8Uwn1p68XItSkAXy5CSerVnPwRSeF-5fdAwoFZn5I3xhbJoR71GLk9ZlOm8iEyhEN5_EItQg8nkvMlj_7ASnA7ypzq7xYZKLoz/s1600/jTable_Particuluar_Column_color_change_web.jpg&quot; title=&quot;jTable_Particuluar_Column_and_cell_color&quot; /&gt;&lt;/a&gt;&lt;/div&gt;In &lt;b&gt;getColumn()&lt;/b&gt; method, you can put any column number inside it and this will apply on that particular column&#39;s rows.&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid #b29a94; color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b style=&quot;color: white;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;(5). jTable Selection background and Foreground Color :&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;In java, there is facility to change selection color of particular rows in jtable according to requirement.&lt;br /&gt;
&lt;br /&gt;
You can apply one line code as described below:&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: #19a56d;&quot;&gt; MyTblView&lt;/span&gt;.setSelectionBackground(Color.&lt;i&gt;&lt;span style=&quot;color: #19a56d;&quot;&gt;BLACK&lt;/span&gt;&lt;/i&gt;);
 &lt;span style=&quot;color: #19a56d;&quot;&gt;MyTblView&lt;/span&gt;.setSelectionForeground(Color.&lt;i&gt;&lt;span style=&quot;color: #19a56d;&quot;&gt;YELLOW&lt;/span&gt;&lt;/i&gt;);
&lt;/pre&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinzPD3bv9D5qZ-IYbD5vDlQk6Ucp0IhSgXihcAX822S9KlWqL_euUAmZrJ-1nPSK2yhFw5k673IrI4WwTH-1yy2pWGMWYqNBJuuL5dxGVgIsxqZ3BhEZ3UU2w9qFG_8sIB5OQYasu0lqH4/s1600/jTable_Selection_Color_Setting_java_web.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;jTable_Selection_Background_Foreground_Color&quot; border=&quot;0&quot; data-original-height=&quot;105&quot; data-original-width=&quot;276&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinzPD3bv9D5qZ-IYbD5vDlQk6Ucp0IhSgXihcAX822S9KlWqL_euUAmZrJ-1nPSK2yhFw5k673IrI4WwTH-1yy2pWGMWYqNBJuuL5dxGVgIsxqZ3BhEZ3UU2w9qFG_8sIB5OQYasu0lqH4/s1600/jTable_Selection_Color_Setting_java_web.jpg&quot; title=&quot;jTable_Selection_Color_Setting_java&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid #b29a94; color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b style=&quot;color: white;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;(6). jTable Selection Background and Foreground Setting in NetBeans :&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;If you are using NetBeans, then you can simply go to &lt;b&gt;“Properties”&lt;/b&gt; window and find &lt;b&gt;“selectionBackground”&lt;/b&gt; and &lt;b&gt;“selectionForeground”&lt;/b&gt; option and choose color according to your requirement.&lt;br /&gt;
&lt;br /&gt;
Steps are described in given following image:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhuHtNNkoo36tw7_gEfEq9QhKZP2JtsIg_DYU1-yeflztZen2woRG0tddBJ4HNArrL9IK2ZDRim0SEpJqzamGiSDggsiLxz9JvyGauDOmw0BXkzuiRRknRW5QBAatvqo605MpQBuNGdw9lG/s1600/jTable_Selection_Color_Setting_Netbeans_web.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;jTable_Selection_Color_Setting_Netbeans&quot; border=&quot;0&quot; data-original-height=&quot;183&quot; data-original-width=&quot;602&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhuHtNNkoo36tw7_gEfEq9QhKZP2JtsIg_DYU1-yeflztZen2woRG0tddBJ4HNArrL9IK2ZDRim0SEpJqzamGiSDggsiLxz9JvyGauDOmw0BXkzuiRRknRW5QBAatvqo605MpQBuNGdw9lG/s1600/jTable_Selection_Color_Setting_Netbeans_web.jpg&quot; title=&quot;jTable_Selection_Color_Setting_Netbeans&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
So, these are the color changing process which is explained in &lt;b&gt;Change jTable Column Header and Rows Color in Java NetBeans Easily.&lt;/b&gt;&lt;/div&gt;</description><link>https://www.skotechlearn.com/2020/07/jtable-column-and-rows-color-change-java.html</link><author>noreply@blogger.com (SKOTechLearn)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQShwZ3M2DZW_XetZO9V_j2n3S45UI_vEAoFupDMs8KwQlKb2DjlKJ2t3sPgklCC_r-9NFLL5fR3T9j3kDQS7em6-RQxOPZBj94GzL-jjhftXmKDDvN-Wsou-xY1L6W7LrzuWGBYS6x0mG/s72-c/1_jTable-Color_Settings_web.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2258844867892945003.post-7051171088542744807</guid><pubDate>Sat, 27 Jun 2020 08:04:00 +0000</pubDate><atom:updated>2020-08-04T05:02:51.411-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">NetBeans</category><title>Add Column Header in JTable and Grid Line Settings in jTable in Java</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;When you design you java project and want to show list of data in rows and columns format, you require a table or list, but List only contain one column with multiple rows and table contains multiple columns with multiple rows. You can find complete details of &lt;a href=&quot;https://docs.oracle.com/javase/7/docs/api/javax/swing/JTable.html&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;jTable class&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
So Friends, here SKOTechLearn will discuss about jTable in Java with details description of &lt;b&gt;Add Column Header in JTable in Java&lt;/b&gt; with &lt;b&gt;jTable Grid setting in java NetBeans&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;&lt;a href=&quot;https://www.skotechlearn.com/2020/07/jtable-column-and-rows-color-change-java.html&quot; target=&quot;_blank&quot;&gt;Change jTable&#39;s Column Header, Rows, Cell, Selection Color With Simple Steps&lt;/a&gt;&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Suppose, you want to display some records which contains some Column. Then we have to drag jTable or write code for Adding Column Header in Java with Grid Settigns.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;u&gt;&lt;a href=&quot;https://www.skotechlearn.com/2020/06/jtable-sorting-in-java-netbeans.html&quot; target=&quot;_blank&quot;&gt;Add Sort option in JTable in Java&lt;/a&gt;&lt;/u&gt;&lt;/b&gt;&amp;nbsp;&lt;/div&gt;&lt;br /&gt;
Here we proceed with following way:&lt;br /&gt;
&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;b&gt;&lt;span style=&quot;color: #38576c; font-family: &amp;quot;arial&amp;quot;; font-size: 16px; line-height: 35px;&quot;&gt;Add Column Header in jTable in Java Code&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;&lt;span style=&quot;color: #38576c; font-family: &amp;quot;arial&amp;quot;; font-size: 16px; line-height: 35px;&quot;&gt;Add Column Header in jTable in Netbeans through Properties&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;&lt;span style=&quot;color: #38576c; font-family: &amp;quot;arial&amp;quot;; font-size: 16px; line-height: 35px;&quot;&gt;jTable Grid Line Setting in java code&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;&lt;span style=&quot;color: #38576c; font-family: &amp;quot;arial&amp;quot;; font-size: 16px; line-height: 35px;&quot;&gt;jTable Grid line Setting in java Netbeans through Properties&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;br /&gt;
So, let’s start with point to point.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid #b29a94; color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;font-size: 17px;&quot;&gt;&lt;b&gt;(1). Add Column Header in jTable in Java Code :&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;For &lt;b&gt;Column Header in JTable&lt;/b&gt;, you have to import some class as describe bellow:&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;import&lt;/span&gt; javax.swing.JFrame;
 &lt;span style=&quot;color: blue;&quot;&gt;import&lt;/span&gt; javax.swing.JScrollPane;
 &lt;span style=&quot;color: blue;&quot;&gt;import&lt;/span&gt; javax.swing.JTable;
 &lt;span style=&quot;color: blue;&quot;&gt;import&lt;/span&gt; javax.swing.table.DefaultTableModel;
&lt;/pre&gt;&lt;br /&gt;
After that simply write following code:&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt; import&lt;/span&gt; javax.swing.JFrame;
 &lt;span style=&quot;color: blue;&quot;&gt;import &lt;/span&gt;javax.swing.JScrollPane;
 &lt;span style=&quot;color: blue;&quot;&gt;import&lt;/span&gt; javax.swing.JTable;
 &lt;span style=&quot;color: blue;&quot;&gt;import&lt;/span&gt; javax.swing.table.DefaultTableModel;

 &lt;span style=&quot;color: blue;&quot;&gt;public class&lt;/span&gt; MyTableClass {

   &lt;span style=&quot;color: blue;&quot;&gt;public static void&lt;/span&gt; main(String[] args) {
    &lt;span style=&quot;color: #999999;&quot;&gt;// TableModel is use for showing rows and columns&lt;/span&gt;
    DefaultTableModel MyTablemodel = &lt;span style=&quot;color: blue;&quot;&gt;new &lt;/span&gt;DefaultTableModel();
    &lt;span style=&quot;color: #999999;&quot;&gt;//Create New Table&lt;/span&gt;
    JTable &lt;span style=&quot;color: #0abc34;&quot;&gt;MyTableView &lt;/span&gt;= &lt;span style=&quot;color: blue;&quot;&gt;new &lt;/span&gt;JTable(MyTablemodel);
    &lt;span style=&quot;color: #999999;&quot;&gt;// Add jTable in jScollPane for Showing Column Header&lt;/span&gt;
    JScrollPane &lt;span style=&quot;color: #0abc34;&quot;&gt;MyScrollPane&lt;/span&gt;= &lt;span style=&quot;color: blue;&quot;&gt;new &lt;/span&gt;JScrollPane(&lt;span style=&quot;color: #0abc34;&quot;&gt;MyTableView&lt;/span&gt;);
    &lt;span style=&quot;color: #999999;&quot;&gt;//Add Column Name &lt;/span&gt;
    MyTablemodel.addColumn(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;MyColHead_ID&quot;&lt;/span&gt;);
    MyTablemodel.addColumn(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;MyColHead_Name&quot;&lt;/span&gt;);
    MyTablemodel.addColumn(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;MyColHead_Contact&quot;&lt;/span&gt;);
    &lt;span style=&quot;color: #999999;&quot;&gt;//Add jFrame for showing Table inside frame&lt;/span&gt;
    JFrame MyTblFrame = &lt;span style=&quot;color: blue;&quot;&gt;new &lt;/span&gt;JFrame();
    MyTblFrame.setTitle(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;jTable Column Header Frame&quot;&lt;/span&gt;);
    &lt;span style=&quot;color: #999999;&quot;&gt;//Set jFrame Size&lt;/span&gt;
    MyTblFrame.setSize(410, 320);
    MyTblFrame.add(&lt;span style=&quot;color: #0abc34;&quot;&gt;MyScrollPane&lt;/span&gt;);
    MyTblFrame.setVisible(&lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;);
   }
    
 }
&lt;/pre&gt;&lt;br /&gt;
&lt;div style=&quot;background-color: #e8f9ef; border-radius: 3px; border: 1px groove #c9e4ff;&quot;&gt;&lt;i&gt;&lt;b&gt;Note : &lt;/b&gt; If you want to add rows and columns,  &lt;b&gt;&lt;a href=&quot;https://docs.oracle.com/javase/7/docs/api/javax/swing/table/DefaultTableModel.html&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;DefaultTableModel &lt;/a&gt;&lt;/b&gt;will provide facility to do this.&lt;/i&gt;&lt;/div&gt;&lt;br /&gt;
When you execute this code this will show the following result:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmhEoDYUVQvKyDlzM4zatHmYstl0J3STw87-T5DulsZTgYSQjbWWrbDZewLdz0hqDxcIMNPh3kryNlAvtwT5YFdv0tqQ6qeOEurmGbHJoDreXm1YwOlsYmh1CLw3bUhPOo8KMuC-5ykAtl/s1600/1_JTable_Column_Header_Java_web.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;jTable Column Header in Java&quot; border=&quot;0&quot; data-original-height=&quot;174&quot; data-original-width=&quot;292&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmhEoDYUVQvKyDlzM4zatHmYstl0J3STw87-T5DulsZTgYSQjbWWrbDZewLdz0hqDxcIMNPh3kryNlAvtwT5YFdv0tqQ6qeOEurmGbHJoDreXm1YwOlsYmh1CLw3bUhPOo8KMuC-5ykAtl/s1600/1_JTable_Column_Header_Java_web.jpg&quot; title=&quot;jTable Column Header in Java&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid #b29a94; color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b style=&quot;color: white;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;(2). Add Column Header in jTable in NetBeans through Properties :&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;If you are using NetBeans for Java, First drag jTable in jFrame after that simply follow the following steps.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background: #ffe6e6; border-radius: 50%; border: 2px solid #886d9a; float: left; font-family: &amp;quot;verdana&amp;quot;; font-size: 16px; padding: 0px 0px 2px 2px; text-align: center; width: 25px;&quot;&gt;&lt;b&gt;1.&lt;/b&gt; &lt;/div&gt;&amp;nbsp;&lt;span style=&quot;font-size: 15px;&quot;&gt;Right Click on jTable control and find &lt;b&gt;“Table Contents…”&lt;/b&gt; option.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background: #ffe6e6; border-radius: 50%; border: 2px solid #886d9a; float: left; font-family: &amp;quot;verdana&amp;quot;; font-size: 16px; padding: 0px 0px 2px 2px; text-align: center; width: 25px;&quot;&gt;&lt;b&gt;2.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;&lt;span style=&quot;font-size: 15px;&quot;&gt;Click on &lt;b&gt;“Table Contents…”&lt;/b&gt; option.  &lt;b&gt;“Customizer Dialog”&lt;/b&gt; will be displayed.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background: #ffe6e6; border-radius: 50%; border: 2px solid #886d9a; float: left; font-family: &amp;quot;verdana&amp;quot;; font-size: 16px; padding: 0px 0px 2px 2px; text-align: center; width: 25px;&quot;&gt;&lt;b&gt;3.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;&lt;span style=&quot;font-size: 15px;&quot;&gt;&lt;b&gt;“Customizer Dialog”&lt;/b&gt; contains three tabs (&lt;b&gt;Table Model&lt;/b&gt;, &lt;b&gt;Columns&lt;/b&gt;, &lt;b&gt;Rows &lt;/b&gt;).&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background: #ffe6e6; border-radius: 50%; border: 2px solid #886d9a; float: left; font-family: &amp;quot;verdana&amp;quot;; font-size: 16px; padding: 0px 0px 2px 2px; text-align: center; width: 25px;&quot;&gt;&lt;b&gt;4.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;&lt;span style=&quot;font-size: 15px;&quot;&gt;For headers, you have to choose &lt;b&gt;“Columns” tab&lt;/b&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background: #ffe6e6; border-radius: 50%; border: 2px solid #886d9a; float: left; font-family: &amp;quot;verdana&amp;quot;; font-size: 16px; padding: 0px 0px 2px 2px; text-align: center; width: 25px;&quot;&gt;&lt;b&gt;5.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;&lt;span style=&quot;font-size: 15px;&quot;&gt;In &lt;b&gt;“Columns”&lt;/b&gt; tab, you will find a table containing &lt;b&gt;“Title, type, Resizable, Editable”&lt;/b&gt;. This is use for Column header settings.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background: #ffe6e6; border-radius: 50%; border: 2px solid #886d9a; float: left; font-family: &amp;quot;verdana&amp;quot;; font-size: 16px; padding: 0px 0px 2px 2px; text-align: center; width: 25px;&quot;&gt;&lt;b&gt;6.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;&lt;span style=&quot;font-size: 15px;&quot;&gt;Choose &lt;b&gt;“Columns”&lt;/b&gt; tab which is also contain some buttons(&lt;b&gt;Insert&lt;/b&gt;, &lt;b&gt;Delete&lt;/b&gt;, &lt;b&gt;Move Up&lt;/b&gt;, &lt;b&gt;Move Down&lt;/b&gt;).&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background: #ffe6e6; border-radius: 50%; border: 2px solid #886d9a; float: left; font-family: &amp;quot;verdana&amp;quot;; font-size: 16px; padding: 0px 0px 2px 2px; text-align: center; width: 25px;&quot;&gt;&lt;b&gt;7.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;&lt;span style=&quot;font-size: 15px;&quot;&gt;&lt;b&gt;‘Insert’&lt;/b&gt; button is used to add Columns, &lt;b&gt;‘Delete’&lt;/b&gt; is used for delete Columns, &lt;b&gt;‘Move Up’&lt;/b&gt; and &lt;b&gt;‘Move Down’&lt;/b&gt; button is used for move column left or right in jTable according to your requirement.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background: #ffe6e6; border-radius: 50%; border: 2px solid #886d9a; float: left; font-family: &amp;quot;verdana&amp;quot;; font-size: 16px; padding: 0px 0px 2px 2px; text-align: center; width: 25px;&quot;&gt;&lt;b&gt;8.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;&lt;span style=&quot;font-size: 15px;&quot;&gt;Select &lt;b&gt;‘Title’&lt;/b&gt; Column from table and go to &lt;b&gt;“Title”&lt;/b&gt; box and write your column Name.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background: #ffe6e6; border-radius: 50%; border: 2px solid #886d9a; float: left; font-family: &amp;quot;verdana&amp;quot;; font-size: 16px; padding: 0px 0px 2px 2px; text-align: center; width: 25px;&quot;&gt;&lt;b&gt;9.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;&lt;span style=&quot;font-size: 15px;&quot;&gt;After that simply close &lt;b&gt;“Customizer Dialog”&lt;/b&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMWGcswleuwhfITbdz-7u63gTNKbK-TUDM_s-pzr1WxAGc3Hy0xjUPifwG4LNBpiP9D8iDD4KDvHsgSi72FeUjqkeRxWErWVJ49y4d26aOfiec4dcpxSFLVpSgYK5hU-3skF1U85mrm8uy/s1600/2_jTable_Column_Header_Setting1_web.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;jTable Column Header Settings in Netbeans&quot; border=&quot;0&quot; data-original-height=&quot;326&quot; data-original-width=&quot;938&quot; height=&quot;222&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMWGcswleuwhfITbdz-7u63gTNKbK-TUDM_s-pzr1WxAGc3Hy0xjUPifwG4LNBpiP9D8iDD4KDvHsgSi72FeUjqkeRxWErWVJ49y4d26aOfiec4dcpxSFLVpSgYK5hU-3skF1U85mrm8uy/s640/2_jTable_Column_Header_Setting1_web.jpg&quot; title=&quot;jTable Column Header Settings in Netbeans&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;b&gt;&lt;i&gt;&lt;span style=&quot;color: purple;&quot;&gt;Column Header Settings in NetBeans&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
When all settings will be done, your table will looks like bellow.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixhNFAkkdjpriJFPHK0ALRNwvnKXBKz3-dvLL8reVXr6iJp6KjqaDhANw9UwX_TKwd8bTEOZll-FN7kWQTQXjkkKdFt5Wekz_oGx9hOUOcKx5GCYvALaG-WfX4zgcGk-nQ0v-inZUWD7Wj/s1600/3_jTable_Column_Settings_output_web.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;jTable Column Header Setting output in Netbeans&quot; border=&quot;0&quot; data-original-height=&quot;207&quot; data-original-width=&quot;272&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixhNFAkkdjpriJFPHK0ALRNwvnKXBKz3-dvLL8reVXr6iJp6KjqaDhANw9UwX_TKwd8bTEOZll-FN7kWQTQXjkkKdFt5Wekz_oGx9hOUOcKx5GCYvALaG-WfX4zgcGk-nQ0v-inZUWD7Wj/s1600/3_jTable_Column_Settings_output_web.jpg&quot; title=&quot;jTable Column Header Setting output in Netbeans&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid #b29a94; color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b style=&quot;color: white;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;(3). jTable Grid Line Setting in java code :&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;If you want to change Grid Line color of jTable, first you have to add some rows and then you can write following code which is very simple and one line code.&lt;br /&gt;
&lt;br /&gt;
Grid Color Setting Code:&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: #0abc34;&quot;&gt; MyTableView&lt;/span&gt;.setGridColor(Color.&lt;i&gt;&lt;span style=&quot;color: #0abc34;&quot;&gt;red&lt;/span&gt;&lt;/i&gt;);
&lt;/pre&gt;&lt;br /&gt;
Now check it with following code:&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;public static void&lt;/span&gt; main(String[] args) {
    DefaultTableModel MyTablemodel = &lt;span style=&quot;color: blue;&quot;&gt;new &lt;/span&gt;DefaultTableModel();
    JTable &lt;span style=&quot;color: #0BAB31;&quot;&gt;MyTableView &lt;/span&gt;= &lt;span style=&quot;color: blue;&quot;&gt;new &lt;/span&gt;JTable(MyTablemodel);
   
    &lt;span style=&quot;color: #999999;&quot;&gt;//jTable grid Line Settings&lt;/span&gt;
    &lt;span style=&quot;color: #0BAB31;&quot;&gt;MyTableView&lt;/span&gt;.setGridColor(Color.&lt;i&gt;&lt;span style=&quot;color: #274e13;&quot;&gt;red&lt;/span&gt;&lt;/i&gt;);
    
    JScrollPane &lt;span style=&quot;color: #274e13;&quot;&gt;MyScrollPane&lt;/span&gt;= &lt;span style=&quot;color: blue;&quot;&gt;new &lt;/span&gt;JScrollPane(&lt;span style=&quot;color: #0BAB31;&quot;&gt;MyTableView&lt;/span&gt;);
    MyTablemodel.addColumn(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;MyColHead_ID&quot;&lt;/span&gt;);
    MyTablemodel.addColumn(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;MyColHead_Name&quot;&lt;/span&gt;);
    MyTablemodel.addColumn(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;MyColHead_Contact&quot;&lt;/span&gt;);
    &lt;span style=&quot;color: #999999;&quot;&gt;// add some rows&lt;/span&gt;
    MyTablemodel.addRow(&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; Object[]{&lt;span style=&quot;color: #990000;&quot;&gt;&quot;Col1Row1_0000&quot;&lt;/span&gt;, &lt;span style=&quot;color: #990000;&quot;&gt;&quot;Col2Row1_ABCD&quot;&lt;/span&gt;, &lt;span style=&quot;color: #990000;&quot;&gt;&quot;Col3Row1_XXX0124556&quot;&lt;/span&gt;});
    MyTablemodel.addRow(&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; Object[]{&lt;span style=&quot;color: #990000;&quot;&gt;&quot;Col1Row1_0001&quot;&lt;/span&gt;, &lt;span style=&quot;color: #990000;&quot;&gt;&quot;Col2Row1_EFGH&quot;&lt;/span&gt;, &lt;span style=&quot;color: #990000;&quot;&gt;&quot;Col3Row1_XXX01253344&quot;&lt;/span&gt;});
    
    JFrame MyTblFrame = &lt;span style=&quot;color: blue;&quot;&gt;new &lt;/span&gt;JFrame();
    MyTblFrame.setTitle(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;jTable Column Header Frame&quot;&lt;/span&gt;);
    
    MyTblFrame.setSize(410, 250);
    MyTblFrame.add(&lt;span style=&quot;color: #274e13;&quot;&gt;MyScrollPane&lt;/span&gt;);
    MyTblFrame.setVisible(&lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;);
  }
&lt;/pre&gt;&lt;br /&gt;
This will display output in given following figure:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8ZZmsTqR05MxQspr942Q4oMyuZfqqg3Cfhhydl_HfEmVaZN2DUtODh1u5r8WBBVO4zCBRN-1G64S6SkQv_WHoZm3jlvx-fUStU9H-Q9qXZAYCYp_kOvAxwPW8DXX4Vy4_NJm1xtymC4EC/s1600/4_jTable_Grid_Line_Color_Setting_java_web.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;jTable Gird Color Change in Java&quot; border=&quot;0&quot; data-original-height=&quot;129&quot; data-original-width=&quot;357&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8ZZmsTqR05MxQspr942Q4oMyuZfqqg3Cfhhydl_HfEmVaZN2DUtODh1u5r8WBBVO4zCBRN-1G64S6SkQv_WHoZm3jlvx-fUStU9H-Q9qXZAYCYp_kOvAxwPW8DXX4Vy4_NJm1xtymC4EC/s1600/4_jTable_Grid_Line_Color_Setting_java_web.jpg&quot; title=&quot;Change Grid line Color in jTable Java&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid #b29a94; color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b style=&quot;color: white;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;(4). jTable Grid Line Setting in java Netbeans through Properties :&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;If you are using NetBeans for creating Swing project, you will find that jTable has no GridLines. First you have to add Gridlines then you can change Grid color according to your requirement.&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: #0BAB31;&quot;&gt; MyTableView&lt;/span&gt;.setShowGrid(&lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;);
 &lt;span style=&quot;color: #0BAB31;&quot;&gt;MyTableView&lt;/span&gt;.setGridColor(Color.&lt;i&gt;&lt;span style=&quot;color: #0BAB31;&quot;&gt;MAGENTA&lt;/span&gt;&lt;/i&gt;);
&lt;/pre&gt;&lt;br /&gt;
Or you can simple choose Grid Color from &lt;b&gt;“Properties”&lt;/b&gt; window like bellow:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZWhvqJIDQoiQZ4m2bAqa2tulkYz4ETmMsdnVBSJbRLM9lvL-UipG0kDd6TnWyn-tM6T-NOZl9hLMKx6ggtUn9LOTUeRR_BYr9CwV-0JIahhyphenhyphenb8Qw-7-2MwFQok8ilpW29iv6ZXqvWKe4h/s1600/5_jTable_Grid_Color_properties_in_netbeans_web.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;jTable Grid Color Properties in Netbeans&quot; border=&quot;0&quot; data-original-height=&quot;274&quot; data-original-width=&quot;697&quot; height=&quot;251&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZWhvqJIDQoiQZ4m2bAqa2tulkYz4ETmMsdnVBSJbRLM9lvL-UipG0kDd6TnWyn-tM6T-NOZl9hLMKx6ggtUn9LOTUeRR_BYr9CwV-0JIahhyphenhyphenb8Qw-7-2MwFQok8ilpW29iv6ZXqvWKe4h/s640/5_jTable_Grid_Color_properties_in_netbeans_web.jpg&quot; title=&quot;jTable Grid Color Properties in Netbeans&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
So, In this post you can see, how amazing is to work in java and NetBeans framework. You can simply &lt;b&gt;Add Column Header in JTable&lt;/b&gt; and &lt;b&gt;Grid Line Setting in jTable in Java&lt;/b&gt; which is detailed explained by SKOTechLearn.&lt;/div&gt;&lt;/div&gt;</description><link>https://www.skotechlearn.com/2020/06/add-column-header-in-jtable-grid-setting-java-netbeans.html</link><author>noreply@blogger.com (SKOTechLearn)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmhEoDYUVQvKyDlzM4zatHmYstl0J3STw87-T5DulsZTgYSQjbWWrbDZewLdz0hqDxcIMNPh3kryNlAvtwT5YFdv0tqQ6qeOEurmGbHJoDreXm1YwOlsYmh1CLw3bUhPOo8KMuC-5ykAtl/s72-c/1_JTable_Column_Header_Java_web.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2258844867892945003.post-5802535209121119602</guid><pubDate>Wed, 24 Jun 2020 07:48:00 +0000</pubDate><atom:updated>2020-08-04T03:27:12.706-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">NetBeans</category><title>Best Way of JTable Sorting in Java Netbeans with Details</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;jTable basically used for displaying information in the form of rows and columns. In Java you can easily design your table according to your need, so In this post we learn the Best way of &lt;b&gt;jTable Sorting in Java NetBeans&lt;/b&gt;. &lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;&lt;a href=&quot;https://www.skotechlearn.com/2020/06/add-column-header-in-jtable-grid-setting-java-netbeans.html&quot; target=&quot;_blank&quot;&gt;Easy Way to Add Coulmn Header and Change Grid Line Color of jTable in Java&lt;/a&gt;&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Here, SKOTechLearn will explain row sorting of jTable with following way.&lt;br /&gt;
&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li style=&quot;color: #38576c; font-family: Arial; font-size: 15px; line-height: 35px;&quot;&gt;&lt;b&gt;Static way to Enable Row Sorting of jTable in Java&lt;/b&gt;&lt;/li&gt;
&lt;li style=&quot;color: #38576c; font-family: Arial; font-size: 15px; line-height: 35px;&quot;&gt;&lt;b&gt;Sort Particular Column of jTable in Java dynamically&lt;/b&gt;&lt;/li&gt;
&lt;li style=&quot;color: #38576c; font-family: Arial; font-size: 15px; line-height: 35px;&quot;&gt;&lt;b&gt;Disable Particular Column for Sorting of jTable in Java dynamically&lt;/b&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;br /&gt;
Suppose we add some records in table. Now we have to proceed with above given point.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid #b29a94; color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b style=&quot;color: white;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;(1). Static way to Enable Row Sorting of jTable in Java :&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;If you want to enable row sorting during design time. And sort it during run time then it can be done by two ways:&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style=&quot;border-bottom: 1px solid grey; border-top: 1px solid grey; text-align: left;&quot;&gt;&lt;b style=&quot;background-color: #fce5cd;&quot;&gt;Enable Row Sorting through Properties in NetBeans&lt;/b&gt;&lt;/h3&gt;In NetBeans, you can just go to jTable’s &lt;b&gt;&quot;Properties&quot;&lt;/b&gt; window, and find &lt;b&gt;“autoCreateRowSorter”&lt;/b&gt; option from it.&lt;br /&gt;
&lt;br /&gt;
Now, you have to check this option for enabling sorting like bellow.&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHbrhnuuX4kOks4yEawm9NfWJrn7VU1v9fe73YLhGFZ5HbXYs0lnyMoNvm1ZwuHB-ZqrjHra_OXukfT5P0xt9r3R0Fp4X-W2NX_6hh1QThNJPLn52Fk_EcughTNa-vphS7J6d1FIE1_keV/s1600/1_Check_Mark_on_AutoCreateRowSorter+in+jTable_web.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;AutoCreateRowSorter Setting in JTable in Netbeans&quot; border=&quot;0&quot; data-original-height=&quot;202&quot; data-original-width=&quot;650&quot; height=&quot;198&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHbrhnuuX4kOks4yEawm9NfWJrn7VU1v9fe73YLhGFZ5HbXYs0lnyMoNvm1ZwuHB-ZqrjHra_OXukfT5P0xt9r3R0Fp4X-W2NX_6hh1QThNJPLn52Fk_EcughTNa-vphS7J6d1FIE1_keV/s640/1_Check_Mark_on_AutoCreateRowSorter+in+jTable_web.jpg&quot; title=&quot;AutoCreateRowSorter Setting in JTable in Java&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;b&gt;&lt;i&gt;&lt;span style=&quot;color: purple;&quot;&gt;autoCreateRowSorter Setting&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;When you will check mark on &lt;b&gt;“autoCreateRowSorter”&lt;/b&gt; and run application, you have to double click on any &lt;b&gt;Column Header&lt;/b&gt;, the column will be sorted according to row’s value in &lt;b&gt;ascending &lt;/b&gt;or &lt;b&gt;descending &lt;/b&gt;way.&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRW1aL-Ssu6Vs_Xm-C5fPr3kcJzoRYMLXN-YUVBaw3mSM2YeawRqQEc4PIbpED1Yq6qu-tDjY7hgn6NRweiSAQTf2zQ5hOkbqi-YbADOo_sncVkVgNBUGUjhwp2LwGxhL14emc9KV_MlP1/s1600/2_Rows_In_Ascending_and_Descending_Order_web.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;jTable Column Sorting in Java&quot; border=&quot;0&quot; data-original-height=&quot;422&quot; data-original-width=&quot;438&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRW1aL-Ssu6Vs_Xm-C5fPr3kcJzoRYMLXN-YUVBaw3mSM2YeawRqQEc4PIbpED1Yq6qu-tDjY7hgn6NRweiSAQTf2zQ5hOkbqi-YbADOo_sncVkVgNBUGUjhwp2LwGxhL14emc9KV_MlP1/s1600/2_Rows_In_Ascending_and_Descending_Order_web.jpg&quot; title=&quot;jTable Column Sorting&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;b&gt;&lt;i&gt;&lt;span style=&quot;color: purple;&quot;&gt;jTable Column Sorting&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;h3 style=&quot;border-bottom: 1px solid grey; border-top: 1px solid grey; text-align: left;&quot;&gt;&lt;b style=&quot;background-color: #fce5cd;&quot;&gt;Enable Row Sorting through code in Java NetBeans&lt;/b&gt;&lt;/h3&gt;if you want to set RowSorter through code then you can simply add this&amp;nbsp; &quot;&lt;b style=&quot;font-family: &amp;quot;courier&amp;quot;; font-size: 14px;&quot;&gt;&lt;span style=&quot;color: #1B9E12;&quot;&gt;MyTableView&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;background-color: #fcfbfb; font-family: &amp;quot;courier&amp;quot;; font-size: 14px;&quot;&gt;.setAutoCreateRowSorter(&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;courier&amp;quot;; font-size: 14px;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;background-color: #fcfbfb; font-family: &amp;quot;courier&amp;quot;; font-size: 14px;&quot;&gt;);&quot;&amp;nbsp;&lt;/span&gt;code in following way.&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public &lt;/span&gt;TableSortFrame() {     
   initComponents();
   &lt;span style=&quot;color: #cccccc;&quot;&gt;//Here MyTableView is jTable &lt;/span&gt;  
   &lt;span style=&quot;color: #1B9E12;&quot;&gt;MyTableView&lt;/span&gt;.setAutoCreateRowSorter(&lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;);
 }
&lt;/pre&gt;&lt;br /&gt;
So, this way you can easily create jTable with row sort setting in design time.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid #b29a94; color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b style=&quot;color: white;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;(2). Sort Particular Column of jTable in Java dynamically :&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;Suppose, you make a project or application where you need to sort only specific column, then you have to follow with further steps. &lt;br /&gt;
&lt;br /&gt;
Suppose, we want to sort &lt;b&gt;Column No. 2&lt;/b&gt; as describe above given table’s data. Now we sort &lt;b&gt;“MyCol2”&lt;/b&gt; at runtime.&lt;br /&gt;
&lt;br /&gt;
But first we have to import some classes:&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;import&lt;/span&gt; javax.swing.table.TableModel;
 &lt;span style=&quot;color: blue;&quot;&gt;import&lt;/span&gt; java.util.ArrayList;
 &lt;span style=&quot;color: blue;&quot;&gt;import&lt;/span&gt; java.util.List;
 &lt;span style=&quot;color: blue;&quot;&gt;import&lt;/span&gt; javax.swing.table.TableRowSorter;
 &lt;span style=&quot;color: blue;&quot;&gt;import&lt;/span&gt; javax.swing.RowSorter;
 &lt;span style=&quot;color: blue;&quot;&gt;import&lt;/span&gt; javax.swing.SortOrder;
&lt;/pre&gt;&lt;br /&gt;
After that, we will drag jButton and write code for it like bellow:&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;private void&lt;/span&gt; &lt;b&gt;ColSortBtn&lt;/b&gt;ActionPerformed(java.awt.event.ActionEvent evt) {  
   &lt;span style=&quot;color: #999999;&quot;&gt;// MyTableView is jTable&lt;/span&gt;        
   TableRowSorter&amp;lt;TableModel&amp;gt; ColSort = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; TableRowSorter&amp;lt;&amp;gt;(&lt;span style=&quot;color: #1B9E12;&quot;&gt;MyTableView&lt;/span&gt;.getModel());
   &lt;span style=&quot;color: #1B9E12;&quot;&gt;MyTableView&lt;/span&gt;.setRowSorter(ColSort);
   List&amp;lt;RowSorter.SortKey&amp;gt; ColSortingKeys = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; ArrayList&amp;lt;&amp;gt;();
   &lt;span style=&quot;color: #999999;&quot;&gt;//&quot;SortColNo&quot; is use to set Column No for Sorting&lt;/span&gt;
   &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; SortColNo = 1;
   &lt;span style=&quot;color: #999999;&quot;&gt;//&quot;SortKey&quot; is used for sort order for a particular column&lt;/span&gt;
   ColSortingKeys.add(&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; RowSorter.SortKey(SortColNo, SortOrder.&lt;i&gt;&lt;span style=&quot;color: #1B9E12;&quot;&gt;ASCENDING&lt;/span&gt;&lt;/i&gt;));
 
   ColSort.setSortKeys(ColSortingKeys);
   ColSort.sort();
  }       
&lt;/pre&gt;&lt;br /&gt;
In above code, We have changed jTable’s Name with &lt;b&gt;“MyTableView”&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
When you run &lt;b&gt;jFrame&lt;/b&gt;. And click on &lt;b&gt;“ColSortBtn”&lt;/b&gt;. This will show the following output:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1lLVTO5oXX52qs6tz2oV3s4wUbyrB1VrkG_zfqRBJTddBsdYHh1AbVjCYlpcKAexn-OvjdOeE8HI2SWBX-ORZ2IY2MQcpfFgCdKybde0kYCHfcXRw6kZUKuQ1gZq35SZtLIzGmtJQKsg1/s1600/3_Specific_Column_Sorting_in_JTable_web.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;jTable particular Column Sorting in Java&quot; border=&quot;0&quot; data-original-height=&quot;210&quot; data-original-width=&quot;294&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1lLVTO5oXX52qs6tz2oV3s4wUbyrB1VrkG_zfqRBJTddBsdYHh1AbVjCYlpcKAexn-OvjdOeE8HI2SWBX-ORZ2IY2MQcpfFgCdKybde0kYCHfcXRw6kZUKuQ1gZq35SZtLIzGmtJQKsg1/s1600/3_Specific_Column_Sorting_in_JTable_web.jpg&quot; title=&quot;jTable particular Column Sorting&quot; /&gt;&lt;/a&gt;&lt;/div&gt;Friend, in above given way, you can easily sort any specific or particular column of jTable in Java at run time.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background: linear-gradient(90deg, rgba(36,35,0,0.038941801264044895) 0%, rgba(9,89,121,0.038941801264044895) 35%, rgba(255,142,0,0.2327620259831461) 100%); border-bottom: 3px solid rgb(204 , 204 , 204); border-top: 1px solid rgb(204 , 204 , 204); line-height: 25px;&quot;&gt;&amp;nbsp;&lt;i&gt;&lt;b&gt;Note:&lt;/b&gt; If you Double Click on any other column, then the sorting will also be apply on that column.&lt;/i&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid #b29a94; color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b style=&quot;color: white;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;(3). Disable Particular Column for Sorting of jTable in Java dynamically :&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;As you can see, the above given sorting process will be apply on any other column at run time.&lt;br /&gt;
&lt;br /&gt;
If, you want to fix that only particular column will be sort and other column will not be used as sorting process. Then you have to disable that particular column for sorting.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Disable Column Sorting of jTable in Java&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Suppose, you want to apply sorting in &lt;b&gt;Column No. 3&lt;/b&gt;, and Disable Sorting in &lt;b&gt;Column 1&lt;/b&gt; and &lt;b&gt;Column 2&lt;/b&gt; then you will simply write following code for this process:&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;private void&lt;/span&gt; &lt;b&gt;ColSortBtn&lt;/b&gt;ActionPerformed(java.awt.event.ActionEvent evt) {  
    TableRowSorter&amp;lt;TableModel&amp;gt; ColSort = &lt;span style=&quot;color: blue;&quot;&gt;new &lt;/span&gt;TableRowSorter&amp;lt;&amp;gt;(&lt;span style=&quot;color: #1B9E12;&quot;&gt;MyTableView&lt;/span&gt;.getModel());
    &lt;span style=&quot;color: #1B9E12;&quot;&gt;MyTableView&lt;/span&gt;.setRowSorter(ColSort);
    List&amp;lt;RowSorter.SortKey&amp;gt; ColSortingKeys = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; ArrayList&amp;lt;&amp;gt;();
    &lt;span style=&quot;color: #999999;&quot;&gt;//&quot;SortColNo&quot; is use to set Column No for Sorting&lt;/span&gt;
    &lt;span style=&quot;color: blue;&quot;&gt;int &lt;/span&gt;SortColNo = 2;
    &lt;span style=&quot;color: #999999;&quot;&gt;//&quot;SortKey&quot; is used for sort order for a particular column&lt;/span&gt;
    ColSortingKeys.add(&lt;span style=&quot;color: blue;&quot;&gt;new &lt;/span&gt;RowSorter.SortKey(SortColNo, SortOrder.&lt;i&gt;&lt;span style=&quot;color: #1B9E12;&quot;&gt;ASCENDING&lt;/span&gt;&lt;/i&gt;));
 
    ColSort.setSortKeys(ColSortingKeys);
    ColSort.sort();
    &lt;span style=&quot;color: #999999;&quot;&gt;//Disable sorting in column 0 and column 1&lt;/span&gt;
    ColSort.setSortable(0, &lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;);
    ColSort.setSortable(1, &lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;);
 }
&lt;/pre&gt;When you run it, this will work like following image.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEP5ZVqZdUUj_wjPIKqVkuw-YSGn5tWV46HTVM_g9Kpper5dCPvTAxhsd2jwmQHEAyh9j8ATGAopY9DsZZbUhsTDnVQxcFqLFIRi4Tyy3Ia4eccph73u-7I3Zfvb_lC_FIZveaw2r4qa6O/s1600/4_Disasble_particular_Column_Sorting_in_Jtable_web.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Disable Column Sorting in jTable in Java&quot; border=&quot;0&quot; data-original-height=&quot;290&quot; data-original-width=&quot;816&quot; height=&quot;226&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEP5ZVqZdUUj_wjPIKqVkuw-YSGn5tWV46HTVM_g9Kpper5dCPvTAxhsd2jwmQHEAyh9j8ATGAopY9DsZZbUhsTDnVQxcFqLFIRi4Tyy3Ia4eccph73u-7I3Zfvb_lC_FIZveaw2r4qa6O/s640/4_Disasble_particular_Column_Sorting_in_Jtable_web.jpg&quot; title=&quot;Disable Column Sorting in jTable&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;So Friends, you can try it yourself and find that what will happen.  Simply create project in Java and write code for&lt;b&gt; jTable Row sorting in Java Netbeans&lt;/b&gt; using SKOTechLearn Tips.&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;</description><link>https://www.skotechlearn.com/2020/06/jtable-sorting-in-java-netbeans.html</link><author>noreply@blogger.com (SKOTechLearn)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHbrhnuuX4kOks4yEawm9NfWJrn7VU1v9fe73YLhGFZ5HbXYs0lnyMoNvm1ZwuHB-ZqrjHra_OXukfT5P0xt9r3R0Fp4X-W2NX_6hh1QThNJPLn52Fk_EcughTNa-vphS7J6d1FIE1_keV/s72-c/1_Check_Mark_on_AutoCreateRowSorter+in+jTable_web.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2258844867892945003.post-679802749304054943</guid><pubDate>Tue, 23 Jun 2020 06:02:00 +0000</pubDate><atom:updated>2021-06-30T11:58:47.634-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">NetBeans</category><title>SQL Server Database Connection String in Java NetBeans with Query</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;In java, when you want to connect MS SQL Server Database and want to show Table’s record in java, then you have to remember one thing, you have to require suitable &lt;b&gt;database driver for java&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
So, Here SKOTechLearn will describe the process steps by step for &lt;b&gt;SQL Server Database Connection String in Java with Query&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;&lt;a href=&quot;https://www.skotechlearn.com/2019/07/connect-sql-server-database-in-netbeans.html&quot; target=&quot;_blank&quot;&gt;Connect Database And Access All Tables and Records with NetBeans&lt;/a&gt;&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
&lt;br /&gt;
For This process you have to follow the steps given following.&lt;br /&gt;
&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li style=&quot;color: #38576c; font-family: Arial; font-size: 15px; line-height: 35px;&quot;&gt;&lt;b&gt;Download “sqljdbc4.jar” file&amp;nbsp;&lt;/b&gt;&lt;/li&gt;
&lt;li style=&quot;color: #38576c; font-family: Arial; font-size: 15px; line-height: 35px;&quot;&gt;&lt;b&gt;Attach “sqljdbc4.jar” File in Project’s Package&lt;/b&gt;&lt;/li&gt;
&lt;li style=&quot;color: #38576c; font-family: Arial; font-size: 15px; line-height: 35px;&quot;&gt;&lt;b&gt;Import SQL Class and Other Related Class&amp;nbsp;&lt;/b&gt;&lt;/li&gt;
&lt;li style=&quot;color: #38576c; font-family: Arial; font-size: 15px; line-height: 35px;&quot;&gt;&lt;b&gt;SQL Server Connection Code in Java with Example&lt;/b&gt;&lt;/li&gt;
&lt;li style=&quot;color: #38576c; font-family: Arial; font-size: 15px; line-height: 35px;&quot;&gt;&lt;b&gt;Use SQL Server Query in Java NetBeans&lt;/b&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&lt;b&gt;Step&lt;/b&gt;&lt;/span&gt;&lt;b style=&quot;color: white;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;(1). Download “sqljdbc4.jar” file :&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;If you want to use database connection on your projects, you have to know that you have to required suitable driver for database connection in java. &lt;br /&gt;
&lt;br /&gt;
So, For &lt;b&gt;SQL Server Connection in Java&lt;/b&gt;, you can use &lt;b&gt;“sqljdbc4.jar”&lt;/b&gt; file for driver.&lt;br /&gt;
&lt;br /&gt;
You can find it from many sites, and here are two sites where you can find this driver easily.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://mvnrepository.com/artifact/com.microsoft.sqlserver/sqljdbc4/4.0&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;First Site&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.java2s.com/Code/Jar/s/sqljdbc4.htm&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Second Site&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&lt;b&gt;Step&lt;/b&gt;&lt;/span&gt;&lt;b style=&quot;color: white;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;(2). Attach “sqljdbc4.jar” File in Project’s Package :&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;After that you have to create your project and when you expand your project in NetBeans, you will find there are many Package Folders available.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: paleturquoise; border-radius: 3px; border: 2px solid rgb(204, 204, 204); float: left; width: 20px;&quot;&gt;&amp;nbsp;&lt;b&gt;1.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;Find &lt;b&gt;“Libraries”&lt;/b&gt; Package Folder from you project.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: paleturquoise; border-radius: 3px; border: 2px solid rgb(204, 204, 204); float: left; width: 20px;&quot;&gt;&amp;nbsp;&lt;b&gt;2.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;Right click on &lt;b&gt;“Libraries”&lt;/b&gt; Package Folder. And Select third option &lt;b&gt;“Add JAR/Folder…”&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: paleturquoise; border-radius: 3px; border: 2px solid rgb(204, 204, 204); float: left; width: 20px;&quot;&gt;&amp;nbsp;&lt;b&gt;3.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;This option will show you &lt;b&gt;“Add JAR/Folder”&lt;/b&gt; Window.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: paleturquoise; border-radius: 3px; border: 2px solid rgb(204, 204, 204); float: left; width: 20px;&quot;&gt;&amp;nbsp;&lt;b&gt;4.&lt;/b&gt;&lt;/div&gt;&amp;nbsp;&lt;b&gt;Browse &lt;/b&gt;your downloaded &lt;b&gt;“sqljdbc4.jar”&lt;/b&gt; file.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgY0vyICOzdyZfQ4-WtHGggeCcsQYEqq6F8XC00CMwO_37wjJp1FiyVHT_8dQIJQ4mpJF4mlMjRcxJtUVWn-StyKkqU0dVBIXCJmtkPSBsMsF8ksmR7nxX6IIYAFvVimlkzHv0OwjPcZ277/s1600/1_attach+sqljdbc4.jar+file+in+libraries+in+Java+project_web.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Add sqljdbc4 jar file in Java Project&#39;s Libraries&quot; border=&quot;0&quot; data-original-height=&quot;394&quot; data-original-width=&quot;924&quot; height=&quot;272&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgY0vyICOzdyZfQ4-WtHGggeCcsQYEqq6F8XC00CMwO_37wjJp1FiyVHT_8dQIJQ4mpJF4mlMjRcxJtUVWn-StyKkqU0dVBIXCJmtkPSBsMsF8ksmR7nxX6IIYAFvVimlkzHv0OwjPcZ277/s640/1_attach+sqljdbc4.jar+file+in+libraries+in+Java+project_web.jpg&quot; title=&quot;Add sqljdbc4 jar file in Java Libraries&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;This jar file will be added on your project’s &lt;b&gt;“Libraries”&lt;/b&gt; like above given image.&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;&lt;a href=&quot;https://www.skotechlearn.com/2019/11/change-main-class-in-java-netbeans.html&quot; target=&quot;_blank&quot;&gt;How to Set Default Main Class in Java Using Netbeans&lt;/a&gt;&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&lt;b&gt;Step&lt;/b&gt;&lt;/span&gt;&lt;b style=&quot;color: white;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;(3). Import SQL Class and Other Related Class :&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;Now, before start connection string, you have to import some class as described below.&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #999999;&quot;&gt;//java.sql.Connection is use for establishing connection from database&lt;/span&gt;
 &lt;span style=&quot;color: blue;&quot;&gt;import&lt;/span&gt; java.sql.Connection;
 &lt;span style=&quot;color: #999999;&quot;&gt;//java.sql.DriverManager is used for calling driver with connection string&lt;/span&gt;
 &lt;span style=&quot;color: blue;&quot;&gt;import&lt;/span&gt; java.sql.DriverManager;
 &lt;span style=&quot;color: #999999;&quot;&gt;//javax.swing.JOptionPane for Display Message&lt;/span&gt;
 &lt;span style=&quot;color: blue;&quot;&gt;import&lt;/span&gt; javax.swing.JOptionPane;
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&lt;b&gt;Step&lt;/b&gt;&lt;/span&gt;&lt;b style=&quot;color: white;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;(4). SQL Server Connection Code in Java with Example :&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;Now let’s try to connect database from server in java Netbeans,  We will write code inside &lt;b&gt;jButton’s ActionPerformed&lt;/b&gt; event.&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;private void&lt;/span&gt; SQLConn_BtnActionPerformed(java.awt.event.ActionEvent evt) {    
  &lt;span style=&quot;color: blue;&quot;&gt;try &lt;/span&gt;{
     Class.forName(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;com.microsoft.sqlserver.jdbc.SQLServerDriver&quot;&lt;/span&gt;);
     Connection SQlCnn = DriverManager.getConnection(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;jdbc:sqlserver://&lt;b&gt;XXX.XXX.X.XX&lt;/b&gt;; databaseName= &lt;b&gt;MySQLDB&lt;/b&gt;; user= &lt;b&gt;MYSQLUser&lt;/b&gt;; password= &lt;b&gt;MySQLPasswrd&lt;/b&gt;&quot;&lt;/span&gt;);
     JOptionPane.&lt;i&gt;showMessageDialog&lt;/i&gt;(&lt;span style=&quot;color: blue;&quot;&gt;null&lt;/span&gt;, &lt;span style=&quot;color: #990000;&quot;&gt;&quot;SQL Server Connection Successfully.&quot;&lt;/span&gt;);
     SQlCnn.close();
  }&lt;span style=&quot;color: blue;&quot;&gt;catch &lt;/span&gt;(&lt;span style=&quot;color: blue;&quot;&gt;Exception &lt;/span&gt;CnnErr){
     JOptionPane.&lt;i&gt;showMessageDialog&lt;/i&gt;(&lt;span style=&quot;color: blue;&quot;&gt;null&lt;/span&gt;, &lt;span style=&quot;color: #990000;&quot;&gt;&quot;SQL Server Connection Problem&quot;&lt;/span&gt;);
  }
 }
&lt;/pre&gt;&lt;br /&gt;
When you run this code, the following output will be shown:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHX6MKPtau_Lmt0rU_qjghgYcFdDWtwD0C9N2rRnqAEJl6DeHohtQvtlH4M1gPVCsH1eqFYeo4e-xb4-2xYDdb5JQ5en2y7-AmofcS_uniap2JZEaKejwTr0-b6VXpA9w2ih4YljeCmxe9/s1600/SQL_Server_Connection_Output_In_Java_web.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;SQL Server Connection String Output in Java&quot; border=&quot;0&quot; data-original-height=&quot;229&quot; data-original-width=&quot;441&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHX6MKPtau_Lmt0rU_qjghgYcFdDWtwD0C9N2rRnqAEJl6DeHohtQvtlH4M1gPVCsH1eqFYeo4e-xb4-2xYDdb5JQ5en2y7-AmofcS_uniap2JZEaKejwTr0-b6VXpA9w2ih4YljeCmxe9/s1600/SQL_Server_Connection_Output_In_Java_web.jpg&quot; title=&quot;SQL Server Connection String Output&quot; /&gt;&lt;/a&gt;&lt;/div&gt;Simply copy above code and modify &lt;b&gt;servername&lt;/b&gt;, &lt;b&gt;databasename&lt;/b&gt;, &lt;b&gt;username and&lt;/b&gt;&amp;nbsp;&lt;b&gt;password &lt;/b&gt;then run your project.&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;&lt;a href=&quot;https://www.skotechlearn.com/2020/07/display-show-image-in-jframe-java-netbeans.html&quot; target=&quot;_blank&quot;&gt;Simple Way to Display Image in Java&lt;/a&gt;&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid rgb(178, 154, 148); color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&lt;b&gt;Step&lt;/b&gt;&lt;/span&gt;&lt;b style=&quot;color: white;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;(5). Use SQL Server Query in Java NetBeans :&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;Suppose we have a table “&lt;b&gt;MySQLDBTable&lt;/b&gt;” and there is two column “&lt;b&gt;MyTBL_ID&lt;/b&gt;” and “&lt;b&gt;MyUsrName&lt;/b&gt;”. And this table contains some records like bellow:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6EZ7jt9L5nF3hfZXaUwJj9Lp-xHWOjeFpGbOUQS3pgfJqBkyotTSFZcL30vsf-AewFSXIsBHreu0Dgk3AsAh5fBzhQ0tW0nvoW7rE5PQACxZBfovy3MTSR_lSHQcc2UxqeeMzWmsq1mt3/s1600/2_Database_table_With_records_web.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Database Table&#39;s Record in Netbeans&quot; border=&quot;0&quot; data-original-height=&quot;208&quot; data-original-width=&quot;489&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6EZ7jt9L5nF3hfZXaUwJj9Lp-xHWOjeFpGbOUQS3pgfJqBkyotTSFZcL30vsf-AewFSXIsBHreu0Dgk3AsAh5fBzhQ0tW0nvoW7rE5PQACxZBfovy3MTSR_lSHQcc2UxqeeMzWmsq1mt3/s1600/2_Database_table_With_records_web.jpg&quot; title=&quot;Database Table&#39;s Record in Netbeans&quot; /&gt;&lt;/a&gt;&lt;/div&gt;So, if you want to display all records, you have to use &lt;b&gt;“Select Query Statement”&lt;/b&gt;. And write code in NetBeans in following way.&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;Use of&amp;nbsp; Select Query in Java&amp;nbsp;&lt;/h3&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;private void&lt;/span&gt; SQLQuery_BtnActionPerformed(java.awt.event.ActionEvent evt) {
  &lt;span style=&quot;color: blue;&quot;&gt;try &lt;/span&gt;{
     Class.forName(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;com.microsoft.sqlserver.jdbc.SQLServerDriver&quot;&lt;/span&gt;);
     Connection SQlCnn = DriverManager.getConnection(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;jdbc:sqlserver://&lt;b&gt;XXX.XXX.X.XX&lt;/b&gt;; databaseName= &lt;b&gt;MySQLDB&lt;/b&gt;; user= &lt;b&gt;MYSQLUser&lt;/b&gt;; password= &lt;b&gt;MySQLPasswrd&lt;/b&gt;&quot;&lt;/span&gt;);
     Statement MyDBstmt = SQlCnn.createStatement();
     ResultSet MyRSet = MyDBstmt.executeQuery(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;Select * From MySQLDBTable&quot;&lt;/span&gt;);
     &lt;span style=&quot;color: blue;&quot;&gt;while&lt;/span&gt;( MyRSet.next()) {
          System.&lt;i&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;out&lt;/span&gt;&lt;/i&gt;.println(MyRSet.getString(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;MyTBL_ID&quot;&lt;/span&gt;) + &lt;span style=&quot;color: #990000;&quot;&gt;&quot;   |   &quot;&lt;/span&gt; + MyRSet.getString(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;MyUsrName&quot;&lt;/span&gt;));
        }    
     MyRSet.close();
     MyDBstmt.close();
     SQlCnn.close();
        
   }&lt;span style=&quot;color: blue;&quot;&gt;catch &lt;/span&gt;(&lt;span style=&quot;color: blue;&quot;&gt;Exception &lt;/span&gt;DBErr){
      JOptionPane.&lt;i&gt;showMessageDialog&lt;/i&gt;(&lt;span style=&quot;color: blue;&quot;&gt;null&lt;/span&gt;, &lt;span style=&quot;color: #990000;&quot;&gt;&quot;SQL Server Connection Problem&quot;&lt;/span&gt;);
   }
 }   
&lt;/pre&gt;&lt;br /&gt;
When you run this code, this will show you following output.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifcZhhBs81IgHS_DcFJAU7U-aqgU-ssfEAesTyxBOcatAgyMAx7wQGBylEyrz9p2wYUKwR7zKrw_M1iIzgyQ4EWhXBwUh2jKfLeBOTMLaDc9NCKbnrx483QB33LFBrlofgzAj9QWDEpCrf/s1600/4_Select_Query_Statement_Output_web.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Select Query Output in Java NetBeans&quot; border=&quot;0&quot; data-original-height=&quot;154&quot; data-original-width=&quot;288&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifcZhhBs81IgHS_DcFJAU7U-aqgU-ssfEAesTyxBOcatAgyMAx7wQGBylEyrz9p2wYUKwR7zKrw_M1iIzgyQ4EWhXBwUh2jKfLeBOTMLaDc9NCKbnrx483QB33LFBrlofgzAj9QWDEpCrf/s1600/4_Select_Query_Statement_Output_web.jpg&quot; title=&quot;Select Query Output in Java&quot; /&gt;&lt;/a&gt;&lt;/div&gt;So, these are the steps for establishing connection from database server or &lt;b&gt;SQL Server Database Connection String in Java Netbeans with Query.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;&lt;a href=&quot;https://www.skotechlearn.com/2019/04/auto-resize-control-change-control-name-in-java.html&quot; target=&quot;_blank&quot;&gt;What Settings for Auto Resize Control in Java Using Netbeans?&lt;/a&gt;&lt;/b&gt;&lt;/u&gt;&lt;/div&gt;</description><link>https://www.skotechlearn.com/2020/06/sql-server-database-connection-string-in-java.html</link><author>noreply@blogger.com (SKOTechLearn)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgY0vyICOzdyZfQ4-WtHGggeCcsQYEqq6F8XC00CMwO_37wjJp1FiyVHT_8dQIJQ4mpJF4mlMjRcxJtUVWn-StyKkqU0dVBIXCJmtkPSBsMsF8ksmR7nxX6IIYAFvVimlkzHv0OwjPcZ277/s72-c/1_attach+sqljdbc4.jar+file+in+libraries+in+Java+project_web.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2258844867892945003.post-5891517131002255359</guid><pubDate>Fri, 19 Jun 2020 11:28:00 +0000</pubDate><atom:updated>2020-08-04T02:53:21.450-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Work with VB6.0</category><title>Show Files List With Icons In Listview Using ImageList in VB6.0</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;In this post, we will learn items with image in Listview. Sometimes we require a list which contain image including items. The listview will use for this process due to its fast and easiest way in vb6.0. There is a simple process for doing practical on your VB6.0 application development. So, SKOTechLearn will explain the way to &lt;b&gt;Show Files List with Icons in Listview using ImageList in VB6.0&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
In the following steps we describe the 3 code process, in which you can use anyone code process for your desire.&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;&lt;a href=&quot;https://www.skotechlearn.com/2018/04/how-to-add-items-in-listview.html&quot; target=&quot;_blank&quot;&gt;Dynamically Add Items in ListView in VB6&lt;/a&gt;&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Show files List with Path and Icon in Listview using ImageList in vb6.0&lt;/b&gt; like bellow:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWiw4l7DfNVJTAA5kZtibvk6Sn22LJ49vQSWDpelz8EDJhhfp9q4rP38eV_-ULAZbbcr-2__oceQZwhFl5eoLxoPvEh3awALOgbCRLKeeAspdDZehXpX0QZ282i-Xq6pAALssV7DakpTtr/s1600/5_ListView_with_Files_and_Icons_Output_web.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;ListView_with_Files_and_Icons_in_VB6.0&quot; border=&quot;0&quot; data-original-height=&quot;310&quot; data-original-width=&quot;401&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWiw4l7DfNVJTAA5kZtibvk6Sn22LJ49vQSWDpelz8EDJhhfp9q4rP38eV_-ULAZbbcr-2__oceQZwhFl5eoLxoPvEh3awALOgbCRLKeeAspdDZehXpX0QZ282i-Xq6pAALssV7DakpTtr/s1600/5_ListView_with_Files_and_Icons_Output_web.jpg&quot; title=&quot;ListView_with_Files_and_Icons_in_VB6.0&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Let’s find and learn, how can we find this type of output?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid #b29a94; color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b style=&quot;color: white;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;(1). Create some images for Icons:&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;&amp;nbsp;We have to create some images for showing as icon in Listview. Now ,try to create through Paint with Print Screen process as I created bellow.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKNSZ1T2j-_KlyHKHJ3kFKSoJU5foSFlt_9AJ98Ih8ZuErdaZLy_Fh7PEm5F9LGW1qS4RKQHiMN2Xj5O4SUTePdAxVqMa9tsCYKa3aaTd4C77eTIqBCb-cKKSrXbYK9fhybTzOO7vrhb1L/s1600/1_Create_Images_web.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Images for Listview Icons in Vb6.0&quot; border=&quot;0&quot; data-original-height=&quot;107&quot; data-original-width=&quot;563&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKNSZ1T2j-_KlyHKHJ3kFKSoJU5foSFlt_9AJ98Ih8ZuErdaZLy_Fh7PEm5F9LGW1qS4RKQHiMN2Xj5O4SUTePdAxVqMa9tsCYKa3aaTd4C77eTIqBCb-cKKSrXbYK9fhybTzOO7vrhb1L/s1600/1_Create_Images_web.jpg&quot; title=&quot;Images for Listview Icons&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid #b29a94; color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b style=&quot;color: white;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;(2). Drag Some Controls:&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;&amp;nbsp;Now drag some controls like &lt;b&gt;Command &lt;/b&gt;button for doing activity and &lt;b&gt;Listview &lt;/b&gt;for Showing List with icons and Path and &lt;b&gt;ImageList &lt;/b&gt;Control for fetching images.&lt;br /&gt;
&lt;br /&gt;
Here we changed Listview1 name is &lt;b&gt;MyLstView &lt;/b&gt;and ImageList1 name is &lt;b&gt;MyImageList&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;&lt;a href=&quot;https://www.skotechlearn.com/2018/04/how-to-edit-or-delete-selected-listview-item.html&quot; target=&quot;_blank&quot;&gt;Simply use ListView for Edit or Delete Selected Items&lt;/a&gt;&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid #b29a94; color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b style=&quot;color: white;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;(3) ImageList and Listview Settings:&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;&amp;nbsp;First we add some image in &lt;b&gt;ImageList &lt;/b&gt;through properties and set every image with &lt;b&gt;Key&lt;/b&gt; name, which is use for calling inside Listview. After that we setting on &lt;b&gt;Listview Properties&lt;/b&gt; like Column header and View type etc.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwrgjKw72m_aBsOc7lq8F662-EaWzD1rIb0IKJ-skmS4tFeTiF5hOi9qMsSz5lRdr8i0wVFj-SDzbyH1f3As6PGO1Vby_4du0wbzGUySHz01z3VZRDnoV0bO2BrRBhKwrppHfQX4HDmO-p/s1600/3_ImageList+and+ListView+Settings_web.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;ImageList properties and ListView Properties Settings&quot; border=&quot;0&quot; data-original-height=&quot;510&quot; data-original-width=&quot;421&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwrgjKw72m_aBsOc7lq8F662-EaWzD1rIb0IKJ-skmS4tFeTiF5hOi9qMsSz5lRdr8i0wVFj-SDzbyH1f3As6PGO1Vby_4du0wbzGUySHz01z3VZRDnoV0bO2BrRBhKwrppHfQX4HDmO-p/s1600/3_ImageList+and+ListView+Settings_web.jpg&quot; title=&quot;ImageList and ListView Properties Settings&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
In above given image you can &lt;u&gt;&lt;b&gt;&lt;a href=&quot;https://www.skotechlearn.com/2018/04/how-to-find-and-add-listview-in-toolbox-VB.html&quot; target=&quot;_blank&quot;&gt;Set Listview Properties with Column Header&lt;/a&gt;&lt;/b&gt; easily.&lt;/u&gt;&lt;br /&gt;
&lt;br /&gt;
Now write code for listing Files with icon as describe bellow.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: powderblue; background: #e7f9bf; border-radius: 6px; border: 1px solid rgb(204 , 204 , 204); color: black; float: left; line-height: 25px; width: 120px;&quot;&gt;&amp;nbsp;&lt;b&gt;Process(1):&lt;/b&gt;&lt;/div&gt;&amp;nbsp;In this process we use &lt;b&gt;Select Case Statement&lt;/b&gt; for showing files with path and icons in Listview.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;VB6.0:&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt; Private Sub&lt;/span&gt; ShowFileIcon_Btn_Click()
 &lt;span style=&quot;color: #93c47d;&quot;&gt;&#39;First you have to set listview smallicon with ImageList&lt;/span&gt;
 &lt;span style=&quot;color: blue;&quot;&gt;Set &lt;/span&gt;MyLstView.SmallIcons = MyImageList
 &lt;span style=&quot;color: blue;&quot;&gt;Dim &lt;/span&gt;i &lt;span style=&quot;color: blue;&quot;&gt;As Integer&lt;/span&gt;
 i = 1
 &lt;span style=&quot;color: blue;&quot;&gt;With &lt;/span&gt;MyLstView

  &lt;span style=&quot;color: blue;&quot;&gt;Dim &lt;/span&gt;myFilesList &lt;span style=&quot;color: blue;&quot;&gt;As String&lt;/span&gt;
  &lt;span style=&quot;color: #93c47d;&quot;&gt;&#39;Use Dir for Collection files&#39; List&lt;/span&gt;
  myFilesList = &lt;span style=&quot;color: blue;&quot;&gt;Dir&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;C:\SKOTechLearn_Files\*.*&quot;&lt;/span&gt;)
  &lt;span style=&quot;color: #93c47d;&quot;&gt;&lt;i&gt;&#39;&lt;/i&gt;Clear Listview&lt;/span&gt;
  MyLstView.ListItems.Clear
  &lt;span style=&quot;color: #93c47d;&quot;&gt;&#39;Loop wntil Files&#39; list will not Null or Empty&lt;/span&gt;
  &lt;span style=&quot;color: blue;&quot;&gt;While &lt;/span&gt;myFilesList &amp;gt; &lt;span style=&quot;color: blue;&quot;&gt;vbNullString&lt;/span&gt;

   &lt;span style=&quot;color: blue;&quot;&gt;Dim &lt;/span&gt;MyFLExten &lt;span style=&quot;color: blue;&quot;&gt;As String&lt;/span&gt;
   &lt;span style=&quot;color: #93c47d;&quot;&gt;&#39;Following formula is used for Extract &quot;Extension&quot; from Files&lt;/span&gt;
   MyFLExten = &lt;span style=&quot;color: blue;&quot;&gt;UCase&lt;/span&gt;(&lt;span style=&quot;color: blue;&quot;&gt;Mid&lt;/span&gt;(myFilesList, &lt;span style=&quot;color: blue;&quot;&gt;InStrRev&lt;/span&gt;(myFilesList, &lt;span style=&quot;color: #990000;&quot;&gt;&quot;.&quot;&lt;/span&gt;), &lt;span style=&quot;color: blue;&quot;&gt;Len&lt;/span&gt;(myFilesList)))
      
   &lt;span style=&quot;color: blue;&quot;&gt;Select Case&lt;/span&gt; MyFLExten
      &lt;span style=&quot;color: blue;&quot;&gt;Case &lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&quot;.JPG&quot;&lt;/span&gt;
           &lt;span style=&quot;color: #93c47d;&quot;&gt;&#39; Listview.ListItems.Ass [Index], [key], [Text],[Icon], [SmallIcon]&lt;/span&gt;
           .ListItems.Add , , myFilesList, , &lt;span style=&quot;color: #990000;&quot;&gt;&quot;ImgIco1&quot;&lt;/span&gt;
      &lt;span style=&quot;color: blue;&quot;&gt;Case &lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&quot;.PNG&quot;&lt;/span&gt;
              .ListItems.Add , , myFilesList, , &lt;span style=&quot;color: #990000;&quot;&gt;&quot;ImgIco1&quot;&lt;/span&gt;
      &lt;span style=&quot;color: blue;&quot;&gt;Case &lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&quot;.XLS&quot;&lt;/span&gt;, &lt;span style=&quot;color: #990000;&quot;&gt;&quot;.XLSX&quot;&lt;/span&gt;
              .ListItems.Add , , myFilesList, , &lt;span style=&quot;color: #990000;&quot;&gt;&quot;XlsIco6&quot;&lt;/span&gt;
      &lt;span style=&quot;color: blue;&quot;&gt;Case &lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&quot;.PDF&quot;&lt;/span&gt;
              .ListItems.Add , , myFilesList, , &lt;span style=&quot;color: #990000;&quot;&gt;&quot;PdfIco2&quot;&lt;/span&gt;
      &lt;span style=&quot;color: blue;&quot;&gt;Case &lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&quot;.TXT&quot;&lt;/span&gt;
              .ListItems.Add , , myFilesList, , &lt;span style=&quot;color: #990000;&quot;&gt;&quot;TxtIco4&quot;&lt;/span&gt;
      &lt;span style=&quot;color: blue;&quot;&gt;Case &lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&quot;.XPS&quot;&lt;/span&gt;
              .ListItems.Add , , myFilesList, , &lt;span style=&quot;color: #990000;&quot;&gt;&quot;XpsIco7&quot;&lt;/span&gt;
      &lt;span style=&quot;color: blue;&quot;&gt;Case &lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&quot;.DOC&quot;&lt;/span&gt;, &lt;span style=&quot;color: #990000;&quot;&gt;&quot;.DOCX&quot;&lt;/span&gt;
              .ListItems.Add , , myFilesList, , &lt;span style=&quot;color: #990000;&quot;&gt;&quot;DocIco5&quot;&lt;/span&gt;
      &lt;span style=&quot;color: blue;&quot;&gt;Case Else&lt;/span&gt;
              .ListItems.Add , , myFilesList, , &lt;span style=&quot;color: #990000;&quot;&gt;&quot;OtherIco8&quot;&lt;/span&gt;
    &lt;span style=&quot;color: blue;&quot;&gt;End Select&lt;/span&gt;

    .ListItems(i).ForeColor = &lt;span style=&quot;color: blue;&quot;&gt;vbBlue&lt;/span&gt;
    &lt;span style=&quot;color: #93c47d;&quot;&gt;&#39;List with Path and Files&lt;/span&gt;
    .ListItems(i).ListSubItems.Add , , &lt;span style=&quot;color: #990000;&quot;&gt;&quot;C:\SKOTechLearn_Files\&quot;&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;&amp;amp; &lt;/span&gt;myFilesList
    .ListItems(i).ListSubItems(1).ForeColor = &lt;span style=&quot;color: blue;&quot;&gt;vbRed&lt;/span&gt;
    .ListItems(i).ListSubItems.Add , , MyFLExten
    &lt;span style=&quot;color: #93c47d;&quot;&gt;&#39; retun remaining Dir File&#39;s List&lt;/span&gt;
     myFilesList = &lt;span style=&quot;color: blue;&quot;&gt;Dir&lt;/span&gt;
    &lt;span style=&quot;color: blue;&quot;&gt;DoEvents&lt;/span&gt;
    i = i + 1
  &lt;span style=&quot;color: blue;&quot;&gt;Wend&lt;/span&gt;

 &lt;span style=&quot;color: blue;&quot;&gt;End With&lt;/span&gt;

 &lt;span style=&quot;color: blue;&quot;&gt;End Sub&lt;/span&gt;

&lt;/pre&gt;&lt;br /&gt;
&lt;u&gt;&lt;b&gt;&lt;a href=&quot;https://www.skotechlearn.com/2020/05/remove-multiple-checked-items-from-listview-vb6.html&quot; target=&quot;_blank&quot;&gt;Remove Multiple Checked Items from Listview Easily&lt;/a&gt;&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: powderblue; background: #e7f9bf; border-radius: 6px; border: 1px solid rgb(204 , 204 , 204); color: black; float: left; line-height: 25px; width: 120px;&quot;&gt;&amp;nbsp;&lt;b&gt;Process(2):&lt;/b&gt;&lt;/div&gt;&amp;nbsp;In this Process we Use &lt;b&gt;If Else Statement&lt;/b&gt; for showing Files List with icons in ListView.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;VB6.0:&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;Private Sub&lt;/span&gt; ShowFileIcon_Btn2_Click()
 &lt;span style=&quot;color: #93c47d;&quot;&gt;&#39;First you have to set listview smallicon with ImageList&lt;/span&gt;
 &lt;span style=&quot;color: blue;&quot;&gt;Set &lt;/span&gt;MyLstView.SmallIcons = MyImageList
 &lt;span style=&quot;color: blue;&quot;&gt;Dim &lt;/span&gt;i &lt;span style=&quot;color: blue;&quot;&gt;As Integer&lt;/span&gt;
 i = 1
 &lt;span style=&quot;color: blue;&quot;&gt;With &lt;/span&gt;MyLstView

   &lt;span style=&quot;color: blue;&quot;&gt;Dim &lt;/span&gt;MyFlList &lt;span style=&quot;color: blue;&quot;&gt;As String&lt;/span&gt;
  &lt;span style=&quot;color: #93c47d;&quot;&gt;&#39;Use Dir for Collection files&#39; List From path&lt;/span&gt;
   MyFlList = &lt;span style=&quot;color: blue;&quot;&gt;Dir&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;C:\SKOTechLearn_Files\*.*&quot;&lt;/span&gt;)
   MyLstView.ListItems.Clear
   &lt;span style=&quot;color: blue;&quot;&gt;While &lt;/span&gt;MyFlList &amp;gt; &lt;span style=&quot;color: blue;&quot;&gt;vbNullString&lt;/span&gt;

      &lt;span style=&quot;color: blue;&quot;&gt;Dim &lt;/span&gt;MyFLExt &lt;span style=&quot;color: blue;&quot;&gt;As String&lt;/span&gt;
     &lt;span style=&quot;color: #93c47d;&quot;&gt;&#39;following formula used to extact &quot;Extension&quot; From Files&lt;/span&gt;
      MyFLExt = &lt;span style=&quot;color: blue;&quot;&gt;UCase&lt;/span&gt;(&lt;span style=&quot;color: blue;&quot;&gt;Mid&lt;/span&gt;(MyFlList, &lt;span style=&quot;color: blue;&quot;&gt;InStrRev&lt;/span&gt;(MyFlList, &lt;span style=&quot;color: #990000;&quot;&gt;&quot;.&quot;&lt;/span&gt;), &lt;span style=&quot;color: blue;&quot;&gt;Len&lt;/span&gt;(MyFlList)))

      &lt;span style=&quot;color: blue;&quot;&gt;If &lt;/span&gt;MyFLExt = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;.JPG&quot;&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;Or &lt;/span&gt;MyFLExt = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;.PNG&quot;&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;Or &lt;/span&gt;MyFLExt = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;.XLS&quot;&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;Or&lt;/span&gt; MyFLExt = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;.XLSX&quot;&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;Or&lt;/span&gt; MyFLExt = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;.PDF&quot;&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;Or&lt;/span&gt; MyFLExt = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;.TXT&quot;&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;Or&lt;/span&gt; MyFLExt = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;.XPS&quot;&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;Or &lt;/span&gt;MyFLExt = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;.DOC&quot;&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;Or&lt;/span&gt; MyFLExt = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;.DOCX&quot;&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;Then&lt;/span&gt;

          &lt;span style=&quot;color: blue;&quot;&gt;If &lt;/span&gt;MyFLExt = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;.JPG&quot;&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;Then&lt;/span&gt;
              &lt;span style=&quot;color: #93c47d;&quot;&gt;&#39; Listview.ListItems.Ass [Index], [key], &lt;b&gt;[Text]&lt;/b&gt;,[Icon], &lt;b&gt;[SmallIcon]&lt;/b&gt;&lt;/span&gt;
              .ListItems.Add , , MyFlList, , &lt;span style=&quot;color: #990000;&quot;&gt;&quot;ImgIco1&quot;&lt;/span&gt;
          &lt;span style=&quot;color: blue;&quot;&gt;End If&lt;/span&gt;
          &lt;span style=&quot;color: blue;&quot;&gt;If&lt;/span&gt; MyFLExt = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;.PNG&quot;&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;Then&lt;/span&gt;
              .ListItems.Add , , MyFlList, , &lt;span style=&quot;color: #990000;&quot;&gt;&quot;ImgIco1&quot;&lt;/span&gt;
          &lt;span style=&quot;color: blue;&quot;&gt;End If&lt;/span&gt;
          &lt;span style=&quot;color: blue;&quot;&gt;If&lt;/span&gt; MyFLExt = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;.XLS&quot;&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;Or&lt;/span&gt; MyExt = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;.XLSX&quot;&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;Then&lt;/span&gt;
              .ListItems.Add , , MyFlList, , &lt;span style=&quot;color: #990000;&quot;&gt;&quot;XlsIco6&quot;&lt;/span&gt;
          &lt;span style=&quot;color: blue;&quot;&gt;End If&lt;/span&gt;
          &lt;span style=&quot;color: blue;&quot;&gt;If&lt;/span&gt; MyFLExt = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;.PDF&quot;&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;Then&lt;/span&gt;
              .ListItems.Add , , MyFlList, , &lt;span style=&quot;color: #990000;&quot;&gt;&quot;PdfIco2&quot;&lt;/span&gt;
          &lt;span style=&quot;color: blue;&quot;&gt;End If&lt;/span&gt;
          &lt;span style=&quot;color: blue;&quot;&gt;If&lt;/span&gt; MyFLExt = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;.TXT&quot;&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;Then&lt;/span&gt;
              .ListItems.Add , , MyFlList, , &lt;span style=&quot;color: #990000;&quot;&gt;&quot;TxtIco4&quot;&lt;/span&gt;
          &lt;span style=&quot;color: blue;&quot;&gt;End If&lt;/span&gt;
          &lt;span style=&quot;color: blue;&quot;&gt;If&lt;/span&gt; MyFLExt = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;.XPS&quot;&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;Then&lt;/span&gt;
              .ListItems.Add , , MyFlList, , &lt;span style=&quot;color: #990000;&quot;&gt;&quot;XpsIco7&quot;&lt;/span&gt;
          &lt;span style=&quot;color: blue;&quot;&gt;End If&lt;/span&gt;
          &lt;span style=&quot;color: blue;&quot;&gt;If&lt;/span&gt; MyFLExt = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;.DOC&quot;&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;Or&lt;/span&gt; MyExt = &lt;span style=&quot;color: #990000;&quot;&gt;&quot;.DOCX&quot;&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;Then&lt;/span&gt;
              .ListItems.Add , , MyFlList, , &lt;span style=&quot;color: #990000;&quot;&gt;&quot;DocIco5&quot;&lt;/span&gt;
          &lt;span style=&quot;color: blue;&quot;&gt;End If&lt;/span&gt;
          
      &lt;span style=&quot;color: blue;&quot;&gt;Else&lt;/span&gt;
              .ListItems.Add , , MyFlList, , &lt;span style=&quot;color: #990000;&quot;&gt;&quot;OtherIco8&quot;&lt;/span&gt;
      &lt;span style=&quot;color: blue;&quot;&gt;End If&lt;/span&gt;

      .ListItems(i).ForeColor = &lt;span style=&quot;color: blue;&quot;&gt;vbBlue&lt;/span&gt;
      .ListItems(i).ListSubItems.Add , , &lt;span style=&quot;color: #990000;&quot;&gt;&quot;C:\SKOTechLearn_Files\&quot;&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;&amp;amp;&lt;/span&gt; MyFlList
      .ListItems(i).ListSubItems(1).ForeColor = &lt;span style=&quot;color: blue;&quot;&gt;vbRed&lt;/span&gt;
      .ListItems(i).ListSubItems.Add , , MyFLExt
      &lt;span style=&quot;color: #93c47d;&quot;&gt;&#39; retun remaining Dir File&#39;s List&lt;/span&gt;
       MyFlList = &lt;span style=&quot;color: blue;&quot;&gt;Dir&lt;/span&gt;
     &lt;span style=&quot;color: blue;&quot;&gt;DoEvents&lt;/span&gt;
     i = i + 1
   &lt;span style=&quot;color: blue;&quot;&gt;Wend&lt;/span&gt;

 &lt;span style=&quot;color: blue;&quot;&gt;End With&lt;/span&gt;
 &lt;span style=&quot;color: blue;&quot;&gt;End Sub&lt;/span&gt;
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: powderblue; background: #e7f9bf; border-radius: 6px; border: 1px solid rgb(204 , 204 , 204); color: black; float: left; line-height: 25px; width: 120px;&quot;&gt;&amp;nbsp;&lt;b&gt;Process(3):&lt;/b&gt;&lt;/div&gt;In this process we use &lt;b&gt;FileSystemObject &lt;/b&gt;for show Files in Listview with Icons.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;How To Add FileSystemObject (scrrun.dll) in VB6.0?&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
For Using &lt;b&gt;FileSystemObject&lt;/b&gt;, you have to first add references &lt;b&gt;‘Microsoft Scripting Runtime’&lt;/b&gt;. This reference contains FileSystemObject class.&lt;br /&gt;
&lt;br /&gt;
The following image will show how to add &lt;b&gt;Microsoft Scripting Runtime (scrrun.dll) in VB6.0&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background: #ffe6e6; border-radius: 50%; border: 2px solid #886d9a; float: left; font-family: &amp;quot;verdana&amp;quot;; font-size: 16px; padding: 0px 0px 2px 2px; text-align: center; width: 25px;&quot;&gt;&lt;b&gt;1.&lt;/b&gt; &lt;/div&gt;&amp;nbsp; Go to &lt;b&gt;Project &lt;/b&gt;menu and find &lt;b&gt;“References..”&lt;/b&gt; option.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background: #ffe6e6; border-radius: 50%; border: 2px solid #886d9a; float: left; font-family: &amp;quot;verdana&amp;quot;; font-size: 16px; padding: 0px 0px 2px 2px; text-align: center; width: 25px;&quot;&gt;&lt;b&gt;2.&lt;/b&gt; &lt;/div&gt;&amp;nbsp; Click on this option and this will show &lt;b&gt;“References..”&lt;/b&gt; window.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background: #ffe6e6; border-radius: 50%; border: 2px solid #886d9a; float: left; font-family: &amp;quot;verdana&amp;quot;; font-size: 16px; padding: 0px 0px 2px 2px; text-align: center; width: 25px;&quot;&gt;&lt;b&gt;3.&lt;/b&gt; &lt;/div&gt;&amp;nbsp; This window will show the &lt;b&gt;Available References&lt;/b&gt; List.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background: #ffe6e6; border-radius: 50%; border: 2px solid #886d9a; float: left; font-family: &amp;quot;verdana&amp;quot;; font-size: 16px; padding: 0px 0px 2px 2px; text-align: center; width: 25px;&quot;&gt;&lt;b&gt;4.&lt;/b&gt; &lt;/div&gt;&amp;nbsp; Find &lt;b&gt;“Microsoft Scripting Runtime”&lt;/b&gt; and check on it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhG0k4MGIaIblx-PmjJKPfgNhRg8EKt5fXebiqMFHWFu3ThNpTG1NmNIrPpfICuO_xRZj92SCTEP3uv696at38xt1fQ9UFnNWp4E_aWjpWzWGYzC7fDilkBsRdn2J7n1Cc2vpk1Krq6E_sY/s1600/4_Add_Microsoft_Scripting_Runtime_Reference_in_Vb6.0_web.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;add FileSystemObject class in VB6.0&quot; border=&quot;0&quot; data-original-height=&quot;328&quot; data-original-width=&quot;587&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhG0k4MGIaIblx-PmjJKPfgNhRg8EKt5fXebiqMFHWFu3ThNpTG1NmNIrPpfICuO_xRZj92SCTEP3uv696at38xt1fQ9UFnNWp4E_aWjpWzWGYzC7fDilkBsRdn2J7n1Cc2vpk1Krq6E_sY/s1600/4_Add_Microsoft_Scripting_Runtime_Reference_in_Vb6.0_web.jpg&quot; title=&quot;Add Microsoft Scription Runtime reference&quot; /&gt;&lt;/a&gt;&lt;/div&gt;In this way you can add any Reference.&lt;br /&gt;
&lt;br /&gt;
After adding &lt;b&gt;Microsoft Scripting Runtime&lt;/b&gt;. Write following code.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;VB6.0:&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;Private Sub&lt;/span&gt; FilesListFSO_Cmd_Click()
 &lt;span style=&quot;color: blue;&quot;&gt;Dim &lt;/span&gt;myfsobj &lt;span style=&quot;color: blue;&quot;&gt;As New FileSystemObject&lt;/span&gt;
 &lt;span style=&quot;color: blue;&quot;&gt;Dim &lt;/span&gt;myfldr &lt;span style=&quot;color: blue;&quot;&gt;As Folder&lt;/span&gt;
 &lt;span style=&quot;color: blue;&quot;&gt;Dim &lt;/span&gt;myfl &lt;span style=&quot;color: blue;&quot;&gt;As File&lt;/span&gt;
 &lt;span style=&quot;color: blue;&quot;&gt;Set&lt;/span&gt; myfldr = myfsobj.GetFolder( &lt;span style=&quot;color: #990000;&quot;&gt;&quot;C:\SKOTechLearn_Files\&quot; &lt;/span&gt;)
 &lt;span style=&quot;color: #93c47d;&quot;&gt;&#39;First you have to set listview smallicon with ImageList&lt;/span&gt;
 MyLstView.ListItems.Clear
 &lt;span style=&quot;color: blue;&quot;&gt;Set&lt;/span&gt; MyLstView.SmallIcons = MyImageList

 &lt;span style=&quot;color: blue;&quot;&gt;With&lt;/span&gt; MyLstView
   &lt;span style=&quot;color: blue;&quot;&gt;Dim&lt;/span&gt; li &lt;span style=&quot;color: blue;&quot;&gt;As Integer&lt;/span&gt;
   li = 1

   &lt;span style=&quot;color: blue;&quot;&gt;For Each&lt;/span&gt; myfl In myfldr.Files
      &lt;span style=&quot;color: blue;&quot;&gt;Dim &lt;/span&gt;MyFLExten &lt;span style=&quot;color: blue;&quot;&gt;As String&lt;/span&gt;
      &lt;span style=&quot;color: #93c47d;&quot;&gt;&#39;Extract Extension through FileSystemobject&#39;s GetExtensionName method&lt;/span&gt;
      MyFLExten = &lt;span style=&quot;color: blue;&quot;&gt;UCase&lt;/span&gt;(myfsobj.GetExtensionName(myfl))

      &lt;span style=&quot;color: blue;&quot;&gt;Select Case&lt;/span&gt; MyFLExten
          &lt;span style=&quot;color: blue;&quot;&gt;Case&lt;/span&gt; &lt;span style=&quot;color: #990000;&quot;&gt;&quot;JPG&quot;&lt;/span&gt;
              .ListItems.Add , , myfl.Name, , &lt;span style=&quot;color: #990000;&quot;&gt;&quot;ImgIco1&quot;&lt;/span&gt;
          &lt;span style=&quot;color: blue;&quot;&gt;Case&lt;/span&gt; &lt;span style=&quot;color: #990000;&quot;&gt;&quot;PNG&quot;&lt;/span&gt;
              .ListItems.Add , , myfl.Name, , &lt;span style=&quot;color: #990000;&quot;&gt;&quot;ImgIco1&quot;&lt;/span&gt;
          &lt;span style=&quot;color: blue;&quot;&gt;Case&lt;/span&gt; &lt;span style=&quot;color: #990000;&quot;&gt;&quot;XLS&quot;&lt;/span&gt;, &lt;span style=&quot;color: #990000;&quot;&gt;&quot;XLSX&quot;&lt;/span&gt;
              .ListItems.Add , , myfl.Name, , &lt;span style=&quot;color: #990000;&quot;&gt;&quot;XlsIco6&quot;&lt;/span&gt;
          &lt;span style=&quot;color: blue;&quot;&gt;Case&lt;/span&gt; &lt;span style=&quot;color: #990000;&quot;&gt;&quot;PDF&quot;&lt;/span&gt;
              .ListItems.Add , , myfl.Name, , &lt;span style=&quot;color: #990000;&quot;&gt;&quot;PdfIco2&quot;&lt;/span&gt;
          &lt;span style=&quot;color: blue;&quot;&gt;Case&lt;/span&gt; &lt;span style=&quot;color: #990000;&quot;&gt;&quot;TXT&quot;&lt;/span&gt;
              .ListItems.Add , , myfl.Name, , &lt;span style=&quot;color: #990000;&quot;&gt;&quot;TxtIco4&quot;&lt;/span&gt;
          &lt;span style=&quot;color: blue;&quot;&gt;Case&lt;/span&gt; &lt;span style=&quot;color: #990000;&quot;&gt;&quot;XPS&quot;&lt;/span&gt;
              .ListItems.Add , , myfl.Name, , &lt;span style=&quot;color: #990000;&quot;&gt;&quot;XpsIco7&quot;&lt;/span&gt;
          &lt;span style=&quot;color: blue;&quot;&gt;Case&lt;/span&gt; &lt;span style=&quot;color: #990000;&quot;&gt;&quot;DOC&quot;&lt;/span&gt;, &lt;span style=&quot;color: #990000;&quot;&gt;&quot;DOCX&quot;&lt;/span&gt;
              .ListItems.Add , , myfl.Name, , &lt;span style=&quot;color: #990000;&quot;&gt;&quot;DocIco5&quot;&lt;/span&gt;
          &lt;span style=&quot;color: blue;&quot;&gt;Case Else&lt;/span&gt;
              .ListItems.Add , , myfl.Name, , &lt;span style=&quot;color: #990000;&quot;&gt;&quot;OtherIco8&quot;&lt;/span&gt;
      &lt;span style=&quot;color: blue;&quot;&gt;End Select&lt;/span&gt;

      .ListItems(li).ForeColor = &lt;span style=&quot;color: blue;&quot;&gt;vbBlue&lt;/span&gt;
      .ListItems(li).ListSubItems.Add , , myfl
      .ListItems(li).ListSubItems(1).ForeColor = &lt;span style=&quot;color: blue;&quot;&gt;vbRed&lt;/span&gt;
      .ListItems(li).ListSubItems.Add , , MyFLExten
      &lt;span style=&quot;color: blue;&quot;&gt;DoEvents&lt;/span&gt;
      li = li + 1

   &lt;span style=&quot;color: blue;&quot;&gt;Next&lt;/span&gt;
 &lt;span style=&quot;color: blue;&quot;&gt;End With&lt;/span&gt;
 &lt;span style=&quot;color: #93c47d;&quot;&gt;&#39;After show files list, clear Files Folders and FileSystemObject class&lt;/span&gt;
 &lt;span style=&quot;color: blue;&quot;&gt;Set&lt;/span&gt; myfl = &lt;span style=&quot;color: blue;&quot;&gt;Nothing&lt;/span&gt;
 &lt;span style=&quot;color: blue;&quot;&gt;Set &lt;/span&gt;myfldr = &lt;span style=&quot;color: blue;&quot;&gt;Nothing&lt;/span&gt;
 &lt;span style=&quot;color: blue;&quot;&gt;Set&lt;/span&gt; myfsobj = &lt;span style=&quot;color: blue;&quot;&gt;Nothing&lt;/span&gt;
 &lt;span style=&quot;color: blue;&quot;&gt;End Sub&lt;/span&gt;

&lt;/pre&gt;&lt;br /&gt;
Give above 3 process will show the same output as shown bellow image.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiumVQ4rnKlq5Ek7OIc45aKLdPp4RDZASZngQtW6C2Q9NXepJJs3U8VTHGe0sFVQVQRfHwc2KbOTEGaH0HxeibSPQJ1UO9i12drydhHjPA7tWokTSSCLbuMxkvPbo-grjXT2bJH_mokj_29/s1600/6_ListView_with_Files_and_Icons_Output_web.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Listview With Icons, path and Filenames in Vb6.0&quot; border=&quot;0&quot; data-original-height=&quot;368&quot; data-original-width=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiumVQ4rnKlq5Ek7OIc45aKLdPp4RDZASZngQtW6C2Q9NXepJJs3U8VTHGe0sFVQVQRfHwc2KbOTEGaH0HxeibSPQJ1UO9i12drydhHjPA7tWokTSSCLbuMxkvPbo-grjXT2bJH_mokj_29/s1600/6_ListView_with_Files_and_Icons_Output_web.jpg&quot; title=&quot;Listview With Icons, path and Filenames in Vb6.0&quot; /&gt;&lt;/a&gt;&lt;/div&gt;So, SKOTechLearn has Explained with some simple process to &lt;b&gt;Show Files List With Icons In Listview Using ImageList in VB6.0&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;&lt;a href=&quot;https://www.skotechlearn.com/2018/04/get-listview-checked-item-in-another-listview.html&quot; target=&quot;_blank&quot;&gt;How to move checked items from one Listview to Another?&lt;/a&gt;&lt;/b&gt;&lt;/u&gt;&lt;/div&gt;</description><link>https://www.skotechlearn.com/2020/06/show-files-icons-in-listview-using-imagelist-vb6.html</link><author>noreply@blogger.com (SKOTechLearn)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWiw4l7DfNVJTAA5kZtibvk6Sn22LJ49vQSWDpelz8EDJhhfp9q4rP38eV_-ULAZbbcr-2__oceQZwhFl5eoLxoPvEh3awALOgbCRLKeeAspdDZehXpX0QZ282i-Xq6pAALssV7DakpTtr/s72-c/5_ListView_with_Files_and_Icons_Output_web.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2258844867892945003.post-5858705680087787579</guid><pubDate>Sun, 14 Jun 2020 06:40:00 +0000</pubDate><atom:updated>2022-07-02T14:31:58.352-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">HTML</category><title>About HTML and HTML Element with HTML Example</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Whenever a developer desires to jump from desktop application’s development to web development. Then he has to learn &lt;b&gt;about HTML&lt;/b&gt;. Suppose, you want to be a web developer or you want to develop your own website. Then you must have the knowledge of &lt;b&gt;HTML&lt;/b&gt;. &lt;br /&gt;
&lt;br /&gt;
If you &lt;b&gt;learn HTML&lt;/b&gt;, the door of web development will be open for you. So, here we will&amp;nbsp;&lt;b&gt;Understand About HTML and HTML Document with Example&lt;/b&gt;.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNjw0QCBFJAujzoi-H-6zioYCNpkuylXNNFKTc1hlKZVVahXrbVECByaEA9XBgk1XB8EFl6OnvabhZ72yYoIFuG55rCLg_McehrTQB85jtwB_MtGakqhpaswQCdv8YD24kh6kQseEN0inS/s1600/1_HTML_logo.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;html Logo&quot; border=&quot;0&quot; data-original-height=&quot;76&quot; data-original-width=&quot;438&quot; height=&quot;108&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNjw0QCBFJAujzoi-H-6zioYCNpkuylXNNFKTc1hlKZVVahXrbVECByaEA9XBgk1XB8EFl6OnvabhZ72yYoIFuG55rCLg_McehrTQB85jtwB_MtGakqhpaswQCdv8YD24kh6kQseEN0inS/s640/1_HTML_logo.jpg&quot; title=&quot;html Logo&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;So here we learn it through following point:&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: #fcfeff; border: 1px solid #bedaf6; box-shadow: 0px 0px 3px 3px #ECF2F7; padding: 6px 10px;&quot;&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li style=&quot;color: #344B68; font-family: Arial; font-size: 15px; line-height: 35px;&quot;&gt;&lt;b&gt;What Is HTML?&amp;nbsp;&lt;/b&gt;&lt;/li&gt;
&lt;li style=&quot;color: #344B68; font-family: Arial; font-size: 15px; line-height: 35px;&quot;&gt;&lt;b&gt;Understand about HTML Document&lt;/b&gt;&lt;/li&gt;
&lt;li style=&quot;color: #344B68; font-family: Arial; font-size: 15px; line-height: 35px;&quot;&gt;&lt;b&gt;HTML Syntax with Base Code process&lt;/b&gt;&lt;/li&gt;
&lt;li style=&quot;color: #344B68; font-family: Arial; font-size: 15px; line-height: 35px;&quot;&gt;&lt;b&gt;Best Tool For HTML Code Editor&lt;/b&gt;&lt;/li&gt;
&lt;li style=&quot;color: #344B68; font-family: Arial; font-size: 15px; line-height: 35px;&quot;&gt;&lt;b&gt;Simple Example of HTML Coding Structure&lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid #b29a94; color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;b style=&quot;color: white;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;What Is HTML?&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;In simple word the definition is defined inside its full form &lt;b&gt;(Hypertext Markup Language )&lt;/b&gt;.  HTML language is used with Hypertext and markup language, where it displays the information in the form of (text, images etc) to users’ screen on any web-browser( &lt;a href=&quot;https://www.mozilla.org/en-US/firefox/new/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Firefox&lt;/a&gt;, &lt;a href=&quot;https://www.google.com/chrome/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Chrome&lt;/a&gt;, Internet Explorer etc.)&lt;br /&gt;
&lt;br /&gt;
In HTML, hypertext is the way where we put the link that can be active or explore through key process. Basically hypertext is Hyperlink which is defined by &lt;b&gt;&lt;i&gt;&lt;span style=&quot;color: #4c1130;&quot;&gt;Anchor (&amp;lt; a &amp;gt;) Tags&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
And the markup language is the writing way where we can write code for web document with the use of &lt;b&gt;HTML Tags&lt;/b&gt;. &lt;b&gt;HTML Tag&lt;/b&gt; is markup Language.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid #b29a94; color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;b style=&quot;color: white;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;Understand about HTML Document&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;When we prepare a file including layout, text, Images and hyperlinks with “.html” extension for web process. And what to execute it on any web-browser. Then that execution time this file will be Displayed in any web browser called HTML Document. &lt;br /&gt;
&lt;br /&gt;
Now, in this time you are viewing or reading HTML Document on your web browser.&lt;br /&gt;
&lt;br /&gt;
Basically web page is HTML Document which is mainly written in HTML.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid #b29a94; color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b style=&quot;color: white;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;HTML Syntax with Code process&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;Now, we will learn what is the code writing process and what is syntax of HTML?&lt;br /&gt;
&lt;br /&gt;
When you want to create or design web page then the HTML Syntax will be use. The HTML has following syntax:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYmAJXwfimBDbZCwwrmsLNOdRqnjUVBtAKxZyqzrPd5RNOBwo459RGfT59eRNFy0ZwV43-ezE8pu1FoQDyT691SfYxUCsKJLzYx2K-Ow74BFcHpcc1KaHDKSF7NWdl88J1aIKRKog4S8LP/s1600/HTML_Code_Syntax.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;HTML Tag and HTML Element&quot; border=&quot;0&quot; data-original-height=&quot;290&quot; data-original-width=&quot;683&quot; height=&quot;271&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYmAJXwfimBDbZCwwrmsLNOdRqnjUVBtAKxZyqzrPd5RNOBwo459RGfT59eRNFy0ZwV43-ezE8pu1FoQDyT691SfYxUCsKJLzYx2K-Ow74BFcHpcc1KaHDKSF7NWdl88J1aIKRKog4S8LP/s640/HTML_Code_Syntax.jpg&quot; title=&quot;HTML Tag and Element&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;&lt;b style=&quot;background-color: #fff2cc;&quot;&gt;&lt;span style=&quot;color: #073763;&quot;&gt;&amp;lt;tag open&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #cc0000;&quot;&gt;Content &lt;/span&gt;&lt;span style=&quot;color: #073763;&quot;&gt;&amp;lt;/tag close&amp;gt;&lt;/span&gt;&lt;/b&gt;
&lt;b&gt;
&lt;/b&gt;&lt;/code&gt;&lt;/pre&gt;&lt;pre&gt;&lt;code&gt;&lt;b&gt;eg.:&lt;/b&gt; &lt;span style=&quot;color: #073763;&quot;&gt;&amp;lt;h1&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #990000;&quot;&gt;HTML Heading Tag example&lt;/span&gt; &lt;span style=&quot;color: #073763;&quot;&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
 &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;So, the whole html code is base on Tags and Elements.&lt;br /&gt;
&lt;br /&gt;
Now, let&#39;s know about Tag.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;What is Tag in HTML?&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
In simple word,&amp;nbsp;The entire code of the HTML revolves around the &lt;b&gt;Tags&lt;/b&gt;. And&amp;nbsp;The &lt;b&gt;Tag &lt;/b&gt;is surrounded by &lt;b&gt;Angular Brackets &quot;&amp;lt; &amp;gt;&quot;&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
For example if you see the above syntax. We use &amp;lt;h1&amp;gt;.&amp;nbsp; Here &lt;b&gt;h1&lt;/b&gt; is Tag. There are may tags like&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
&amp;lt;h2&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
etc.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;What is Element in HTML?&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Normally, you can define &lt;b&gt;Element&lt;/b&gt; is the combination of&amp;nbsp;&lt;b&gt;Opening Tag&lt;/b&gt;&amp;nbsp;+&lt;b&gt; Content&amp;nbsp;&lt;/b&gt;+&amp;nbsp;&lt;b&gt;Closing Tag&lt;/b&gt;. Now, let&#39;s try to understand by given following example.&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;title&amp;gt;&lt;/span&gt; First Element with &quot;Title&quot; Tag &lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;h1&amp;gt;&lt;/span&gt; Second Element with &quot;h1&quot; Tag &lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;div&amp;gt;&lt;/span&gt; Third Element with &quot;DIV&quot; Tag &lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;

&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid #b29a94; color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b style=&quot;color: white;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;Best Tool For HTML Code Editor&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;Now, the next point is in which Tool we can write code for HTML document of Web-page Design. The answer is, there are many tools which you can use for it easily like (Notepad, &lt;a href=&quot;https://notepad-plus-plus.org/downloads/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Notepad++&lt;/a&gt;, &lt;a href=&quot;https://netbeans.apache.org/download/index.html&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;NetBeans&lt;/a&gt;,VS Code, &lt;a href=&quot;https://www.eclipse.org/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Eclipse &lt;/a&gt;etc.).&lt;br /&gt;
&lt;br /&gt;
But remember one thing, For HTML Code writing, you have to need Text Editor or HTML Designer Tool and Reading this code or HTML file you need Web-browser on your PC or laptop. &lt;br /&gt;
&lt;br /&gt;
Basically HTML Document of File is simple or normal text files. And Web-browser works to understand the tags of HTML code and other supporting code like CSS, JavaScript etc. &lt;br /&gt;
&lt;br /&gt;
So, &lt;b&gt;Text Editor and Web-browser&lt;/b&gt; is necessary for HTML Coding.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid #b29a94; color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;b style=&quot;color: white;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;Simple Example of HTML Coding Structure&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;Now, if you have some basic knowledge of computer or OS then you can easily proceed in following way. You can now write following code or you can copy that code and see the output.&lt;br /&gt;
&lt;br /&gt;
HTML Code Example:&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
 &lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
   &lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;title&amp;gt;&lt;/span&gt; SKOTechLearn Document Title &lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
 &lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
 &lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
   &lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;h1&amp;gt;&lt;/span&gt; SKOTechLearn HTML Heading H1 &lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
   &lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;p&amp;gt;&lt;/span&gt; SKOTechLearn HTML Paragraph &lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
 &lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;&lt;/pre&gt;When you run this file, the following output will be displayed. You can easily copy this code and try it yourself.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixy7d0AysT5PaNaBlXh9w2k-9hLLLSZPxOm-ZjOQVnUIYQMCdQEuSfg5_cuktc6RFJeUjlDNtnzZCdVplaPMOwPd7F7lsYYbWIeWHxfXRbgDoDPB31-9YcvYIywVROEM5PswzqgHhY3gY1/s1600/HTML_Example_With+output.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;HTML Example with output&quot; border=&quot;0&quot; data-original-height=&quot;473&quot; data-original-width=&quot;680&quot; height=&quot;444&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixy7d0AysT5PaNaBlXh9w2k-9hLLLSZPxOm-ZjOQVnUIYQMCdQEuSfg5_cuktc6RFJeUjlDNtnzZCdVplaPMOwPd7F7lsYYbWIeWHxfXRbgDoDPB31-9YcvYIywVROEM5PswzqgHhY3gY1/s640/HTML_Example_With+output.jpg&quot; title=&quot;HTML Example with output&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;Now, you can also try to design a web-page after learning Easy &lt;b&gt;Understand About HTML and HTML Document with Example&lt;/b&gt;.&lt;/div&gt;</description><link>https://www.skotechlearn.com/2020/06/understand-about-html-and-html-document.html</link><author>noreply@blogger.com (SKOTechLearn)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNjw0QCBFJAujzoi-H-6zioYCNpkuylXNNFKTc1hlKZVVahXrbVECByaEA9XBgk1XB8EFl6OnvabhZ72yYoIFuG55rCLg_McehrTQB85jtwB_MtGakqhpaswQCdv8YD24kh6kQseEN0inS/s72-c/1_HTML_logo.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2258844867892945003.post-3150936519108058465</guid><pubDate>Tue, 09 Jun 2020 09:35:00 +0000</pubDate><atom:updated>2020-08-04T02:26:49.157-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Python</category><title>Set Tkinter Window Position and Size or Center Screen Tkinter in Python</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;When you start programming in python using Tkinter. You will find that the default form or dialog location is not appear as desired location. You will have to move it by mouse. And also in some cases you just need to show Tkinter window in center position on the screen. Find latest version of &lt;a href=&quot;https://www.python.org/downloads/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Python&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
So, here SKOTechLearn will explain and describe step by step process to&amp;nbsp;&lt;b&gt;Set Tkinter Window Position and Size or Center Screen Tkinter in Python&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;&lt;a href=&quot;https://www.skotechlearn.com/2020/06/use-label-in-python-using-tkinter.html&quot; target=&quot;_blank&quot;&gt;Easy Way to Use Tkinter Label in Python.&lt;/a&gt;&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
&lt;br /&gt;
Let’s Start with following way:&lt;br /&gt;
&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li style=&quot;color: #476184; font-family: Arial; font-size: 15px; line-height: 35px;&quot;&gt;&lt;b&gt;Set Tkinter Window Size in Python&amp;nbsp;&lt;/b&gt;&lt;/li&gt;
&lt;li style=&quot;color: #476184; font-family: Arial; font-size: 15px; line-height: 35px;&quot;&gt;&lt;b&gt;Set Tkinter Window Position in Python&lt;/b&gt;&lt;/li&gt;
&lt;li style=&quot;color: #476184; font-family: Arial; font-size: 15px; line-height: 35px;&quot;&gt;&lt;b&gt;Center Screen Tkinter Window in Python&lt;/b&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;br /&gt;
By default tkinter is set in 200x200 height and width size.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid #b29a94; color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b style=&quot;color: white;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;(1). Set Tkinter Window Size in Python :&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;If you make an application in python using tkinter. And you want to increase or decrease the size of Window or Height width of your window, you have to use following syntax:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;Tk().geometry(&quot;&lt;span style=&quot;color: #990000;&quot;&gt;width&lt;/span&gt;x&lt;span style=&quot;color: #990000;&quot;&gt;height&lt;/span&gt;&quot;)&lt;/pre&gt;&lt;br /&gt;
In this syntax, you have to change width and height with desired number or integer.&lt;br /&gt;
&lt;br /&gt;
Now lets see the example how its work?&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt; from &lt;/span&gt;tkinter &lt;span style=&quot;color: blue;&quot;&gt;import &lt;/span&gt;* 
 TkForm = &lt;span style=&quot;color: blue;&quot;&gt;Tk&lt;/span&gt;()

&lt;i&gt;&lt;span style=&quot;color: #666666;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #999999;&quot;&gt;#Set Height and Width of Window&lt;/span&gt;&lt;/i&gt;
 TkForm.&lt;span style=&quot;color: blue;&quot;&gt;geometry&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;350x150&quot;&lt;/span&gt;) 

&lt;i&gt;&lt;span style=&quot;color: #666666;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #999999;&quot;&gt;#Set the Title according to desire&lt;/span&gt;&lt;/i&gt;
 TkForm.&lt;span style=&quot;color: blue;&quot;&gt;title&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;TK Size in Python&quot;&lt;/span&gt;)

 TkForm.&lt;span style=&quot;color: blue;&quot;&gt;mainloop&lt;/span&gt;()
&lt;/pre&gt;When you run this code, the following geometry will show bellow&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhiFXIxxneoVKV0EfOyrIBmhF0x4t7FNKKZ-9wPTGEU_4Ez-6KzfSD2C1pU4NERtDBSMUMm9uGHRgSaMe2WOW1sra71eCFNarDhsDDMn3_dIMZe4U_ELKv8Ijd55tdavLGnnqnHeYQqeTTn/s1600/1_Tkinter_Size_in_Python.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;Tkinter Window size Setting in Python&quot; border=&quot;0&quot; data-original-height=&quot;180&quot; data-original-width=&quot;358&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhiFXIxxneoVKV0EfOyrIBmhF0x4t7FNKKZ-9wPTGEU_4Ez-6KzfSD2C1pU4NERtDBSMUMm9uGHRgSaMe2WOW1sra71eCFNarDhsDDMn3_dIMZe4U_ELKv8Ijd55tdavLGnnqnHeYQqeTTn/s1600/1_Tkinter_Size_in_Python.jpg&quot; title=&quot;Tkinter Window size in Python&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;b&gt;&lt;i&gt;&lt;span style=&quot;color: purple;&quot;&gt;Tk Size Output&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;This way you can set the size of your application form.&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;&lt;a href=&quot;https://www.skotechlearn.com/2020/05/if-else-statement-in-python.html&quot; target=&quot;_blank&quot;&gt;Python If Else Statement with Details Description and Example.&lt;/a&gt;&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid #b29a94; color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b style=&quot;color: white;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;(2). Set Tkinter Window Position in Python :&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;Like above given Size setting, you can set the position using “geometry” option in TK() class. So, let’s see the syntax of position setting.&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;Tk().geometry(&quot;+&lt;span style=&quot;color: #990000;&quot;&gt;Left&lt;/span&gt;+&lt;span style=&quot;color: #990000;&quot;&gt;Top&lt;/span&gt;&quot;)&lt;/pre&gt;&lt;br /&gt;
Here, you have to replace “Left” and “Top” with integer.&lt;br /&gt;
&lt;br /&gt;
So, the simple example of position settings is shown bellow.&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt; from &lt;/span&gt;tkinter &lt;span style=&quot;color: blue;&quot;&gt;import &lt;/span&gt;* 
 TkForm = &lt;span style=&quot;color: blue;&quot;&gt;Tk&lt;/span&gt;()
 &lt;i&gt;&lt;span style=&quot;color: #999999;&quot;&gt;#position setting with desire location.
 # &lt;b&gt;&quot;+&quot;&lt;/b&gt; sign indicate the Window&#39;s position in geometry option.&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt; &lt;/span&gt;&lt;/i&gt;
 TkForm.&lt;span style=&quot;color: blue;&quot;&gt;geometry&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;+120+50&quot;&lt;/span&gt;)

 TkForm.&lt;span style=&quot;color: blue;&quot;&gt;title&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;TK Position Setting&quot;&lt;/span&gt;)
 TkForm.&lt;span style=&quot;color: blue;&quot;&gt;mainloop&lt;/span&gt;()
&lt;/pre&gt;Now the output will be like this.&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyDVmqpEWa7DEetri5nNEq_jAEDmw9BteYyCKy2VCx7Odi6p-lIIccAlXMXpgc38d59GjgCx686I7tF4ikFhX723Y2qiloLBU98DwR8yyhWpZiwUAkoyRvfdEVt_9zRS5MFbQ9ZgA0aXBS/s1600/2_Tkinter_Window_position_in_Python.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;Tkinter Window Location Setting in Python&quot; border=&quot;0&quot; data-original-height=&quot;768&quot; data-original-width=&quot;1366&quot; height=&quot;359&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyDVmqpEWa7DEetri5nNEq_jAEDmw9BteYyCKy2VCx7Odi6p-lIIccAlXMXpgc38d59GjgCx686I7tF4ikFhX723Y2qiloLBU98DwR8yyhWpZiwUAkoyRvfdEVt_9zRS5MFbQ9ZgA0aXBS/s640/2_Tkinter_Window_position_in_Python.jpg&quot; title=&quot;Tkinter Window Location Setting in Python&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;b&gt;&lt;i&gt;&lt;span style=&quot;color: purple;&quot;&gt;Location Setting&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;Now, if you want to &lt;b&gt;set height and Width and Position of Tkinter&lt;/b&gt; window in one line code, then you have to use following syntax:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;Tk().geometry(&quot;&lt;span style=&quot;color: #990000;&quot;&gt;width&lt;/span&gt;x&lt;span style=&quot;color: #990000;&quot;&gt;height&lt;/span&gt;+&lt;span style=&quot;color: #990000;&quot;&gt;Left&lt;/span&gt;+&lt;span style=&quot;color: #990000;&quot;&gt;Top&lt;/span&gt;&quot;)&lt;/pre&gt;&lt;br /&gt;
Lets see, how its work with given following example:&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt; from &lt;/span&gt;tkinter &lt;span style=&quot;color: blue;&quot;&gt;import &lt;/span&gt;* 
 TkForm = &lt;span style=&quot;color: blue;&quot;&gt;Tk&lt;/span&gt;()
 &lt;i&gt;&lt;span style=&quot;color: #999999;&quot;&gt;# Width and Height with Location Setting&lt;/span&gt;&lt;/i&gt;
 TkForm.&lt;span style=&quot;color: blue;&quot;&gt;geometry&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;350x150+220+80&quot;&lt;/span&gt;)

 TkForm.&lt;span style=&quot;color: blue;&quot;&gt;title&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;TK Position Setting&quot;&lt;/span&gt;)
 TkForm.&lt;span style=&quot;color: blue;&quot;&gt;mainloop&lt;/span&gt;()
&lt;/pre&gt;This will display the output like:&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCp2riodim5iKKe0DihcLo-CW_snO-dIzKu_Cr9J44D05mjuwQIcYPYI6bhOVhFc7mGmnU0KWPI1by0E1PTqntT3DV6Trpb-s-p1iazbDhCDxxNc6PZVJQvKuSW7_9JRHlV5cuP4dvLZfB/s1600/3_Tkinter_Window_Size_And_position_in_Python.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;Tkinter Window size and Location setting in Python&quot; border=&quot;0&quot; data-original-height=&quot;768&quot; data-original-width=&quot;1366&quot; height=&quot;358&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCp2riodim5iKKe0DihcLo-CW_snO-dIzKu_Cr9J44D05mjuwQIcYPYI6bhOVhFc7mGmnU0KWPI1by0E1PTqntT3DV6Trpb-s-p1iazbDhCDxxNc6PZVJQvKuSW7_9JRHlV5cuP4dvLZfB/s640/3_Tkinter_Window_Size_And_position_in_Python.jpg&quot; title=&quot;Tkinter Window size and Location setting in Python&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;b&gt;&lt;i&gt;&lt;span style=&quot;color: purple;&quot;&gt;Height and Width with Location Setting&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;So, In This way, you can set the &lt;b&gt;Size and Position of Tkinter&lt;/b&gt; easily.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid #b29a94; color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b style=&quot;color: white;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;(3). Center Screen Tkinter Window in Python :&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;Now, if you want to set widow as center Screen with desire screen Size, then we have found following way where you can set center screen in python.&lt;br /&gt;
&lt;br /&gt;
Remember one thing, first you have to get the size of Screen by given root option.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: #fce5cd;&quot;&gt;&lt;b&gt;winfo_screenwidth()&lt;/b&gt;: This will show the screen Width&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fce5cd;&quot;&gt;&lt;b&gt;winfo_screenheight()&lt;/b&gt;: This will show the screen Height&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
you can get more details of &lt;b&gt;&lt;u&gt;&lt;a href=&quot;http://effbot.org/tkinterbook/wm.htm#Tkinter.Wm.geometry-method&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;.geometry() from here&lt;/a&gt;&lt;/u&gt;.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Process (1):&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt; from &lt;/span&gt;Tkinter &lt;span style=&quot;color: blue;&quot;&gt;import &lt;/span&gt;*
 MyTkForm = &lt;span style=&quot;color: blue;&quot;&gt;Tk&lt;/span&gt;()

 &lt;i&gt;&lt;span style=&quot;color: #999999;&quot;&gt;#Set desired Tkinter Window Size.&lt;/span&gt;&lt;/i&gt;
 MyTkForm.&lt;span style=&quot;color: blue;&quot;&gt;geometry&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;350x150&quot;&lt;/span&gt;)

 &lt;span style=&quot;color: #999999;&quot;&gt;&lt;i&gt;#Same size will be defined in variable for center screen in Tk_Width and Tk_height&lt;/i&gt;&lt;/span&gt;
 Tk_Width = 350
 Tk_Height = 150

 &lt;i&gt;&lt;span style=&quot;color: #999999;&quot;&gt;#calculate coordination of screen and window form&lt;/span&gt;&lt;/i&gt;
 x_Left = &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;(MyTkForm.&lt;span style=&quot;color: blue;&quot;&gt;winfo_screenwidth&lt;/span&gt;()/2 - Tk_Width/2)
 y_Top = &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;(MyTkForm.&lt;span style=&quot;color: blue;&quot;&gt;winfo_screenheight&lt;/span&gt;()/2 - Tk_Height/2)
 
 &lt;i&gt;&lt;span style=&quot;color: #999999;&quot;&gt;# Write following format for center screen&lt;/span&gt;&lt;/i&gt;
 MyTkForm.&lt;span style=&quot;color: blue;&quot;&gt;geometry&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;+{}+{}&quot;&lt;/span&gt;.&lt;span style=&quot;color: blue;&quot;&gt;format&lt;/span&gt;(x_Left, y_Top))

 MyTkForm.&lt;span style=&quot;color: blue;&quot;&gt;title&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;Process (1): Center screen with size&quot;&lt;/span&gt;)

 MyTkForm.&lt;span style=&quot;color: blue;&quot;&gt;mainloop&lt;/span&gt;()

&lt;/pre&gt;&lt;br /&gt;
&lt;b&gt;Process (2):&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt; from &lt;/span&gt;tkinter &lt;span style=&quot;color: blue;&quot;&gt;import &lt;/span&gt;* 
 
 MyTkForm = &lt;span style=&quot;color: blue;&quot;&gt;Tk&lt;/span&gt;()

 &lt;i&gt;&lt;span style=&quot;color: #999999;&quot;&gt;# Set desired size (height and width) in following variable&lt;/span&gt;&lt;/i&gt;
 Tk_Width = 350
 Tk_Height = 150
 
 &lt;i&gt;&lt;span style=&quot;color: #999999;&quot;&gt;#calculate coordination of screen and window form&lt;/span&gt;&lt;/i&gt;
 positionRight = &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;( MyTkForm.&lt;span style=&quot;color: blue;&quot;&gt;winfo_screenwidth&lt;/span&gt;()/2 - Tk_Width/2 )
 positionDown = &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;( MyTkForm.&lt;span style=&quot;color: blue;&quot;&gt;winfo_screenheight&lt;/span&gt;()/2 - Tk_Height/2 )

 &lt;i&gt;&lt;span style=&quot;color: #999999;&quot;&gt;# Set window in center screen with following way.&lt;/span&gt;&lt;/i&gt;
 MyTkForm.&lt;span style=&quot;color: blue;&quot;&gt;geometry&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;{}x{}+{}+{}&quot;&lt;/span&gt;.&lt;span style=&quot;color: blue;&quot;&gt;format&lt;/span&gt;(500,200,positionRight, positionDown))

 &lt;i&gt;&lt;span style=&quot;color: #999999;&quot;&gt;# Set Desired Title&lt;/span&gt;&lt;/i&gt;
 MyTkForm.&lt;span style=&quot;color: blue;&quot;&gt;title&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;Process (2) : Center screen with size&quot;&lt;/span&gt;)

 MyTkForm.&lt;span style=&quot;color: blue;&quot;&gt;mainloop&lt;/span&gt;()
&lt;/pre&gt;&lt;br /&gt;
&lt;b&gt;Process (3):&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;from &lt;/span&gt;tkinter &lt;span style=&quot;color: blue;&quot;&gt;import &lt;/span&gt;*

 TkForm2 = &lt;span style=&quot;color: blue;&quot;&gt;Tk&lt;/span&gt;()

 &lt;i&gt;&lt;span style=&quot;color: #999999;&quot;&gt;#set center screen window with following coordination&lt;/span&gt;&lt;/i&gt;
 MyLeftPos = (TkForm2.&lt;span style=&quot;color: blue;&quot;&gt;winfo_screenwidth&lt;/span&gt;() - 500) / 2
 myTopPos = (TkForm2.&lt;span style=&quot;color: blue;&quot;&gt;winfo_screenheight&lt;/span&gt;() - 300) / 2
 TkForm2.&lt;span style=&quot;color: blue;&quot;&gt;geometry&lt;/span&gt;( &lt;span style=&quot;color: #990000;&quot;&gt;&quot;%dx%d+%d+%d&quot;&lt;/span&gt; % (500, 300, MyLeftPos, myTopPos))

 TkForm2.&lt;span style=&quot;color: blue;&quot;&gt;title&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;Process (3): TK Center Screen&quot;&lt;/span&gt;)
 TkForm2.&lt;span style=&quot;color: blue;&quot;&gt;mainloop&lt;/span&gt;()
&lt;/pre&gt;&lt;br /&gt;
&lt;b&gt;Process (4):&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;import &lt;/span&gt;tkinter &lt;span style=&quot;color: blue;&quot;&gt;as &lt;/span&gt;tk

 TkForm3 = tk.&lt;span style=&quot;color: blue;&quot;&gt;Tk&lt;/span&gt;()

 &lt;i&gt;&lt;span style=&quot;color: #999999;&quot;&gt;# set window width and height&lt;/span&gt;&lt;/i&gt;
 mywidth = 350
 myheight = 150

 &lt;i&gt;&lt;span style=&quot;color: #999999;&quot;&gt;# get screen height and width&lt;/span&gt;&lt;/i&gt;
 scrwdth = TkForm3.&lt;span style=&quot;color: blue;&quot;&gt;winfo_screenwidth&lt;/span&gt;()
 scrhgt = TkForm3.&lt;span style=&quot;color: blue;&quot;&gt;winfo_screenheight&lt;/span&gt;()

 &lt;i&gt;&lt;span style=&quot;color: #999999;&quot;&gt;# write formula for center screen&lt;/span&gt;&lt;/i&gt;
 xLeft = (scrwdth/2) - (mywidth/2)
 yTop = (scrhgt/2) - (myheight/2)

 &lt;span style=&quot;color: #999999;&quot;&gt;# set geometry &lt;/span&gt;
 TkForm3.&lt;span style=&quot;color: blue;&quot;&gt;geometry&lt;/span&gt;(&lt;span style=&quot;color: blue;&quot;&gt;str&lt;/span&gt;(mywidth) + &lt;span style=&quot;color: #990000;&quot;&gt;&quot;x&quot;&lt;/span&gt; + &lt;span style=&quot;color: blue;&quot;&gt;str&lt;/span&gt;(myheight) + &lt;span style=&quot;color: #990000;&quot;&gt;&quot;+&quot;&lt;/span&gt; + &lt;span style=&quot;color: blue;&quot;&gt;str&lt;/span&gt;(xLeft) + &lt;span style=&quot;color: #990000;&quot;&gt;&quot;+&quot; &lt;/span&gt;+ &lt;span style=&quot;color: blue;&quot;&gt;str&lt;/span&gt;(yTop))

 TkForm3.&lt;span style=&quot;color: blue;&quot;&gt;title&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&#39;Process (4): Center screen with size&#39;&lt;/span&gt;)
 TkForm3.&lt;span style=&quot;color: blue;&quot;&gt;mainloop&lt;/span&gt;()

&lt;/pre&gt;&lt;br /&gt;
So, all the process will work as same for center screen. You can choose anyone for your application development. The output will looks like:&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgY_Pbm3gV0ljLh3OCsSl5Uz59VpWvQ2q8H5l9n4GKzHX8WAj95PfjWbfJZLj-hxzhLPCN9pv8M_yYH-zo4-SEsfxSiKiyTlLIoFOgUKLlKa7ch6Blync77Hn0VcbbMU37rGzyLaTZzNvE7/s1600/4_Tkinter_Center_Screen_in_Python.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;Center Screen Tkinter Window in Python&quot; border=&quot;0&quot; data-original-height=&quot;768&quot; data-original-width=&quot;1366&quot; height=&quot;358&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgY_Pbm3gV0ljLh3OCsSl5Uz59VpWvQ2q8H5l9n4GKzHX8WAj95PfjWbfJZLj-hxzhLPCN9pv8M_yYH-zo4-SEsfxSiKiyTlLIoFOgUKLlKa7ch6Blync77Hn0VcbbMU37rGzyLaTZzNvE7/s640/4_Tkinter_Center_Screen_in_Python.jpg&quot; title=&quot;Center Screen Tkinter Window in Python&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;i&gt;&lt;b&gt;&lt;span style=&quot;color: purple;&quot;&gt;Center Screen Window&lt;/span&gt;&lt;/b&gt;&lt;/i&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;These are the process for &lt;b&gt;Set Tkinter Window Position or Center Screen Tkinter in Python&lt;/b&gt; with complete description.&lt;/div&gt;</description><link>https://www.skotechlearn.com/2020/06/tkinter-window-position-size-center-screen-in-python.html</link><author>noreply@blogger.com (SKOTechLearn)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhiFXIxxneoVKV0EfOyrIBmhF0x4t7FNKKZ-9wPTGEU_4Ez-6KzfSD2C1pU4NERtDBSMUMm9uGHRgSaMe2WOW1sra71eCFNarDhsDDMn3_dIMZe4U_ELKv8Ijd55tdavLGnnqnHeYQqeTTn/s72-c/1_Tkinter_Size_in_Python.jpg" height="72" width="72"/><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2258844867892945003.post-7614687537903491436</guid><pubDate>Sat, 06 Jun 2020 07:45:00 +0000</pubDate><atom:updated>2020-08-13T11:36:18.849-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Python</category><title>Features and Use of Label in Python Tkinter Example</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
In &lt;a href=&quot;https://www.python.org/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Python&lt;/a&gt;, when you want to display desired text or desired Image, There are many widgets availabel in python. you can Simply use label for multiple purpose. So, here we learn about how to use &lt;b&gt;Tkinter Label in Python&lt;/b&gt;. But first you should understand about Tkinter.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;What is Tkinter?&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
Tkinter is Python’s Basic Package or you can say it is Basic Graphical User Interface Toolkit, which contains many widgets. And a beginner programmer can start GUI Base application using &lt;b&gt;Tkinter&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
So, Here SKOTechLearn Describe the easy way to use &lt;b&gt;Label in Python using Tkinter&lt;/b&gt; Example. And we describe the use of &lt;b&gt;Label widgets in Python&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;&lt;a href=&quot;https://www.skotechlearn.com/2020/05/if-else-statement-in-python.html&quot; target=&quot;_blank&quot;&gt;Check How if else statement will work in Python?&lt;/a&gt;&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
&lt;br /&gt;
Now, Let’s start the basic Options, we need for &lt;b&gt;Label Settings in Python&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;table valign=&quot;CENTER&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;background: linear-gradient(90deg, rgb(253, 226, 226) 0%, rgb(190, 215, 236) 74%); border-radius: 5px 10px; border: 1pt solid rgb(190, 216, 236); line-height: medium; padding: 2.5pt 5.4pt; width: 150px;&quot;&gt;&lt;span style=&quot;color: #134f5c;&quot;&gt;&lt;b&gt;Options&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;    &lt;td style=&quot;background: linear-gradient(90deg, rgb(253, 226, 226) 0%, rgb(190, 215, 236) 74%); border-radius: 5px 10px; border: 1pt solid rgb(190, 216, 236); line-height: medium; padding: 2.5pt 5.4pt;&quot;&gt;&lt;span style=&quot;color: #134f5c;&quot;&gt;&lt;b&gt;Details and use&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;   &lt;/tr&gt;
&lt;tr&gt;   &lt;td style=&quot;background: linear-gradient(90deg , #ffffe6 0% , rgba(249 , 255 , 255 , 1) 64%); border-radius: 5px 10px; border: solid #bed8ec 1.0pt; font-size: 16px; line-height: normal; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;&lt;b&gt;text&lt;/b&gt;&lt;/td&gt;     &lt;td style=&quot;background: linear-gradient(90deg , #ffffe6 0% , rgba(249 , 255 , 255 , 1) 64%); border-radius: 5px 10px; border: solid #bed8ec 1.0pt; font-size: 16px; line-height: normal; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;&lt;div&gt;
Input desire string or value for display&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/td&gt;  &lt;/tr&gt;
&lt;tr&gt;   &lt;td style=&quot;background: linear-gradient(90deg , #ffffe6 0% , rgba(249 , 255 , 255 , 1) 64%); border-radius: 5px 10px; border: solid #bed8ec 1.0pt; font-size: 16px; line-height: normal; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;&lt;b&gt;anchor&amp;nbsp;&lt;/b&gt;&lt;/td&gt;    &lt;td style=&quot;background: linear-gradient(90deg , rgb(255 , 255 , 230) 0% , rgb(249 , 255 , 255) 64%); border-radius: 5px 10px; border: 1pt solid rgb(190 , 216 , 236); font-size: 16px; line-height: normal; padding: 2.5pt 5.4pt;&quot;&gt;This will align the text in Left, Right, Center. eg.:&lt;br /&gt;
For Left align :&amp;nbsp; anchor=W&lt;br /&gt;
For Right align : anchor=E&lt;br /&gt;
For Center align : anchor=CENTER&lt;br /&gt;
by default Label already set in center align.&lt;br /&gt;
&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr&gt;   &lt;td style=&quot;background: linear-gradient(90deg , #ffffe6 0% , rgba(249 , 255 , 255 , 1) 64%); border-radius: 5px 10px; border: solid #bed8ec 1.0pt; font-size: 16px; line-height: normal; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;&lt;b&gt;bg / background&lt;/b&gt;&lt;/td&gt;    &lt;td style=&quot;background: linear-gradient(90deg , #ffffe6 0% , rgba(249 , 255 , 255 , 1) 64%); border-radius: 5px 10px; border: solid #bed8ec 1.0pt; font-size: 16px; line-height: normal; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;&lt;div&gt;
Label’s background color change option&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/td&gt;  &lt;/tr&gt;
&lt;tr&gt;   &lt;td style=&quot;background: linear-gradient(90deg , #ffffe6 0% , rgba(249 , 255 , 255 , 1) 64%); border-radius: 5px 10px; border: solid #bed8ec 1.0pt; font-size: 16px; line-height: normal; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;&lt;b&gt;fg / foreground&lt;/b&gt;&lt;/td&gt;    &lt;td style=&quot;background: linear-gradient(90deg , #ffffe6 0% , rgba(249 , 255 , 255 , 1) 64%); border-radius: 5px 10px; border: solid #bed8ec 1.0pt; font-size: 16px; line-height: normal; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;&lt;div&gt;
Label’s Text or Font color change option&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/td&gt;  &lt;/tr&gt;
&lt;tr&gt;   &lt;td style=&quot;background: linear-gradient(90deg , #ffffe6 0% , rgba(249 , 255 , 255 , 1) 64%); border-radius: 5px 10px; border: solid #bed8ec 1.0pt; font-size: 16px; line-height: normal; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;&lt;b&gt;relief&amp;nbsp;&lt;/b&gt;&lt;/td&gt;    &lt;td style=&quot;background: linear-gradient(90deg , #ffffe6 0% , rgba(249 , 255 , 255 , 1) 64%); border-radius: 5px 10px; border: solid #bed8ec 1.0pt; font-size: 16px; line-height: normal; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;&lt;div&gt;
Option to set border style (raised, groove, solid, ridge, sunken, flat)&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/td&gt;  &lt;/tr&gt;
&lt;tr&gt;   &lt;td style=&quot;background: linear-gradient(90deg , #ffffe6 0% , rgba(249 , 255 , 255 , 1) 64%); border-radius: 5px 10px; border: solid #bed8ec 1.0pt; font-size: 16px; line-height: normal; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;&lt;b&gt;font&lt;/b&gt;&lt;/td&gt;    &lt;td style=&quot;background: linear-gradient(90deg , rgb(255 , 255 , 230) 0% , rgb(249 , 255 , 255) 64%); border-radius: 5px 10px; border: 1pt solid rgb(190 , 216 , 236); font-size: 17px; line-height: normal; padding: 2.5pt 5.4pt;&quot;&gt;Set the font with font name, size and style. This option syntax is:&lt;br /&gt;
font=(&quot;FontName&quot;, Size, style) eg: font=(&quot;Courier&quot;, 14, &quot;bold&quot;)&lt;br /&gt;
&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr&gt;   &lt;td style=&quot;background: linear-gradient(90deg , #ffffe6 0% , rgba(249 , 255 , 255 , 1) 64%); border-radius: 5px 10px; border: solid #bed8ec 1.0pt; font-size: 16px; line-height: normal; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;&lt;b&gt;image&amp;nbsp;&lt;/b&gt;&lt;/td&gt;    &lt;td style=&quot;background: linear-gradient(90deg , #ffffe6 0% , rgba(249 , 255 , 255 , 1) 64%); border-radius: 5px 10px; border: solid #bed8ec 1.0pt; font-size: 16px; line-height: normal; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;&lt;div&gt;
This option will be use to display image inside Label and Image Control.&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/td&gt;  &lt;/tr&gt;
&lt;tr&gt;   &lt;td style=&quot;background: linear-gradient(90deg , #ffffe6 0% , rgba(249 , 255 , 255 , 1) 64%); border-radius: 5px 10px; border: solid #bed8ec 1.0pt; font-size: 16px; line-height: normal; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;&lt;b&gt;textvariable&amp;nbsp;&lt;/b&gt;&lt;/td&gt;    &lt;td style=&quot;background: linear-gradient(90deg , #ffffe6 0% , rgba(249 , 255 , 255 , 1) 64%); border-radius: 5px 10px; border: solid #bed8ec 1.0pt; font-size: 16px; line-height: normal; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;&lt;div&gt;
This option is used to call predefined string to pass the variable in label to that particular class. This option uses &lt;b&gt;StringVar&lt;/b&gt; for variable control.&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/td&gt;  &lt;/tr&gt;
&lt;tr&gt;   &lt;td style=&quot;background: linear-gradient(90deg , #ffffe6 0% , rgba(249 , 255 , 255 , 1) 64%); border-radius: 5px 10px; border: solid #bed8ec 1.0pt; font-size: 16px; line-height: normal; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;&lt;b&gt;bd / borderwidth&lt;/b&gt;&lt;/td&gt;    &lt;td style=&quot;background: linear-gradient(90deg , #ffffe6 0% , rgba(249 , 255 , 255 , 1) 64%); border-radius: 5px 10px; border: solid #bed8ec 1.0pt; font-size: 16px; line-height: normal; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;&lt;div&gt;
You can set border width from these two option: either bd or borderwidth.&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/td&gt;  &lt;/tr&gt;
&lt;tr&gt;   &lt;td style=&quot;background: linear-gradient(90deg , #ffffe6 0% , rgba(249 , 255 , 255 , 1) 64%); border-radius: 5px 10px; border: solid #bed8ec 1.0pt; font-size: 16px; line-height: normal; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;&lt;b&gt;height&amp;nbsp;&lt;/b&gt;&lt;/td&gt;    &lt;td style=&quot;background: linear-gradient(90deg , #ffffe6 0% , rgba(249 , 255 , 255 , 1) 64%); border-radius: 5px 10px; border: solid #bed8ec 1.0pt; font-size: 16px; line-height: normal; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;&lt;div&gt;
Increasing or decreasing Label’s height will be control by this option by passing value like: height=4&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/td&gt;  &lt;/tr&gt;
&lt;tr&gt;   &lt;td style=&quot;background: linear-gradient(90deg , #ffffe6 0% , rgba(249 , 255 , 255 , 1) 64%); border-radius: 5px 10px; border: solid #bed8ec 1.0pt; font-size: 16px; line-height: normal; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;&lt;b&gt;width&lt;/b&gt;&lt;/td&gt;    &lt;td style=&quot;background: linear-gradient(90deg , #ffffe6 0% , rgba(249 , 255 , 255 , 1) 64%); border-radius: 5px 10px; border: solid #bed8ec 1.0pt; font-size: 17px; line-height: normal; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;&lt;div&gt;
Increasing or decreasing Label’s width will be control by this option by passing value like: width=30&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
Now Lets start to understand how to pass variable in label and some basic label’s setting through above given options:&lt;br /&gt;
&lt;br /&gt;
Here, first you have to import all widgets from Tkinter toolkit.&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;from &lt;/span&gt;Tkinter &lt;span style=&quot;color: blue;&quot;&gt;import &lt;/span&gt;*
&lt;/pre&gt;
&lt;br /&gt;
After that you will proceed:&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt; from &lt;/span&gt;Tkinter &lt;span style=&quot;color: blue;&quot;&gt;import &lt;/span&gt;*
 Myroot = &lt;span style=&quot;color: #351c75;&quot;&gt;Tk&lt;/span&gt;()
 myLbl = &lt;span style=&quot;color: #351c75;&quot;&gt;Label&lt;/span&gt;(Myroot, text=&lt;span style=&quot;color: #b45f06;&quot;&gt;&quot;SKOTechLearn&quot;&lt;/span&gt;, relief=&lt;span style=&quot;color: #b45f06;&quot;&gt;&quot;groove&quot;&lt;/span&gt;, bd=2) 
 myLbl.&lt;span style=&quot;color: #351c75;&quot;&gt;pack&lt;/span&gt;()
 Myroot.title(&lt;span style=&quot;color: #b45f06;&quot;&gt;&quot;Tkinter Label in Python&quot;&lt;/span&gt;)
 Myroot.&lt;span style=&quot;color: #0b5394;&quot;&gt;mainloop&lt;/span&gt;()
&lt;/pre&gt;
&lt;br /&gt;
After executing this code, the following output will be show:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxut4BxUtyscFCEhDsYYztiPtQjCIlMshnR1fXAd_NCh-BNfNDv0td4XcQtj8GHj2S8Pyg-S3OqnwIv99ik28KcHs5XFffM2mj3yiDJYBHFVcUqj3Tsj2r2wcoeb9oI9Sn7RqJQL8URiAP/s1600/1_Label_Example_in_Python.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Tkinter Label in Python&quot; border=&quot;0&quot; data-original-height=&quot;63&quot; data-original-width=&quot;225&quot; height=&quot;89&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxut4BxUtyscFCEhDsYYztiPtQjCIlMshnR1fXAd_NCh-BNfNDv0td4XcQtj8GHj2S8Pyg-S3OqnwIv99ik28KcHs5XFffM2mj3yiDJYBHFVcUqj3Tsj2r2wcoeb9oI9Sn7RqJQL8URiAP/s320/1_Label_Example_in_Python.jpg&quot; title=&quot;Tkinter Label in Python Example&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;u&gt;&lt;br /&gt;
&lt;b&gt;&lt;a href=&quot;https://www.skotechlearn.com/2020/06/tkinter-window-position-size-center-screen-in-python.html&quot; target=&quot;_blank&quot;&gt;Tkinter window position and size setting with center screen process in Python&lt;/a&gt;&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
&lt;br /&gt;
Now, Let’s see the &lt;b&gt;textvariable example in Tkinter Label&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: #edf9d9; border-radius: 10px; border: 2px solid #98BAB2; font-size: 17px; padding: 4px 4px;&quot;&gt;
&lt;b&gt;Font, background or foreground color and border settings of Label&amp;nbsp;&amp;nbsp;in Python:&lt;/b&gt;&lt;/div&gt;
So, following code will cover the point:&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Tkinter Label font style in Python&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Tkinter Label Background Color in Python&lt;/li&gt;
&lt;li&gt;Tkinter Label Foreground Color in Python&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Tkinter Label Border Setting in Python&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt; from &lt;/span&gt;Tkinter &lt;span style=&quot;color: blue;&quot;&gt;import &lt;/span&gt;*
 Myroot = &lt;span style=&quot;color: #351c75;&quot;&gt;Tk&lt;/span&gt;()
 myvar = &lt;span style=&quot;color: #134f5c;&quot;&gt;StringVar&lt;/span&gt;()
 myLbl = &lt;span style=&quot;color: #134f5c;&quot;&gt;Label&lt;/span&gt;( Myroot, textvariable=myvar, relief = &lt;span style=&quot;color: #b45f06;&quot;&gt;&quot;groove&quot;&lt;/span&gt;, font =( &lt;span style=&quot;color: #b45f06;&quot;&gt;&quot;Courier&quot;&lt;/span&gt;, 14, &lt;span style=&quot;color: #b45f06;&quot;&gt;&quot;bold&quot;&lt;/span&gt;),  bd=1, fg = &lt;span style=&quot;color: #b45f06;&quot;&gt;&quot;red&quot;&lt;/span&gt;, bg =&lt;span style=&quot;color: #b45f06;&quot;&gt;&quot;#DDEEF0&quot;&lt;/span&gt; )    
 myvar.set( &lt;span style=&quot;color: #b45f06;&quot;&gt;&quot;SKOTechLearn&quot; &lt;/span&gt;)
 myLbl.&lt;span style=&quot;color: #134f5c;&quot;&gt;pack&lt;/span&gt;()
 Myroot.title( &lt;span style=&quot;color: #b45f06;&quot;&gt;&quot;Label in Python&quot;&lt;/span&gt; )
 Myroot.&lt;span style=&quot;color: #134f5c;&quot;&gt;mainloop&lt;/span&gt;()
&lt;/pre&gt;
&lt;br /&gt;
This will show the following output.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7STkjbaG3cm-TxqvJx3JlQVRp35Hh8AYWx4JAQJnOzG7tWtIhqbqg7ntV8dx6JVfKo8UHthe80wnBfXlck6HiPxSTbuodV1GDuEjHNxoFuhqY7_1EumnUbb9RaosH_mQbow64afoddDFS/s1600/2_Textvariable_Label_Example_in_Python.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Font and color in Label in Python with Tkinter&quot; border=&quot;0&quot; data-original-height=&quot;66&quot; data-original-width=&quot;199&quot; height=&quot;106&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7STkjbaG3cm-TxqvJx3JlQVRp35Hh8AYWx4JAQJnOzG7tWtIhqbqg7ntV8dx6JVfKo8UHthe80wnBfXlck6HiPxSTbuodV1GDuEjHNxoFuhqY7_1EumnUbb9RaosH_mQbow64afoddDFS/s320/2_Textvariable_Label_Example_in_Python.jpg&quot; title=&quot;Font and color in Label in Python with Tkinter&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
And the Last Example will be use to show the multiple line label in Python.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Tkinter Multi-Line Label in Python&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
So, the simple process is to use &lt;b&gt;“\n”&lt;/b&gt; inside text variable like following example.&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt; from &lt;/span&gt;Tkinter &lt;span style=&quot;color: blue;&quot;&gt;import &lt;/span&gt;*
 Myroot = &lt;span style=&quot;color: #351c75;&quot;&gt;Tk&lt;/span&gt;()
 myvar = &lt;span style=&quot;color: #134f5c;&quot;&gt;StringVar&lt;/span&gt;()
 myLbl = &lt;span style=&quot;color: #134f5c;&quot;&gt;Label&lt;/span&gt;( Myroot, textvariable=myvar, relief = &lt;span style=&quot;color: #b45f06;&quot;&gt;&quot;groove&quot;&lt;/span&gt;, font =( &lt;span style=&quot;color: #b45f06;&quot;&gt;&quot;Courier&quot;&lt;/span&gt;, 14, &lt;span style=&quot;color: #b45f06;&quot;&gt;&quot;bold&quot;&lt;/span&gt;),  bd=1, fg = &lt;span style=&quot;color: #b45f06;&quot;&gt;&quot;red&quot;&lt;/span&gt;, bg =&lt;span style=&quot;color: #b45f06;&quot;&gt;&quot;#DDEEF0&quot;&lt;/span&gt; )   
&lt;span style=&quot;color: #cccccc;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #999999;&quot;&gt;# Use &quot;\n&quot; for Next Line in Python by Following Way .&lt;/span&gt;
 myvar.set( &lt;span style=&quot;color: #b45f06;&quot;&gt;&quot;SKO \n Tech \n Learn \n Tips&quot; &lt;/span&gt;)
 myLbl.&lt;span style=&quot;color: #134f5c;&quot;&gt;pack&lt;/span&gt;()
 Myroot.title( &lt;span style=&quot;color: #b45f06;&quot;&gt;&quot;Label in Python&quot;&lt;/span&gt; )
 Myroot.&lt;span style=&quot;color: #134f5c;&quot;&gt;mainloop&lt;/span&gt;()
&lt;/pre&gt;
&lt;br /&gt;
And the final &lt;b&gt;Multiline Label in Python&lt;/b&gt; output will be as:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgv3CqzdrmUaRXbuqGmyq0D-V28J8RdeXNJEtb8rqIZajzMFp0BYDfNrqTrPbZUP4LLfabUfBoL1TOA6-NNGe4s6HjUUW8M7-WbscOeH3gGMpUwWbyjmnZ7FjRCFy5whm65o4P05hE4IAXB/s1600/3_Multiline_Label_Example_in_Python.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Multiline Label in Python using Tkinter&quot; border=&quot;0&quot; data-original-height=&quot;139&quot; data-original-width=&quot;203&quot; height=&quot;217&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgv3CqzdrmUaRXbuqGmyq0D-V28J8RdeXNJEtb8rqIZajzMFp0BYDfNrqTrPbZUP4LLfabUfBoL1TOA6-NNGe4s6HjUUW8M7-WbscOeH3gGMpUwWbyjmnZ7FjRCFy5whm65o4P05hE4IAXB/s320/3_Multiline_Label_Example_in_Python.jpg&quot; title=&quot;Multiline Label in Python&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
So, this is the easy way to understand how to use &lt;b&gt;Tkinter label in Python&lt;/b&gt; with step by step process and descriptions described in SKOTechLearn Tips.&lt;/div&gt;
</description><link>https://www.skotechlearn.com/2020/06/use-label-in-python-using-tkinter.html</link><author>noreply@blogger.com (SKOTechLearn)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxut4BxUtyscFCEhDsYYztiPtQjCIlMshnR1fXAd_NCh-BNfNDv0td4XcQtj8GHj2S8Pyg-S3OqnwIv99ik28KcHs5XFffM2mj3yiDJYBHFVcUqj3Tsj2r2wcoeb9oI9Sn7RqJQL8URiAP/s72-c/1_Label_Example_in_Python.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2258844867892945003.post-5528221307903069007</guid><pubDate>Sat, 30 May 2020 12:14:00 +0000</pubDate><atom:updated>2020-08-04T00:52:20.010-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">VB.Net</category><category domain="http://www.blogger.com/atom/ns#">Work with VB6.0</category><title>Display Date time in Different DateTime Format in Vb6 or VB.net</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;If you want to display date and time or get system Date Time with various format or specific format then there are various type of method available in VB or VB.Net or C# code. In this post SKOTechLearn explain how to Display Date Time in Different &lt;b&gt;DateTime Format in VB&lt;/b&gt;&amp;nbsp;or Vb.Net programming.&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;&lt;a href=&quot;https://www.skotechlearn.com/2019/01/search-files-from-folders-or-directories-through-string-VB-Dot-Net.html&quot; target=&quot;_blank&quot;&gt;Search Files Tips From Folders and Sub-Folders in VB.Net Programming.&lt;/a&gt;&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
&lt;br /&gt;
First, you have to know that, In programming you can use &lt;a href=&quot;https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/format-function-visual-basic-for-applications&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Date Time Formatting&lt;/a&gt; with two way:&lt;br /&gt;
&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li style=&quot;color: #293D57; font-family: Arial; font-size: 15px; line-height: 35px;&quot;&gt;&lt;b&gt;Predefined Format method&lt;/b&gt;&lt;/li&gt;
&lt;li style=&quot;color: #293D57; font-family: Arial; font-size: 15px; line-height: 35px;&quot;&gt;&lt;b&gt;User-defined Format method&lt;/b&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid #b29a94; color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b style=&quot;color: white;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;(1)  Predefined Format Method:&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;Following details and code will describe, how these method will work to show predefined DateTime Format. Let&#39;s follow the following Table:&lt;br /&gt;
&lt;table style=&quot;border: 1px solid;&quot;&gt;&lt;tbody&gt;
&lt;tr style=&quot;background: #F5EBF7; border-radius: 5px 10px; border: solid #bed8ec 1px; font-size: 16px; line-height: medium; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;     &lt;th style=&quot;background: #F5EBF7; border-radius: 5px 10px; border: solid #bed8ec 1px; line-height: medium; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;Predefined Format Method&lt;/th&gt;     &lt;th style=&quot;background: #F5EBF7; border-radius: 5px 10px; border: solid #bed8ec 1px; line-height: normal; padding: 2.5pt 5.4pt 2.5pt 5.4pt; vertical-align: middle;&quot;&gt;Uses &lt;/th&gt;   &lt;/tr&gt;
&lt;tr style=&quot;background: #FFFAF5; border-radius: 5px 10px; border: solid #bed8ec 1px; font-size: 16px; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;     &lt;td style=&quot;border-radius: 5px 10px; border: solid #bed8ec 1px; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;Now&lt;/td&gt;     &lt;td rowspan=&quot;2&quot; style=&quot;border-radius: 5px 10px; border: solid #bed8ec 1px; padding: 2.5pt 5.4pt 2.5pt 5.4pt; text-align: center; vertical-align: middle;&quot;&gt;VB6.0, VB.Net&lt;/td&gt;   &lt;/tr&gt;
&lt;tr&gt;     &lt;td style=&quot;background: #FFFAF5; border-radius: 5px 10px; border: solid #bed8ec 1px; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;Date&lt;/td&gt;   &lt;/tr&gt;
&lt;tr&gt;     &lt;td style=&quot;background: #FFFAF5; border-radius: 5px 10px; border: solid #bed8ec 1px; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;Time&lt;/td&gt;     &lt;td style=&quot;background: #FFFAF5; border-radius: 5px 10px; border: solid #bed8ec 1px; padding: 2.5pt 5.4pt 2.5pt 5.4pt; text-align: center; vertical-align: middle;&quot;&gt;VB6.0&lt;/td&gt;   &lt;/tr&gt;
&lt;tr&gt;     &lt;td style=&quot;background: #FFFAF5; border-radius: 5px 10px; border: solid #bed8ec 1px; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;Format (Now, &quot;Short date&quot;)&lt;/td&gt;     &lt;td rowspan=&quot;5&quot; style=&quot;background: #FFFAF5; border-radius: 5px 10px; border: solid #bed8ec 1px; padding: 2.5pt 5.4pt 2.5pt 5.4pt; text-align: center; vertical-align: middle;&quot;&gt;VB6.0, VB.Net&lt;/td&gt;   &lt;/tr&gt;
&lt;tr&gt;     &lt;td style=&quot;background: #FFFAF5; border-radius: 5px 10px; border: solid #bed8ec 1px; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;Format (Now, &quot;Long Date&quot;)&lt;/td&gt;   &lt;/tr&gt;
&lt;tr&gt;     &lt;td style=&quot;background: #FFFAF5; border-radius: 5px 10px; border: solid #bed8ec 1px; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;Format (Now, &quot;General date&quot;)&lt;/td&gt;   &lt;/tr&gt;
&lt;tr&gt;     &lt;td style=&quot;background: #FFFAF5; border-radius: 5px 10px; border: solid #bed8ec 1px; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;Format (Now, &quot;Short Time&quot;)&lt;/td&gt;   &lt;/tr&gt;
&lt;tr&gt;     &lt;td style=&quot;background: #FFFAF5; border-radius: 5px 10px; border: solid #bed8ec 1px; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;Format (Now, &quot;Long Time&quot;)&lt;/td&gt;   &lt;/tr&gt;
&lt;tr&gt;     &lt;td style=&quot;background: #FFFAF5; border-radius: 5px 10px; border: solid #bed8ec 1px; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;Today&lt;/td&gt;     &lt;td rowspan=&quot;2&quot; style=&quot;background: #FFFAF5; border-radius: 5px 10px; border: solid #bed8ec 1px; padding: 2.5pt 5.4pt 2.5pt 5.4pt; text-align: center; vertical-align: middle;&quot;&gt;VB.Net&lt;/td&gt;   &lt;/tr&gt;
&lt;tr&gt;     &lt;td style=&quot;background: #FFFAF5; border-radius: 5px 10px; border: solid #bed8ec 1px; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;TimeOfDay &lt;/td&gt;   &lt;/tr&gt;
&lt;tr&gt;     &lt;td style=&quot;background: #FFFAF5; border-radius: 5px 10px; border: solid #bed8ec 1px; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;DateTime.Now.ToString()&lt;/td&gt;     &lt;td rowspan=&quot;8&quot; style=&quot;background: #FFFAF5; border-radius: 5px 10px; border: solid #bed8ec 1px; padding: 2.5pt 5.4pt 2.5pt 5.4pt; text-align: center; vertical-align: middle;&quot;&gt;C#, VB.Net&lt;/td&gt;   &lt;/tr&gt;
&lt;tr&gt;     &lt;td style=&quot;background: #FFFAF5; border-radius: 5px 10px; border: solid #bed8ec 1px; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;DateTime.Today.ToString()  &lt;/td&gt;   &lt;/tr&gt;
&lt;tr&gt;     &lt;td style=&quot;background: #FFFAF5; border-radius: 5px 10px; border: solid #bed8ec 1px; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;DateTime.Now.TimeOfDay.ToString()  &lt;/td&gt;   &lt;/tr&gt;
&lt;tr&gt;     &lt;td style=&quot;background: #FFFAF5; border-radius: 5px 10px; border: solid #bed8ec 1px; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;DateTime.Now.ToShortDateString() &lt;/td&gt;   &lt;/tr&gt;
&lt;tr&gt;     &lt;td style=&quot;background: #FFFAF5; border-radius: 5px 10px; border: solid #bed8ec 1px; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;DateTime.Now.ToLongDateString() &lt;/td&gt;   &lt;/tr&gt;
&lt;tr&gt;     &lt;td style=&quot;background: #FFFAF5; border-radius: 5px 10px; border: solid #bed8ec 1px; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;DateTime.Now.ToLocalTime().ToString() &lt;/td&gt;   &lt;/tr&gt;
&lt;tr&gt;     &lt;td style=&quot;background: #FFFAF5; border-radius: 5px 10px; border: solid #bed8ec 1px; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;DateTime.Now.ToShortTimeString()  &lt;/td&gt;   &lt;/tr&gt;
&lt;tr&gt;     &lt;td style=&quot;background: #FFFAF5; border-radius: 5px 10px; border: solid #bed8ec 1px; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;DateTime.Now.ToLongTimeString()  &lt;/td&gt;   &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
So, let&#39;s see the examples which can be use to format predefined type in VB6, VB.Net and C# code:&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;&lt;a href=&quot;https://www.skotechlearn.com/2018/06/menu-design-and-its-related-feature-in-vb6.html&quot; target=&quot;_blank&quot;&gt;Step by Step to Design Menu and Sub-Menu with Settings in VB6.0.&lt;/a&gt;&lt;/b&gt;&amp;nbsp;&lt;/u&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;VB6.0:&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt; Private Sub&lt;/span&gt; MyButton1_Click()
    MyTxtBox1.Text = Now
    MyTxtBox2.Text = Date
    MyTxtBox3.Text = Time

    MyTxtBox4.Text = &lt;span style=&quot;color: blue;&quot;&gt;Format&lt;/span&gt;(Now, &lt;span style=&quot;color: #990000;&quot;&gt;&quot;Short date&quot;&lt;/span&gt;)
    MyTxtBox5.Text = &lt;span style=&quot;color: blue;&quot;&gt;Format&lt;/span&gt;(Now, &lt;span style=&quot;color: #990000;&quot;&gt;&quot;Long Date&quot;&lt;/span&gt;)
    MyTxtBox6.Text = &lt;span style=&quot;color: blue;&quot;&gt;Format&lt;/span&gt;(Now, &lt;span style=&quot;color: #990000;&quot;&gt;&quot;General date&quot;&lt;/span&gt;)
    MyTxtBox7.Text = &lt;span style=&quot;color: blue;&quot;&gt;Format&lt;/span&gt;(Now, &lt;span style=&quot;color: #990000;&quot;&gt;&quot;Short Time&quot;&lt;/span&gt;)
    MyTxtBox8.Text = &lt;span style=&quot;color: blue;&quot;&gt;Format&lt;/span&gt;(Now, &lt;span style=&quot;color: #990000;&quot;&gt;&quot;Long Time&quot;&lt;/span&gt;)
&lt;span style=&quot;color: blue;&quot;&gt; End Sub&lt;/span&gt;&lt;/pre&gt;After Executing application, you will find that the following output will be Shown:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOamJF4MuxIn_7dQH6XNLBR7CDA-9KGmyGv3Mq2KYb_83Xjpqlle1oNbh0lioVhqjDJOJlRM3y3LASD1l1qwd7CFde6S7qJv52PQGhO5cBiL-TMRam-7qAtMq9_nNJ5kVYKg1SlTBPMJTi/s1600/Predefined_DateTime_Format_VB6_web.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Pedefined dateTime Format in Vb6.0&quot; border=&quot;0&quot; data-original-height=&quot;230&quot; data-original-width=&quot;518&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOamJF4MuxIn_7dQH6XNLBR7CDA-9KGmyGv3Mq2KYb_83Xjpqlle1oNbh0lioVhqjDJOJlRM3y3LASD1l1qwd7CFde6S7qJv52PQGhO5cBiL-TMRam-7qAtMq9_nNJ5kVYKg1SlTBPMJTi/s1600/Predefined_DateTime_Format_VB6_web.jpg&quot; title=&quot;Pedefined dateTime Format in Vb6.0&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;b&gt;VB.Net :&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt; Sub&lt;/span&gt; MyDateBtnClick(sender &lt;span style=&quot;color: blue;&quot;&gt;As&lt;/span&gt; Object, &lt;span style=&quot;color: blue;&quot;&gt;As&lt;/span&gt; EventArgs)
     MyText1.&lt;span style=&quot;color: blue;&quot;&gt;Text&lt;/span&gt; = &lt;span style=&quot;color: blue;&quot;&gt;Now&lt;/span&gt;.ToString
     MyText2.&lt;span style=&quot;color: blue;&quot;&gt;Text&lt;/span&gt; = &lt;span style=&quot;color: blue;&quot;&gt;Today&lt;/span&gt;.ToString
     MyText3.&lt;span style=&quot;color: blue;&quot;&gt;Text&lt;/span&gt; = &lt;span style=&quot;color: blue;&quot;&gt;TimeOfDay&lt;/span&gt;.ToString
     MyText4.&lt;span style=&quot;color: blue;&quot;&gt;Text&lt;/span&gt; = &lt;span style=&quot;color: blue;&quot;&gt;Format&lt;/span&gt;(Now, &lt;span style=&quot;color: #990000;&quot;&gt;&quot;Short date&quot;&lt;/span&gt;)
     MyText5.&lt;span style=&quot;color: blue;&quot;&gt;Text&lt;/span&gt; = &lt;span style=&quot;color: blue;&quot;&gt;Format&lt;/span&gt;(Now, &lt;span style=&quot;color: #990000;&quot;&gt;&quot;Long Date&quot;&lt;/span&gt;)
     MyText6.&lt;span style=&quot;color: blue;&quot;&gt;Text&lt;/span&gt; = &lt;span style=&quot;color: blue;&quot;&gt;Format&lt;/span&gt;(Now, &lt;span style=&quot;color: #990000;&quot;&gt;&quot;General date&quot;&lt;/span&gt;)
     MyText7.&lt;span style=&quot;color: blue;&quot;&gt;Text&lt;/span&gt; = &lt;span style=&quot;color: blue;&quot;&gt;Format&lt;/span&gt;(Now, &lt;span style=&quot;color: #990000;&quot;&gt;&quot;Short Time&quot;&lt;/span&gt;)
     MyText8.&lt;span style=&quot;color: blue;&quot;&gt;Text&lt;/span&gt; = &lt;span style=&quot;color: blue;&quot;&gt;Format&lt;/span&gt;(Now, &lt;span style=&quot;color: #990000;&quot;&gt;&quot;Long Time&quot;&lt;/span&gt;)
 &lt;span style=&quot;color: blue;&quot;&gt;End Sub&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;This will show the following output:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYQlI5TJFOb7QqttHqKq4-RfX3p8wWrV_XnOoJMZxWJk2RauBHVOnBKaqm508STLf-zM20sIHA_NlNjo2ykaNPtCWHLU83a_muQ9TaNS-DVZzRDbgjPzupOvfUav-3dKzwk9HjQcx81djF/s1600/Predefined_DateTime_Format_VB.Net_web.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;predefined datetime format in VB.Net code&quot; border=&quot;0&quot; data-original-height=&quot;192&quot; data-original-width=&quot;503&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYQlI5TJFOb7QqttHqKq4-RfX3p8wWrV_XnOoJMZxWJk2RauBHVOnBKaqm508STLf-zM20sIHA_NlNjo2ykaNPtCWHLU83a_muQ9TaNS-DVZzRDbgjPzupOvfUav-3dKzwk9HjQcx81djF/s1600/Predefined_DateTime_Format_VB.Net_web.jpg&quot; title=&quot;predefined datetime format in VB.Net&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;b&gt;PreDefined DateTime Format in C#&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;C# :&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: #b45f06;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;MyDateBtnClick&lt;/span&gt;(&lt;span style=&quot;color: #b45f06;&quot;&gt;object&lt;/span&gt; sender, &lt;span style=&quot;color: #b45f06;&quot;&gt;EventArgs&lt;/span&gt; e)
  &lt;span style=&quot;color: blue;&quot;&gt;{&lt;/span&gt;
     MyCTxt1.Text = DateTime.Now.&lt;span style=&quot;color: blue;&quot;&gt;ToString()&lt;/span&gt;;
     MyCTxt2.Text = DateTime.Today.&lt;span style=&quot;color: blue;&quot;&gt;ToString()&lt;/span&gt;;
     MyCTxt3.Text = DateTime.Now.TimeOfDay.&lt;span style=&quot;color: blue;&quot;&gt;ToString()&lt;/span&gt;;
     MyCTxt4.Text = DateTime.Now.&lt;span style=&quot;color: blue;&quot;&gt;ToShortDateString()&lt;/span&gt;;
     MyCTxt5.Text = DateTime.Now.&lt;span style=&quot;color: blue;&quot;&gt;ToLongDateString()&lt;/span&gt;;
     MyCTxt6.Text = DateTime.Now.&lt;span style=&quot;color: blue;&quot;&gt;ToLocalTime().ToString()&lt;/span&gt;; 
     MyCTxt7.Text = DateTime.Now.&lt;span style=&quot;color: blue;&quot;&gt;ToShortTimeString()&lt;/span&gt;;
     MyCTxt8.Text = DateTime.Now.&lt;span style=&quot;color: blue;&quot;&gt;ToLongTimeString()&lt;/span&gt;;                  
   &lt;span style=&quot;color: blue;&quot;&gt;}&lt;/span&gt; &lt;/pre&gt;&lt;br /&gt;
After compiling this code, you will find the following output, when you click on Button.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdtSRkFOVdIOqLwOBaMeZAVnHzKUW5RfzaFadTHdCx5KC9wPt2vS_7FDgnhgRyvjK3djgy7tbN7Hl-EY5Q_PXWdd-I_Lq3SWU6Q_BIcgzbdD0lLgzkHKnohuRmg_vAcf7u29DUCi1Hwm1_/s1600/Predefined_DateTime_Format_CSharp_web.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Predefined DateTime Format in CSharp&quot; border=&quot;0&quot; data-original-height=&quot;277&quot; data-original-width=&quot;321&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdtSRkFOVdIOqLwOBaMeZAVnHzKUW5RfzaFadTHdCx5KC9wPt2vS_7FDgnhgRyvjK3djgy7tbN7Hl-EY5Q_PXWdd-I_Lq3SWU6Q_BIcgzbdD0lLgzkHKnohuRmg_vAcf7u29DUCi1Hwm1_/s1600/Predefined_DateTime_Format_CSharp_web.jpg&quot; title=&quot;Predefined DateTime Format in C# &quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
So these are the predefined method in VB6, VB.Net and C#. Now Let&#39;s Find Custom method or User-Defined Method for Display Date and Time.&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;&lt;a href=&quot;https://www.skotechlearn.com/2018/04/login-form-with-adodc-connection-to-MS-Access.html&quot; target=&quot;_blank&quot;&gt;How to Create Login Form with Database Connection in Vb6.0?&lt;/a&gt;&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #165270; border-radius: 6px; border: 2px solid #b29a94; color: white; font-size: 16px; line-height: 25px; padding: 2px 4px;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;b&gt;(2)&amp;nbsp; User-defined Format method :&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;The following table describe the method of User-defined DateTime Format in VB6.0, VB.Net and C# code.&lt;br /&gt;
&lt;table &gt;&lt;tbody&gt;
&lt;tr style=&quot;border-radius: 5px 10px;&quot;&gt;   &lt;td style=&quot;background: #E3F0D6; border-radius: 5px 10px; border: 1pt solid rgb(190, 216, 236); line-height: normal; padding: 2.5pt 5.4pt;&quot;&gt;&lt;span style=&quot;color: #134f5c;&quot;&gt;&lt;b&gt;User Defined Format Method&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;    &lt;td style=&quot;background: #E3F0D6; border-radius: 5px 10px; border: 1pt solid rgb(190, 216, 236); line-height: normal; padding: 2.5pt 5.4pt;&quot;&gt;&lt;span style=&quot;color: #134f5c;&quot;&gt;&lt;b&gt;Use&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;   &lt;/tr&gt;
&lt;tr style=&quot;border-radius: 5px 10px;&quot;&gt;   &lt;td style=&quot;background: #FFFBD7; border-radius: 5px 10px; border: solid #bed8ec 1.0pt; font-size: 15px; line-height: normal; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;Format ( now, “Your Formatted String” )&amp;nbsp;&amp;nbsp;&lt;/td&gt;     &lt;td style=&quot;background: #FFFBD7; border-radius: 5px 10px; border: solid #bed8ec 1.0pt; font-size: 15px; line-height: normal; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;&lt;div&gt;VB6.0, VB.Net&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr&gt;   &lt;td style=&quot;background: #FFFBD7; border-radius: 5px 10px; border: solid #bed8ec 1.0pt; font-size: 15px; line-height: normal; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;Now.Today.ToString ( “Your Formated String” )&amp;nbsp;&lt;/td&gt;    &lt;td style=&quot;background: #FFFBD7; border-radius: 5px 10px; border: solid #bed8ec 1.0pt; font-size: 15px; line-height: normal; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;&lt;div&gt;VB.Net&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr&gt;   &lt;td style=&quot;background: #FFFBD7; border-radius: 5px 10px; border: solid #bed8ec 1.0pt; font-size: 15px; line-height: normal; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;DateTime.Now.ToString ( “Your Formated String” )&amp;nbsp;&amp;nbsp;&lt;/td&gt;    &lt;td style=&quot;background: #FFFBD7; border-radius: 5px 10px; border: solid #bed8ec 1.0pt; font-size: 15px; line-height: normal; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;&lt;div&gt;C#, VB.Net&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr&gt;   &lt;td style=&quot;background: #FFFBD7; border-radius: 5px 10px; border: solid #bed8ec 1.0pt; font-size: 15px; line-height: normal; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;DateAndTime.Now.ToString ( “Your Formated String” )&amp;nbsp;&lt;/td&gt;    &lt;td style=&quot;background: #FFFBD7; border-radius: 5px 10px; border: solid #bed8ec 1.0pt; font-size: 15px; line-height: normal; padding: 2.5pt 5.4pt 2.5pt 5.4pt;&quot;&gt;&lt;div&gt;VB.Net&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
Why user defined format method is required? The answer is, in some case or sometime we required specific date time output on their application. So, the user defined format method is used.&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;&lt;a href=&quot;https://www.skotechlearn.com/2020/05/sql-server-connection-string-and-sql-query-vb.net.html&quot; target=&quot;_blank&quot;&gt;SQL Server Connection String with Example and SQL Query Process in VB.Net.&lt;/a&gt;&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
&lt;br /&gt;
Now, follow the following method for User Defined format process.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;VB6.0 :&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;Private Sub &lt;/span&gt;UsrDtBtn_Click()
    UsrTxtBox1.Text = &lt;span style=&quot;color: blue;&quot;&gt;Format&lt;/span&gt;(Now, &lt;span style=&quot;color: #990000;&quot;&gt;&quot;dd&quot;&lt;/span&gt;)
    UsrTxtBox2.Text = &lt;span style=&quot;color: blue;&quot;&gt;Format&lt;/span&gt;(Now, &lt;span style=&quot;color: #990000;&quot;&gt;&quot;dddd&quot;&lt;/span&gt;)
    UsrTxtBox3.Text = &lt;span style=&quot;color: blue;&quot;&gt;Format&lt;/span&gt;(Now, &lt;span style=&quot;color: #990000;&quot;&gt;&quot;MM&quot;&lt;/span&gt;)
    UsrTxtBox4.Text = &lt;span style=&quot;color: blue;&quot;&gt;Format&lt;/span&gt;(Now, &lt;span style=&quot;color: #990000;&quot;&gt;&quot;MMMM&quot;&lt;/span&gt;)
    UsrTxtBox5.Text = &lt;span style=&quot;color: blue;&quot;&gt;Format&lt;/span&gt;(Now, &lt;span style=&quot;color: #990000;&quot;&gt;&quot;yyyy&quot;&lt;/span&gt;)
    UsrTxtBox6.Text = &lt;span style=&quot;color: blue;&quot;&gt;Format&lt;/span&gt;(Now, &lt;span style=&quot;color: #990000;&quot;&gt;&quot;dd/MM/yyyy&quot;&lt;/span&gt; )
    UsrTxtBox7.Text = &lt;span style=&quot;color: blue;&quot;&gt;Format&lt;/span&gt;(Now, &lt;span style=&quot;color: #990000;&quot;&gt;&quot;dd-MM-yyyy&quot;&lt;/span&gt; )
    UsrTxtBox8.Text = &lt;span style=&quot;color: blue;&quot;&gt;Format&lt;/span&gt;(Now, &lt;span style=&quot;color: #990000;&quot;&gt;&quot;MM/dd/yyyy hh:mm:ss AMPM&quot;&lt;/span&gt;&lt;span style=&quot;color: #b45f06;&quot;&gt; &lt;/span&gt;)
    UsrTxtBox9.Text = &lt;span style=&quot;color: blue;&quot;&gt;Format&lt;/span&gt;(Now, &lt;span style=&quot;color: #990000;&quot;&gt;&quot;hh:mm:ss AMPM&quot;&lt;/span&gt;&lt;span style=&quot;color: #b45f06;&quot;&gt; &lt;/span&gt;)
    UsrTxtBox10.Text = &lt;span style=&quot;color: blue;&quot;&gt;Format&lt;/span&gt;(Now, &lt;span style=&quot;color: #990000;&quot;&gt;&quot;hh:mm:ss&quot;&lt;/span&gt;&lt;span style=&quot;color: #b45f06;&quot;&gt; &lt;/span&gt;)
 &lt;span style=&quot;color: blue;&quot;&gt;End Sub&lt;/span&gt;
&lt;/pre&gt;When you run VB Form, The following image output will be show.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO8sFixPy67NjGzKugnALVVRalQ_xlHrypLnZmsYgoX4JxZNSd1xR3fONLY27v0_zvunZE2n0EjAczfQJ0tO3Im_qWzY6CN9jk4P-ufwXDwlATwDNi-REOWHM8mOn-42bu1oFkyTBxGn_g/s1600/User_defined_DateTime_Format_VB6_web.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;User-Defined DateTime Format in VB6.0&quot; border=&quot;0&quot; data-original-height=&quot;323&quot; data-original-width=&quot;335&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO8sFixPy67NjGzKugnALVVRalQ_xlHrypLnZmsYgoX4JxZNSd1xR3fONLY27v0_zvunZE2n0EjAczfQJ0tO3Im_qWzY6CN9jk4P-ufwXDwlATwDNi-REOWHM8mOn-42bu1oFkyTBxGn_g/s1600/User_defined_DateTime_Format_VB6_web.jpg&quot; title=&quot;User-Defined DateTime Format in VB6.0&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;b&gt;VB.Net :&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;Sub &lt;/span&gt;UsrDTBtnClick(sender &lt;span style=&quot;color: blue;&quot;&gt;As &lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;Object&lt;/span&gt;, e &lt;span style=&quot;color: blue;&quot;&gt;As &lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;EventArgs&lt;/span&gt;)
    
    UsrTxt1.Text = &lt;span style=&quot;color: blue;&quot;&gt;Now&lt;/span&gt;.ToString(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;dd/MM/yyyy&quot;&lt;/span&gt;)
    UsrTxt2.Text = &lt;span style=&quot;color: blue;&quot;&gt;Now&lt;/span&gt;.ToString(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;MM/dd/yyyy hh:mm:ss tt&quot;&lt;/span&gt;)
    UsrTxt3.Text = &lt;span style=&quot;color: blue;&quot;&gt;DateAndTime&lt;/span&gt;.Now.ToString(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;dddd&quot;&lt;/span&gt;)
    UsrTxt4.Text = &lt;span style=&quot;color: blue;&quot;&gt;DateAndTime&lt;/span&gt;.Now.ToString(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;MMMM&quot;&lt;/span&gt;)
    UsrTxt5.Text = &lt;span style=&quot;color: blue;&quot;&gt;DateTime&lt;/span&gt;.Now.ToString(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;hh:mm:ss tt&quot;&lt;/span&gt;)
    UsrTxt6.Text = &lt;span style=&quot;color: blue;&quot;&gt;DateTime&lt;/span&gt;.Now.ToString(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;dddd; dd-MMMM-yyyy&quot;&lt;/span&gt;)
    UsrTxt7.Text = &lt;span style=&quot;color: blue;&quot;&gt;Format&lt;/span&gt;(Now, &lt;span style=&quot;color: #990000;&quot;&gt;&quot;dd-MM-yyyy&quot;&lt;/span&gt;)
    UsrTxt8.Text = &lt;span style=&quot;color: blue;&quot;&gt;Format&lt;/span&gt;(Now, &lt;span style=&quot;color: #990000;&quot;&gt;&quot;MMMM, yyyy&quot;&lt;/span&gt;)
        
 &lt;span style=&quot;color: blue;&quot;&gt;End Sub&lt;/span&gt;
&lt;/pre&gt;Ok, Let&#39;s see the output:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUtzdxxXfmFR0VTiscs8smSICoDqmz9ETfpsBqlRRRxym0OUc3zOwmN-98I5xGc4lztZswasczkm2hRSxZ41DNNoFXh2do99VzVSs_QAI-fvY4wRyx3fP8jifWgdi4-QMYfKxRYy4H8Hya/s1600/User_defined_DateTime_Format_VB_Net_web.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;User-Defined DateTime Format in VB.Net&quot; border=&quot;0&quot; data-original-height=&quot;270&quot; data-original-width=&quot;359&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUtzdxxXfmFR0VTiscs8smSICoDqmz9ETfpsBqlRRRxym0OUc3zOwmN-98I5xGc4lztZswasczkm2hRSxZ41DNNoFXh2do99VzVSs_QAI-fvY4wRyx3fP8jifWgdi4-QMYfKxRYy4H8Hya/s1600/User_defined_DateTime_Format_VB_Net_web.jpg&quot; title=&quot;User-Defined DateTime Format in VB.Net&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;b&gt;C# :&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #fcfbfb; border-radius: 5px; border: 1px solid rgb(218, 218, 218); box-shadow: rgb(247, 210, 179) 0px 0px 10px; font-family: verdana, sans-serif; font-size: 13px; line-height: 22px; overflow-wrap: break-word; overflow: scroll; padding: 10px 6px;&quot;&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;void &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;UserDtBtnClick&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;object &lt;/span&gt;sender, &lt;span style=&quot;color: #990000;&quot;&gt;EventArgs &lt;/span&gt;e)
 {
     &lt;span style=&quot;color: blue;&quot;&gt;DateTime &lt;/span&gt;UsrDt;
     UsrDt = &lt;span style=&quot;color: blue;&quot;&gt;DateTime&lt;/span&gt;.Now;
     MyText1.Text = UsrDt.&lt;span style=&quot;color: blue;&quot;&gt;ToString&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;dd/MM/yyyy&quot;&lt;/span&gt;);
     MyText2.Text = UsrDt.&lt;span style=&quot;color: blue;&quot;&gt;ToString&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;MM/dd/yyyy hh:mm:ss tt&quot;&lt;/span&gt;);
     MyText3.Text = UsrDt.&lt;span style=&quot;color: blue;&quot;&gt;ToString&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;dddd&quot;&lt;/span&gt;);
     MyText4.Text = UsrDt.&lt;span style=&quot;color: blue;&quot;&gt;ToString&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;MMMM&quot;&lt;/span&gt;);
     MyText5.Text = UsrDt.&lt;span style=&quot;color: blue;&quot;&gt;ToString&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;hh:mm:ss tt&quot;&lt;/span&gt;);
     MyText6.Text = UsrDt.&lt;span style=&quot;color: blue;&quot;&gt;ToString&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;dddd; dd-MMMM-yyyy&quot;&lt;/span&gt;);
     MyText7.Text = UsrDt.&lt;span style=&quot;color: blue;&quot;&gt;ToString&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;MMMM, dd-yyyy&quot;&lt;/span&gt;);
     MyText8.Text = UsrDt.&lt;span style=&quot;color: blue;&quot;&gt;ToString&lt;/span&gt;(&lt;span style=&quot;color: #990000;&quot;&gt;&quot;dd-MMMM-yy&quot;&lt;/span&gt;);
                    
  }
&lt;/pre&gt;After that we get following output:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNJgggA0kS51txGHaAE_4HdRLbKxubGQK6y_NVXsRicxVLxcIbzPrRYG4TsW3yPsO2Kq4Q0m7lVbr0vmuCe53ljN-7tH7cAcIgNStIs6yCCHIUbL-OCHCzdnz-TQnrMHS2n0wrjUvMILhy/s1600/User_defined_DateTime_Format_CSharp_web.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;User-Defined DateTime Format in CSharp&quot; border=&quot;0&quot; data-original-height=&quot;284&quot; data-original-width=&quot;388&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNJgggA0kS51txGHaAE_4HdRLbKxubGQK6y_NVXsRicxVLxcIbzPrRYG4TsW3yPsO2Kq4Q0m7lVbr0vmuCe53ljN-7tH7cAcIgNStIs6yCCHIUbL-OCHCzdnz-TQnrMHS2n0wrjUvMILhy/s1600/User_defined_DateTime_Format_CSharp_web.jpg&quot; title=&quot;User-Defined DateTime Format in C#&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Now, these are the process to use to Display Date Time in Different DateTime Format in VB6.0 or VB.Net and C# with SKOTechLearn Tips.&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;&lt;a href=&quot;https://www.skotechlearn.com/2019/02/change-progressbar-color-style-use-in-vb.html&quot; target=&quot;_blank&quot;&gt;Styling ProgressBar with Color Change and Settings in Vb6.0 or VB.Net.&lt;/a&gt;&lt;/b&gt;&lt;/u&gt;&lt;/div&gt;</description><link>https://www.skotechlearn.com/2020/05/display-datetime-format-in-vb6-vb.net.html</link><author>noreply@blogger.com (SKOTechLearn)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOamJF4MuxIn_7dQH6XNLBR7CDA-9KGmyGv3Mq2KYb_83Xjpqlle1oNbh0lioVhqjDJOJlRM3y3LASD1l1qwd7CFde6S7qJv52PQGhO5cBiL-TMRam-7qAtMq9_nNJ5kVYKg1SlTBPMJTi/s72-c/Predefined_DateTime_Format_VB6_web.jpg" height="72" width="72"/><thr:total>0</thr:total></item></channel></rss>