鱼C论坛

 找回密码
 立即注册
查看: 1024|回复: 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()
这个代码我是想点击进入切换到下一个用户登录界面,结果点进入后上一个页面的内容也出现了,想问一下怎么解决
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2018-10-11 16:32:40 | 显示全部楼层

  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Thu Oct 11 10:27:40 2018

  4. @author: rose
  5. """

  6. from tkinter import *
  7. def callback():
  8.     Label(root, text ="用户登录").grid(row=0,column=0)
  9.     Label(root, text ="账号:").grid(row=1,column=0)
  10.     Label(root, text ="密码:").grid(row=2,column=0)
  11.     v1=StringVar()
  12.     v2=StringVar()
  13.     e1=Entry(root,textvariable=v1)
  14.     e2=Entry(root,textvariable=v2,show="*")
  15.     e1.grid(row=1,column=1,padx=10,pady=5)
  16.     e2.grid(row=2,column=1,padx=10,pady=5)
  17.     Button(root,text="登陆",width=10,command=show).grid(row=3,column=0,sticky=W,padx=10,pady=5)
  18.     Button(root,text="退出",width=10,command=root.quit).grid(row=3,column=1,sticky=E,padx=10,pady=5)
  19.     b1.destroy()
  20.     b2.destroy()
  21.     theLabel.destroy()
  22.     theButton.destroy()
  23.     root.update()
  24. def show():
  25.     print("账号:%s"%e1.get())
  26.     print("密码:%s"%e2.get())
  27.    

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


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



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



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



  46. mainloop()
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

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

你这是跳转到下一个窗口啊,我希望在原窗口基础上跳转,还有第一页的登陆和退出还是存在啊,这个是第二个页面的
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2018-10-12 09:43:13 | 显示全部楼层
你函数里又建的登录退出好不好,
我只是给你照着改
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

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

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

使用道具 举报

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

是不是同一个函数建立只能跳到另一个窗口啊
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2018-10-12 15:37:22 | 显示全部楼层
你的意思是多跳出来个,同学A登录A的,B登录B的,点几次进入出来几次?
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-2 18:21

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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