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

from tkinter import *
from tkinter import messagebox

class Application(Frame):
    """一个经典GUI的程序的类的写法"""

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

        self.createWidget()

    def createWidget(self):
        """创建组件"""
        self.btn01 = Button(self)
        self.btn01["text"] = '送花'
        self.btn01.pack()
        self.btn01["command"] = self.songhua

        #创建一个退出按键
        self.btnQuit = Button(self, text='退出', command=root.destory)
        self.btnQuit.pack()

        def songhua(self):
            messagebox.showinfo("送花","送你一多玫瑰花,亲亲我吧")


root = Tk()
root.title("我的第一个Gui程序")
root.geometry("600x500+0+0")
app = Application(master=root)

root.mainloop()

D:\Users\asus\PycharmProjects\gui\venv\Scripts\python.exe D:/Users/asus/PycharmProjects/gui/my01.01.py
Traceback (most recent call last):
  File "D:/Users/asus/PycharmProjects/gui/my01.01.py", line 34, in <module>
    app = Application(master=root)
  File "D:/Users/asus/PycharmProjects/gui/my01.01.py", line 13, in __init__
    self.createWidget()
  File "D:/Users/asus/PycharmProjects/gui/my01.01.py", line 21, in createWidget
    self.btn01["command"] = self.songhua
AttributeError: 'Application' object has no attribute 'songhua'

Process finished with exit code 1

QQ截图20200402222047.png

Python 全系列/第二阶段:Python 深入与提高/GUI编程(隐藏) 33541楼
JAVA 全系列/第一阶段:JAVA 快速入门/面向对象详解和JVM底层内存分析 33542楼
JAVA 全系列/第三阶段:数据库编程/JDBC技术(旧) 33547楼
Python 全系列/第十二阶段:Python_Django3框架/Django初级 33550楼
JAVA 全系列/第四阶段:网页编程和设计/CSS3(旧) 33551楼
Python 全系列/第二阶段:Python 深入与提高/异常机制 33553楼

老师,我安装mysqlclient,出现如下错误,是要安装visual吗?


    building 'MySQLdb._mysql' extension

    creating build\temp.win32-3.6

    creating build\temp.win32-3.6\Release

    creating build\temp.win32-3.6\Release\MySQLdb

    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversion_info=(1,4,6,'final',0) -D__version__=1.4.6 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include\mariadb" -ID:\pythontest\env_test\include "-Ic:\program files (x86)\python36-32\inclu

de" "-Ic:\program files (x86)\python36-32\include" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:

\Program Files (x86)\Windows Kits\8.1\include\winrt" /TcMySQLdb/_mysql.c /Fobuild\temp.win32-3.6\Release\MySQLdb/_mysql.obj /Zl /D_CRT_SECURE_NO_WARNINGS

    _mysql.c

    MySQLdb/_mysql.c(29): fatal error C1083: Cannot open include file: 'mysql.h': No such file or directory

    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\cl.exe' failed with exit status 2

    ----------------------------------------

ERROR: Command errored out with exit status 1: 'D:\pythontest\env_test\Scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\pip-install-p29ocnax\\mysqlclient\\setup.py'"'"'; __file__='"'"'C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\pip-i

nstall-p29ocnax\\mysqlclient\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\ADMINI~1\AppData\Local\Temp\pip-record-jqeeg1hh\install-record.txt' --sing

le-version-externally-managed --compile --install-headers 'D:\pythontest\env_test\include\site\python3.6\mysqlclient' Check the logs for full command output.


(env_test) D:\pythontest\env_test>pip list

Package    Version

---------- -------

asgiref    3.2.7

Django     3.0.5

pip        20.0.2

pytz       2019.3

setuptools 46.1.3

sqlparse   0.3.1

wheel      0.34.2


Python 全系列/第十二阶段:Python_Django3框架/Django初级 33554楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

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