"""
#!/usr/bin/env python
# -*- coding:utf-8 -*-
@Project : project1
@File : main_interface.py
@Author : 19082
@Time : 2023/9/17 21:01
"""
import datetime
import time
from tkinter import *
from tkinter.messagebox import *
from tkinter import filedialog
global question_image
global question_photo
global question_path
global answer_photo
global answer_image
global question_new_path
global question_new_name
global first_global
global easy_question_list
class main_interface(object):
def __init__(self, master=None):
self.root = master # 定义内部变量root
self.root.geometry('%dx%d' % (1000, 800)) # 设置窗口大小
self.username = StringVar()
self.password = StringVar()
self.createPage()
def createPage(self):
self.page0 = Frame(self.root) # 创建Frame
self.page0.pack()
Label(self.page0, text='杜晓扬考研错题本').grid(row=0, stick=W, pady=30)
Button(self.page0, text='添加错题', command=self.add_all_question).grid(row=1, pady=5)
Button(self.page0, text='错题回看', command=self.review_all_question).grid(row=2, pady=5)
def add_all_question(self):
self.page0.destroy()
self.page = Frame(self.root)
self.page.pack()
Label(self.page, text='杜晓扬考研错题本').grid(row=0, stick=W, pady=30)
Button(self.page, text='高数', command=self.higher_mathematics_page).grid(row=1, pady=5)
Button(self.page, text='现代', command=self.linear_algebra_page).grid(row=2, pady=5)
Button(self.page, text='概率论', command=self.probabilism_page).grid(row=3, pady=5)
Button(self.page, text='专业课', command=self.special_disciplines_page).grid(row=4, pady=5)
Button(self.page, text='英语阅读', command=self.read_page).grid(row=5, pady=5)
Button(self.page, text='英语翻译', command=self.translation_page).grid(row=6, pady=5)
Button(self.page, text='英语作文', command=self.composition_page).grid(row=7, pady=5)
def higher_mathematics_page(self):
import tkinter
import tkinter as tk
from tkinter import ttk
global question_photo
global answer_photo
global question_type
global question_new_path
global answer_new_path
global question_label
global question_grade
question_photo = None
answer_photo = None
self.page.destroy()
self.page1 = Frame(self.root)
self.page1.pack()
question_type = "高数"
question_new_path = "F:\study\question\higher_mathematics"
answer_new_path = "F:\study\snswer\higher_mathematics"
Label(self.page1, text='考研高数').grid(row=0, stick=W, pady=30)
Button(self.page1, text='导入题目', command=self.add_question).grid(row=1, pady=0)
self.question_path = StringVar()
Entry(self.page1, state='readonly', text=self.question_path, width=100).grid(row=2, pady=0)
Button(self.page1, text='导入答案', command=self.add_answer).grid(row=3, pady=3)
self.answer_path = StringVar()
Entry(self.page1, state='readonly', text=self.answer_path, width=100).grid(row=4, pady=0)
Button(self.page1, text='加入题库', command=self.add_question_bank).grid(row=5, pady=3)
self.question_grade = StringVar()
Entry(self.page1, textvariable=self.question_grade).grid(row=6, column=1, stick=E)
Button(self.page1, text='难度等级', command=self.add_question_grade).grid(row=6, pady=3)
self.question_image_show = Label(self.page1, image=question_photo)
self.question_image_show.grid(column=7, row=1)
self.answer_image_show = Label(self.page1, image=answer_photo)
self.answer_image_show.grid(column=7, row=2)
def add_question_grade(self):
global question_grade
question_grade = self.question_grade.get()
print(question_grade)
def add_question(self):
import tkinter as tk
import tkinter.filedialog
from PIL import Image, ImageTk
global question_image
global question_photo
global question_path
global question_new_path
global question_new_name
global new_name
global question_label
global question_grade
question_path = filedialog.askopenfilename(title='选择文件', filetypes=[(('JPG', '*.jpg')), ('All Files', '*')])
question_image = Image.open(question_path)
question_image.show()
new_size = (200, 200)
question_image = question_image.resize(new_size)
question_photo = ImageTk.PhotoImage(question_image) # 实际上是把这个变成全局变量
self.question_image_show.configure(image=question_photo)
self.question_image_show.image = question_photo
print(question_path)
import datetime
import time
now_time = datetime.datetime.now()
question_year = str(now_time.year)
question_month = str(now_time.month)
question_day = str(now_time.day)
question_hour = str(now_time.hour)
question_minute = str(now_time.minute)
question_second = str(now_time.second)
question_first = str("")
new_name = question_year + "" + question_month + "" + question_day + "" + question_hour + "" + question_minute + "" + question_second
question_new_name = question_first + "" + new_name
print(question_new_name)
def add_answer(self):
import tkinter as tk
import tkinter.filedialog
global answer_path
from PIL import Image, ImageTk
global answer_new_name
global answer_new_path
global answer_image
global new_name
global answer_photo
answer_path = filedialog.askopenfilename(title='选择文件', filetypes=[(('JPG', '*.jpg')), ('All Files', '*')])
answer_image = Image.open(answer_path)
answer_image.show()
answer_new_name = question_new_name
new_size = (200, 200)
answer_image = answer_image.resize(new_size)
answer_photo = ImageTk.PhotoImage(answer_image) # 实际上是把这个变成全局变量
self.answer_image_show.configure(image=answer_photo)
self.answer_image_show.image = answer_photo
print(answer_path)
def add_question_bank(self):
global answer_new_path
global question_new_path
global question_type
global question_new_name
global answer_new_name
global question_label
import mysql.connector
global answer_path
global question_path
global question_grade
global new_size
new_size = (200, 200)
# 人员表1
add_question_bank = mysql.connector.connect(
host="localhost",
user="root",
passwd="dxy123",
db='study'
)
mycursor = add_question_bank.cursor()
mysql = "insert into 高数 (题目编号,题目类型,题目地址,答案编号,答案地址,标记) values (%s,%s,%s,%s,%s,%s)"
try:
# 执行sql
mycursor.execute(mysql, (
question_new_name, question_type, question_new_path, answer_new_name, answer_new_path, question_grade))
add_question_bank.commit()
print("插入数据成功")
except Exception as e:
print(e)
add_question_bank.rollback()
print("插入数据失败")
finally:
# 关闭游标连接
mycursor.close()
# 关闭数据库连接
add_question_bank.close()
from PIL import Image
import os
question_new_name = question_new_name + "" + ".jpg"
answer_n
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
study.rar (4个子文件)
study
__init__.py 146B
study_start.py 292B
main_interface.py 70KB
__pycache__
main_interface.cpython-39.pyc 33KB
共 4 条
- 1
资源评论
江湖妖兔
- 粉丝: 3
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- ModifyJSON.zip
- 各种系统编程和并行编程作业实验C和C++源码(含任务管理、进程间通信、并行算法等).zip
- 基于人工神经网络-随机森林-LSTM的径流预测项目源码(Python期末大作业)
- open固件库001.7z
- WinDDK 配置过的驱动模板
- WinDBG-10.0.16299.15.zip
- VMware-workstation-full-16.2.4-20089737.zip
- 章节2:编程基本概念之变量的声明-初始化-垃圾回收机制.rar
- 【java毕业设计】SpringBoot+Vue大学生就业(信息管理)服务平台 源码+sql脚本+论文 完整版
- 基于类关键路径的神经网络通道量化框架python实现源码.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功