0

I am trying to develop a GUI using Tkinter and Python2.7 by following a few tutorials and their documentation. Right now i am stuck on how to keep my frame a constant size (Because i want to have a nice background).

I have tried to use geometry() function from their documentation but always returns with an error - geometry attribute not found

import Tkinter as tk
import ttk

class Application(tk.Tk):

    def __init__(self, *args, **kwargs):

        # Initialize Tkinter 
        tk.Tk.__init__(self, *args, **kwargs)
        tk.Tk.wm_title(self, "ScraperBot")
        tk.Tk.geometry('250x250')       

        # Make a container
        container = tk.Frame(self)
        container.pack(side="top", fill="both", expand=True)
        container.grid_rowconfigure(0, weight=1)
        container.grid_columnconfigure(0, weight=1)

        # Define Frames

        self.frames = {}

        for myFrame in (HomePage, PageOne, PageTwo):
            frame = myFrame(container, self)
            self.frames[myFrame] = frame
            frame.grid(row=0, column=0, sticky="nsew")

        #  Which frame do we wanna display? 
        self.show_frame(HomePage)


    def show_frame(self, cont):
        frame = self.frames[cont]
        frame.tkraise()


class HomePage(tk.Frame):

    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)

        # Make a Label
        label = ttk.Label(self, text="HomePage", font=LARGE_FONT)
        label.pack(pady=10, padx=10) # Padding on top and bottom

        # Add a Button to navigate from one page to another
        button1 = tk.Button(self, text="Go to Page_1", fg="red", 
            command= lambda: controller.show_frame(PageOne))
        button1.pack()

                # Add a Button to navigate from one page to another
        button6 = tk.Button(self, text="Go to Page_2", fg="green", 
            command= lambda: controller.show_frame(PageTwo))
        button6.pack()


def button_Function(parameter):
    print(parameter)


app = Application()
app.mainloop()
Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
y_1234
  • 61
  • 1
  • 7
  • Possible duplicate of [How to make a Tkinter window not resizable?](https://stackoverflow.com/questions/37446710/how-to-make-a-tkinter-window-not-resizable) – Reblochon Masque Sep 07 '19 at 05:53
  • @ReblochonMasque I failed to understand in this answer how to integrate root.geometry() in my code. Maybe there is something i am missing fundamentally but am not quite sure. – y_1234 Sep 07 '19 at 07:44
  • you need to replace `tk.Tk.wm_title(self, "ScraperBot")` with `self.title("ScraperBot")` and `tk.Tk.geometry('250x250')` with `self.geometry('250x250')` – Reblochon Masque Sep 07 '19 at 13:41

0 Answers0