该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

代码如下:

#!/usr/bin/env python

#codec='utf-8'

import os

from time import sleep

from Tkinter import *

class DirList(object):

def __init__(self,initdir=None):

self.top=Tk()

self.label = Label(self.top,

text='Dirctory Lister v1.1')

self.label.pack()

self.cwd = StringVar(self.top)

self.dirl = Label(self.top,fg='blue',

font=('Helvetica',12,'bold'))

self.dirl.pack()

self.dirfm = Frame(self.top)

self.dirsb = Scrollbar(self.dirfm)

self.dirsb.pack(side=RIGHT, fill=Y)

self.dirs=Listbox(self.dirfm,height=15,

width=50,yscrollcommand=self.dirsb.set)

self.dirs.bind('',self.setDirAndGo)

self.dirsb.config(command=self.dirs.yview)

self.dirs.pack(side=LEFT,fill=BOTH)

self.dirfm.pack()

self.dirn = Entry(self.top,width=50,

textvariable=self.cwd)

self.dirn.bind('',self.doLS)

self.dirn.pack()

self.bfm = Frame(self.top)

self.clr = Button(self.bfm,text='Clear',

command=self.doLS,

activeforeground='white',

activebackground='green')

self.ls = Button(self.bfm,text='List Directory',

command=self.doLS,

activeforeground='white',

activebackground='green')

self.quit = Button(self.bfm,text='Quit',

command=self.top.quit,

activeforeground='white',

activebackground='red')

self.clr.pack(side=LEFT)

self.ls.pack(side=LEFT)

self.quit.pack(side=LEFT)

self.bfm.pack()

if initdir:

self.cwd.set(os.curdir)

self.doLS()

def clrDir(self,ev=None):

self.cwd.set('')

def setDirAndGo(self,ev=None):

self.last=self.cwd.get()

self.dirs.config(selecbackground='red')

check=self.dirs.get(self.dirs.curselection())

if not check:

check = os.curdir

self.cwd.set(check)

self.doLS()

def doLS(self,ev=None):

error=''

tdir=self.cwd.get()

if not tdir:

tdir=os.curdir

if not os.path.exists(tdir):

error = tdir + ':no such file'

elif not os.path.isdir(tdir):

error =tdir+':not a directory'

if error:

self.cwd.set(error)

self.top.upateo()

sleep(2)

if not (hastrrr(self,'last')\

and self.self.last):

self.last = os.curdir

self.cwd.set(self.last)

self.dirs.config(\

selectbackground='LightSkyBlue')

self.top.update()

return

self.cwd.set('FETCHING DIRCTORY CONTENTS...')

self.top.update()

dirlist=os.listdir(tdir)

dirlist.sort()

os.chdir(tdir)

self.dirl.config(text=os.getcwd())

self.dirs.delete(0,END)

self.dirs.insert(END,os.curdir)

self.dirs.insert(END,os.pardir)

for eachFile in dirlist:

self.dirs.insert(END,eachFile)

self.cwd.set(os.curdir)

self.dirs.config(\

selectbackground='LightSkyBlue')

def main():

d = DirList(os.curdir)

mainloop()

if __name__=='__main__':

main()

