-1

Here's an excerpt for a main menu using Python Tkinter

master = Tk()

lbl = Label(master, text = "Main Menu:")
lbl.grid(row=0,column=1)


def list():
    import list

listb = Button(master, text = "Patient List", command=list, width=10)
listb.grid(row=1, column=1)

There's a button "Patient List" that when pressed, opens a window specified from a different python file.

My problem is that the Main Menu window suffers a bug where the window will collapse. The new window comes out fine, but after closing it, I can't use my Main Menu.

Also, on my other buttons. The Main Menu doesn't collapse, but let's say I have a button Add Patient and after clicking it, the Add Patient window appears. It's functional. And then I close it, either using the quit button I programmed in it, or the close button. The Main Menu won't open the Add Patient window again.

So how can I smoothly navigate from one python program to another? Without the main menu collapsing. While being able to open a window over and over again.

My Patient List program has a lot of customized gui programming in it. I think it's because I use a grid in my Main Menu, and it's not a grid in my Patient List. But it shouldn't be affecting the Main Menu because they're supposed to be separate programs.

Zenon
  • 21
  • 1
  • 4
  • 1
    Calling your own module *and* function `list` is not a great idea, perhaps start by changing that? – jonrsharpe Feb 25 '15 at 08:56
  • same thing. Say I renamed it to look like this "def plist(): import patlist" It's the same thing. – Zenon Feb 25 '15 at 09:11
  • Yes, but then readers of your question don't have to spend time wondering why you've named them like that! Please read http://stackoverflow.com/help/mcve. You may also find http://stackoverflow.com/q/26213549/3001761 useful. – jonrsharpe Feb 25 '15 at 09:20

1 Answers1

0

When doing such program with TKinter I generally use Screen classes.

To your example it would be for example: "MainScreen", "AddPatienScreen", ...

All are subclass of the Frame tkinter class. My Tk app only display one screen and furnish function to destroy and replace one screen by another one.

I have not access to any code now, but I invite yourself to try this approach if you understand it. It lead to well separated code and had good results.

I may provide you a very short example if required.

Arthur Vaïsse
  • 1,551
  • 1
  • 13
  • 26
  • Obviously, this pattern let you add some functionalities such as "backward/forward" screen navigation by retaining a fixed size list of screen object that was displayed before. May be useful. – Arthur Vaïsse Feb 25 '15 at 09:10