Created
March 24, 2024 21:52
-
-
Save vigilantPotato/8e81400afde67842a09f2e2cf6c07835 to your computer and use it in GitHub Desktop.
How to use sub-window
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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