python如何创建问答窗口_点击按钮在Python3和tkinter中创建新窗口

这是我现在做的程序,但我有问题。。。

当我点击按钮1然后打开新窗口时,我该怎么做import sys

from tkinter import *

import tkinter as tk

def mhello1():

mlabel = Label(mGui, text='A1').pack()

def mhello2():

mlabel = Label(mGui, text='A2').pack()

def mhello3():

mlabel = Label(mGui, text='A3').pack()

def mhello4():

mlabel

return

def mAbout():

messagebox.showinfo(title="About",message="program")

return

def mQuit():

mExit = messagebox.askyesno(title="Quit",message="y/n")

if mExit > 0:

mGui.destroy()

return

mGui = Tk()

mGui.geometry('450x450+200+200')

mGui.title('program')

mGui.configure(bg='gray')

mlabel = Label(text='option:',fg='red',bg = 'blue').pack()

mbutton1 = Button(mGui,text ='Button1',command = mhello1, height=5, width=20).pack()

mbutton2 = Button(mGui,text ='Button2',command = mhello2, height=5, width=20).pack()

mbutton3 = Button(mGui,text ='Button3',command = mhello3, height=5, width=20).pack()

mbutton4 = Button(mGui,text ='Button4',command = mhello4, height=5, width=20).pack()

mlabel2 = Label(text='activity:',fg='red',bg = 'blue').pack()

menubar=Menu(mGui)

filemenu = Menu(menubar, tearoff = 0)

filemenu.add_command(label="qwer")

filemenu.add_command(label="quit",command = mQuit)

menubar.add_cascade(label="more options",menu=filemenu)

helpmenu = Menu(menubar, tearoff = 0)

helpmenu.add_command(label="Help Docs")

helpmenu.add_command(label="About", command = mAbout)

menubar.add_cascade(label="help",menu=helpmenu)

mGui.config(menu=menubar)

mGui.mainloop()

有没有一种方法我不使用tkinter toplevel?

Tnx很多:)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值