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
  Tkinter:Unable to bind and unbind function with a button shallanq 2 112 Mar-28-2020, 02:05 AM
Last Post: joe_momma
  Returning a value from a tkinter.button call markr0804 4 233 Feb-16-2020, 10:35 AM
Last Post: markr0804
  Problem with Submit button Tkinter Reldaing 2 205 Jan-05-2020, 01:58 AM
Last Post: balenaucigasa
  [Tkinter] Mouse click event not working on multiple tkinter window evrydaywannabe 2 428 Dec-16-2019, 04:47 AM
Last Post: woooee
  tkinter button not accessing the command when clicked jhf2 1 292 Nov-23-2019, 10:17 PM
Last Post: DT2000
  Tkinter button in for Simpsunt 3 254 Nov-23-2019, 01:41 AM
Last Post: Larz60+
  [Tkinter] Tkinter button help and general commands Iceman 1 415 Sep-01-2019, 05:09 PM
Last Post: Yoriz
  [PyQt] Problem how to click a button inside a group box? mart79 2 394 Aug-05-2019, 01:21 PM
Last Post: mart79
  [PySimpleGui] How to alter mouse click button of a standard submit button? skyerosebud 3 675 Jul-21-2019, 06:02 PM
Last Post: FullOfHelp
  [Tkinter] Tkinter window pop up again when i click button Orimura_Sandy 1 903 May-12-2019, 08:17 PM
Last Post: joe_momma

Forum Jump:


Users browsing this thread: 1 Guest(s)