Tkinter coding style

Divided into three parts, the top is to create the drawing board is an intermediate material (various controls) on a drawing board, the bottom is finished showing Artboards.
In an example Tkinter Label two kinds of coding style module, other components are also similar.
 
Style 1
import Tkinter as tk
window = tk.Tk () #Tk () to add before the module name.
window.title('My Window')
window.geometry('600x800')  
 
tk.Label (text = '123'). pack () to add before the control module # name.
 
window.mainloop ()
 
 
Style 2
from Tkinter import *
window = Tk () #Tk without module name () before.
window.title('My Window')
window.geometry('600x800')  
 
Label (text = '123'). Pack () without prior control module # name.
 
window.mainloop ()
 
 
DETAILED line semantics are the same, defined as below:
import Tkinter as tk
window=tk.Tk()  
# Instantiated object, create a window window. Note Tk case.
window.title('My Window')  
# To the visualization window of a name.
window.geometry('600x800')  
# Set the window size (L * W). Take note here is the small x.
 
Middle ...... various controls slightly ......
 
window.mainloop ()  
# Loop display main window. All the windows file must have a similar function mainloop, mainloop is the key to the key file window.
# Note, loop the loop because it is meant, window.mainloop will make window constantly refresh, if not mainloop, is a static window, there will be a value passed into circulation, mainloop the equivalent of a big while loop, there is a while, each click will be updated once, so we must have a cycle
 
 

Guess you like

Origin www.cnblogs.com/myshuzhimei/p/11764420.html