Python Tkinter Treeview Get Values
>>>self.allrow.bind("",self.myFunc)
>>>def myFunc(self,event):
allrow=allrow.mytreeview.item(self.mytreeview.selection())
print(allrow)
print(allrow["values"][0])
{'text': '8', 'image': '', 'values': ['KARDAN ADAM', 'http://www.m-eken.com'], 'open': 0, 'tags': ''}
Aruz
>>>
Treeview in Python Tkinter
import tkinter
from tkinter import *
from tkinter import ttk
p=tkinter.Tk()
t=ttk.Treeview(p)
t["columns"]=("first","second")
t.column("first",width=75,anchor="center" )
t.column("second",width=100)
t.heading("first",text="first column")
t.heading("second",text="second column")
t.insert("",0,"dir1",text="directory 1")
t.insert("dir1","end","dir 1",text="file 1 1",values=("file 1 A","file 1 B"))
id=t.insert("","end","dir2",text="directory 2")
t.insert("dir2","end",text="dir 2",values=("file 2 A","file 2 B"))
t.insert(id,"end",text="dir 3",values=("val 1 ","val 2"))
t.insert("",0,text="first line",values=("first line 1","first line 2"))
t.tag_configure("ttk")
t.pack(side=BOTTOM,fill=X)
p.mainloop()
Google Search with Python 3 and Tkinter
Google Search with Python and Tkinter;
# http://m-eken.com
# python 3
#google Searcher
import tkinter,urllib.request,urllib.parse,urllib.error
from tkinter import *
from tkinter import ttk
class window:
def __init__(self,root):
self.root=root
self.root.title("Google Searcher")
ttk.Frame(self.root, width=500,height=250).pack()
self.init_widgets()
def init_widgets(self):
ttk.Button(self.root, command=self.insert_text,text="Gooo",width="10").place(x=400,y=10)
self.txt=tkinter.Text(self.root,width="52",height="10", font=12)
self.txt.place(x=10,y=40)
self.searchWord=tkinter.Text(self.root,width="42",height="1", font=12)
self.searchWord.insert(tkinter.INSERT,"google search with python 3 tkinter")
self.searchWord.place(x=10,y=15)
def insert_text(self):
GWord=self.searchWord.get(1.0,END)
url="http://www.google.com/search?hl=en&q="+"+".join(GWord.split())
req=urllib.request.Request(url)
req.add_header("User-Agent","Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.29 Safari/525.13")
GWord= urllib.request.urlopen(req).read()
self.txt.insert(tkinter.INSERT, GWord)
if __name__=="__main__":
root=tkinter.Tk()
window(root)
root.mainloop()