Skip to content

Instantly share code, notes, and snippets.

@vigilantPotato
Created March 24, 2024 21:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vigilantPotato/8e81400afde67842a09f2e2cf6c07835 to your computer and use it in GitHub Desktop.
Save vigilantPotato/8e81400afde67842a09f2e2cf6c07835 to your computer and use it in GitHub Desktop.
How to use sub-window
import ctypes
import tkinter
if __name__ == "__main__":
ctypes.windll.shcore.SetProcessDpiAwareness(1)
#main-window
root = tkinter.Tk()
root.title("main")
#label in main-window
l = tkinter.Label(
root,
text = "Label in main-window"
)
l.pack()
#sub-window
sub_window = tkinter.Toplevel(root)
sub_window.title("sub")
#label in sub-window
l_s = tkinter.Label(
sub_window, #set sub-window as master
text = "Label in sub-window",
bg = "lightblue",
)
l_s.pack()
root.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment