会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132655个问题

老师,使用面向对象的方法实现的话,只能是这样吗?我自己觉着要是像课件里讲的调用两个Frame,只能是定义两个类。求解惑!!!

"""测试pack布局管理器"""

from tkinter import *


class Application(Frame):

    def __init__(self, master=None):
        super().__init__(master)          # super()代表的是父类的定义,而不是父类对象
        self.master = master
        self.pack()                       # 调用布局管理器
        self.create_widget()

    def create_widget(self):
        btnText = ("流行风", "中国风", "日本风", "重金属", "轻音乐")

        for txt in btnText:
            Button(self, text=txt).pack(side="left", padx="10")


class Application2(Frame):

    def __init__(self, master=None):
        super().__init__(master)  # super()代表的是父类的定义,而不是父类对象
        self.master = master
        self.pack()  # 调用布局管理器
        self.create_widget()

    def create_widget(self):
        for i in range(1, 15):
            Button(self, width=5, height=10, bg="black" if i % 2 == 0 else "white").pack(side="left")


if __name__ == "__main__":
    root = Tk()                           # 创建根窗口对象
    root.geometry("700x200+200+300")
    app = Application(master=root)
    app2 = Application2(master=root)
    root.mainloop()                       # 调用组件的mainloop(),进入时间循环


Python 全系列/第二阶段:Python 深入与提高/GUI编程(隐藏) 1742楼
Python 全系列/第二阶段:Python 深入与提高/文件处理 1744楼
Python 全系列/第二阶段:Python 深入与提高/GUI编程(隐藏) 1746楼

老师 ,我照着高淇老师上传的模块显示,上传失败是怎么回事

1、Microsoft Windows [版本 10.0.18363.1379]
(c) 2019 Microsoft Corporation。保留所有权利。

(mypro-modules) C:\Users\lzh\Desktop\资料\mypro-modules\math3>python setup.py sdist upload
running sdist
running check
warning: check: missing required meta-data: url

warning: sdist: manifest template 'MANIFEST.in' does not exist (using default file list)

warning: sdist: standard file not found: should have one of README, README.txt, README.rst

writing manifest file 'MANIFEST'
creating baizhanSuperMath-1.0
creating baizhanSuperMath-1.0\baizhanSuperMath
making hard links in baizhanSuperMath-1.0...
hard linking setup.py -> baizhanSuperMath-1.0
hard linking baizhanSuperMath\__init__.py -> baizhanSuperMath-1.0\baizhanSuperMath
hard linking baizhanSuperMath\demo1.py -> baizhanSuperMath-1.0\baizhanSuperMath
hard linking baizhanSuperMath\demo2.py -> baizhanSuperMath-1.0\baizhanSuperMath
Creating tar archive
removing 'baizhanSuperMath-1.0' (and everything under it)
running upload
Submitting dist\baizhanSuperMath-1.0.tar.gz to https://upload.pypi.org/legacy/
Upload failed (400): Invalid value for blake2_256_digest. Error: Use a valid, hex-encoded, BLAKE2 message digest.
error: Upload failed (400): Invalid value for blake2_256_digest. Error: Use a valid, hex-encoded, BLAKE2 message digest.

(mypro-modules) C:\Users\lzh\Desktop\资料\mypro-modules\math3>

就显示失败 什么原因啊

image.png

Python 全系列/第二阶段:Python 深入与提高/模块 1747楼
Python 全系列/第二阶段:Python 深入与提高/GUI编程(隐藏) 1748楼
Python 全系列/第二阶段:Python 深入与提高/(旧)坦克大战 1749楼
Python 全系列/第二阶段:Python 深入与提高/模块 1750楼
Python 全系列/第二阶段:Python 深入与提高/游戏开发-坦克大战 1751楼
Python 全系列/第二阶段:Python 深入与提高/游戏开发-坦克大战 1752楼
Python 全系列/第二阶段:Python 深入与提高/模块 1753楼
Python 全系列/第二阶段:Python 深入与提高/GUI编程(隐藏) 1755楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637