鱼C论坛

 找回密码
 立即注册
查看: 756|回复: 6

如何从一个页面切换到下一个页面

[复制链接]
发表于 2018-10-11 16:18:39 | 显示全部楼层 |阅读模式

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

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

x
# -*- coding: utf-8 -*-
"""
Created on Thu Oct 11 10:27:40 2018

@author: rose
"""

from tkinter import *
def callback():
    Label(root, text ="用户登录").grid(row=0,column=0)
    Label(root, text ="账号:").grid(row=1,column=0)
    Label(root, text ="密码:").grid(row=2,column=0)
    v1=StringVar()
    v2=StringVar()
    e1=Entry(root,textvariable=v1)
    e2=Entry(root,textvariable=v2,show="*")
    e1.grid(row=1,column=1,padx=10,pady=5)
    e2.grid(row=2,column=1,padx=10,pady=5)
    Button(root,text="登陆",width=10,command=show).grid(row=3,column=0,sticky=W,padx=10,pady=5)
    Button(root,text="退出",width=10,command=root.quit).grid(row=3,column=1,sticky=E,padx=10,pady=5)
def show():
    print("账号:%s"%e1.get())
    print("密码:%s"%e2.get())
   

root=Tk()
root.title("花伴侣")


photo = PhotoImage(file="3.gif")
theLabel =Label(root,
                 text="欢迎来到花伴侣",
                 justify=LEFT,
                 image=photo,
                 compound=CENTER,
                 font=("宋体",20),
                 fg="black",
                 padx=50)#更改边距,横轴的距离
theLabel.grid(row=0)



theButton=Button(root,text="进入",command=callback)#command命令使得按钮按下去连接command后面相关联的函数
theButton.grid(row=1)



Button(root,text="登陆",width=10,command=show).grid(row=3,column=0,sticky=W,padx=10,pady=5)
Button(root,text="退出",width=10,command=root.quit).grid(row=3,column=1,sticky=E,padx=10,pady=5)



mainloop()
这个代码我是想点击进入切换到下一个用户登录界面,结果点进入后上一个页面的内容也出现了,想问一下怎么解决
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2018-10-11 16:32:40 | 显示全部楼层
# -*- coding: utf-8 -*-
"""
Created on Thu Oct 11 10:27:40 2018

@author: rose
"""

from tkinter import *
def callback():
    Label(root, text ="用户登录").grid(row=0,column=0)
    Label(root, text ="账号:").grid(row=1,column=0)
    Label(root, text ="密码:").grid(row=2,column=0)
    v1=StringVar()
    v2=StringVar()
    e1=Entry(root,textvariable=v1)
    e2=Entry(root,textvariable=v2,show="*")
    e1.grid(row=1,column=1,padx=10,pady=5)
    e2.grid(row=2,column=1,padx=10,pady=5)
    Button(root,text="登陆",width=10,command=show).grid(row=3,column=0,sticky=W,padx=10,pady=5)
    Button(root,text="退出",width=10,command=root.quit).grid(row=3,column=1,sticky=E,padx=10,pady=5)
    b1.destroy()
    b2.destroy()
    theLabel.destroy()
    theButton.destroy()
    root.update()
def show():
    print("账号:%s"%e1.get())
    print("密码:%s"%e2.get())
    

root=Tk()
root.title("花伴侣")


photo = PhotoImage(file="1.gif")
theLabel =Label(root,
                 text="欢迎来到花伴侣",
                 justify=LEFT,
                 image=photo,
                 compound=CENTER,
                 font=("宋体",20),
                 fg="black",
                 padx=50)#更改边距,横轴的距离
theLabel.grid(row=0)



theButton=Button(root,text="进入",command=callback)#command命令使得按钮按下去连接command后面相关联的函数
theButton.grid(row=1)



b1=Button(root,text="登陆",width=10,command=show)
b1.grid(row=3,column=0,sticky=W,padx=10,pady=5)
b2=Button(root,text="退出",width=10,command=root.quit)
b2.grid(row=3,column=1,sticky=E,padx=10,pady=5)



mainloop()
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2018-10-12 09:30:11 | 显示全部楼层

你这是跳转到下一个窗口啊,我希望在原窗口基础上跳转,还有第一页的登陆和退出还是存在啊,这个是第二个页面的
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2018-10-12 09:43:13 | 显示全部楼层
你函数里又建的登录退出好不好,
我只是给你照着改
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2018-10-12 14:56:52 | 显示全部楼层
塔利班 发表于 2018-10-12 09:43
你函数里又建的登录退出好不好,
我只是给你照着改

不好意思啊,我才学python,还不知道怎么弄,谢谢你啊,我是跟着小甲鱼视频敲的然后改的内容想实现从第一个页面切换到第二个页面,
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2018-10-12 14:58:04 | 显示全部楼层
江老师实验室 发表于 2018-10-12 14:56
不好意思啊,我才学python,还不知道怎么弄,谢谢你啊,我是跟着小甲鱼视频敲的然后改的内容想实现从第一 ...

是不是同一个函数建立只能跳到另一个窗口啊
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2018-10-12 15:37:22 | 显示全部楼层
你的意思是多跳出来个,同学A登录A的,B登录B的,点几次进入出来几次?
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-10-7 07:33

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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