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

代码

from tkinter import *
from tkinter import messagebox
from random import randint


class Application(Frame):

    def __init__(self, master=None):
        super().__init__(master)
        self.master = master
        self.pack()

    def creat_weight(self):
        self.label = Label(self, text="生成的数字").grid(row=0, column=0)

        self.text1 = Text(self, width=20, height=1, bg="gray", font=("黑体", 30)).grid(row=0, column=1)

        self.label2 = Label(self, text="输入你的数字").grid(row=1, column=0)

        v2 = StringVar()
        self.entry2 = Entry(self, textvariable=v2, font=("黑体", 30)).grid(row=1, column=1)

        self.btn1 = Button(self, text="生成数字", command=self.randint1).grid(row=2, column=1, sticky=W)

        self.btn2 = Button(self, text="—确定—", command=self.judge).grid(row=2, column=1)

    def randint1(self):
        self.text1.delete(1.0, END)
        num = randint(100000, 999999)
        self.text1.insert(1.7, str(num))

    def judge(self):
        if int(self.entry2.get()) == int(self.text1.get(1.7, END)):
            messagebox.showinfo("提示", "right")
        else:
            messagebox.showinfo("提示", "wrong")

        print(self.text1.get(1.7, 1.13))
        print(self.entry2.get())


if __name__ == '__main__':
    root = Tk("entry_test")
    root.geometry("500x300+200+100")
    app = Application(master=root)
    app.creat_weight()
    root.mainloop()

运行截图

image.png

按下  生成数字之后出现下列错误


image.png

Python 全系列/第二阶段:Python 深入与提高/GUI编程(隐藏) 36993楼
JAVA 全系列/第四阶段:数据库与AI协同技术实战/JDBC技术 36994楼
JAVA 全系列/第二十二阶段:分布式医疗云平台/系统管理前后端开发(旧) 36995楼
JAVA 全系列/第十一阶段:分布式RPC调用和分布式文件存储/Swagger 36996楼
Python 全系列/第一阶段:Python入门/编程基本概念 36999楼
Python 全系列/第一阶段:Python入门/序列 37000楼

在mac下会报错 没有join的情况,为什么报如下的错误:

Traceback (most recent call last):

  File "<string>", line 1, in <module>

  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/spawn.py", line 116, in spawn_main

Traceback (most recent call last):

      File "<string>", line 1, in <module>

exitcode = _main(fd, parent_sentinel)

  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/spawn.py", line 126, in _main

  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/spawn.py", line 116, in spawn_main

    self = reduction.pickle.load(from_parent)

  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/synchronize.py", line 110, in __setstate__

    exitcode = _main(fd, parent_sentinel)

  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/spawn.py", line 126, in _main

    self = reduction.pickle.load(from_parent)

  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/synchronize.py", line 110, in __setstate__

    self._semlock = _multiprocessing.SemLock._rebuild(*state)

FileNotFoundError: [Errno 2] No such file or directory

    self._semlock = _multiprocessing.SemLock._rebuild(*state)

FileNotFoundError: [Errno 2] No such file or directory

Traceback (most recent call last):

  File "<string>", line 1, in <module>

  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/spawn.py", line 116, in spawn_main

    exitcode = _main(fd, parent_sentinel)

  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/spawn.py", line 126, in _main

    self = reduction.pickle.load(from_parent)

  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/synchronize.py", line 110, in __setstate__

    self._semlock = _multiprocessing.SemLock._rebuild(*state)

FileNotFoundError: [Errno 2] No such file or directory


Python 全系列/第三阶段:Python 网络与并发编程/并发编程 37001楼
Python 全系列/第十一阶段:重量级Web框架-Django/Redis的入门与应用(拓展) 37002楼
Python 全系列/第十六阶段:Python 爬虫开发/爬虫基础(旧) 37003楼
人工智能/第五阶段:机器学习-线性回归/梯度下降法 37005楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

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