Do interface, you first need to create a window, Python Tkinter windows create a very simple :( note, Tkinter package name because of differences in the different versions of Python, there are two: Tkinter and tkinter, readers discover if the program can not run, you can try switching package name)
Import the Tkinter * from # initialization Tk () myWindow = Tk () # enter the message loop myWindow.mainloop ()
Window above procedure is very simple to create, pending further beautify, set the title, window size, window is variable, involving attributes: title (setting the window title); geometry (set the window size); resizable (whether the window can be set changes in length and width) the following examples:
Import the Tkinter * from # initialization Tk () myWindow = Tk () # Set Title myWindow.title ( 'KKconfigmenu') # Set Window Size myWindow.geometry ( '380x300') # window settings are variable length, width, True: available change, False: immutable myWindow.resizable (width = False, height = True) # enter the message loop myWindow.mainloop ()
Further, the window is placed in the center of the screen, the following examples:
Import the Tkinter * from # initialization Tk () myWindow = Tk () # Set Title myWindow.title ( 'KKconfigMenu') # size setting window width = 380 height = 300 # screen size acquired layout parameters to calculate the center of the screen window ranking screenwidth myWindow.winfo_screenwidth = () screenHeight = myWindow.winfo_screenheight () alignstr = 'DX%%% D + D + D%'% (width, height, (ScreenWidth-width) / 2, (screenHeight-height) / 2) myWindow.geometry (alignstr) # set window is variable length, width, True: variable, False: immutable myWindow.resizable (width = False, height = True) # enter the message loop myWindow.mainloop ()