为什么python用不了中文_【TK例子】为什么不显示中文相关推荐

  1. Matplotlib:在图像上用中文进行标记时,不能显示中文,显示为方框

    Matplotlib:在图像上用中文进行标记时,不能显示中文,显示为方框 1.问题背景 2.解决方法 1.问题背景 首先,博主的系统环境如下: Win10 1709  教育版 Anaconda3-5. ...

  2. linux命令框显示中文乱码_CentOS终端命令行显示中文乱码的解决方法

    这篇文章主要介绍了CentOS终端命令行显示中文乱码的解决方法,以及测试方法和缺少中文字体时的解决方法,需要的朋友可以参考下 安装CentOS的时候选择了中文,结果在终端不能显示中文,都是乱码,解决方 ...

  3. python有中文无法保存_解决python3爬虫无法显示中文的问题

    解决python3爬虫无法显示中文的问题 有时候使用python从网站上爬数据的时候,如果数据里包含中文,有时候显示的却是如下所示...\xe4\xba\xba\xef\xbc\x8c\xe6...类 ...

  4. ajax后台返回数据中文乱码_解决Jmeter返回值显示中文乱码 的三种方法及设置随机动态参数(非原创侵删)...

    一.Jmeter返回值显示中文乱码解决方法 第一种解决方法: 1. 点击线程组--添加--后置处理器--BeanShell后置处理程序 2.点击BeanShell后置处理程序,编写:prev.setD ...

  5. python画图显示不了中文_Python使用matplotlib绘图无法显示中文问题的解决方法

    本文实例讲述了Python使用matplotlib绘图无法显示中文问题的解决方法.分享给大家供大家参考,具体如下: 在python中,默认情况下是无法显示中文的,如下代码: import matplo ...

  6. python微软雅黑字体_win10+python3.7下matplotlib显示中文,可使用微软雅黑.md

    win10+python3.7下matplotlib显示中文,可使用微软雅黑和思源黑体 更新时间20200109 网上很多教程,基本上都没用有效解决win10下matplotlib显示中文雅黑的问题, ...

  7. pandas 作图 统计_解决pandas 作图无法显示中文的问题

    最近开始使用 pandas 处理可视化数据,挖掘信息.但是在作图时遇到,无法显示中文的问题. 下面这段代码是统计 fujian1.csv 文件中 City 所在列中各个城市出现次数的代码.可是作图直方 ...

  8. python plot如何保存图片_Matplotlib 保存图片、图画接口和显示中文的使用方法

    一.保存图片 可以通过savefig()方法,将绘制的图形保存为文件: importnumpy as npimportmatplotlib.pyplot as plt x= np.linspace(0 ...

  9. Python数据可视化——matplotlib绘制的图里面不能正常显示中文,提示警告的解决方法

    运行下列代码: import matplotlib.pyplot as pltedu = [0.2515,0.3724,0.3336,0.0368,0.0057] labels = ['中专','大专 ...

  10. 服务器不能显示中文,彻底解决delphi WebBroker服务器中文乱码 delphi WebBroker服务器不能显示中文网页 WebBroker中文显示乱码...

    彻底解决delphi WebBroker服务器中文乱码 彻底解决WebBroker中文显示乱码 彻底解决delphi WebBroker服务器不能显示中文网页 这个问题被折腾惨啦! 网上一大堆,就没能 ...

最新文章

  1. c # 学习笔记(一)
  2. Oracle CEO狂妄而真实的演讲
  3. 2.2.2 指数加权平均
  4. ssd3 employee.java_SSD3Panswers icarnegie ssd3的所有答案~十分齐全 - 下载 - 搜珍网
  5. Java的重写和重载机制
  6. 飞控所有PID参数都无法消除振荡问题
  7. IXMLDOMDocument 成員
  8. java 获取rss_如何使用java代码获取RSS中信息
  9. parallels网络初始化失败_出神入化:特斯拉AI主管、李飞飞高徒Karpathy的33个神经网络炼丹技巧...
  10. poj 2376 bzoj 3389: [Usaco2004 Dec]Cleaning Shifts安排值班(贪心)
  11. 企业如何从大数据系统中获益
  12. 精心收集的 48 个 JavaScript 代码片段,仅需 30 秒就可理解
  13. 解决更改文件扩展名,文件类型没有发生变化的问题
  14. 博友关于炒股理念的思考
  15. java 视频转换 avi 转 MP4
  16. yourls短链接项目部署及API使用
  17. SYS/BIOS内存分配相关问题
  18. 西工大c语言考试历年试题,西工大C语言上机考试题库
  19. 用canvas画阴阳鱼
  20. 如何策划新闻稿,低成本实现品牌影响力增长

热门文章

  1. 安检x光机原理计算机实现,安检x光机成像原理介绍
  2. Windows服务的安装,启动,停止和卸载
  3. 7月10日云栖精选夜读丨ApsaraCache开源之路,阿里云Redis团队LC3全球顶级开源峰会获CRUG开源社区最具影响力奖...
  4. TypeScript 类型兼容
  5. 访谈:摩尔定律后时代,看13位行业专家如何看量子计算机的未来?
  6. FreeMarker 一二事 - 静态模板的使用与生成
  7. 关于滑动条滚动 scroll兼容
  8. load average
  9. 小白学数据分析-----Excel制作INFOGRAPHIC
  10. 有些话不知道怎么说才好