Selector de acciones de programación GUI de Python (Tkinter)

Programación Tkinter
Tkinter es la biblioteca GUI estándar para Python. Python usa Tkinter para crear rápidamente aplicaciones GUI.

Dado que Tkinter está integrado en el paquete de instalación de Python, siempre que Python esté instalado, puede importar la biblioteca de Tkinter, y IDLE también está escrito en Tkinter. Tkinter aún puede manejar una interfaz gráfica simple.

Insertar descripción de la imagen aquí
Insertar descripción de la imagen aquí

#-*- 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()

Originalmente quería escribir algo. Sin embargo, mi nivel es limitado y siempre siento que el libro no puede transmitir completamente el significado.

agraviado
Insertar descripción de la imagen aquí

Supongo que te gusta

Origin blog.csdn.net/qq_20575249/article/details/115419920
Recomendado
Clasificación