Skip to content Skip to sidebar Skip to footer

Simple Python Gui Program Won't Run, Says Restart

I'm trying to create a python program that pulls up a simple window that displays the text 'Hello World?' I've imported tkinter and have created a class called MyGUI that should cr

Solution 1:

The good news:

  • Your code works (in that it doesn't crash in python3, as is)!

The bad news:

  1. Your code doesn't do anything :( Your only function would raise an exception if called
  2. You have a code-unrelated problem

To resolve problem #1, change init to __init__ and tkinter.tk to tkinter.Tk()

__init__ is the function called by default on instance construction. The underscores are important if you want to override it. The other issue is just a typo.

You're broader problem is... broader. yes it matters where you save your file. If you don't save it in the place you are running python from, you need to supply an absolute path to it, or a relative path from the place you are running from. This is a broad topic, but pretty important and not too challenging. Maybe try here, or any python tutorial.

I don't know what type F5 does on your computer. I would not in general expect it to run python code. Are you in an IDE, then maybe it does run python code? Are you playing call of duty, because then it's more likely to lob a virtual grenade? F5 is app-dependent, probably not a universal binding on your machine

Post a Comment for "Simple Python Gui Program Won't Run, Says Restart"