Python Forum
[Tkinter] bind lambda keypress counter
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] bind lambda keypress counter
#13
This may help you figure out what you are looking for.
A splash screen will show and close automatically after a delay, then the main window that has a button to open up a second window.
import tkinter as tk


class TkApp(tk.Tk):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.geometry('300x300')
        tk.Label(self, text='MainFrame').pack()
        tk.Button(self, text='SecondFrame', command=self.on_button).pack()
        self.create_splashframe()

    def create_splashframe(self):
        splashframe = SplashFrame(self)
        self.withdraw()
        self.wait_window(splashframe)
        self.deiconify()

    def on_button(self):
        secondframe = SecondFrame(self)
        self.withdraw()
        self.wait_window(secondframe)
        self.deiconify()


class SplashFrame(tk.Toplevel):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        tk.Label(self, text='SplashFrame').pack()
        self.geometry('200x200')
        self.overrideredirect(True)
        self.after(3000, self.destroy)


class SecondFrame(tk.Toplevel):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.geometry('300x300')
        tk.Label(self, text='SecondFrame').pack()
        tk.Button(self, text='Close', command=self.destroy).pack()


tk_app = TkApp()
tk_app.mainloop()
Note this post is going off-topic, has the original question been resolved?
Reply


Messages In This Thread
bind lambda keypress counter - by knoxvilles_joker - Apr-11-2021, 01:02 AM
RE: tkinter bind lambda keypress counter - by Yoriz - Apr-11-2021, 10:16 AM
RE: tkinter bind lambda keypress counter - by Yoriz - Apr-11-2021, 10:57 PM
RE: bind lambda keypress counter - by Yoriz - Apr-12-2021, 06:03 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] bind menator01 1 1,274 Apr-15-2022, 08:47 PM
Last Post: menator01
  update text variable on label with keypress knoxvilles_joker 3 4,973 Apr-17-2021, 11:21 PM
Last Post: knoxvilles_joker
  [Tkinter] Mouse click without use bind ATARI_LIVE 8 7,556 Oct-23-2020, 10:41 PM
Last Post: ATARI_LIVE
  [Kivy] AttributeError: 'NoneType' object has no attribute 'bind' faszination_92 2 6,312 Apr-12-2020, 07:01 PM
Last Post: Larz60+
  [WxPython] Bind error PeterLinux 1 2,268 Apr-06-2020, 03:07 AM
Last Post: joe_momma
  Tkinter:Unable to bind and unbind function with a button shallanq 2 5,074 Mar-28-2020, 02:05 AM
Last Post: joe_momma
  [Tkinter] How to bind an event when enter is pressed on a Entry control? Michael4 4 3,986 Aug-29-2019, 10:11 PM
Last Post: Michael4
  Update plot by <Return> bind with entry widget Zorro 1 4,163 Mar-09-2019, 12:27 PM
Last Post: Zorro
  Bind only fires off once? WuchaDoin 3 4,524 Dec-18-2018, 07:46 PM
Last Post: buran
  [WxPython] bind label and entry text with return key metulburr 1 3,299 Aug-14-2018, 10:02 PM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020