Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am new to Python, trying to make the Launch TFL App button open another GUI called "Menu GUI" but I don't know what to do for the def open_Menu(): function below. I want to use the popup GUI below as a launcher which takes the user to my main GUI. The only problem with the code below is that the button for launch TFL app doesn't do anything when you click it. Here's my current code :

How can I implement open_menu()

What I have tried:

Python
from tkinter import *


root = Tk()

root.title('TFL App')

p = Label(root, text = "TFL Journey Planner", height = "18", width = "250", bg = 'brown', fg = 
'white',
      font = ('Helvetica', '20', 'bold', 'italic'))
p.pack()
root.configure(bg = 'brown')
root.geometry('400x700')

photo = PhotoImage(file = 'trainstation.png')
label = Label(root, image = photo)

label.pack()


****#Buttons****

def open_Menu():
    
    

Button1 = Button(root, text = "Launch TFL App", command = open_Menu, bg = "black", fg = 'white', padx 
 = 40,
             pady = 10,
             font = ('Calibri Light', '15', 'bold'))
Button1.pack(padx = 25, pady = 0)


Button2 = Button(root, text = "Exit ", command = root.destroy, bg = "black", fg = 'white', padx = 65, 
pady = 8,
             font = ('Calibri Light', '15', 'bold'))
Button2.pack(padx = 25, pady = 10)

root.mainloop()
Posted
Updated 11-Nov-20 4:05am
v7
Comments
Richard MacCutchan 7-Nov-20 4:11am    
"but it doesn't work."
Sorry, but we are not mind readers. Please use the Improve question link above and explain in detail exactly what the problem is, and where it occurs.
Richard MacCutchan 11-Nov-20 9:34am    
Well you have changed much of the question but not really explained what the issue is. And you have now removed MainMenu(): and replaced it with open_Menu(): but that also does nothing. You need to add some code to do whatever open_Menu is supposed to do.
[no name] 11-Nov-20 9:47am    
The code above is for my first GUI and everything works except the "Launch TFL App" Button. I am trying to create a function that allows the def open_Menu():, to open my main GUI through the "Launch TFL App" Button on my first GUI.
Richard MacCutchan 11-Nov-20 9:54am    
Yes, because open_Menu does not do anything.
[no name] 11-Nov-20 10:06am    
would this work?
def OpenMenu():
import Menu

OK, so a longer look at the code reveals that your program is designed to do nothing.
1. The definition of the launcher button:
Python
button = Button(root, text = 'Launch TFL App', command = MainMenu, bg = "black", fg = 'white', padx = 
which calls the function MainMenu.

2. The definition of MainMenu
Python
def MainMenu():
    pass # which means "do nothing".
 
Share this answer
 
v3
I strongly suggest you go to Graphical User Interfaces with Tk — Python 3.7.9 documentation[^] and see how to construct a well ordered tk application.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900