0

So Im creating a software for my mom and i want to resize a button here is my code:

from tkinter import *
from tkinter.ttk import *

class Client():

    def __init__(self):

        self.name = ""
        self.last_name = ""
        self.full_name = ""
        self.birth_date = ""
        self.email = ""
        self.phone_number = ""

    def set_Properties(self, name, last_name, birth_date, email, phone_number):

        self.name = name
        self.last_name = last_name
        self.full_name = f"{name} {last_name}"
        self.birth_date = birth_date
        self.email = email
        self.phone_number = phone_number

def main():
    root = Tk()
    root.title("client Manager")
    root.resizable(width=False, height=False)

    global grid_list
    grid_list = []

    name_label = Label(root, text = "First name")
    lastName_label = Label(root, text = "Last name")
    birthDate_label = Label(root, text = "Birth date")
    email_label = Label(root, text = "Email")
    phoneNumber_label = Label(root, text = "Phone namber")

    name_entry = Entry(root)
    lastName_entry = Entry(root)
    birthDate_entry = Entry(root)
    email_entry = Entry(root)
    phoneNumber_entry = Entry(root)

    clients = {}

    clients_labels = {}

    global numbering
    numbering = 0

    def finish():

        full_name = f"{name_entry} {lastName_entry}"

        clients[full_name] = Client()
        clients[full_name].set_Properties(name_entry.get(), lastName_entry.get(), birthDate_entry.get(), email_entry.get(), phoneNumber_entry.get())

        global numbering
        clients_labels[numbering] = Label(root, text = f"Name: {clients[full_name].full_name} | Email: {clients[full_name].email} | Birth date: {clients[full_name].birth_date} | Phone number: {clients[full_name].phone_number}")
        numbering += 1

        global grid_list

        for i in grid_list:
            i.grid_forget()
        grid_list = []

        x = 0
        for i in clients_labels:
            clients_labels[i].grid(row=x, column=1, padx=10, pady=5)
            grid_list.append(clients_labels[i])
            x+=1

        add_button.grid(row=x, column=0, padx=20, pady=20)
        grid_list.append(add_button)

    def add():
        global grid_list

        for i in grid_list:
            i.grid_forget()

        grid_list = []

        # setting up the add text
        name_label.grid(row=0, column=0, padx=10, pady=5)
        grid_list.append(name_label)

        lastName_label.grid(row=1, column=0, padx=10, pady=5)
        grid_list.append(lastName_label)

        birthDate_label.grid(row=2, column=0, padx=10, pady=5)
        grid_list.append(birthDate_label)

        email_label.grid(row=3, column=0, padx=10, pady=5)
        grid_list.append(email_label)

        phoneNumber_label.grid(row=4, column=0, padx=10, pady=5)
        grid_list.append(phoneNumber_label)

        # setting up the add entry
        name_entry.grid(row=0, column=1, padx=10, pady=5)
        grid_list.append(name_entry)

        lastName_entry.grid(row=1, column=1, padx=10, pady=5)
        grid_list.append(lastName_entry)

        birthDate_entry.grid(row=2, column=1, padx=10, pady=5)
        grid_list.append(birthDate_entry)

        email_entry.grid(row=3, column=1, padx=10, pady=5)
        grid_list.append(email_entry)

        phoneNumber_entry.grid(row=4, column=1, padx=10, pady=5)
        grid_list.append(phoneNumber_entry)

        # setting up the finish button
        finish_button.grid(row=5, column=0, padx=10, pady=5)
        grid_list.append(finish_button)

    add_button = Button(root, text="Add", command=add)
    finish_button = Button(root, text="finish", command=finish)

    add_button.grid(row=0, column=0, padx=20, pady=20)
    grid_list.append(add_button)

    root.mainloop()

main()

and i need a better why to make the program looks good maybe a theme or something can you add tables to tkinter?

https://www.delftstack.com/howto/python-tkinter/how-to-change-the-tkinter-button-size/ thet here didnt helped me.

Im working with themed python Can anyone help me?

Bhbf
  • 157
  • 13
Matan Boas
  • 16
  • 3
  • If you really only want to change the button size, try passing a width as in `Button(..., width=50)`. This seems to work here. Mentioning the error message would also have helped, I got `_tkinter.TclError: unknown option "-height"` passing height and width. It appears that the themed Tk widgets actually don't allow configuring the height, see e.g. http://www.tcl-lang.org/man/tcl8.6/TkCmd/ttk_button.htm for the button options. – Bluehorn Dec 01 '20 at 11:13
  • The answer of this [question](https://stackoverflow.com/a/9934839/5317403) may help. – acw1668 Dec 01 '20 at 15:33

1 Answers1

-1

You need to specify height and width in the arguments of button and it must work

  • The question had a link to https://www.delftstack.com/howto/python-tkinter/how-to-change-the-tkinter-button-size/ which gives `tk.Button(..., height=20, width=20)` as an example, so I fear that this does not help the questioner. As he provided example code, I just checked and in fact this does not work. Did you consider that importing tkinter.ttk overriding the tkinter names may affect the available options to `Button`? – Bluehorn Dec 01 '20 at 11:10
  • yes i want the ttk button biger not the tk – Matan Boas Dec 01 '20 at 12:27