I make a simple GUI program:
Entry and Button objects that are next to each other must be three cells lower. How to do it? Here is the code itself:
from tkinter import * class Shell(Frame): def __init__(self, window): super().__init__(window) self.grid() self.__clicked = 0 self.__init_widgets() def __init_widgets(self): self.__lbl = Label(self, text = "Button clicked: " + str(self.__clicked)) self.__lbl.grid(row = 0, column = 0, columnspan = 2, sticky = W) self.__btn = Button(self, text = "Click on me", command = self.__clicker) self.__btn.grid(row = 0, column = 2, columnspan = 2, sticky = W) self.__ent = Entry(self) self.__ent.grid(row = 3, column = 0, columnspan = 2, sticky = W) self.__ent_button = Button(self, text = "Enter", command = self.__input_bold) self.__ent_button.grid(row = 3, column = 2, sticky = W) self.__fuck_label = Label(self, text = "Hey, bitch") self.__fuck_label.grid(row = 5, columnspan = 3) def __clicker(self): self.__clicked += 1 self.__lbl["text"] = "Button clicked: " + str(self.__clicked) def __input_bold(self): if self.__ent.get() == "Fuck you": self.__fuck_label["text"] = "O_0" else: self.__fuck_label["text"] = "What a fuck did you say?!" if __name__ == "__main__": main_window = Tk() main_window.title("Clicker") main_window.geometry("200x200") shell = Shell(main_window) main_window.mainloop() 