#πŸ”’ tkinkter help

8 messages Β· Page 1 of 1 (latest)

winter marsh
#

hi all, this is probably a little silly but I can't get my button to pack in the following code. Everything else works perfectly, but I don't see the actual button. Why is that?

from tkinter import *
import csv


class Gui:
    def __init__(self, window):
        self.window = window

        self.frame_name = Frame(self.window)
        self.label_name = Label(self.frame_name, text='Name')
        self.input_name = Entry(self.frame_name)
        self.label_name.pack(side='left')
        self.input_name.pack(padx=5, side='left')
        self.frame_name.pack(anchor='w', padx=10, pady=10)

        self.frame_age = Frame(self.window)
        self.label_age = Label(self.frame_age, text='Age')
        self.input_age = Entry(self.frame_age)
        self.label_age.pack(side='left')
        self.input_age.pack(padx=5, side='right')
        self.frame_age.pack(anchor='w', padx=10, pady=10)

        self.frame_radio = Frame(self.window)
        self.label_status = Label(self.frame_radio, text='Status')
        self.radio_answer = IntVar()
        self.radio_answer.set(0)
        self.radio_student = Radiobutton(self.frame_radio, text='Student', variable=self.radio_answer, value=1)
        self.radio_staff = Radiobutton(self.frame_radio, text='Staff', variable=self.radio_answer, value=2)
        self.radio_both = Radiobutton(self.frame_radio, text='Both', variable=self.radio_answer, value=3)
        self.label_status.pack(side='left')
        self.radio_student.pack(side='left')
        self.radio_staff.pack(side='left')
        self.radio_both.pack(side='left')
        self.frame_radio.pack()

        self.frame_button = Frame(self.window)
        self.button_submit = Button(self.frame_button, text='SAVE', command=self.submit)
        self.button_submit.pack(side='bottom')

    def submit(self):
        print('test')```

Thanks!
forest cobaltBOT
#

@winter marsh

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

ancient heath
winter marsh
#

ohh my gosh

#

… thanks

ancient heath
#

Welcome ! πŸ™‚

forest cobaltBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.