I'm trying to figure out how to left justify my label text, when I set the columnconfigure so that my controls grow with the window resize the text/control is in the middle but I'd like the text to start at the left. I'm new to tkinter so I might be missing something obvious. I will have several more controls so I'm using the grid layout. Thanks for any guidance.
from tkinter import *
from tkinter import filedialog
class Application(Frame):
def __init__(self, master=None):
Frame.__init__(self, master)
self.master.geometry("800x600")
self.grid()
self.label_ccdata_path = Label(master, text='My message goes here')
self.label_ccdata_path.grid(row=0, column=0, columnspan=3, sticky=N+S+E+W)
root = Tk()
root.columnconfigure(0, weight=1)
app = Application(root)
app.mainloop()
You can set the anchor
of your label to the west with anchor = "w"
I have modified your code below:
from tkinter import *
from tkinter import filedialog
class Application(Frame):
def __init__(self, master=None):
Frame.__init__(self, master)
self.master.geometry("800x600")
self.grid()
self.label_ccdata_path = Label(master, text='My message goes here', anchor = "w")
self.label_ccdata_path.grid(row=0, column=0, columnspan=3, sticky=N+S+E+W)
root = Tk()
root.columnconfigure(0, weight=1)
app = Application(root)
app.mainloop()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.