發表文章

目前顯示的是 5月, 2024的文章

林心憲GUI計算機eval函數比較美國與印度程式碼

圖片
 印度計算機 程式碼: from tkinter import * def button_press ( num ):     global equation_text     equation_text = equation_text + str (num)     equation_label.set(equation_text) def equals ():     global equation_text     try :         total = str ( eval (equation_text))         equation_label.set(total)         equation_text = total     except SyntaxError :         equation_label.set( "syntax error" )         equation_text = ""     except ZeroDivisionError :         equation_label.set( "arithmetic error" )         equation_text = "" def clear ():     global equation_text     equation_label.set( "" )     equation_text = '' window = Tk() window.title( '林心憲拷貝美國人的程式碼' ) window.geometry( "500x500" ) equation_text = "" equation_label = Stri...

林心憲python建立tkinter視窗控制其他視窗

圖片
  #VS Code開啟資料夾,開新檔案xxx.py貼上以下的指令,再去修改,寫出對指令的了解 from tkinter import * #從tkinter函式庫輸入所有函式,檔案'window001.py' import time           #412單元延續數入time套件 def delete ():         #增加自訂函數def delete()     List[ int (n.get()) - 1 ].destroy() #destroy破壞視窗List[索引]     window.config( bg = '#10fF10' )     b1 = Label(window, text = '林心憲' , font = 'Arial 100 bold' , bg = '#10ff10' ).pack() X = ( '😵‍💫' , '😖' , '😺' , '🤖' , '🥳' , '🤫' ) #建立元祖tuple名為x,0,1,2,3,4,5 List = []                   #建立串列list名為List for i in range ( 6 ):     window = Tk()     window.title( '林心憲第%d個視窗' % (i + 1 ))     window.geometry( '300x300+%d+%d' % (i * 300 ,i * 100 ))     b1 = Label(window, text = X[i], font = 'Arial 200 bold' ).pack()     window.update()     time.sleep( 0.1 )     List.append(window) #新增指令:將視窗存在串列List wind...