iT邦幫忙

0

(初學者) 請問 Tkinter 如何製作簡單GUI介面 GET API JSON資料

  • 分享至 

  • twitterImage

小弟想用Python Tkinter 做一個簡易的 獲取API JSON格式資料
但因為是初學者 目前只用好
https://ithelp.ithome.com.tw/upload/images/20200412/20126275I4JMDqWg18.jpg

如果能附上code 讓我參考一下非常感謝..
畫面需求簡易
一個文字輸入方塊 = 輸入API網址
按鈕 = 請求獲取
呈現資料方塊 <<想請問這個要用哪個物件瀏覽API資料

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

1
echochio
iT邦高手 1 級 ‧ 2020-04-12 19:56:34

給你看看改成你想要的
輸入 http://api.open-notify.org/astros.json

import PySimpleGUI as sg
def box(values):
    import requests
    response = requests.get(url=values)  
    sg.popup_scrolled('輸出 : \n'+response.text, title="API JSON", size=(80, None))

layout = [  [sg.Text('API 輸入網址')],
            [sg.Text('輸入 :'), sg.InputText()],
            [sg.OK(), sg.Cancel()]]

window = sg.Window('API 輸入', layout)
while True:             
    event, values = window.read()
    if event in (None, 'Cancel'):
        break
    box(values[0])

window.close()

https://ithelp.ithome.com.tw/upload/images/20200412/20110611zZteOXIO6D.png

https://ithelp.ithome.com.tw/upload/images/20200412/20110611Ahj5CAftsl.png

既然程式都寫了
不妨也拿去回答這一題

不知道是否是同班同學...
/images/emoticon/emoticon10.gif

echochio iT邦高手 1 級 ‧ 2020-04-13 20:01:19 檢舉

@ 海綿寶寶
交上去给老師會說 不行呦 !
明明題目寫 Tkinter ...但是卻用 PySimpleGUI
這樣不及格的 ....
而且現在老師不笨上網搜尋一下就看到有人提問了
重點是交回去的作業還用到 PySimpleGUI 那不是完全打槍了嗎 ?

我要發表回答

立即登入回答