Home > other >  Python's grid of tkinter always can not get the desired results
Python's grid of tkinter always can not get the desired results

Time:09-21

Excuse me each warrior, I want to show the label on the right of time, to the left of the label with the rest of the how to do, I don't always show right

 
The import time
The import tkinter as tk

The class Application () :
# define main form
Def __init__ (self, root) :
# call create_statusbar, generate the status bar
Self. Create_statusbar ()

# define application form title
Root. Title (' my Python programs')

# define application form size, starting position
Root. Geometry (' 1000 x300 ')
Root. The anchor (the 'center')

# define status bar
Def create_statusbar (self) :
# to add a Frame container
Self. TheFrame=tk. Frame (root, height=1, bd=1, relief='sunken')
Self. TheFrame. Pack (side='bottom', the fill='x')
# display date, time
Date_time_now=time. Strftime (" % d % % m Y year month day % H: % m: % S ', and time. The localtime ())
Self. Date_time_label=tk. Label (self theFrame, text=date_time_now, fg='red')
Self. Date_time_label. Config (width=30, anchor='c')
Self. Date_time_label. The grid (row=0, the column=1, sticky='e', padx=2)
# show filename
Self. Filename_label=tk. Label (self) theFrame, text='good')
Self. Filename_label. The grid (row=0, the column=0, padx=2, sticky='we')

If __name__=="__main__ ':
Root=tk. Tk ()
App=Application (root)
Root. Mainloop ()
  • Related