1、python2如何导入tkinter模块
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 *
2、使用Messagebox
3、tkinter布置快捷键
示例绑定ctrl+a全选entry控件
root.bind('<Control-a>', eventhandler)
def eventhandler(event):
inp1.selection_range(0,len(inp1.get()))
网友评论