這是我第一次發佈堆棧溢出。 我整天在Google上搜索信息後,整理了我的第一個python Tkinter軟件。 當我運行我的第一款軟件tkinter時,對我自己的想法並沒有產生任何錯誤或顯示任何東西感到沮喪。 我決定在堆棧溢出時發佈我的代碼。Tkinter學習如何使用包和網格的困難方式
請閱讀我的Python代碼#explanes Python的工作原理是:
#load the normal drivers
import Tkinter
from Tkinter import *
import Tkinter as tk
import tkMessageBox
from PIL import Image, ImageTk
from Tkconstants import *
# this makes the master app window
master = Tk()
master.geometry('+0+0')
master.wm_title("App Window")
frame = Frame(master, height=300, width=700, background="black")
frame.pack_propagate(0)
#intro image on the right column
img = ImageTk.PhotoImage(file="1.gif")
panel = tk.Label(master, image = img).grid(row = 1, column = 2)
#code to put Buttons into the left column Label
panel2 = tk.Label().grid(row = 1, column = 1)
#onClick commands I will work on Later.
def onClick1():
master.image = PhotoImage(file="captain_scarlett.gif")
w = Label(master, image=master.image)
w.photo = master
w.pack(side=RIGHT)
def onClick2():
photo = PhotoImage(file="1.gif")
w = Label(master, image=photo)
w.photo = photo
w.pack(side=RIGHT)
def onClick3():
photo = PhotoImage(file="1.gif")
w = Label(master, image=photo)
w.photo = photo
w.pack(side=RIGHT)
def onClick4():
photo = PhotoImage(file="1.gif")
w = Label(master, image=photo)
w.photo = photo
w.pack(side=RIGHT)
#these are the Buttons that go into left column
master.Button1 = Button(panel2, text="captain_scarlet", fg="#000",
width=17, background="yellow", command=onClick1)
master.Button2 = Button(panel2, text="Page 2", fg="#000", width=17,
background="yellow", command=onClick2)
master.Button3 = Button(panel2, text="Page 3", fg="#000", width=17,
background="yellow", command=onClick3)
master.Button4 = Button(panel2, text="Page 4", fg="#000", width=17,
background="yellow", command=onClick4)
#normal exiting commands
frame.pack()
master.mainloop()
答案我得到了改變了我整個的Tkinter的是如何工作的,並格式化的認識。
您似乎已將您的問題更改爲聲明。那是爲什麼?這個網站是針對問題和問題的答案。如果你回過頭來大幅改變問題,那麼答案就會停止。 – 2013-02-27 20:20:56