Is there a way of using lower more effectively in tkinter

0 votes
When asking the user for an input I would like it to be set to .lower() like in python when you do start=start.lower() for example. Is there any way I can do this in tkinter without putting Command_Line.get().lower every time due to my code having a code of inputs and me wanting to be efficient?
Sep 25, 2018 in Python by bug_seeker
• 15,510 points
2,346 views

1 answer to this question.

0 votes

Here is a simple function and some example code that will modify the value of a string var to lower case. Just pass the stringvar to the function.

from tkinter import *

root = Tk()
#No need for the following line in your code
root.withdraw()


def lowerStringVar(var):
    """Function to convert the text in a StringVar to lower case"""
    if isinstance(var, StringVar):
        var.set(var.get().lower())

myTextVar = StringVar()
myTextVar.set("ALL UPPER CASE")
print(myTextVar.get())

lowerStringVar(myTextVar)

print(myTextVar.get())
answered Sep 25, 2018 by Priyaj
• 58,020 points

Related Questions In Python

0 votes
1 answer

Is there a way to list out in-built variables and functions of Python?

The in-built variables and functions are defined ...READ MORE

answered May 14, 2019 in Python by Junaid
2,221 views
0 votes
1 answer

Is there a way to store this text in a list using selenium (python)

Try using this code snippet to resolve ...READ MORE

answered Aug 24, 2020 in Python by Carlos
1,566 views
0 votes
1 answer

Is there a foreach function in python and is there a way to implement it if there isnt any

Every occurence of "foreach" I've seen (PHP, ...READ MORE

answered Aug 31, 2018 in Python by charlie_brown
• 7,720 points
1,153 views
0 votes
1 answer

What is the recommended way to randomize a list of strings using Python?

Hi. Nice question. Here is the simplified answer ...READ MORE

answered Jan 18, 2019 in Python by Nymeria
• 3,560 points
934 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,434 views
0 votes
1 answer
0 votes
1 answer

Is there a label/goto in Python?

No, Python does not support labels and ...READ MORE

answered Aug 1, 2018 in Python by Priyaj
• 58,020 points
862 views
0 votes
1 answer

What is the meaning of “int(a[::-1])” in Python?

Assumming a is a string. The Slice ...READ MORE

answered Aug 27, 2018 in Python by Priyaj
• 58,020 points
6,471 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP