Tkinter aligning text












-1















I am using Tkinter to align screen text. I have been unsuccessful in properly aligning the text I want to display. Currently this is displaying on a 24" monitor and I cannot get some of the text to go all the way to the right of the screen. I have tried



sticky=E 


but it did not move the text to right.Screen Image



from __future__ import division
import matplotlib
matplotlib.use('Agg')
from Tkinter import *
import tkFont
import RPi.GPIO as GPIO
import time
import datetime

win = Tk()

###################################################################################################
##################################### CONFIGURATIONS ##############################################
###################################################################################################


#Change according to the true target value for this shift
TARGET_VALUE = 600

#Change according to the target value displayed for this shift
TARGET_DISPLAY = 480

#Change to met you display sizes , try by increasing and decreasing this value to change labels
SIZE = 120


###################################################################################################
########################################### END ###################################################
###################################################################################################


GPIO.setmode(GPIO.BOARD)
GPIO.setup(40, GPIO.IN,pull_up_down=GPIO.PUD_DOWN)

ACTUAL_VALUE = IntVar()
ACTUAL_VALUE.set(0)

ACTUAL_CTR=0

Efficiency_VALUE = IntVar()
Efficiency_VALUE.set(100)

StartTime = datetime.datetime.now()
currentState = 0
previousState = 0

myFont = tkFont.Font(family = 'Helvetica', size = SIZE , weight = 'bold')
win.attributes("-fullscreen",True)
BACKGROUND = 'white'
win.configure(background=BACKGROUND)

def getNumberOfMinutes(a,b):
c=b-a
x=divmod(c.days*86400 + c.seconds,60)
return x[0]

def RESET():
global StartTime
global Efficiency_VALUE
global ACTUAL_VALUE
global BACKGROUND
global ACTUAL_CTR

print(" Reset pressed")
ACTUAL_VALUE.set(0)
ACTUAL_CTR=0
Efficiency_VALUE.set(100)
StartTime = datetime.datetime.now()
BACKGROUND = 'white'
win.configure(background=BACKGROUND)

def task():
global StartTime
global TARGET_VALUE
global ACTUAL_CTR
global BACKGROUND
global Efficiency_VALUE
global previousState
global currentState
Eff_Value = 0

if(ACTUAL_CTR != TARGET_VALUE):
TimeNow = datetime.datetime.now()

currentState = GPIO.input(40)

if (currentState == 1 and previousState == 0):
ACTUAL_CTR=ACTUAL_CTR+1
ACTUAL_CTR = int(ACTUAL_CTR)
ACTUAL_VALUE.set(ACTUAL_CTR)

previousState = currentState
Minutes= getNumberOfMinutes(StartTime,TimeNow)
if(Minutes < 1):
Minutes=1
if(ACTUAL_CTR >0):
Eff_Value = ((ACTUAL_CTR/Minutes)/(TARGET_VALUE/48000))
if(Eff_Value>135):
Eff_Value=135
Eff_Value = int(Eff_Value)
Efficiency_VALUE.set(Eff_Value)
if(Eff_Value >= 80):
BACKGROUND = 'green'
elif(Eff_Value >= 70):
BACKGROUND = 'yellow'
elif(Eff_Value < 60):
BACKGROUND = 'red'

win.configure(background=BACKGROUND)
win.after(500,task)
else:
print "finished"


Label(win,text="%",font=myFont,bg=BACKGROUND).grid(row=2,column=30)
Label(win,text="PCS",font=myFont,bg=BACKGROUND).grid(row=2,column=80)
Label(win,text="",font=myFont,bg=BACKGROUND).grid(row=3,sticky=W)

Label(win,text="Target:",font=myFont,bg=BACKGROUND).grid(row=4)
Label(win,text="75",font=myFont,bg=BACKGROUND).grid(row=4,column=30)
Label(win,text=TARGET_DISPLAY,font=myFont,bg=BACKGROUND).grid(row=4,column=80)
Label(win,text="",font=myFont,bg=BACKGROUND).grid(row=5,sticky=W)

Label(win,text="Actual:",font=myFont,bg=BACKGROUND).grid(row=6)
Label(win,textvariable=ACTUAL_VALUE,font=myFont,bg=BACKGROUND).grid(row=6,column=80)
Label(win,textvariable=Efficiency_VALUE,font=myFont,bg=BACKGROUND).grid(row=6,column=30)

win.after(500,task)
mainloop()









share|improve this question




















  • 2





    Please provide a Minimal, Complete, and Verifiable example. We need to see if you're giving any weights to rows or columns, and how win is put in its parent.

    – Bryan Oakley
    Nov 19 '18 at 15:47











  • I have a detailed answer about how the geometry manager works for grid(). This will explain why you are not able to simple use columns to move your widget to the right of the screen. Here: Details on grid manager resizing

    – Mike - SMT
    Nov 19 '18 at 15:59











  • This is way too much code. Please try to narrow it down. And since this is purely related to the visual experience, the example shouldn’t depend on matplotlib and RPi

    – Bryan Oakley
    Nov 19 '18 at 18:21
















-1















I am using Tkinter to align screen text. I have been unsuccessful in properly aligning the text I want to display. Currently this is displaying on a 24" monitor and I cannot get some of the text to go all the way to the right of the screen. I have tried



sticky=E 


but it did not move the text to right.Screen Image



from __future__ import division
import matplotlib
matplotlib.use('Agg')
from Tkinter import *
import tkFont
import RPi.GPIO as GPIO
import time
import datetime

win = Tk()

###################################################################################################
##################################### CONFIGURATIONS ##############################################
###################################################################################################


#Change according to the true target value for this shift
TARGET_VALUE = 600

#Change according to the target value displayed for this shift
TARGET_DISPLAY = 480

#Change to met you display sizes , try by increasing and decreasing this value to change labels
SIZE = 120


###################################################################################################
########################################### END ###################################################
###################################################################################################


GPIO.setmode(GPIO.BOARD)
GPIO.setup(40, GPIO.IN,pull_up_down=GPIO.PUD_DOWN)

ACTUAL_VALUE = IntVar()
ACTUAL_VALUE.set(0)

ACTUAL_CTR=0

Efficiency_VALUE = IntVar()
Efficiency_VALUE.set(100)

StartTime = datetime.datetime.now()
currentState = 0
previousState = 0

myFont = tkFont.Font(family = 'Helvetica', size = SIZE , weight = 'bold')
win.attributes("-fullscreen",True)
BACKGROUND = 'white'
win.configure(background=BACKGROUND)

def getNumberOfMinutes(a,b):
c=b-a
x=divmod(c.days*86400 + c.seconds,60)
return x[0]

def RESET():
global StartTime
global Efficiency_VALUE
global ACTUAL_VALUE
global BACKGROUND
global ACTUAL_CTR

print(" Reset pressed")
ACTUAL_VALUE.set(0)
ACTUAL_CTR=0
Efficiency_VALUE.set(100)
StartTime = datetime.datetime.now()
BACKGROUND = 'white'
win.configure(background=BACKGROUND)

def task():
global StartTime
global TARGET_VALUE
global ACTUAL_CTR
global BACKGROUND
global Efficiency_VALUE
global previousState
global currentState
Eff_Value = 0

if(ACTUAL_CTR != TARGET_VALUE):
TimeNow = datetime.datetime.now()

currentState = GPIO.input(40)

if (currentState == 1 and previousState == 0):
ACTUAL_CTR=ACTUAL_CTR+1
ACTUAL_CTR = int(ACTUAL_CTR)
ACTUAL_VALUE.set(ACTUAL_CTR)

previousState = currentState
Minutes= getNumberOfMinutes(StartTime,TimeNow)
if(Minutes < 1):
Minutes=1
if(ACTUAL_CTR >0):
Eff_Value = ((ACTUAL_CTR/Minutes)/(TARGET_VALUE/48000))
if(Eff_Value>135):
Eff_Value=135
Eff_Value = int(Eff_Value)
Efficiency_VALUE.set(Eff_Value)
if(Eff_Value >= 80):
BACKGROUND = 'green'
elif(Eff_Value >= 70):
BACKGROUND = 'yellow'
elif(Eff_Value < 60):
BACKGROUND = 'red'

win.configure(background=BACKGROUND)
win.after(500,task)
else:
print "finished"


Label(win,text="%",font=myFont,bg=BACKGROUND).grid(row=2,column=30)
Label(win,text="PCS",font=myFont,bg=BACKGROUND).grid(row=2,column=80)
Label(win,text="",font=myFont,bg=BACKGROUND).grid(row=3,sticky=W)

Label(win,text="Target:",font=myFont,bg=BACKGROUND).grid(row=4)
Label(win,text="75",font=myFont,bg=BACKGROUND).grid(row=4,column=30)
Label(win,text=TARGET_DISPLAY,font=myFont,bg=BACKGROUND).grid(row=4,column=80)
Label(win,text="",font=myFont,bg=BACKGROUND).grid(row=5,sticky=W)

Label(win,text="Actual:",font=myFont,bg=BACKGROUND).grid(row=6)
Label(win,textvariable=ACTUAL_VALUE,font=myFont,bg=BACKGROUND).grid(row=6,column=80)
Label(win,textvariable=Efficiency_VALUE,font=myFont,bg=BACKGROUND).grid(row=6,column=30)

win.after(500,task)
mainloop()









share|improve this question




















  • 2





    Please provide a Minimal, Complete, and Verifiable example. We need to see if you're giving any weights to rows or columns, and how win is put in its parent.

    – Bryan Oakley
    Nov 19 '18 at 15:47











  • I have a detailed answer about how the geometry manager works for grid(). This will explain why you are not able to simple use columns to move your widget to the right of the screen. Here: Details on grid manager resizing

    – Mike - SMT
    Nov 19 '18 at 15:59











  • This is way too much code. Please try to narrow it down. And since this is purely related to the visual experience, the example shouldn’t depend on matplotlib and RPi

    – Bryan Oakley
    Nov 19 '18 at 18:21














-1












-1








-1








I am using Tkinter to align screen text. I have been unsuccessful in properly aligning the text I want to display. Currently this is displaying on a 24" monitor and I cannot get some of the text to go all the way to the right of the screen. I have tried



sticky=E 


but it did not move the text to right.Screen Image



from __future__ import division
import matplotlib
matplotlib.use('Agg')
from Tkinter import *
import tkFont
import RPi.GPIO as GPIO
import time
import datetime

win = Tk()

###################################################################################################
##################################### CONFIGURATIONS ##############################################
###################################################################################################


#Change according to the true target value for this shift
TARGET_VALUE = 600

#Change according to the target value displayed for this shift
TARGET_DISPLAY = 480

#Change to met you display sizes , try by increasing and decreasing this value to change labels
SIZE = 120


###################################################################################################
########################################### END ###################################################
###################################################################################################


GPIO.setmode(GPIO.BOARD)
GPIO.setup(40, GPIO.IN,pull_up_down=GPIO.PUD_DOWN)

ACTUAL_VALUE = IntVar()
ACTUAL_VALUE.set(0)

ACTUAL_CTR=0

Efficiency_VALUE = IntVar()
Efficiency_VALUE.set(100)

StartTime = datetime.datetime.now()
currentState = 0
previousState = 0

myFont = tkFont.Font(family = 'Helvetica', size = SIZE , weight = 'bold')
win.attributes("-fullscreen",True)
BACKGROUND = 'white'
win.configure(background=BACKGROUND)

def getNumberOfMinutes(a,b):
c=b-a
x=divmod(c.days*86400 + c.seconds,60)
return x[0]

def RESET():
global StartTime
global Efficiency_VALUE
global ACTUAL_VALUE
global BACKGROUND
global ACTUAL_CTR

print(" Reset pressed")
ACTUAL_VALUE.set(0)
ACTUAL_CTR=0
Efficiency_VALUE.set(100)
StartTime = datetime.datetime.now()
BACKGROUND = 'white'
win.configure(background=BACKGROUND)

def task():
global StartTime
global TARGET_VALUE
global ACTUAL_CTR
global BACKGROUND
global Efficiency_VALUE
global previousState
global currentState
Eff_Value = 0

if(ACTUAL_CTR != TARGET_VALUE):
TimeNow = datetime.datetime.now()

currentState = GPIO.input(40)

if (currentState == 1 and previousState == 0):
ACTUAL_CTR=ACTUAL_CTR+1
ACTUAL_CTR = int(ACTUAL_CTR)
ACTUAL_VALUE.set(ACTUAL_CTR)

previousState = currentState
Minutes= getNumberOfMinutes(StartTime,TimeNow)
if(Minutes < 1):
Minutes=1
if(ACTUAL_CTR >0):
Eff_Value = ((ACTUAL_CTR/Minutes)/(TARGET_VALUE/48000))
if(Eff_Value>135):
Eff_Value=135
Eff_Value = int(Eff_Value)
Efficiency_VALUE.set(Eff_Value)
if(Eff_Value >= 80):
BACKGROUND = 'green'
elif(Eff_Value >= 70):
BACKGROUND = 'yellow'
elif(Eff_Value < 60):
BACKGROUND = 'red'

win.configure(background=BACKGROUND)
win.after(500,task)
else:
print "finished"


Label(win,text="%",font=myFont,bg=BACKGROUND).grid(row=2,column=30)
Label(win,text="PCS",font=myFont,bg=BACKGROUND).grid(row=2,column=80)
Label(win,text="",font=myFont,bg=BACKGROUND).grid(row=3,sticky=W)

Label(win,text="Target:",font=myFont,bg=BACKGROUND).grid(row=4)
Label(win,text="75",font=myFont,bg=BACKGROUND).grid(row=4,column=30)
Label(win,text=TARGET_DISPLAY,font=myFont,bg=BACKGROUND).grid(row=4,column=80)
Label(win,text="",font=myFont,bg=BACKGROUND).grid(row=5,sticky=W)

Label(win,text="Actual:",font=myFont,bg=BACKGROUND).grid(row=6)
Label(win,textvariable=ACTUAL_VALUE,font=myFont,bg=BACKGROUND).grid(row=6,column=80)
Label(win,textvariable=Efficiency_VALUE,font=myFont,bg=BACKGROUND).grid(row=6,column=30)

win.after(500,task)
mainloop()









share|improve this question
















I am using Tkinter to align screen text. I have been unsuccessful in properly aligning the text I want to display. Currently this is displaying on a 24" monitor and I cannot get some of the text to go all the way to the right of the screen. I have tried



sticky=E 


but it did not move the text to right.Screen Image



from __future__ import division
import matplotlib
matplotlib.use('Agg')
from Tkinter import *
import tkFont
import RPi.GPIO as GPIO
import time
import datetime

win = Tk()

###################################################################################################
##################################### CONFIGURATIONS ##############################################
###################################################################################################


#Change according to the true target value for this shift
TARGET_VALUE = 600

#Change according to the target value displayed for this shift
TARGET_DISPLAY = 480

#Change to met you display sizes , try by increasing and decreasing this value to change labels
SIZE = 120


###################################################################################################
########################################### END ###################################################
###################################################################################################


GPIO.setmode(GPIO.BOARD)
GPIO.setup(40, GPIO.IN,pull_up_down=GPIO.PUD_DOWN)

ACTUAL_VALUE = IntVar()
ACTUAL_VALUE.set(0)

ACTUAL_CTR=0

Efficiency_VALUE = IntVar()
Efficiency_VALUE.set(100)

StartTime = datetime.datetime.now()
currentState = 0
previousState = 0

myFont = tkFont.Font(family = 'Helvetica', size = SIZE , weight = 'bold')
win.attributes("-fullscreen",True)
BACKGROUND = 'white'
win.configure(background=BACKGROUND)

def getNumberOfMinutes(a,b):
c=b-a
x=divmod(c.days*86400 + c.seconds,60)
return x[0]

def RESET():
global StartTime
global Efficiency_VALUE
global ACTUAL_VALUE
global BACKGROUND
global ACTUAL_CTR

print(" Reset pressed")
ACTUAL_VALUE.set(0)
ACTUAL_CTR=0
Efficiency_VALUE.set(100)
StartTime = datetime.datetime.now()
BACKGROUND = 'white'
win.configure(background=BACKGROUND)

def task():
global StartTime
global TARGET_VALUE
global ACTUAL_CTR
global BACKGROUND
global Efficiency_VALUE
global previousState
global currentState
Eff_Value = 0

if(ACTUAL_CTR != TARGET_VALUE):
TimeNow = datetime.datetime.now()

currentState = GPIO.input(40)

if (currentState == 1 and previousState == 0):
ACTUAL_CTR=ACTUAL_CTR+1
ACTUAL_CTR = int(ACTUAL_CTR)
ACTUAL_VALUE.set(ACTUAL_CTR)

previousState = currentState
Minutes= getNumberOfMinutes(StartTime,TimeNow)
if(Minutes < 1):
Minutes=1
if(ACTUAL_CTR >0):
Eff_Value = ((ACTUAL_CTR/Minutes)/(TARGET_VALUE/48000))
if(Eff_Value>135):
Eff_Value=135
Eff_Value = int(Eff_Value)
Efficiency_VALUE.set(Eff_Value)
if(Eff_Value >= 80):
BACKGROUND = 'green'
elif(Eff_Value >= 70):
BACKGROUND = 'yellow'
elif(Eff_Value < 60):
BACKGROUND = 'red'

win.configure(background=BACKGROUND)
win.after(500,task)
else:
print "finished"


