窗体显示


显示结果
1.jpg
button显示的是
2.jpg
这个是可以点击的 主要是没有那个事件绑定所以没有啥事只有点击之后啥都没有啦
我每一部分都用的一个主程序
所以看着会比较乱但是不影响复习
源代码奉上

# -*-coding=utf-8-*-
# 时间:2021/4/25;20:14
# 编写人:刘钰琢
import tkinter
LOGO_PATH = 'resources/2.ico'  # 文件路径`
# LOGO_PATH='resources'+os.sep+'2.ico'
Img_path = 'resources/tu.png'
class MainForm:
    def __init__(self):
        # root=tkinter.Tk()
        # root.title("lyz")
        # root.mainloop()
        root = tkinter.Tk()  # 创建一个窗体
        root.title('my frist tk')  # 标题
        root.iconbitmap(LOGO_PATH)  # 设置logo资源
        # 这里的ico文件不能直接更高后缀 要通过转移网站进行转到ico文件才可已实现
        # 要不然能运行时能运行,只是logo那一块只是会变成一块白板
        root.geometry('800x600')
        root.minsize(800, 600)
        root.maxsize(1750, 883)
        root['background'] = "LightSlateGray"
        # text = tkinter.Text(root, width=50, height=15, font=('微软雅黑', 20))
        # text.insert(tkinter.CURRENT, '刘钰琢:')  # tkinter.COURRENT="courent"
        # # 如果想要进行图片的加载一定要通过专属的组件类进行了路径的包装
        photo = tkinter.PhotoImage(file=Img_path)
        # text.image_create('end', image=photo)
        # # # label_photo = tkinter.Label(root, resources=photo)
        # # # label_text.pack()
        # text.pack()
        # # label_photo.pack()
        # # label_text.pack()
        button=tkinter.Button(root,text="吐了",image=photo,compound="bottom",fg="black",font=("微软雅黑",20))
        button.pack()
        root.mainloop()  # 显示窗体
        # 这个都属于是python的默认形式
def main():
    MainForm()
if __name__=='__main__':
    main()

文章作者: 毛豆不逗比
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 毛豆不逗比 !
  目录
{% include '_third-party/exturl.swig' %} {% include '_third-party/bookmark.swig' %} {% include '_third-party/copy-code.swig' %} + {% include '_custom/custom.swig' %}