Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 [Tkinter] Checking button click in Tkinter
#1
Good evening everyone, I am trying to make a menu for one of my games. The idea is,

you see the start menu
you hit the start button
then it goes to the main game menu.

It seems simple but I have run into complications.

NOTE: I am new to Tkinter, I don't know any complicated workarounds, I am so new that you can tell my abilities from the code I have already written (for the most part). As it turns out, the transition from 3+ years of console to GUI is proving to be difficult

Here is my code:

import tkinter
from tkinter import *

#Window Setup

window = Tk()
window.title("WIP NAME")
window.geometry("650x400")

#Variables

Happy = 0 #Counter for the peoples opinion
Survival = 0 #Water, Food, etc.
Social = 0 #Events

Awards = 0 #Simply to keep the player playing

#Definitions

def mainmenu(): #main menu
    starttxt = Label(window, text = "WIP NAME") #text
    starttxt.pack()
    startbtn = Button(window, text = "START", command = gamestart) #starts the game (I want to check if this is pressed and then proceed to forget the pack if it is)
    startbtn.pack()
    
def gamestart(): #Starts the game
    Label(window, text = "itworked")
    
#mainloop

mainmenu()
window.mainloop()
Any pointers in the right direction would be greatly appreciated, thanks in advance.
steve_shambles likes this post
Quote
#2
You forgot to pack the label.

def gamestart(): #Starts the game
    lbl = Label(window, text="itworked")
    lbl.pack()
Quote
#3
it's cleaner to use a message box,
here's a simple working example:
import tkinter.messagebox as tm

tm.showinfo("gamestart","It worked")
   
steve_shambles likes this post
Quote
#4
(Oct-19-2019, 07:54 AM)Larz60+ Wrote: it's cleaner to use a message box,
here's a simple working example:
import tkinter.messagebox as tm

tm.showinfo("gamestart","It worked")

That was a placeholder
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Problem with Submit button Tkinter Reldaing 2 130 Jan-05-2020, 01:58 AM
Last Post: balenaucigasa
  [Tkinter] Mouse click event not working on multiple tkinter window evrydaywannabe 2 238 Dec-16-2019, 04:47 AM
Last Post: woooee
  tkinter button not accessing the command when clicked jhf2 1 191 Nov-23-2019, 10:17 PM
Last Post: DT2000
  Tkinter button in for Simpsunt 3 157 Nov-23-2019, 01:41 AM
Last Post: Larz60+
  [Tkinter] Tkinter button help and general commands Iceman 1 311 Sep-01-2019, 05:09 PM
Last Post: Yoriz
  [PyQt] Problem how to click a button inside a group box? mart79 2 297 Aug-05-2019, 01:21 PM
Last Post: mart79
  [PySimpleGui] How to alter mouse click button of a standard submit button? skyerosebud 3 515 Jul-21-2019, 06:02 PM
Last Post: FullOfHelp
  [Tkinter] Tkinter window pop up again when i click button Orimura_Sandy 1 758 May-12-2019, 08:17 PM
Last Post: joe_momma
  [Tkinter] Not getting entry values on button click & treeview not updating ? swanysto 4 1,544 May-10-2019, 04:16 PM
Last Post: swanysto
  tkinter- adding a new window after clicking a button built on the gui ShashankDS 2 1,549 Apr-18-2019, 12:48 PM
Last Post: ShashankDS

Forum Jump:


Users browsing this thread: 1 Guest(s)