| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 991 人关注过本帖
标题:求助:这个错误实在找不出原因,求高手帮我看看,谢谢了。
取消只看楼主 加入收藏
wangjx236007
Rank: 1
等 级:新手上路
帖 子:36
专家分:0
注 册:2021-3-2
结帖率:40%
收藏
已结贴  问题点数:14 回复次数:1 
求助:这个错误实在找不出原因,求高手帮我看看,谢谢了。
import tkinter as tk
from tkinter import *
import datetime
from tkinter import ttk

import tkinter.font as tkFont
from tkinter.messagebox import showerror

import main1
import service
from PIL import Image, ImageTk


def _font(fname="微软雅黑", size=12, bold=tkFont.NORMAL):
    """设置字体"""
    ft = tkFont.Font(family=fname, size=size, weight=bold)
    return ft


class Login():

    def __init__(self):
        self.loginwin = Tk()
        self.loginwin.title("系统登录")
        self.width = 600
        self.height = 400
        self.screenwidth = self.loginwin.winfo_screenwidth()
        self.screenheight = self.loginwin.winfo_screenheight()
        self.alignstr = '%dx%d+%d+%d' % (
            self.width, self.height, (self.screenwidth - self.width) / 2, (self.screenheight - self.height) / 2)
        self.loginwin.geometry(self.alignstr)
        self.img1 = Image.open("11.png")
        self.img = ImageTk.PhotoImage(self.img1)
        Label(self.loginwin, image=self.img).place(x=60, y=40, width=80, height=82)
        Label(self.loginwin, text="党支部信息管理平台", font="楷体 30 bold").place(x=170, y=80)
        ttk.Separator(self.loginwin).place(x=0, y=150, width=600)
        Label(self.loginwin, text="用户名:", font="雅黑 18 bold").place(x=150, y=180)
        self.try1 = Entry(self.loginwin, width=15, font="雅黑 18 bold").place(x=250, y=180)
        Label(self.loginwin, text="密  码:", font="雅黑 18 bold").place(x=150, y=230)
        self.try2 = Entry(self.loginwin, show="*", width=15, font="雅黑 18 bold").place(x=250, y=230)
        Button(self.loginwin, text="确   定", font="雅黑 14 bold", command=lambda: self.openmain("")).place(x=220, y=300)
        Button(self.loginwin, text="退   出", font="雅黑 14 bold", command=self.loginwin.destroy).place(x=350, y=300)
        self.loginwin.mainloop()

    def openmain(self,event):
        service.username=self.try1.get()
        password=self.try2.get()
        if service.username=="" or password=="":
            showerror("错误","请输入用户名和密码!")
            return False
        else:
            result=service.query("select * from user where username=%s and password=%s",service.username,password)
            if len(result)>0:
                main1.Win()
            else:
                self.try1.delete(0,END)
                self.try2.delete(0, END)
                showerror("警告","请输入正确的用户名和密码!")
            
            

Login()


出现错误:
 File "F:/dangjgl/login.py", line 46, in openmain
    service.username = self.try1.get()
AttributeError: 'NoneType' object has no attribute 'get'
搜索更多相关主题的帖子: username service from 错误 import 
2022-06-29 11:22
wangjx236007
Rank: 1
等 级:新手上路
帖 子:36
专家分:0
注 册:2021-3-2
收藏
得分:0 
谢谢你,确实是这个问题。
2022-06-29 11:50
快速回复:求助:这个错误实在找不出原因,求高手帮我看看,谢谢了。
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015165 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved