#encoding=utf-8
import tkinter
import re
import tkinter.messagebox
import tkinter.simpledialog
import sys
import os
def get_resources_path(relative_path):
if getattr(sys,'frozen', False):
base_path=sys._MEIPASS#获取临时文件
else:
base_path=os.path.dirname(".")
return os.path.join(base_path,relative_path)
Logopath=get_resources_path(os.path.join("resources",'heart.ico'))
startpath=get_resources_path(os.path.join("resources",'3.png'))
circlepath=get_resources_path(os.path.join("resources",'4.png'))
duopath=get_resources_path(os.path.join("resources",'5.png'))
imgpath=get_resources_path(os.path.join("resources",'01.png'))
class MainForm:#定义窗体类
def __init__(self):
self.root=tkinter.Tk()#创建一个窗体
self.root.title("Katetesting")#设置标题
self.root.iconbitmap(Logopath)
self.root.geometry("500x700")
self.root.maxsize(1000,1000)
self.root.resizable(False,False)
self.canvas=tkinter.Canvas(self.root,height=700,width=500)
self.image=tkinter.PhotoImage(file=imgpath)
self.canvas.create_image(0,0,anchor=tkinter.NW,image=self.image)
self.canvas.create_rectangle(20,30,230,250,fill="yellow")
self.canvas.create_text(130,50,text="Hello World",fill="green",font=("微软雅黑",23))
self.canvas.pack()
self.root.mainloop()#显示窗体
def main():
MainForm()
if __name__=="__main__":
main()
08-17
1007
