0

これは私のコードです:

import sys
from tkinter import *

def forget_page1():
    widgets = [mLabel1, button]
    for widget in widgets:
        widget.place_forget ()

################################
mGui = Tk ()

mGui.geometry("600x600+545+170")
mGui.title("MyMathDictionary")

mLabel1 = Label (text = "Welcome to MyMathDictionary. Press Next to continue.",
                 fg = "blue",bg = "white")
mLabel1.place (x= 150,y = 200)

button = Button (text = "Next", command = forget_page1)
button.place(x = 275,y = 230)

mGui.mainloop()

あなたが私のコードを理解していれば....ウェルカムメッセージのあるページがあり、ユーザーは「次へ」をクリックして次のページに進む必要がplace_forget ()あります。しかし、以前のウィジェットが忘れられている新しいページに新しいボタンまたはラベルを配置するコードをどこに配置すればよいですか???? 私は明確だったと思いますか?

4

1 に答える 1

0

ユーザーインターフェースの開発を始めたばかりであることが分かります。ストーリーボードはすべてのイベントで、Tkカスタム シグナルとスロットを設定できますが、この単純な実装は今のところ機能すると思います。私が行っているのは、新しいウィジェットをロードする関数を呼び出すことだけです。これはテストしていないことに注意してください。

import sys
from tkinter import *

def forget_page1():
    widgets = [mLabel1, button]
    for widget in widgets:
        widget.place_forget ()
    loadNextPage()

def loadNextPage():
    mLabel2 = Label (text="Welcome to the next page.")
    mLabel2.place (x= 222,y = 200)
    button1 = Button (text = "Hello" )
    button1.place(x = 333,y = 230)

################################
mGui = Tk ()

mGui.geometry("600x600+545+170")
mGui.title("MyMathDictionary")

mLabel1 = Label (text = "Welcome to MyMathDictionary. Press Next to continue.",
                 fg = "blue",bg = "white")
mLabel1.place (x= 150,y = 200)

button = Button (text = "Next", command = forget_page1)
button.place(x = 275,y = 230)

mGui.mainloop()
于 2013-08-13T14:49:03.843 に答える