in Education by
So, I am creating an application which displays song lyrics for entered songs, however, longer songs do not fit, so I want to shrink the size of the text if it is a longer song. I am unsure about how to go about this, so any help would be greatly appreciated. I have tried using a conditional, however, it did not seem to work. file = open(artist + song + ".txt", "r") lyrics = file.read() lines = file.readlines() lyricsLabel = tk.Label(root, text = lyrics) lyricsLabel.config(font = ("TkDefaultFont", 5)) lyricsLabel.grid(column = 0, row = 0) if playSong == True: os.startfile(artist + song + ".mp3") JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
you could measure the length of the text file by using len() , then break to elif statements that modify the font size. e.g. text = len(song) if text < 20: font_size = 20 elif text > 20 and < 40: font_size = 15 etc... then song = Lable(root, text= song) song.config(font = ("TkDefaultFont", font_size))

Related questions

0 votes
    I want to draw arrows (that change size dynamically) within a Label or any other widget. I have ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 25, 2022 in Education by JackTerrance
0 votes
    I need to find a way to clear the Listbox for the refresh function which I am making. The function should ... clearing the Listbox) Select the correct answer from above options...
asked Jan 18, 2022 in Education by JackTerrance
0 votes
    This is my code that displays output that I would like to alter: import json from collections import OrderedDict ... find anything. Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    I have the list of sets like so. I basically want to convert this to the dictionary and to address duplicate keys, ... ] = val return d Select the correct answer from above options...
asked Jan 9, 2022 in Education by JackTerrance
0 votes
    Is it possible to terminate a running thread without setting/checking any flags/semaphores/etc.? Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
0 votes
    I have a dataframe with 2 columns and I want to add the new column; This new column should be updated based on ... +=1 is not working. Select the correct answer from above options...
asked Jan 11, 2022 in Education by JackTerrance
0 votes
    I wrote the following code to quickly grab and display information from Wikipedia. It works great unless the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 13, 2022 in Education by JackTerrance
0 votes
    I have tried weight options and such for my frame but nothing seemed to work. I have the following ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Dec 31, 2021 in Education by JackTerrance
0 votes
    I'm trying to make the text move continuously by pressing a button but right now it only moves an ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 1, 2022 in Education by JackTerrance
0 votes
    I'm working on a mini text role playing game where you must survive dinner with the king. I'm ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 8, 2022 in Education by JackTerrance
0 votes
    I'm using Python to open a text document: text_file = open("Output.txt", "w") text_file.write("Purchase Amount: ... how to do this? Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    I have a 20 x 4000 dataframe in python using pandas. Two of these columns are named Year and quarter. I'd ... anyone help with that? Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
0 votes
    I am trying to write my below pinging script results into the Text file, but I am getting an error message. ... object is not iterable Select the correct answer from above options...
asked Jan 11, 2022 in Education by JackTerrance
0 votes
    I am training on 970 samples and validating on 243 samples. How big should batch size and number of epochs be ... on data input size? Select the correct answer from above options...
asked Feb 1, 2022 in Education by JackTerrance
0 votes
    I am writing a Python script in Windows. I want to do something based on the file size. For example, if the ... I check the file size? Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
...