概述
Tkinter 编程
Tkinter 是 Python 的标准 GUI 库。Python 使用 Tkinter 可以快速的创建 GUI 应用程序。
由于 Tkinter 是内置到 python 的安装包中、只要安装好 Python 之后就能 import Tkinter 库、而且 IDLE 也是用 Tkinter 编写而成、对于简单的图形界面 Tkinter 还是能应付自如。
#-*- coding:utf-8 -*-
import requests
from urllib import parse
import json
import tkinter as tk
from concurrent import futures
from tkinter import ttk
from tkinter import EXTENDED
from tkinter import END
from 选股 import Wencai
columns1 = ("代码","名称","价格")
ths_user = Wencai()
def 选股():
clear_list(treeview1)
name = parse.quote(Entry1.get())
data = ths_user.Xuangu(name)
for x in data:
treeview1.insert('', 'end',values=(x['代码'],x['名称'],x['价格']))
def clear_list(tree):
x=tree.get_children()
for item in x:
tree.delete(item)
def pass_download():
xuanzhong_index = Listbox1.curselection()
print(xuanzhong_index)
for n in range(0,len(xuanzhong_index)):
name = Listbox1.get(xuanzhong_index[n])
print(name)
# Entry1.insert(END,","+name)
Entry1.insert(END,name)
def 关键字():
data = ths_user.关键字()
for a in data:
print(a['name'])
Listbox1.insert(END,a['name'])
for a1 in a['options']:
print(a1['name'])
Listbox1.insert(END,a1['name'])
for a2 in a1['options']:
print(a2['name'])
Listbox1.insert(END,a2['name'])
# for a3 in a2['name']:
# print(a3['name'])
# Listbox1.insert(END,a3['name'])
#GUI
windows = tk.Tk()
windows.geometry('870x534')# +34
windows.title('选股2.0 关注公众号:Ctp接口量化')
windows.resizable(0,0)
Entry1 = tk.Entry(windows)
Entry1.place(height = 34,width = 703,x = 3,y = 6)
Button1 = tk.Button(windows,text='选股',command = 选股)
Button1.place(height = 30,width = 90,x = 721,y = 6)
Button2 = tk.Button(windows,text='关键字',command = 关键字)
Button2.place(height = 30,width = 90,x = 721,y =50)
Button3 = tk.Button(windows,text='添加条件',command = pass_download)
Button3.place(height = 30,width = 90,x = 560,y =50)
treeview1 = ttk.Treeview(windows, height=10, show="headings", columns=columns1)
treeview1.place(height = 500,width = 557,x = 3,y = 47+34)
treeview1.column("代码", width=150, anchor='center') # 表示列,不显示
treeview1.column("名称", width=150, anchor='center')
treeview1.column("价格", width=150, anchor='center')
treeview1.heading("代码", text="代码") # 显示表头
treeview1.heading("名称", text="名称")
treeview1.heading("价格", text="价格")
# treeview1.bind('<Double-1>', pass_download)
#列表2
Listbox1 = tk.Listbox(windows,selectmode = EXTENDED)
Listbox1.place(height = 500,width = 306,x = 560,y = 47+34)
# Listbox1.bind('<Double-1>', pass_download)
# Listbox2 = tk.Listbox(windows)
# Listbox2.place(height = 0,width = 0,x = 0,y = 0)
windows.mainloop()
本来想写点啥的 。 奈何水平有限总感觉, 书不尽言 言不尽意
憋屈
最后
以上就是愤怒鸵鸟为你收集整理的Python GUI编程(Tkinter) 之 股票选股器的全部内容,希望文章能够帮你解决Python GUI编程(Tkinter) 之 股票选股器所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复