tkinter是内置的模块,不同的版本的导入形式不同,现总结如下

#coding=utf-8

import os, sys
try:
    from tkinter import *
except ImportError:  #Python 2.x
    PythonVersion = 2
    from Tkinter import *
    from tkFont import Font
    from ttk import *
    from tkMessageBox import *
    import tkFileDialog
else:  #Python 3.x
    PythonVersion = 3
    from tkinter.font import Font
    from tkinter.ttk import *
    from tkinter.messagebox import *

 

posted @ 2018-09-19 14:18  香菜哥哥  阅读(1340)  评论(0编辑  收藏  举报