OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

How to `tag_configure` for changing only font `weight`?

  • Thread starter Thread starter FedKad
  • Start date Start date
F

FedKad

Guest
I have a text widget and defined two tags for two different font faces:

Code:
text1.tag_configure("var", font=textfont)
text1.tag_configure("mon", font=fixedfont)

Now, I want to define one more tag to make either the mono spaced (fixedfont) or variable spaced (textfont) font bold. I defined something like this:

Code:
text1.tag_configure("bld", font='-weight bold')

However, this does not work:

Code:
text1.insert(END, "mono typed bolded text", "mon bld")

and changes the font face to something probably default.

Obviously, I need something like:

Code:
text1.tag_configure("bld", weight="bold")

which is not accepted and gives _unknown option "-weight" error.
<p>I have a text widget and defined two tags for two different font faces:</p>
<pre><code>text1.tag_configure("var", font=textfont)
text1.tag_configure("mon", font=fixedfont)
</code></pre>
<p>Now, I want to define one more tag to make either the mono spaced (<code>fixedfont</code>) or variable spaced (<code>textfont</code>) font <strong>bold</strong>. I defined something like this:</p>
<pre><code>text1.tag_configure("bld", font='-weight bold')
</code></pre>
<p>However, this does not work:</p>
<pre><code>text1.insert(END, "mono typed bolded text", "mon bld")
</code></pre>
<p>and changes the font face to something probably default.</p>
<p>Obviously, I need something like:</p>
<pre><code>text1.tag_configure("bld", weight="bold")
</code></pre>
<p>which is not accepted and gives <code>_unknown option "-weight"</code> error.</p>
 

Latest posts

M
Replies
0
Views
1
Mohit Pant
M
Top