forked from CristiVlad25/misc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tkapp5.py
45 lines (31 loc) · 1.14 KB
/
tkapp5.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import tkinter as tk
from tkinter import ttk
import webbrowser
from tkinter import *
root = tk.Tk()
root.title('Universal Search Bar')
label1 = ttk.Label(root, text='Query')
label1.grid(row=0, column=0)
entry1 = ttk.Entry(root, width=50)
entry1.grid(row=0, column=1)
btn2 = StringVar()
def callback():
if btn2.get() == 'google':
webbrowser.open('http://google.com/search?q='+entry1.get())
elif btn2.get() == 'duck':
webbrowser.open('http://duckduckgo.com/?q='+entry1.get())
def get(event):
if btn2.get() == 'google':
webbrowser.open('http://google.com/search?q='+entry1.get())
elif btn2.get() == 'duck':
webbrowser.open('http://duckduckgo.com/?q='+entry1.get())
MyButton1 = ttk.Button(root, text='Search', width=10, command=callback)
MyButton1.grid(row=0, column=2)
entry1.bind('<Return>', get)
MyButton2 = ttk.Radiobutton(root, text='Google', value='google', variable=btn2)
MyButton2.grid(row=1, column=1, sticky=W)
MyButton3 = ttk.Radiobutton(root, text='Duck', value='duck', variable=btn2)
MyButton3.grid(row=1, column=1, sticky=E)
entry1.focus()
root.wm_attributes('-topmost', 1)
root.mainloop()