此文实例介绍了Python GUI编程。推荐给大伙学习一下,内容如下:
import os
from time import sleep
from tkinter import *
from tkinter.messagebox import showinfo
class DirList(object):
def __init__(self, initdir=None):
self.top = Tk()
self.label = Label(master=self.top, text='Directory Lister V1.0')
self.label.pack()
self.cwd = StringVar(master=self.top)
self.dirl = Label(self.top, fg='blue', font=('Helvetica', 14, 'bold'))
self.dirl.pack()
self.dirfm = Frame(master=self.top)
self.dirsb = Scrollbar(master=self.dirfm)
self.dirsb.pack(side=RIGHT,fill=Y) # fill=Y,垂直填充空间排列
self.dirs = Listbox(master=self.dirfm, height=15, width=50, yscrollcommand=self.dirsb.set)
self.dirs.bind('', func&