Python Forum
[Tkinter] [split] [split] How to make a window stay on top
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] [split] [split] How to make a window stay on top
#2
Does this answer your question?

from tkinter import Tk, Toplevel, Button, Label 

def open_a_toplevel_window (title_number: int) :
	this_windows_title = f'Toplevel Window Number {title_number}'
	toplevel_window = Toplevel (root)
	toplevel_window.title (this_windows_title)
	x = root.winfo_x () + title_number * 30
	y = root.winfo_y () + title_number * 10 
	toplevel_window.geometry (f'270x100+{x}+{y}')
	label = Label(toplevel_window, text = this_windows_title)
	button1 = Button(toplevel_window, text = "open next window")
	n = title_number + 1
	button1.config (command = lambda n = n: open_a_toplevel_window (n))
	button2 = Button (toplevel_window, text = "Exit")
	button2.config (command = toplevel_window.destroy)
	label.pack()
	button1.pack()
	button2.pack()
	toplevel_window.attributes ('-topmost', True)
	toplevel_window.mainloop()

n = 1
root = Tk ()
root.title ("Root Window")  
root.geometry ("400x200")  
label1 = Label (root, text = "This is the Root Window")
button = Button (root, text = "Open Toplevel Windows")
button.config (command = lambda n = n: open_a_toplevel_window (n))
label1.pack ()
button.place (x = 110, y = 50)
root.mainloop ()
Reply


Messages In This Thread
RE: [split] [split] How to make a window stay on top - by BashBedlam - Apr-24-2021, 01:48 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Interaction between Matplotlib window, Python prompt and TKinter window NorbertMoussy 3 733 Mar-17-2024, 09:37 AM
Last Post: deanhystad
  [Tkinter] [split] I want to add a code to the "Save" button to save the data entered LOO 1 2,058 Jan-23-2023, 05:31 PM
Last Post: deanhystad
Question [Tkinter] How to make split button? teknixstuff 2 1,125 Jan-03-2023, 06:21 PM
Last Post: Yoriz
  [split] .delete and .insert not working brigette 5 2,101 Jul-21-2022, 07:46 PM
Last Post: menator01
  [Tkinter] [split] Is there a way to embed a treeview as a row inside another treeview? CyKlop 5 3,473 Oct-20-2021, 12:14 AM
Last Post: CyKlop
  Trying to make random image loop in Tk window using python Jediguy18 1 3,269 Dec-30-2020, 04:56 AM
Last Post: deanhystad
  [Tkinter] How to make message box error stay on top of window scratchmyhead 1 8,461 May-10-2020, 10:21 PM
Last Post: scratchmyhead
  tkinter window and turtle window error 1885 3 6,834 Nov-02-2019, 12:18 PM
Last Post: 1885
  [split] Closing a window but not the whole program scriptdrache 1 2,376 Jun-25-2019, 03:43 PM
Last Post: joe_momma
  [split] What is a GUI's mainloop ? kom2 1 2,811 May-04-2019, 01:58 PM
Last Post: Yoriz

Forum Jump:

User Panel Messages

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