Apr-11-2019, 02:23 PM
from tkinter import * class TheEarnings(Frame): def __init__(self, root=None): Frame.__init__(self) self.root = root self.init_window() radioframe = Frame(root, width=120, height = 200, background="powder blue") self.radioframe.place(relx=.5, rely=.5, anchor="c") def init_window(self): self.root.title("The Ryall Family Earnings") self.pack(fill=BOTH, expand=1) self.create_radiobuttons() def create_radiobuttons(self): self.mode = IntVar() self.modetext = StringVar() self.modetext.set("Earnings") R1 = Radiobutton(radioframe, text="Assignments", variable=self.mode, value=1, command=self.string_table) R1.pack() R2 = Radiobutton(radioframe, text="Companies", variable=self.mode, value=2, command=self.string_table) R2.pack() R3 = Radiobutton(radioframe, text="Earnings", variable=self.mode, value=3, command=self.string_table) R3.pack() R4 = Radiobutton(radioframe, text="Employees", variable=self.mode, value=4, command=self.string_table) R4.pack() R5 = Radiobutton(radioframe, text="Programs", variable=self.mode, value=5, command=self.string_table) R5.pack() R6 = Radiobutton(radioframe, text="Rates", variable=self.mode, value=6, command=self.string_table) R6.pack() R7 = Radiobutton(radioframe, text="SpecialRateTypes", variable=self.mode, value=7, command=self.string_table) R7.pack() close_button = Button(radioframe, text="OK", command=self.quit) close_button.pack() def quit(): self.quit() def string_table(self): self.val = self.mode.get() if self.val == 1: self.tbl = "Assignments" elif self.val == 2: self.tbl = "Companies" elif self.val == 3: self.tbl = "Earnings" elif self.val == 4: self.tbl = "Employees" elif self.val == 5: self.tbl = "Programs" print(self.tbl) elif self.val == 6: self.tbl = "Rates" elif self.val == 7: self.tbl = "SpecialRateTypes" global table table = self.tbl root = Tk() root.title("The Ryall Family Earnings") root.geometry("1250x650") #creation of an instance app = TheEarnings(root) root.mainloop()How do I specify what frame the radionbuttons go into. I tried to specifying the self.radioframe frame that is defined in the the __init__ routine. But it’s not working. How do I specify what frame it’s in for radiobuttons. I’m attaching a screenshot and the radio buttons are supposed to be in the power blue frame. It seems that the radio bottons are outsider the powder blue frame.
PS I tried posting with the screen shot but it isn't working