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,350 points
140 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
• 56,540 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 in Python by Junaid
36 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
79 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 in Python by Nymeria
• 3,520 points
49 views
0 votes
0 answers

is there a way to run android using python?

can you give a few sample projects ...READ MORE

Apr 22 in Python by Waseem
• 4,480 points
28 views
+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 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 238 views
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
• 56,540 points
117 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
• 56,540 points
70 views