Label(win,text="%",font=myFont,bg=BACKGROUND).grid(row=2,column=30)
Label(win,text="PCS",font=myFont,bg=BACKGROUND).grid(row=2,column=80)
Label(win,text="",font=myFont,bg=BACKGROUND).grid(row=3,sticky=W)

Label(win,text="Target:",font=myFont,bg=BACKGROUND).grid(row=4)
Label(win,text="75",font=myFont,bg=BACKGROUND).grid(row=4,column=30)
Label(win,text=TARGET_DISPLAY,font=myFont,bg=BACKGROUND).grid(row=4,column=80)
Label(win,text="",font=myFont,bg=BACKGROUND).grid(row=5,sticky=W)

Label(win,text="Actual:",font=myFont,bg=BACKGROUND).grid(row=6)
Label(win,textvariable=ACTUAL_VALUE,font=myFont,bg=BACKGROUND).grid(row=6,column=80)
Label(win,textvariable=Efficiency_VALUE,font=myFont,bg=BACKGROUND).grid(row=6,column=30)

win.after(500,task)
mainloop()






python tkinter






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 19 '18 at 16:01







knownocode

















asked Nov 19 '18 at 15:40









knownocodeknownocode

32




32








  • 2





    Please provide a Minimal, Complete, and Verifiable example. We need to see if you're giving any weights to rows or columns, and how win is put in its parent.

    – Bryan Oakley
    Nov 19 '18 at 15:47











  • I have a detailed answer about how the geometry manager works for grid(). This will explain why you are not able to simple use columns to move your widget to the right of the screen. Here: Details on grid manager resizing

    – Mike - SMT
    Nov 19 '18 at 15:59











  • This is way too much code. Please try to narrow it down. And since this is purely related to the visual experience, the example shouldn’t depend on matplotlib and RPi

    – Bryan Oakley
    Nov 19 '18 at 18:21














  • 2





    Please provide a Minimal, Complete, and Verifiable example. We need to see if you're giving any weights to rows or columns, and how win is put in its parent.

    – Bryan Oakley
    Nov 19 '18 at 15:47











  • I have a detailed answer about how the geometry manager works for grid(). This will explain why you are not able to simple use columns to move your widget to the right of the screen. Here: Details on grid manager resizing

    – Mike - SMT
    Nov 19 '18 at 15:59











  • This is way too much code. Please try to narrow it down. And since this is purely related to the visual experience, the example shouldn’t depend on matplotlib and RPi

    – Bryan Oakley
    Nov 19 '18 at 18:21








2




2





Please provide a Minimal, Complete, and Verifiable example. We need to see if you're giving any weights to rows or columns, and how win is put in its parent.

– Bryan Oakley
Nov 19 '18 at 15:47





Please provide a Minimal, Complete, and Verifiable example. We need to see if you're giving any weights to rows or columns, and how win is put in its parent.

– Bryan Oakley
Nov 19 '18 at 15:47













I have a detailed answer about how the geometry manager works for grid(). This will explain why you are not able to simple use columns to move your widget to the right of the screen. Here: Details on grid manager resizing

– Mike - SMT
Nov 19 '18 at 15:59





I have a detailed answer about how the geometry manager works for grid(). This will explain why you are not able to simple use columns to move your widget to the right of the screen. Here: Details on grid manager resizing

– Mike - SMT
Nov 19 '18 at 15:59













This is way too much code. Please try to narrow it down. And since this is purely related to the visual experience, the example shouldn’t depend on matplotlib and RPi

– Bryan Oakley
Nov 19 '18 at 18:21





This is way too much code. Please try to narrow it down. And since this is purely related to the visual experience, the example shouldn’t depend on matplotlib and RPi

– Bryan Oakley
Nov 19 '18 at 18:21












1 Answer
1






active

oldest

votes


















0














What you need to do is set a weight for the center column. Weights are used to tell the column/row to expand a specific rate.



Add this line just under win = Tk():



win.columnconfigure(1, weight=1)


Then change your columns in your labels to the following.



Label(win,text="%").grid(row=2,column=1)
Label(win,text="PCS").grid(row=2,column=2)
Label(win,text="").grid(row=3,sticky=W)

Label(win,text="Target:").grid(row=4)
Label(win,text="75").grid(row=4,column=1)
Label(win,text=TARGET_DISPLAY).grid(row=4,column=2)
Label(win,text="").grid(row=5,sticky=W)

