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

springjdbcdemo.zip

public class Test01_SingleDML {
    public static void main(String[] args) {
        ApplicationContext applicationContext=new ClassPathXmlApplicationContext("applicationcontext.xml");
        UsersService usersService =(UsersService) applicationContext.getBean("usersService");
        Users users=new Users();
        users.setUsername("yx");
        users.setUsersex("female");
        int i = usersService.addUsers(users);
        System.out.println(i);
    }
}

老师,我测试单条DML语言,出现如下报错,请帮我看一下,我代码哪里出了问题,谢谢报错.png


JAVA 全系列/第六阶段:项目管理与SSM框架/Spring 30751楼

屏幕截图 2024-06-20 160539.png

为什么在这个字母下面会有波浪线啊 这个波浪线我们用管吗

Python 全系列/第一阶段:Python入门/Python入门(动画版) 30752楼
Python 全系列/第一阶段:Python入门/Python入门(动画版) 30753楼
Python 全系列/第五阶段:数据库编程/python操作mysql 30756楼
JAVA 全系列/第十一阶段:消息中间件与高并发处理/RabbitMQ(旧) 30758楼
JAVA 全系列/第二阶段:JAVA 基础深化和提高/容器(旧) 30759楼
JAVA 全系列/第一阶段:JAVA 快速入门/飞机大战小项目训练 30760楼

一、代码

#coding=utf-8
"""
开发记事本软件的菜单
"""

from tkinter.filedialog import *
from tkinter.colorchooser import *

class Application(Frame):

    def __init__(self, master=None):
        super().__init__(master)        # super()代表的是父类的定义,而不是父类对象
        self.master = master
        self.textpad = None             # textpad表示Text文本框对象
        self.pack()
        self.createWidget()

    def createWidget(self):
        # 创建主菜单栏
        menubar = Menu(root)

        # 创建子菜单
        menuFile = Menu(menubar)
        menuEdit = Menu(menubar)
        menuHelp = Menu(menubar)

        # 将子菜单加入到主菜单栏
        menubar.add_cascade(label="文件(F)", menu=menuFile)
        menubar.add_cascade(label="编辑(E)", menu=menuEdit)
        menubar.add_cascade(label="帮助(H)", menu=menuHelp)

        # 添加菜单项
        menuFile.add_command(label="新建", accelerator="ctrl+n", command=self.newfile)
        menuFile.add_command(label="打开", accelerator="ctrl+o", command=self.openfile)
        menuFile.add_command(label="保存", accelerator="ctrl+s",command=self.savefile)
        menuFile.add_separator()  # 添加分割线
        menuFile.add_command(label="退出", accelerator="ctrl+q",command=self.exit)

        # 将主菜单栏加到根窗口
        root["menu"] = menubar

        #添加快捷键事件处理
        root.bind('<Control-n>', self.newfile)
        root.bind('<Control-o>', self.openfile)
        root.bind('<Control-s>', self.savefile)
        root.bind('<Control-q>', self.exit)

        #文本编辑区
        self.textpad = Text(root, width=50, height=30)
        self.textpad.pack()

        # 创建上下菜单
        self.contextMenu = Menu(root)
        self.contextMenu.add_command(label="背景颜色", command=self.AskColor)

        #为右键绑定事件
        root.bind("<Button-3>",self.createContextMenu)

    def newfile(self,event):
        self.textpad.delete(1.0, END)
        self.filename=asksaveasfilename(title="新建",initialfile="未命名.txt",
                                        initialdir='F:/Python/mypro_GUI',
                                        filetype=[('文本文档','*.txt')],defaultextension='.txt')

    def openfile(self,event):
        with askopenfile(title="打开文件",initialdir='F:/Python/mypro_GUI') as f:
            self.textpad.insert(INSERT,f.read())
            self.filename = f.name

    def savefile(self,event):
        with open(self.filename,'w') as f:
            c = self.textpad.get(1.0,END)
            f.write(c)

    def exit(self,event):
        root.quit()

    def AskColor(self):
        s1 = askcolor(color="red",title='选择背景色')
        self.textpad['bg']=s1[1]

    def createContextMenu(self,event):
        # 菜单在鼠标右键单击的坐标处显示
        self.contextMenu.post(event.x_root, event.y_root)


if __name__ == '__main__':
    root = Tk()
    root.geometry("450x300+200+300")
    root.title("百战程序员的简易记事本")
    app = Application(master=root)
    root.mainloop()

二、问题

image.png

老师,为什么我运行生成的.exe文件,点“文件”—“新建”等按钮,都会报上述的错误?

Python 全系列/第二阶段:Python 深入与提高/GUI编程(隐藏) 30762楼
Python 全系列/第一阶段:Python入门/面向对象 30763楼
Python 全系列/第十一阶段:重量级Web框架-Django/Django初级 30764楼
JAVA 全系列/第一阶段:JAVA 快速入门/变量、数据类型、运算符 30765楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

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