Tkinter TopLevel top of the window

I. Parameters

width  Set width
height  Set the height
background(bg) Background color setting
default values specified by the system
to prevent updates, the color value may be set to the empty string
borderwidth(bd) Set the border width
menu  Setting this option provides a menu bar for the Toplevel window
ADX  Margins in the horizontal direction
pads  Margin in the vertical direction
relief  Specifies the border style, in addition you can also set the "sunken", "raised", "groove" or "ridge" Note that if you want to set the border style, remember to set borderwidth or bd option is not zero, in order to see the border

Second, the sample code

TK Tkinter AS Import 

window tk.Tk = () 
# Set Window Size 
winWidth = 600 
winHeight = 400 
# screen resolution acquired 
screenWidth = window.winfo_screenwidth () 
screenHeight = window.winfo_screenheight () 

X = int ((screenWidth - winWidth) / 2) 
Y = int ((screenHeight - winHeight) / 2) 

# set the main window title 
window.title ( "TopLevel parameter Description") 
# initial position settings window centered on screen 
window.geometry ( "% sx% s + % s +% s "% (winWidth, winHeight, X, Y)) 
# set window icon 
window.iconbitmap (" ./ Image / icon.ico ") 
# setting window width and height fixed 
window.resizable (0, 0) 



DEF the Add (): 
    # create a top-level window 
    TOP_LEVEL = tk.Toplevel () 
    top_level.title ( "new window")
    
    tk.Label(top_level, text="i am yang").pack()
    
tk.Button(window, text="创建窗口", command=add).pack()

window.mainloop()

  

Third, renderings

 

 

 

Guess you like

Origin www.cnblogs.com/yang-2018/p/11796602.html