First attempt.
Here you can see how the font changes size and The text widget changes size. I need the text widget to keep its size. I tried to create a text widget in a frame and make frm.grid_propagate (False)
. the result you see in the second attempt.
In the second attempt, the widget could now only decrease, it could not increase. But when the font size is large the text is printed outside the text widget border and it is not visible
from tkinter import*
import tkinter as tk
def fontUp():
global count
if text.tag_ranges('sel'):
text.tag_add('colortag_' + str(count), SEL_FIRST,SEL_LAST)
text.tag_configure('colortag_' + str(count),font='Area 35')
count+=1
else:
text.configure(font='Area 30')
count=0
root = tk.Tk()
root.geometry("800x800")
frm = tk.Frame(root, height = 300, width = 500)
frm.grid(row = 0, column = 0)
frm.grid_propagate(False)
text = tk.Text(frm, height = 20, width = 50)
text.grid(row = 0, column = 0)
btn = tk.Button(root, text="Font bigger", command = fontUp)
btn.grid(row = 2, column = 0)
This code has the same error as my second attempt.
When we clicked on button size text increases and the widget also increases. But I have a 'fontUp' function that only increases the selected text.the function works like this: first select the text then click on the button and the text increases but the widget does not increase is what I need. How to make that the text changes its size, and the widget does not change its size