Packaging a simple Python library with GUI component

I will share a code sketch below. It has 3 simple parts. I'm trying to go from an amateur piece of one-page code to a professionally structured program.

I'm really confused about placement of the GUI related parts in the code. This is my first packaging and I will really appreciate if someone with experience can comment. I imagine it's a simple question to answer for someone with more experience than I.

Here is the hypothetical code:

class Moon:

    def(greet):
        print(b)

#GUI Window
layout=["Some_Button"]
window=(layout)

#Event Loop
while True:
    window.read()
    a="Hello World"
    b="Hello Moon"
    Moon.abc()

So, this code has 3 main blocks, if you will:

  1. User defined function (does the actual job)
  2. GUI Window construction
  3. Event Loop
    • Opens GUI window
    • Assigns variables from GUI input - Calls user defined function

Now guys, I'm really confused about where to put my GUI window(2) and Event Loop(3) while packaging. If I put them in a user-defined function code breaks. Because, variables won't be returned.

  • Do I put GUI parts (2 & 3) in a user defined function and call it later?
  • Do I put GUI parts in a different file?
  • Does it go in init.py?
  • Do I put this whole thing in one file?

Ideally I want the user to be able to type this, evoke GUI window and get results:

Moon.greet()

You can tell I'm confused about packaging and appropriate way of constructing this. Otherwise the code runs perfectly as is. I'm at a tipping point about packaging and it will be a new level for me. Help is much appreciated.

Thank you very much.