Label(win,text="Actual:").grid(row=6)
Label(win,textvariable=ACTUAL_VALUE).grid(row=6,column=2)
Label(win,textvariable=Efficiency_VALUE).grid(row=6,column=1)


This should move all your labels on the far right that are meant to be there and then the mid labels to the cent of the screen.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53378061%2ftkinter-aligning-text%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    What you need to do is set a weight for the center column. Weights are used to tell the column/row to expand a specific rate.



    Add this line just under win = Tk():



    win.columnconfigure(1, weight=1)


    Then change your columns in your labels to the following.



    Label(win,text="%").grid(row=2,column=1)
    Label(win,text="PCS").grid(row=2,column=2)
    Label(win,text="").grid(row=3,sticky=W)

    Label(win,text="Target:").grid(row=4)
    Label(win,text="75").grid(row=4,column=1)
    Label(win,text=TARGET_DISPLAY).grid(row=4,column=2)
    Label(win,text="").grid(row=5,sticky=W)

    Label(win,text="Actual:").grid(row=6)
    Label(win,textvariable=ACTUAL_VALUE).grid(row=6,column=2)
    Label(win,textvariable=Efficiency_VALUE).grid(row=6,column=1)


    This should move all your labels on the far right that are meant to be there and then the mid labels to the cent of the screen.






    share|improve this answer




























      0














      What you need to do is set a weight for the center column. Weights are used to tell the column/row to expand a specific rate.



      Add this line just under win = Tk():



      win.columnconfigure(1, weight=1)


      Then change your columns in your labels to the following.



      Label(win,text="%").grid(row=2,column=1)
      Label(win,text="PCS").grid(row=2,column=2)
      Label(win,text="").grid(row=3,sticky=W)

      Label(win,text="Target:").grid(row=4)
      Label(win,text="75").grid(row=4,column=1)
      Label(win,text=TARGET_DISPLAY).grid(row=4,column=2)
      Label(win,text="").grid(row=5,sticky=W)

      Label(win,text="Actual:").grid(row=6)
      Label(win,textvariable=ACTUAL_VALUE).grid(row=6,column=2)
      Label(win,textvariable=Efficiency_VALUE).grid(row=6,column=1)


      This should move all your labels on the far right that are meant to be there and then the mid labels to the cent of the screen.






      share|improve this answer


























        0












        0








        0







        What you need to do is set a weight for the center column. Weights are used to tell the column/row to expand a specific rate.



        Add this line just under win = Tk():



        win.columnconfigure(1, weight=1)


        Then change your columns in your labels to the following.



        Label(win,text="%").grid(row=2,column=1)
        Label(win,text="PCS").grid(row=2,column=2)
        Label(win,text="").grid(row=3,sticky=W)

        Label(win,text="Target:").grid(row=4)
        Label(win,text="75").grid(row=4,column=1)
        Label(win,text=TARGET_DISPLAY).grid(row=4,column=2)
        Label(win,text="").grid(row=5,sticky=W)

        Label(win,text="Actual:").grid(row=6)
        Label(win,textvariable=ACTUAL_VALUE).grid(row=6,column=2)
        Label(win,textvariable=Efficiency_VALUE).grid(row=6,column=1)


        This should move all your labels on the far right that are meant to be there and then the mid labels to the cent of the screen.






        share|improve this answer













        What you need to do is set a weight for the center column. Weights are used to tell the column/row to expand a specific rate.



        Add this line just under win = Tk():



        win.columnconfigure(1, weight=1)


        Then change your columns in your labels to the following.



        Label(win,text="%").grid(row=2,column=1)
        Label(win,text="PCS").grid(row=2,column=2)
        Label(win,text="").grid(row=3,sticky=W)

        Label(win,text="Target:").grid(row=4)
        Label(win,text="75").grid(row=4,column=1)
        Label(win,text=TARGET_DISPLAY).grid(row=4,column=2)
        Label(win,text="").grid(row=5,sticky=W)

        Label(win,text="Actual:").grid(row=6)
        Label(win,textvariable=ACTUAL_VALUE).grid(row=6,column=2)
        Label(win,textvariable=Efficiency_VALUE).grid(row=6,column=1)


        This should move all your labels on the far right that are meant to be there and then the mid labels to the cent of the screen.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 19 '18 at 16:23









        Mike - SMTMike - SMT

        9,53421434




        9,53421434






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53378061%2ftkinter-aligning-text%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Guess what letter conforming each word

            Port of Spain

            Run scheduled task as local user group (not BUILTIN)