我有一个有多行的表单。按 Enter 键会打开一个选项窗口。但每次我按回车键时,它都会打开一个新的选项窗口。我如何控制和检查选项窗口是否打开然后不打开选项窗口。
import tkinter as tk
from tkinter import ttk
from tkinter import *
from tkinter import messagebox
# Directory/File processing libraries
import os
import configparser
import csv
def callback():
#messagebox.showinfo("Netezza", Folder_Name_var.get())
#messagebox.showinfo("Netezza", Table_Name_var.get() )
config = configparser.ConfigParser()
config.read('C:\\aa\\config.ini')
#for value in config['Folder']: print(value)
for key in config.items('Folder'):
print (key[1].replace('{Folder_Name}',Folder_Name_var.get()))
os.makedirs(key[1].replace('{Folder_Name}',Folder_Name_var.get()),exist_ok=True)
def click_tv(event):
#messagebox.showinfo("Inside")
selected=trv.focus()
print(trv.item(selected))
def press_enter(event):
#messagebox.showinfo("Inside")
selected=trv.focus()
print(trv.item(selected))
print(str((event.keysym)))
if str((event.keysym))=='Return':
option_wnd=Toplevel(root)
option_wnd.geometry('200x200')
option_wnd.title('Option Window')
option_wnd.grab_set()
#option_wnd.pack()
def selection_change(event):
selected = trv.selection()[0]
print('You clicked on', trv.item(selected))
#option_wnd.mainloop()
root = Tk()
Folder_Name_var = tk.StringVar()
Table_Name_var = tk.StringVar()
# This is the section of code which creates the main window
root.geometry('873x498')
root.configure(background='#63B8FF')
root.title('Automation Software - Blue Shield of California')
pic= Canvas(root, height=100, width=100)
#pic= Canvas(root, height=225, width=580)
#picture_file = PhotoImage(file = 'c:\\aa\\bsc.png')
#pic.create_image(0, 0, anchor=NW, image=picture_file)
#pic.place(x=5, y=5)
每次我在根窗口上按 Enter 键时,都会打开一个弹出窗口。我需要控制它。如果弹出窗口打开,那么我们不应该允许另一个弹出窗口打开。
繁华开满天机
缥缈止盈
ITMISS
慕运维8079593
相关分类