Replies: 9 comments 11 replies
-
Use txt_info.configure(font=("Arial", 12)) |
Beta Was this translation helpful? Give feedback.
-
Thanks! Now, it seems to me that this configure the whole widget (every text in it). What I was looking for is how to configure (differently) each line of the text, as tk.Text allows to doLautaro Barrera BOn Nov 16, 2023, at 4:01 AM, Synctic ***@***.***> wrote:
Use txt_info.configure(font=("Arial", 12))
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Correct!For example underline and center one specific line, make another using a different font etc. even change the style for a couple of words inside a line, just as tk.Text allowsLautaro Barrera BOn Nov 16, 2023, at 8:53 AM, Synctic ***@***.***> wrote:
So you mean changing the font of specific words? or how to make some bold?
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
By the way, and probably this is not the proper way to ask this, but I’m having troubles using ctk in MacOS (segmentation errors). I don’t think this is directly related to ctk but to Tkinter in general. Do you know a good source of information to troubleshoot this issue? Lautaro Barrera BOn Nov 16, 2023, at 8:53 AM, Synctic ***@***.***> wrote:
So you mean changing the font of specific words? or how to make some bold?
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Did it work? |
Beta Was this translation helpful? Give feedback.
-
Thanks!
Perhaps I missed something here: “I just tested and yes there is a tag_add also tag_config in a CTkTextbox”
This is the test I did:
self.txt_Usageinfo = ctk.CTkTextbox(self.frame_content0, wrap=tk.WORD, width=540, height=15)
self.txt_Usageinfo.grid(row = 6, column = 0, columnspan=3, padx = (50,10), pady=(5,10)) #, sticky = 'w'
lin1 = "Important Usage Information"
self.txt_Usageinfo.tag_add("lin1","1.0", "1.end")
self.txt_Usageinfo.tag_configure("lin1", font=("Arial", 16, "bold"))
lin2 = "Second line of this test about usage info"
self.txt_Usageinfo.tag_add("lin2","3.0", "3.end")
self.txt_Usageinfo.tag_configure("lin2", font=("Arial", 12, "Italic"))
self.txt_Usageinfo.insert("end", lin1+"\n")
self.txt_Usageinfo.insert("end", lin2+"\n")
AttributeError: 'CTkTextbox' object has no attribute 'tag_configure'. Did you mean: '_configure'?
I know that tk.Text allows to use different fonts and styles in the text placed, but the ctk manual was silent and while researching on the internet, I came across with a post that says that only can be done at the global level (meaning one style for the whole text). I’m not saying that this is necessarily correct, but as the manual is silent on how to do it, I assumed so.
The reason for not using tk.Text is (obviously) it dated appearance… As Opposed CTK widgets looks modern and neat. A big difference!!
Thanks!
From: Synctic ***@***.***>
Sent: Thursday, November 16, 2023 9:36 AM
To: TomSchimansky/CustomTkinter ***@***.***>
Cc: Lautarob1 ***@***.***>; Author ***@***.***>
Subject: Re: [TomSchimansky/CustomTkinter] Underline, italic, bold, font type and size properties using Textbox (Discussion #2074)
I just tested and yes there is a tag_add also tag_config in a CTkTextbox so try that also try this way in the link and let me know if it works or not: https://stackoverflow.com/questions/52679038/can-i-set-different-fonts-for-different-lines-in-a-tkinter-text-widget
—
Reply to this email directly, view it on GitHub <#2074 (reply in thread)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AKVDBP26PLEF4X4NBX6MKU3YEYQGZAVCNFSM6AAAAAA7NZF4ZGVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM3TKOBYHE3TO> .
You are receiving this because you authored the thread. <https://github.com/notifications/beacon/AKVDBP2QJRT3ZHP3CXSCZN3YEYQGZA5CNFSM6AAAAAA7NZF4ZGWGG33NNVSW45C7OR4XAZNRIRUXGY3VONZWS33OINXW23LFNZ2KUY3PNVWWK3TUL5UWJTQAOPGHC.gif> Message ID: ***@***.*** ***@***.***> >
|
Beta Was this translation helpful? Give feedback.
-
Sorry, still doesn’t work:
This is the code:
self.txt_Usageinfo = ctk.CTkTextbox(self.frame_content0, wrap=tk.WORD, width=550, height=50)
self.txt_Usageinfo.grid(row = 6, column = 0, columnspan=3, padx = (50,10), pady=(5,10)) #, sticky = 'w'
lin1 = "Important Usage Information"
self.txt_Usageinfo.tag_add("lin1","1.0", "1.end")
self.txt_Usageinfo.tag_config("lin1", font=("Arial", 16, "bold"))
lin2 = "Second line of this test about usage info"
self.txt_Usageinfo.tag_add("lin2","3.0", "3.end")
self.txt_Usageinfo.tag_config("lin2", font=("Arial", 12, "Italic"))
self.txt_Usageinfo.insert("end", lin1+"\n")
self.txt_Usageinfo.insert("end", lin2+"\n")
And this is the error:
raise AttributeError("'font' option forbidden, because would be incompatible with scaling")
AttributeError: 'font' option forbidden, because would be incompatible with scaling
If you have test it, please copy the code snip so I can see where is the error in my code…
Thanks a lot!
From: Synctic ***@***.***>
Sent: Friday, November 17, 2023 9:08 AM
To: TomSchimansky/CustomTkinter ***@***.***>
Cc: Lautarob1 ***@***.***>; Author ***@***.***>
Subject: Re: [TomSchimansky/CustomTkinter] Underline, italic, bold, font type and size properties using Textbox (Discussion #2074)
Yeah I know instead of using tag_configure used tag_config this works the stackoverflow solution I sent uses tkinter I just told you to do the same thing since its pretty much the same but using ctk other than that some syntax changes so use ctk
—
Reply to this email directly, view it on GitHub <#2074 (reply in thread)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AKVDBPYPW4JUXK54QT47K63YE5VSZAVCNFSM6AAAAAA7NZF4ZGVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM3TKOJZG4ZTQ> .
You are receiving this because you authored the thread. <https://github.com/notifications/beacon/AKVDBP5IFA4K3O6ZCXCARQTYE5VSZA5CNFSM6AAAAAA7NZF4ZGWGG33NNVSW45C7OR4XAZNRIRUXGY3VONZWS33OINXW23LFNZ2KUY3PNVWWK3TUL5UWJTQAOP3HU.gif> Message ID: ***@***.*** ***@***.***> >
|
Beta Was this translation helpful? Give feedback.
-
Still no solution found? |
Beta Was this translation helpful? Give feedback.
-
There is a solution but it's not ideal. You need to overwrite the def new_tag_config(self, tagName, **kwargs):
return self._textbox.tag_config(tagName, **kwargs)
customtkinter.CTkTextbox.tag_config = new_tag_config You can then use |
Beta Was this translation helpful? Give feedback.
-
In the site/webpage https://customtkinter.tomschimansky.com/documentation/widgets/textbox I couldn't see how to set the properties for lines within CTkTextboxes. In plain tkinter, (tk.Text) you do (for example):
txt_info.tag_configure("bold", font=("Arial", 12, "bold"))
txt_info.tag_configure("italic", font=("Arial", 12, "italic"))
txt_info.tag_configure("underline", underline=True)
txt_info.tag_configure("center", justify="center")
txt_info.tag_configure("multi_sty1", font=("Arial", 12, "bold italic"), underline=True, justify="center")
Then, you apply the styles (underline, multi_sty1 etc) in each line. But I haven't seen information on how to do the same using CTK textbox widget
Beta Was this translation helpful? Give feedback.
All reactions