我有两个脚本,下面是我用作菜单的脚本,因此需要打开的第一个窗口也是如此。当我单击“ Simular”时,需要关闭此窗口或“脚本”,然后打开另一个,但传递参数。
tinymce.init({
selector: "#textarea1",
});
我知道这是使用类的一种方法,但是我不知道如何使用它们,希望您能为我提供帮助,谢谢。
答案 0 :(得分:0)
我在您的代码中进行了一些更改,将Combobox替换为OptionMenu。 然后为新窗口创建新函数,并在按下按钮后传递变量。
from tkinter import *
from tkinter.ttk import *
main = Tk()
# Limpiar registros con botonLimpiar
def valoresLimpiar(*args):
varDes.set('Seleccionar...')
varModo.set('Seleccionar...')
varEst.set('Seleccionar...')
# Obtener Valores con botonSimular
def move_data():
window = Tk() # initiate tkinter to build window
window.geometry('800x500') # set window size
label = Label(window, text='ventanaDeslizante = ' + data_1.get()) # set label
label.grid(column=0, row=0) # position of label
label = Label(window, text='ventanaModoTrans = ' + data_2.get()) # set label
label.grid(column=0, row=1) # position of label
label = Label(window, text='ventanaModoTrans = ' + data_3.get()) # set label
label.grid(column=0, row=2) # position of label
window.mainloop() # loop to show window
# Variables
varDes = StringVar(main)
varDes.set('Seleccionar...')
varModo = StringVar(main)
varModo.set('Seleccionar...')
varEst = StringVar(main)
varEst.set('Seleccionar...')
main.title("Configuración")
main.configure(background = 'light grey') # Color de Fondo
# Caja texto
label = Label(main, text='Ventana Deslizante')
label.grid(row = 0, column = 0)
label = Label(main, text = 'Modo de Transmisión')
label.grid(row = 1, column = 0)
label = Label(main, text = 'Estrategia de Transmisión')
label.grid(row = 2, column = 0)
# Caja de Opciones
data_1= StringVar()
ventanaDeslizante = Combobox(main, width=8, textvariable=data_1)
# create box list
ventanaDeslizante['values'] = ['1','2', '3', '4', '5', '6', '7']
# setup values for the list
ventanaDeslizante.current(0)
# set starting index from the list
ventanaDeslizante.grid(row = 0, column = 1, padx = 30, pady = 30)
data_2= StringVar()
ventanaModoTrans = Combobox(main, width=8, textvariable=data_2)
# create box list
ventanaModoTrans['values'] = ['NRM','ABM']
ventanaModoTrans.current(0)
ventanaModoTrans.grid(row = 1, column = 1, padx = 30, pady = 30)
data_3= StringVar()
ventanaEstTrans = Combobox(main, width=8, textvariable=data_3)
# create box list
ventanaEstTrans['values'] = ['GoBack-N','Repetición Selectiva']
ventanaEstTrans.current(0)
ventanaEstTrans.grid(row = 2, column = 1, padx = 30, pady = 30)
# Botones Limpiar y Simular
botonLimpiar = Button(main, text="Limpiar", width=20,
command=valoresLimpiar)
botonLimpiar.grid(row = 3, column = 0, padx = 20, pady = 30)
botonSimular = Button(main, text="Simular", width=20,
command=move_data)
botonSimular.grid(row = 3, column = 1, padx = 20, pady = 30)
main.mainloop()