from ctypes import sizeof
import tkinter as tk
from tkinter import *
import tkinter.ttk as tkk
from turtle import width
from selenium import *
import webbrowser
new = 1
window = tk.Tk()
def Done():
global species
string= species.get()
furry.configure(text=string)
furry = tk.Label(
text="This is a furry pic generator enjoy",
foreground="Black",
width=60,
height=5
)
furry.pack()
species = tk.Entry()
species.pack(fill=tk.X)
x = species.get()
url = "https://www.google.com/search?q=" species.get()
def openweb():
webbrowser.open(url,new=new)
Furrygen = tk.Button(
text="Get a furry",
width=25,
height=2,
fg="Black",
command=openweb
)
Furrygen.pack(fill=tk.X)
window.mainloop()
這就是我的代碼我想要的是從物種條目中獲取資料并將其添加到谷歌的搜索中以在新選項卡中打開搜索已經完成我已經完成了一切但由于某種原因,它不想將條目中的資料放在搜索標簽上為什么會這樣?
uj5u.com熱心網友回復:
當我測驗它時,將 .get() 添加到您的 openweb() 函式解決了這個問題。查看我添加的列印陳述句,您可以看到它實際上是在抓取輸入。您還應該重新格式化您的腳本以提高可讀性并消除冗余。
import tkinter as tk
import tkinter.ttk as tkk
import webbrowser
new = 1
def openweb():
value = species.get()
species.delete("0", tk.END)
print(value)
url = "https://www.google.com/search?q=" value
print(url)
webbrowser.open(url,new=new)
def Done():
global species
string= species.get()
furry.configure(text=string)
window = tk.Tk()
furry = tk.Label(text="This is a furry pic generator enjoy", foreground="Black",
width=60, height=5)
furry.pack()
species = tk.Entry()
species.pack(fill=tk.X)
Furrygen = tk.Button(text="Get a furry", width=25, height=2,
fg="Black", command=openweb)
Furrygen.pack(fill=tk.X)
window.mainloop()
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/465730.html
