0

I create the draft of interface for my pomodoro app. I want to anchor label titles to left side. To do this I want to use sticky method. Unfortunatelly it does nothing. Can you advice me what I am doing wrong?

import tkinter as tk

window = tk.Tk()
window.geometry("500x300")
window.title("Pomodoro by Gringo")

# HEADER - WORK START/STOP
label_work = tk.Label(text="PRACA", relief="groove", borderwidth=3)
label_work.grid(column=0, row=0, stick=tk.W, padx=150, pady=10)

button_start_work = tk.Button(text="START")
button_start_work.grid(column=1, row=0)

button_stop_work = tk.Button(text="STOP")
button_stop_work.grid(column=2, row=0)

# MAIN - POMODORO START/STOP
label_pom = tk.Label(text="POMODORO", relief="groove", borderwidth=3)
label_pom.grid(column=0, row=2, stick=tk.W, padx=150, pady=10)

button_start_pom= tk.Button(text="START")
button_start_pom.grid(column=1, row=2)

button_stop_pom = tk.Button(text="STOP")
button_stop_pom.grid(column=2, row=2)

window.mainloop()

The result of above code is as shown below. But I want to move titles to the left.

Simple GUI

1 Answer 1

1

Setting padx=150 sets a padding on both right and left of your labels. You probably want this:

import tkinter as tk

window = tk.Tk()
window.geometry("500x300")
window.title("Pomodoro by Gringo")

# HEADER - WORK START/STOP
label_work = tk.Label(text="PRACA", relief="groove", borderwidth=3)
label_work.grid(column=0, row=0, stick=tk.W, padx=(0,150), pady=10)

button_start_work = tk.Button(text="START")
button_start_work.grid(column=1, row=0)

button_stop_work = tk.Button(text="STOP")
button_stop_work.grid(column=2, row=0)

# MAIN - POMODORO START/STOP
label_pom = tk.Label(text="POMODORO", relief="groove", borderwidth=3)
label_pom.grid(column=0, row=2, stick=tk.W, padx=(0,150), pady=10)

button_start_pom= tk.Button(text="START")
button_start_pom.grid(column=1, row=2)

button_stop_pom = tk.Button(text="STOP")
button_stop_pom.grid(column=2, row=2)

window.mainloop()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.