473,562 Members | 3,089 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Justification for a label in code

1 New Member
Quick question, I have a label that is counting the letters that are typed in a textbox. But what I do want with that label is that I need it to be right justified. If I set the properties of the label to have right align it doesn't seem to work. So do I need to align it in the code so when it hits double digits it doesn't run over the item to the right but just expands to the left... How can I justify the label via code?

Here's the code I'm using for the label...

Expand|Select|Wrap|Line Numbers
  1. Dim a As Object
  2. a = Len(Me.tbImperial.Text)
  3. lblImperialCount.Text = (1 + a)
Adding "lblImperialCou nt.TextAlign = ContentAlignmen t.MiddleRight" to it doesn't seem to make a difference either...

I hope I am clear enough with my questions :)

Mar 5 '20 #1
2 17504
6 New Member
A label has no Text property, but a Caption property.
Your code should read:
Expand|Select|Wrap|Line Numbers
  1. Dim a As Object
  2. a = Len(Me.tbImperial.Text)
  3. lblImperialCount.Caption = (1 + a)
Jun 13 '22 #2
2 New Member
Tkinter Label widgets are used to add images and create text in a particular application. There are various functions and methods available in the library which can be used to style the widgets and its property. In order to justify the text in the label widget, we can use the justify property. It is generally used to justify the position or the alignment of the text such as RIGHT, LEFT, and CENTER.

In this application, we will justify the position of a text label using the justify property.

#Import tkinter library
from tkinter import *
#Create an instance of tkinter frame or window
win= Tk()
#Set the geometry of tkinter frame
win.geometry("7 50x350")
#Crate a Label widget
label1= Label(win, text="Box1")
label2= Label(win, text= "\nKeep\nLearni ng", bd=1, relief= "solid",fon t= ("Helvetica 20"), justify= RIGHT)
Label(win, text= "Box2").pac k()
label3= Label(win, text="\nLearnin g\nMakes\nPerfe ct", bd=1, relief="solid", font=('Helvetic a 20'), justify= LEFT)
Jun 23 '22 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Alex | last post by:
The JustiDirect text justification on Stephen LeBans site works well but I cannot get it to work on a sub report. Could anyone tell me if this is possible. Thanks. Alex
by: Victor Nazarov | last post by:
Consider I want to write my own version of standard malloc, calloc, realloc, free. How can I portably check if they work correctly? The most remarkable will be the test for right justification of each C type dynamicly allocated. -- vir
by: pavan | last post by:
in my code i am storing the contents into a label // code is as follows lblSecurity.Text = lblSecurity.Text & vbCrLf & _ "Task Description" this is not working though. please advise
by: Neil | last post by:
Just found out that the Microsoft Rich Textbox does not support full text justification, since it's based on Version 1.0 of the RichEdit Window Class, and full text justification is only available in versions 3.0 or later of the class. However, also just found out that the new Rich Text property in Access 2007 ALSO does not support full...
by: gaetanoortisi | last post by:
Hello, can anyone point me to some piece of code that do text justification of fixed fonts like those that nroff do on manpages? Thanks, Gaetano
by: lamarant | last post by:
OK...I have a datalist that, in each row, has control and a label. What I want to happen is for the text in the label to update when its associated control is clicked. Here's what I have so far...just need to get that label updating. The Control's OnChange Event: Private Sub Rating_Changed(ByVal sender As Object, ByVal e As...
by: crystal2005 | last post by:
Hi all, Can anyone tell me why my image doesn't appear in my frame's container? When I change imageIcon to just normal Label, it does go work. In another condition, if i don't use method return (what is it called? emm...). ImageIcon does work on my normal Label. package practise; import java.awt.*;
by: Dormilich | last post by:
Hi, I just have one thing about the label element, where I’m not certain. <label> is commonly used to attach visual/text information to a form control. so far, so good. <!-- just to make it visible --> <input type="checkbox" value="yes" id="mysql"> <label for="mysql">save MySQL</label> Now supposing I want to toggle the visibility of a...
by: pooja8389 | last post by:
plz tell me how can i give the text "" to textbox and label? if i use this shows the blank page and if i use (Text="""") then it shows output:"""". <asp:Label ID="Label1" runat="server" Text=""></asp:Label>
by: priyasomu | last post by:
I tried to move label option in asp.net 2008 version but I cant..I gave this code in html part: <asp:Label ID ="my label" runat="server" style="position:absolute;display:block;" </asp:label> But I am getting message as Error Creating Control - my label The server tag is not well formed.
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.