我试图创建这样的代码,当状态列表框中的“新交易”文本被选中时,策略输入框将变成一个用x、y、z填充的列表框。
import pandas as pd
import sys, psycopg2, os, xlsxwriter
import PySimpleGUI as sg
import datetime
import getpass
from datetime import date, timedelta
from sqlalchemy import create_engine
# from writing import daily_TDP
from test import conversion
from retrieval_functions import copy_report, word_found, word_row
user_name = getpass.getuser()
out_path= r'path/TRADE_JOURNAL.xlsx'
recovery_path = r'Y:\ERROR_FILE_TRADES_NOT_EXPORTED.xlsx'
recovery_path = recovery_path[0:9] + recovery_path[10:]
columns = ["STATUS", "SYMBOL","TRADE_TYPE","BROKER", "PRICE", "QUANTITY","STRATEGY", "DATE_TRADE"]
param = (20,1)
def TRADE_ENTRY(columns, param, out_path,recovery_path):
sg.theme('Dark Brown 1')
listing = [sg.Text(u, size = param) for u in columns]
header = [[x] for x in listing]
core = [
sg.Listbox(['In Book', 'New Trade', 'Old Book'],enable_events=True,key='TYPE26',size = (20,2)),
sg.Input(size = param),
sg.Input(size = param),
sg.Input(size = param),
sg.Input(size = param),
sg.Input(size = param),
sg.Input(size = param, key= 'STRAT')]
mesh = [[x,y] for (x,y) in list(zip(listing, core))]
layout =[[sg.Button("SEND")]]+ mesh
window = sg.Window('Trade Entry System', layout, font='Courier 12').Finalize()
while True:
event, values = window.read()
if event == sg.WINDOW_CLOSED:
break
if event == "SEND":
data = values
print('DATA', data)
elif event == "TYPE26":
print('here')
if values[event] == ['New Trade']:
window["STRAT"].update(sg.Listbox(['X', 'Y', 'Z']))
window.close()
TRADE_ENTRY(columns, param,out_path, recovery_path)
目前,当按下“new trade”时,它成功地打印了“here”,但很明显,我的代码无法将此策略输入框实际更改为列表框。
谢谢
暂无答案!
目前还没有任何答案,快来回答吧!