0

Running VSCode with MS Python extension and my window will not display here's my code

import tkinter as tk

class FormMain:

    def __init_(self):
        self.build_controls()


    def build_controls(self):
      self.form_main = tk.TK()
      self.form_main.title("Staff Manager")
      
      self.form_main.mainloop()


form = FormMain()
1
  • 1
    __init_ should be __init__ instead. Commented Nov 14 at 11:25

1 Answer 1

1

First issue might be that you have to call the function. You have only defined it, without running it. So add the line at the bottom of your code:

form.build_controls()

Another issue might be that this line may have a casing issue:

self.form_main = tk.TK()

may have to be (note Tk()):

self.form_main = tk.Tk()

Does this help you out?

And to add, there may be a misspelling in the __init__() method, but that may also be the result of formatting on this website.

Sign up to request clarification or add additional context in comments.

2 Comments

Fantastic! That work. I corrected the TK() to Tk() and called the function.
When I used two underscores before and after the init in the def statement I did not need tor run the function

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.