会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 133485个问题
JAVA 全系列/第十四阶段:分布式文件存储与数据缓存/MongoDB 1741楼

#测试Text多行文本
from tkinter import *
import webbrowser

class Application(Frame):

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

    def createWidget(self):   #定义框内容以及属性

        self.w = Text(root,width=40,height=10,bg="white",font=("宋体",18))
        self.w.pack()
        #self.w.insert(1.0)代表在第1行0列插入内容
        #行:123...;列:012...
        self.w.insert(1.0,"0123456789\n0纵观世界与天下\n奇闻异事")
        self.w.insert(2.3, "xxx")

        Button(self, text="重复插入文本", command=self.insertText).pack(side="left")
        Button(self, text="命令行返回文本", command=self.returnText).pack(side="left")
        Button(self, text="添加图片", command=self.addImage).pack(side="left")
        Button(self, text="添加组件", command=self.addWidget).pack(side="left")
        Button(self, text="通过tag精确控制文本", command=self.TextTag).pack(side="left")  #Tag标记


    def insertText(self):
        #INSERT代表从光标处插入内容
        #END在末尾插入内容
        self.w.insert(INSERT,"HE")
        self.w.insert(END, "ST")
        #在指定位置插入指定文本内容
        self.w.insert(2.8,"acz")   #在第2行第8列的位置插入

    def returnText(self):
        #获取文本的内容,并在命令行打印输出,get(初始位置, 终止位置)--获得该区域内容
        print(self.w.get(2.0, 2.5))
        print("文本所有内容:" + self.w.get(1.0, END))

    def addImage(self):
        #添加图片image_create()
        #定义全局变量globle p 或 对象属性self.p
        #global p
        self.p = PhotoImage(file="imgs/13.gif")
        self.w.image_create(END, image=self.p)

    def addWidget(self):
        #添加组件window_create()
        b=Button(self.w,text="点击")  #master为建好的文本域self.w
        self.w.window_create(INSERT,window=b)

    def TextTag(self):
        self.w.delete(1.0,END)
        self.w.insert(1.0,"good dood study!\n尚学堂\n百度一下,你就知道")
        #Tag--标记
        self.w.tag_add("IM",1.0,1.5)   #在指定区域内添加标记,将标记命名为good
        #标记属性定义,标记backgrond背景色,foreground标记体颜色,underline下划线
        self.w.tag_config("IM",background="yellow",foreground="red",underline=True)
        #标记事件绑定,即点击会出现的情况
        self.w.tag_add("bd", 3.0, 3.2)  # 在指定区域内添加标记
        self.w.tag_config("bd",background="blue",underline=True)
        self.w.tag_bind("bd","<Button-1>",self.webshow)  #<Button-1>点击左键

    #定义参数event,将<Button-1>点击左键作为参数event传入
    def webshow(self,event):
        webbrowser.open("https://www.baidu.com/")


if __name__=="__main__":
    root=Tk()                        #创建框大小、位置以及标题
    app=Application(master=root)
    root.title("Text_test")
    root.geometry("500x300+450+200")
    root.mainloop()

老师,请问这个为什么这个程序中图片部分的不能显示,点了没反应是为什么呢?没有图片出来?


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

image.png

java.sql.SQLException: The server time zone value '�й���׼ʱ��' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the 'serverTimezone' configuration property) to use a more specifc time zone value if you want to utilize time zone support.
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:73)
	at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:76)
	at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:836)
	at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:456)
	at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246)
	at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:197)
	at org.mybatis.generator.internal.db.ConnectionFactory.getConnection(ConnectionFactory.java:68)
	at org.mybatis.generator.config.Context.getConnection(Context.java:526)
	at org.mybatis.generator.config.Context.introspectTables(Context.java:436)
	at org.mybatis.generator.api.MyBatisGenerator.generate(MyBatisGenerator.java:222)
	at org.mybatis.generator.api.MyBatisGenerator.generate(MyBatisGenerator.java:133)
	at GeneratorSqlmap.generator(GeneratorSqlmap.java:27)
	at GeneratorSqlmap.main(GeneratorSqlmap.java:33)
Caused by: com.mysql.cj.exceptions.InvalidConnectionAttributeException: The server time zone value '�й���׼ʱ��' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the 'serverTimezone' configuration property) to use a more specifc time zone value if you want to utilize time zone support.
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61)
	at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:85)
	at com.mysql.cj.util.TimeUtil.getCanonicalTimezone(TimeUtil.java:132)
	at com.mysql.cj.protocol.a.NativeProtocol.configureTimezone(NativeProtocol.java:2120)
	at com.mysql.cj.protocol.a.NativeProtocol.initServerSession(NativeProtocol.java:2143)
	at com.mysql.cj.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:1310)
	at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:967)
	at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:826)
	... 10 more

我运行的时候就这个样子了,我的数据库是8的,jar包也换了。

JAVA 全系列/第六阶段:项目管理与SSM框架/Mybatis 1744楼
JAVA 全系列/第四阶段:数据库与AI协同技术实战/MySQL数据库 1745楼
Java架构课程/第七阶段:Spring全家桶(Spring Cloud)/Spring Cloud 1751楼
Python 全系列/第八阶段:Web全栈开发基础与前端/jQuery 1752楼
WEB前端全系列/第一阶段:HTML5+CSS3模块/CSS3新特性 1753楼
JAVA 全系列/第十四阶段:分布式文件存储与数据缓存/MongoDB 1754楼
JAVA 全系列/第十九阶段:亿级高并发电商项目/亿级高并发电商项目(旧) 1755楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

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