0

I'm trying to set the width and the height for a Python GUI Application with tkinter. But it gets ignored, it also doesn't show any warnings or error messages.

I'm passing the root window in as master to my class. However when I set the width and height of the frame. It doesn't change the size of the screen. I'm experimenting with Python(C#, iOS background) and I can't figure out what i'm doing wrong. I saw a tutorial that did exactly the same as me, and he was able to set the height and width of the application with exactly the same code that I included below.

from tkinter import *   


class MainWindow:
    def __init__(self, master):
        frame = Frame(master, width=300,height =250)
        frame.pack()
        button1 = Button(frame, text="Click on me", command=self.btnLoginClicked)
        button1.pack(side=LEFT)

    def btnLoginClicked(self):
        Download.downloadFileFromUrl()

root = Tk()
w = MainWindow(root)
oot.mainloop()

Is this the right way to set the size of the window? Did I forget something or do I need to set it somewhere else?

EDIT: Below code does the job perfectly. So there might be a problem in my class

root = Tk()
frame = Frame(root, width=1000, height=700)
frame.pack()

root.mainloop()
Bas
  • 4,423
  • 8
  • 36
  • 53
  • _exactly_ the same code? That seems unlikely. If it was exactly the same code it would have exactly the same behavior. – Bryan Oakley May 26 '15 at 19:24
  • @BryanOakley It actually is the same code, speaking about setting the width and height! The problem apparently is in creating stuff like Buttons/Labels. The screen resizes to the size to fit the Button. – Bas May 26 '15 at 19:26

0 Answers0