劉任昌輸入tkinter繪圖模組金融常識測驗app
以上嵌入的指令 <IFRAME WIDTH="100%" HEIGHT='400' SRC="https://zh.wikipedia.org/zh-tw/Tkinter"></IFRAME>
import tkinter #輸入tkinter繪圖模組 #財金程式設計602
#劉任昌import進口export出口
class Financial: #類別用於建構504道金融常識題目
def __init__(self, number, q, a, b, c, d, ans):
self.number, self.q, self.ans = number, q, ans
self.a, self.b, self.c, self.d = a, b, c, d
def check(choice):
choice = reply.get() #以字串存'1'...'4'
temp = number.get() - 1 #題號
if choice == '1':
LBa.config(bg="#b8c1a4")
if choice == List[temp].ans: LBa.config(bg='blue',fg='white')
if choice == '2':
LBb.config(bg="#b7c1a4")
if choice == List[temp].ans: LBb.config(bg='blue',fg='white')
if choice == '3':
LBc.config(bg="#b0b3bf")
if choice == List[temp].ans: LBc.config(bg='blue',fg='white')
if choice == '4':
LBd.config(bg="#3658c5")
if choice == List[temp].ans: LBd.config(bg='blue',fg='white')
def update():
qtk.set(List[number.get()-1].q)
atk.set(List[number.get()-1].a)
btk.set(List[number.get()-1].b)
ctk.set(List[number.get()-1].c)
dtk.set(List[number.get()-1].d)
reply.set('答')
def refresh():
LBa.config(bg='white',fg='black')
LBb.config(bg='white',fg='black')
LBc.config(bg='white',fg='black')
LBd.config(bg='white',fg='black')
def prev():
if number.get() == 1: number.set(504)#如果1前一個504
else: number.set(number.get() - 1)
update()
refresh()
def next():
if number.get() == 504: number.set(1)#set如果504設定1
else: number.set(number.get() + 1)
update()
refresh()
f = open('金融常識.txt','r',encoding='utf-8')
read = f.readlines() #read = f.read()
f.close()
List = []
Answer=(4,4,3,4,3,2,3,3,4,2,4,4,4,3,4,2,3,1,1,2,1,2,3,3,1,3,4,4,3,4,1,4,3,2,4,2,2,3,2,4,1,4,1,1,4,3,1,2,4,1,2,1,4,4,4,1,4,2,1,3,3,1,4,4,3,2,2,2,4,4,1,3,3,1,2,4,1,3,4,4,2,4,4,3,4,1,3,2,3,2,3,2,2,2,4,4,4,1,1,2,2,4,4,1,4,1,4,4,4,2,1,1,2,1,2,1,2,2,3,3,3,4,2,1,1,1,1,2,2,1,4,4,4,4,4,4,4,3,4,4,1,1,2,2,3,4,4,3,1,4,2,3,3,2,1,3,4,4,2,4,1,1,3,3,2,2,3,1,2,1,4,3,3,2,2,2,1,4,2,4,3,3,3,1,3,3,2,3,3,1,4,4,3,2,4,2,2,4,1,1,1,3,1,3,2,2,3,4,4,3,2,2,1,2,4,1,1,2,2,1,1,1,3,1,2,2,2,1,1,4,1,3,1,1,1,1,1,3,1,2,3,3,3,2,4,3,3,3,1,2,4,2,3,3,1,4,2,3,3,3,4,1,2,3,2,3,4,2,3,4,4,1,2,4,3,4,4,2,2,3,1,4,3,4,2,1,2,3,2,4,2,1,3,4,1,2,1,1,4,1,2,4,1,4,3,4,4,2,2,1,1,2,3,4,3,3,1,3,1,4,4,3,2,4,4,2,1,1,4,1,1,2,3,2,3,3,4,2,2,4,3,3,3,2,1,1,2,2,4,1,4,1,3,1,1,4,1,4,4,3,1,4,3,3,2,1,1,4,2,4,2,4,1,1,4,1,3,1,2,4,1,1,4,1,3,1,3,4,1,4,2,3,1,3,2,3,3,3,4,2,3,4,3,1,4,1,3,3,4,4,4,4,1,2,3,1,3,3,3,1,3,4,1,3,1,4,1,3,2,4,4,3,1,1,4,2,1,3,1,2,2,1,1,4,3,2,3,4,1,4,1,1,4,2,1,2,1,2,4,3,1,3,3,2,4,3,1,2,1,3,3,3,1,4,3,1,3,2,3,1,3,1,4,1,1,4,4,2,3,1,4,4,3,4,1,3,4,2,3,4,4,2,3,1)
nList, nAnswer = len(read), len(Answer)
if nList != nAnswer: print('題目長度 ', nList, ' 與答案長度 ', nAnswer,' 不同!')
for i in range( nList ):
a1 = read[i].find('(1)')
b2 = read[i].find('(2)')
c3 = read[i].find('(3)')
d4 = read[i].find('(4)')
q = read[i][:a1]
a = '(1) ' + read[i][a1 + 3 : b2]
b = '(2) ' + read[i][b2 + 3 : c3]
c = '(3) ' + read[i][c3 + 3 : d4]
d = '(4) ' + read[i][d4 + 3 : -1]
List.append( Financial( i+1, q, a, b, c, d, str(Answer[i])) )
tk = tkinter.Tk()
tk.title("劉任昌Python tkinter GUI金融常識測驗app")
tk.geometry('1200x400')
number = tkinter.IntVar(tk)
reply, qtk = tkinter.StringVar(tk), tkinter.StringVar(tk)
atk, btk = tkinter.StringVar(tk), tkinter.StringVar(tk)
ctk, dtk = tkinter.StringVar(tk), tkinter.StringVar(tk)
select = ('1', '2', '3', '4')
reply.set('答')
number.set(1)
update()
option = tkinter.OptionMenu(tk, reply, *select, command=check).grid(column=1, row=0)
LBq = tkinter.Label(tk, textvariable=qtk, wrap=1000, font=('微軟中黑體',20),justify="left")#題目
LBq.grid(column=2, row=0, sticky=tkinter.W)
LBa = tkinter.Label(tk, textvariable=atk, bg='white', fg='black')
LBa.grid(column=2, row=1, sticky=tkinter.W) #選項(1)
LBb = tkinter.Label(tk, textvariable=btk, bg='white', fg='black')
LBb.grid(column=2, row=2, sticky=tkinter.W) #選項(2)
LBc = tkinter.Label(tk, textvariable=ctk, bg='white', fg='black')
LBc.grid(column=2, row=3, sticky=tkinter.W) #選項(3)
LBd = tkinter.Label(tk, textvariable=dtk, bg='white', fg='black')
LBd.grid(column=2, row=4, sticky=tkinter.W) #選項(4)
LBnumber = tkinter.Entry(tk, textvariable=number, width = 3)
LBnumber.grid(column=0, row=0)
btnprev = tkinter.Button(tk, text='前一題', width=6, command=prev).grid(column=0, row=1)
btnnext = tkinter.Button(tk, text='下一題', width=6, command=next, font=('微軟中黑體',20), bg='yellow').grid(column=0, row=2)
tk.mainloop()
https://lihtml-css-javascript-java.blogspot.com/2025/10/tkinterapp.html
回覆刪除先貼上就對了,大家都有所交代。https://lihtml-css-javascript-java.blogspot.com/2025/10/tkinterapp.html
刪除"<PRE> style='border: 3px red solid'>"錯誤!請用心,開始與結束的對稱"
刪除;<STYLE;>H1{background:purple;color:white};</STHLE;> 錯誤沒改,導致整個網頁不能閱讀。
刪除https://kobasam.blogspot.com/2025/10/tkinterapp.html
回覆刪除必須在練習遷入維基百科網頁。https://kobasam.blogspot.com/2025/10/tkinterapp.html
刪除這個網頁錯誤無法閱讀,通常是因為指令沒有結束,沒有用大於符號結束HTML指令。https://kobasam.blogspot.com/2025/09/pythonfind.html
https://hsieh02.blogspot.com/2025/10/tkinterapp.html
回覆刪除完美呈現!繼續學習,壯大自己,地球需要你的保護。
刪除https://penny0610.blogspot.com/2025/10/tkinterapp.html
回覆刪除已經有嵌入網頁,也有練習CSS,以已經很完美!https://penny0610.blogspot.com/2025/09/pythonyfind.html
刪除https://ddjcfiv.blogspot.com/2025/10/tkinterapp.html
回覆刪除嵌入影片與網頁,妳太完美了!https://ddjcfiv.blogspot.com/2025/09/pythonfind.html
刪除https://qiujixuan.blogspot.com/2025/10/tkinterapp.html
回覆刪除916第一次上課.https://qiujixuan.blogspot.com/2025/09/stringmethodcountsplit.html
刪除https://caipeizhen.blogspot.com/2025/10/tkinterapp.html
回覆刪除佳,持續學習,壯大自己,拯救人類!
刪除https://jiajinglai38.blogspot.com/2025/10/thinterapp.html
回覆刪除認真趕進度,全人類需要你的積極態度。https://jiajinglai38.blogspot.com/2025/09/pythonfind.html
刪除https://z828253084.blogspot.com/2025/10/import-tkinter-tkinter-602-importexport.html
回覆刪除https://jay960413.blogspot.com/2025/10/thinter.html
回覆刪除https://fake888.blogspot.com/2025/10/tkinterapp.html
回覆刪除作者已經移除這則留言。
回覆刪除https://16pyoyo.blogspot.com/2025/10/tkinterapp.html
回覆刪除作者已經移除這則留言。
回覆刪除https://dutchifkhoh.blogspot.com/2025/10/tkinterapp.html
回覆刪除https://lyon416.blogspot.com/2025/10/2.html
回覆刪除https://chenyunxi.blogspot.com/2025/10/tkinter.html
回覆刪除https://liuyuhsuan0.blogspot.com/2025/10/tkinter.htm
回覆刪除https://xuweiwen.blogspot.com/2025/10/tkinter.html
回覆刪除https://rui960104.blogspot.com/2025/10/tkinterapp.html
回覆刪除作者已經移除這則留言。
回覆刪除https://hidhfcaha.blogspot.com/2025/10/tkinterapp.html
回覆刪除https://yehkotang.blogspot.com/2025/10/tkinterapp.html
回覆刪除作者已經移除這則留言。
回覆刪除作者已經移除這則留言。
回覆刪除https://wu-hanlin.blogspot.com/2025/10/tkinterapp.html
回覆刪除https://www.blogger.com/blog/post/edit/3670060619581794585/5270834486320122038
回覆刪除作者已經移除這則留言。
回覆刪除