Reputation: 91
Rather a specific request I can't seem to find any online documentation on:
I'm trying to change the position of the font on frames surrounding buttons. As shown below the text is currently centered above the button. I would like the text to be displayed to the right of the button.
Heres my code for the frames and buttons:
"""Button frames"""
constituent_frame = LabelFrame(root, text="Fibre and resin data inputs", padx=2, pady=2)
ply_frame = LabelFrame(root, text="Single lamina data inputs", padx=2, pady=2)
laminate_frame = LabelFrame(root, text="Complete ply stack data inputs", padx=2, pady=2)
"""Frame positions"""
constituent_frame.grid(row=2, column=1, padx=50)
ply_frame.grid(row=3, column=1, padx=50)
laminate_frame.grid(row=4, column=1, padx=50)
"""Button definitions"""
constituent_button = Button(constituent_frame, text='Constituent', width=15, command=click_constituent)
ply_button = Button(ply_frame, text='Ply', width=15, command=click_ply)
laminate_button = Button(laminate_frame, text='Laminate', width=15, command=click_laminate)
"""Button positions"""
constituent_button.grid(row=2, column=1, pady=2)
ply_button.grid(row=3, column=1, pady=2)
laminate_button.grid(row=4, column=1, pady=2)
Any advice or links to resources would be greatly appreciated.
Upvotes: 0
Views: 525
Reputation: 1211
You can use the labelanchor
argument on the LabelFrame
class to achieve this:
from tkinter import *
root = Tk()
labelframe = LabelFrame(root, text="Hello", labelanchor=E)
button = Button(labelframe, text="BUTTON")
labelframe.pack()
button.pack()
root.mainloop()
possible values are the cardinal directions (NSEW) - tkinter has constants for these
Upvotes: 1