鱼C论坛

 找回密码
 立即注册
查看: 752|回复: 2

求助,为什么调用顶层窗口时不能显示信息

[复制链接]
发表于 2019-3-16 16:09:14 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
求助,在登录时调用get得到的账号保存为act,迭代list中的账号比对,为什么结果msg不能显示在窗口中
   list = [100,200,300,400]

    def backstage_interface(self):

        #self.root.destroy()

        top = Toplevel(master=None)

        top.geometry('200x100')

        top.title("login demo")

        act = self.input_account.get()

        for i in list():

            if i == act:

                msg = Message(top,text="成功")

                msg.pack()

            else:

                msg = Message(top,text="不存在该用户")

                msg.pack()
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2019-3-16 20:30:35 | 显示全部楼层
list你就不能换个名,非得要跟BFI同名?

你不上代码,我眼能看到的问题就是这个了。
list1 = [100,200,300,400]
   for i in list1:
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-3-17 15:18:48 | 显示全部楼层
ba21 发表于 2019-3-16 20:30
list你就不能换个名,非得要跟BFI同名?

你不上代码,我眼能看到的问题就是这个了。

你好,定义完整登陆和顶层窗口代码如下,错误显示列表没有定义,先谢谢大佬帮忙

from tkinter import *

class Login(object):
    def __init__(self):
        self.root = Tk()
        self.root.title("**医药系统")
        self.root.geometry('450x300')
        
        self.bg_image = PhotoImage(file='cloud.png')
        self.bg_label = Label(self.root,image=self.bg_image)
        self.bg_label.place(x=0,y=0,relwidth=1,relheight=1)

        self.canvas = Canvas(self.bg_label,height=150,width=300)
        self.image_file = PhotoImage(file='cd.gif')
        self.image = self.canvas.create_image(0,0,anchor='w',image=self.image_file)
        self.canvas.pack(side='top')

        self.label_account = Label(self.bg_label,text='account:   ',)
        self.label_account.place(x=80,y=170)
        self.label_password = Label(self.bg_label,text='password:')
        self.label_password.place(x=80,y=205)

        self.input_account = Entry(self.bg_label,width='30')
        self.input_account.place(x=150,y=170)
        self.input_passeord = Entry(self.bg_label,width='30',show='*')
        self.input_passeord.place(x=150,y=205)

        self.login_button = Button(self.bg_label,text="login",command=self.backstage_interface)
        self.login_button.place(x=140,y=235)
        self.sigin_button = Button(self.bg_label,text="sigin",command=self.sigin_interface)
        self.sigin_button.place(x=260,y=235)

    list1 = [100,200,300,400]
    def backstage_interface(self):
        #self.root.destroy()
        top = Toplevel(master=None)
        top.geometry('200x100')
        top.title("login demo")
        act = self.input_account.get()
        for each in list1():
            if each == act:
                msg = Message(top,text="成功")

            else:
                msg = Message(top,text="不存在该用户")
                msg.pack()
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2026-1-14 15:58

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表