def test1(): top = tix.Tk() lab = tix.Label(top) lab.pack() # 使用的是config()而不是之前使用的字典来设置文本属性。事件处理程序lambda函数使用了字符串参数s # 它是通过小部件事件传入的。字符串保存当前选择的值 cb = tix.ComboBox(top, command=lambda s: lab.config(text=s)) for s in ["Fred", "Ginger", "Gene", "Debbie"]: cb.insert("end", s) cb.pick(0) lab["text"] = "Pick any item" cb.pack() top.mainloop()
def __init__(self, fenetre, **kwargs): Frame.__init__(self, fenetre, width=100, height=100, **kwargs) self.pack(fill=BOTH, expand=True) #initialisation self.listefield1 = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 ] self.listefield2 = [1, 2, 3, 4, 1, 2, 3, 4] self.listefield3 = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 4] self.listefield4 = [1, 2, 3, 4, 1, 2, 3, 4] self.listefield5 = [1, 2, 3, 4, 1, 2, 3, 4, 3] self.value_input_zsro = StringVar() self.value_input_pfsro = StringVar() self.value_input_zpbo = StringVar() self.value_input_pfpbo = StringVar() self.value_input_piq = StringVar() self.value_input_zsro.set("Charger la Zone Arrière SRO") self.value_input_pfsro.set("Charger les emplacements SRO") self.value_input_zpbo.set("Charger la Zone arrière PBO") self.value_input_pfpbo.set("Charger les emplacements PBO") self.value_input_piq.set("Charger le Piq_BAL") self.varcombo1 = tix.StringVar() self.varcombo2 = tix.StringVar() self.varcombo3 = tix.StringVar() self.varcombo4 = tix.StringVar() self.varcombo5 = tix.StringVar() self.champs_choisi1 = StringVar() self.champs_choisi2 = StringVar() self.champs_choisi3 = StringVar() self.champs_choisi4 = StringVar() self.champs_choisi5 = StringVar() self.path1 = StringVar() self.path2 = StringVar() self.path3 = StringVar() self.path4 = StringVar() self.path5 = StringVar() self.coherence = coherence() # création des Frames dans la fenêtre principale self.Frame1 = Frame(self, relief=GROOVE) self.Frame2 = Frame(self, relief=GROOVE) self.Frame3 = Frame(self, relief=GROOVE) self.Frame4 = Frame(self, relief=GROOVE) self.Frame5 = Frame(self, relief=GROOVE) # Placement des frames self.Frame1.place(x=20, y=00, width=650, height=40) self.Frame2.place(x=20, y=40, width=650, height=40) self.Frame3.place(x=20, y=80, width=650, height=40) self.Frame4.place(x=20, y=120, width=650, height=40) self.Frame5.place(x=20, y=160, width=650, height=40) #Frame exécution self.Frame6 = Frame(self, relief=GROOVE) self.Frame6.place(x=180, y=200, width=100, height=40) # ---------------------------------------------------------------------------------------------------------------------- # FRAME 1 constructeur # ---------------------------------------------------------------------------------------------------------------------- self.entree1 = Entry( self.Frame1, textvariable=self.value_input_zsro) # création de l'entrer self.entree1.pack( side=LEFT, fill=X, padx=5, expand=True ) # afficher le champ et le placer (expend true (si plus grand va s'adapter)) self.combo1 = tix.ComboBox(self.Frame1, editable=1, dropdown=1, variable=self.varcombo1, command=self.Affiche1) self.combo1.entry.config( state='readonly') ## met la zone de texte en lecture seule # bouton1 parcourir self.bouton1 = Button(self.Frame1, text="Parcourir...", command=self.chose_file1) # création de bouton self.bouton1.pack(side=RIGHT, padx=5, pady=5) # afficher le bouton et le placer # ---------------------------------------------------------------------------------------------------------------------- # FRAME 2 constructeur # ---------------------------------------------------------------------------------------------------------------------- self.entree2 = Entry( self.Frame2, textvariable=self.value_input_pfsro) # création de l'entrer self.entree2.pack( side=LEFT, fill=X, padx=5, expand=True ) # afficher le champ et le placer (expend true (si plus grand va s'adapter)) # liste déroulante self.combo2 = tix.ComboBox(self.Frame2, editable=1, dropdown=1, variable=self.varcombo2, command=self.Affiche2) self.combo2.entry.config( state='readonly') ## met la zone de texte en lecture seule # bouton parcourir self.bouton2 = Button(self.Frame2, text="Parcourir...", command=self.chose_file2) # création de bouton self.bouton2.pack(side=RIGHT, padx=5, pady=5) # afficher le bouton et le placer #----------------------------------------------------------------------------------------------------------------------- # FRAME 3 constructeur #----------------------------------------------------------------------------------------------------------------------- self.entree3 = Entry( self.Frame3, textvariable=self.value_input_zpbo) # création de l'entrer self.entree3.pack( side=LEFT, fill=X, padx=5, expand=True ) # afficher le champ et le placer (expend true (si plus grand va s'adapter)) # liste déroulante self.combo3 = tix.ComboBox(self.Frame3, editable=1, dropdown=1, variable=self.varcombo3, command=self.Affiche3) self.combo3.entry.config( state='readonly') ## met la zone de texte en lecture seule # bouton parcourir self.bouton3 = Button(self.Frame3, text="Parcourir...", command=self.chose_file3) # création de bouton self.bouton3.pack(side=RIGHT, padx=5, pady=5) # afficher le bouton et le placer # ----------------------------------------------------------------------------------------------------------------------- # FRAME 4 constructeur # ----------------------------------------------------------------------------------------------------------------------- self.entree4 = Entry( self.Frame4, textvariable=self.value_input_pfpbo) # création de l'entrer self.entree4.pack( side=LEFT, fill=X, padx=5, expand=True ) # afficher le champ et le placer (expend true (si plus grand va s'adapter)) # liste déroulante self.combo4 = tix.ComboBox(self.Frame4, editable=1, dropdown=1, variable=self.varcombo4, command=self.Affiche4) self.combo4.entry.config( state='readonly') ## met la zone de texte en lecture seule # bouton parcourir self.bouton4 = Button(self.Frame4, text="Parcourir...", command=self.chose_file4) # création de bouton self.bouton4.pack(side=RIGHT, padx=5, pady=5) # afficher le bouton et le placer # ---------------------------------------------------------------------------------------------------------------------- # FRAME 5 constructeur # ---------------------------------------------------------------------------------------------------------------------- self.entree5 = Entry( self.Frame5, textvariable=self.value_input_piq) # création de l'entrer self.entree5.pack( side=LEFT, fill=X, padx=5, expand=True ) # afficher le champ et le placer (expend true (si plus grand va s'adapter)) # liste déroulante self.combo5 = tix.ComboBox(self.Frame5, editable=1, dropdown=1, variable=self.varcombo5, command=self.Affiche5) self.combo5.entry.config( state='readonly') ## met la zone de texte en lecture seule # bouton parcourir self.bouton5 = Button(self.Frame5, text="Parcourir...", command=self.chose_file5) # création de bouton self.bouton5.pack(side=RIGHT, padx=5, pady=5) # afficher le bouton et le placer # ----------------------------------------------------------------------------------------------------------------------- # FRAME 6 fonction # ----------------------------------------------------------------------------------------------------------------------- # bouton parcourir self.bouton6 = Button(self.Frame6, text="Executer") # création de bouton self.bouton6.pack(side=RIGHT, padx=5, pady=5) # afficher le bouton et le placer
def __init__(self, fenetre, **kwargs): Frame.__init__(self, fenetre, width=100, height=100, **kwargs) # Création de la fenêtre principale (main window) self.pack(fill=BOTH, expand=True) #initialisation self.liste1 = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 ] self.liste2 = [1, 2, 3, 4, 1, 2, 3, 4] self.liste3 = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 4] self.liste4 = [1, 2, 3, 4, 1, 2, 3, 4] self.liste5 = [1, 2, 3, 4, 1, 2, 3, 4, 3] self.value_input1 = StringVar() self.value_input2 = StringVar() self.value_input3 = StringVar() self.value_input4 = StringVar() self.value_input5 = StringVar() self.value_input1.set("Charger un fichier") self.value_input2.set("Charger un fichier") self.value_input3.set("Charger un fichier") self.value_input4.set("Charger un fichier") self.value_input5.set("Charger un fichier") self.varcombo1 = tix.StringVar() self.varcombo2 = tix.StringVar() self.varcombo3 = tix.StringVar() self.varcombo4 = tix.StringVar() self.varcombo5 = tix.StringVar() self.champs_choisi1 = StringVar() self.champs_choisi2 = StringVar() self.champs_choisi3 = StringVar() self.champs_choisi4 = StringVar() self.champs_choisi5 = StringVar() self.path1 = StringVar() self.path2 = StringVar() self.path3 = StringVar() self.path4 = StringVar() self.path5 = StringVar() # création des Frames dans la fenêtre principale self.Frame1 = Frame(self, relief=GROOVE) self.Frame2 = Frame(self, relief=GROOVE) self.Frame3 = Frame(self, relief=GROOVE) self.Frame4 = Frame(self, relief=GROOVE) self.Frame5 = Frame(self, relief=GROOVE) # Placement des frames self.Frame1.place(x=20, y=00, width=650, height=40) self.Frame2.place(x=20, y=40, width=650, height=40) self.Frame3.place(x=20, y=80, width=650, height=40) self.Frame4.place(x=20, y=120, width=650, height=40) self.Frame5.place(x=20, y=160, width=650, height=40) #Frame exécution self.Frame6 = Frame(self, relief=GROOVE) self.Frame6.place(x=180, y=200, width=100, height=40) # ---------------------------------------------------------------------------------------------------------------------- # FRAME 1 constructeur # ---------------------------------------------------------------------------------------------------------------------- self.entree1 = Entry( self.Frame1, textvariable=self.value_input1) # création de l'entrer self.entree1.pack( side=LEFT, fill=X, padx=5, expand=True ) # afficher le champ et le placer (expend true (si plus grand va s'adapter)) self.combo1 = tix.ComboBox(self.Frame1, editable=1, dropdown=1, variable=self.varcombo1, command=self.Affiche1) self.combo1.entry.config( state='readonly') ## met la zone de texte en lecture seule for i in range(0, len(self.liste1)): self.combo1.insert( i, self.liste1[i]) # Liste est la liste qui récupère les champs i += 1 self.combo1.pack(side=LEFT, padx=5, pady=5) # bouton1 parcourir self.bouton1 = Button(self.Frame1, text="Parcourir...", command=self.chose_file1) # création de bouton self.bouton1.pack(side=RIGHT, padx=5, pady=5) # afficher le bouton et le placer # ---------------------------------------------------------------------------------------------------------------------- # FRAME 2 constructeur # ---------------------------------------------------------------------------------------------------------------------- self.entree2 = Entry( self.Frame2, textvariable=self.value_input2) # création de l'entrer self.entree2.pack( side=LEFT, fill=X, padx=5, expand=True ) # afficher le champ et le placer (expend true (si plus grand va s'adapter)) # liste déroulante self.combo2 = tix.ComboBox(self.Frame2, editable=1, dropdown=1, variable=self.varcombo2, command=self.Affiche2) self.combo2.entry.config( state='readonly') ## met la zone de texte en lecture seule for i in range(0, len(self.liste2)): self.combo2.insert( i, self.liste1[i]) # Liste est la liste qui récupère les champs i += 1 self.combo2.pack(side=LEFT, padx=5, pady=5) # bouton parcourir self.bouton2 = Button(self.Frame2, text="Parcourir...", command=self.chose_file2) # création de bouton self.bouton2.pack(side=RIGHT, padx=5, pady=5) # afficher le bouton et le placer #----------------------------------------------------------------------------------------------------------------------- # FRAME 3 constructeur #----------------------------------------------------------------------------------------------------------------------- self.entree3 = Entry( self.Frame3, textvariable=self.value_input3) # création de l'entrer self.entree3.pack( side=LEFT, fill=X, padx=5, expand=True ) # afficher le champ et le placer (expend true (si plus grand va s'adapter)) # liste déroulante self.combo3 = tix.ComboBox(self.Frame3, editable=1, dropdown=1, variable=self.varcombo3, command=self.Affiche3) self.combo3.entry.config( state='readonly') ## met la zone de texte en lecture seule for i in range(0, len(self.liste3)): self.combo3.insert( i, self.liste1[i]) # Liste est la liste qui récupère les champs i += 1 self.combo3.pack(side=LEFT, padx=5, pady=5) # bouton parcourir self.bouton3 = Button(self.Frame3, text="Parcourir...", command=self.chose_file3) # création de bouton self.bouton3.pack(side=RIGHT, padx=5, pady=5) # afficher le bouton et le placer # ----------------------------------------------------------------------------------------------------------------------- # FRAME 4 constructeur # ----------------------------------------------------------------------------------------------------------------------- self.entree4 = Entry( self.Frame4, textvariable=self.value_input4) # création de l'entrer self.entree4.pack( side=LEFT, fill=X, padx=5, expand=True ) # afficher le champ et le placer (expend true (si plus grand va s'adapter)) # liste déroulante combo4 = tix.ComboBox(self.Frame4, editable=1, dropdown=1, variable=self.varcombo4, command=self.Affiche4) combo4.entry.config( state='readonly') ## met la zone de texte en lecture seule for i in range(0, len(self.liste4)): combo4.insert( i, self.liste1[i]) # Liste est la liste qui récupère les champs i += 1 combo4.pack(side=LEFT, padx=5, pady=5) # bouton parcourir self.bouton4 = Button(self.Frame4, text="Parcourir...", command=self.chose_file4) # création de bouton self.bouton4.pack(side=RIGHT, padx=5, pady=5) # afficher le bouton et le placer # ---------------------------------------------------------------------------------------------------------------------- # FRAME 5 constructeur # ---------------------------------------------------------------------------------------------------------------------- self.entree5 = Entry( self.Frame5, textvariable=self.value_input5) # création de l'entrer self.entree5.pack( side=LEFT, fill=X, padx=5, expand=True ) # afficher le champ et le placer (expend true (si plus grand va s'adapter)) # liste déroulante self.combo5 = tix.ComboBox(self.Frame5, editable=1, dropdown=1, variable=self.varcombo5, command=self.Affiche5) self.combo5.entry.config( state='readonly') ## met la zone de texte en lecture seule for i in range(0, len(self.liste5)): self.combo5.insert( i, self.liste1[i]) # Liste est la liste qui récupère les champs i += 1 self.combo5.pack(side=LEFT, padx=5, pady=5) # bouton parcourir self.bouton5 = Button(self.Frame5, text="Parcourir...", command=self.chose_file5) # création de bouton self.bouton5.pack(side=RIGHT, padx=5, pady=5) # afficher le bouton et le placer # ----------------------------------------------------------------------------------------------------------------------- # FRAME 6 fonction # ----------------------------------------------------------------------------------------------------------------------- # bouton parcourir self.bouton6 = Button(self.Frame6, text="Executer") # création de bouton self.bouton6.pack(side=RIGHT, padx=5, pady=5) # afficher le bouton et le placer
def body(self, master): self.disks = DiskAnalyzer.PhysicalDiskAnalyzer().disks if self.disks == -1: pass else: list = tix.ComboBox( master, label="Drive: ", command=self.__updateDeviceInfo, dropdown=1, editable=0, options='listbox.height 6 label.width 10 label.anchor e') list.pack(side=tix.TOP, anchor=tix.W) for d in self.disks: list.insert(tix.END, d["Disk"]) diskInfoFrame = Frame(master) diskInfoFrame.pack() self.vdiskpath = StringVar() self.vsize = StringVar() self.vtpc = StringVar() self.vcyl = StringVar() self.vbps = StringVar() self.vmtype = StringVar() self.vspt = StringVar() diskpath = self.__createEntryField(diskInfoFrame, "Disk Path: ", row=0, state="readonly", textvariable=self.vdiskpath) size = self.__createEntryField(diskInfoFrame, "Size in GB: ", row=1, state="readonly", textvariable=self.vsize) tpc = self.__createEntryField(diskInfoFrame, "Tracks Per Cylinder: ", row=2, state="readonly", textvariable=self.vtpc) cyl = self.__createEntryField(diskInfoFrame, "Cylinders: ", row=3, state="readonly", textvariable=self.vcyl) bps = self.__createEntryField(diskInfoFrame, "Bytes Per Sector: ", row=4, state="readonly", textvariable=self.vbps) mtype = self.__createEntryField(diskInfoFrame, "Media Type: ", row=5, state="readonly", textvariable=self.vmtype) spt = self.__createEntryField(diskInfoFrame, "Sectors Per Track: ", row=6, state="readonly", textvariable=self.vspt)
def concatener_ou_reunion(self, concate=True): """ le géstionnaire d'événement click sur les bouttons de menu 'concaténation' ou 'réunion'. lorsque le paramétre concate=True donc cette méthode fait la concaténation sinon fait la réunion. """ if len(AutoApp.autos.keys()) < 2: showinfo( "aucun autre automate ouvré", "il faut ouvrir des autres automates pour faire la concaténation.", parent=self) return top = tix.Tk() top.config(bg='#2E2E2E') dimension, xl, yl = self.geometry().split('+') wl, hl = dimension.split('x') xl, yl, wl, hl = int(xl), int(yl), int(wl), int(hl) top.geometry("+%d+%d" % (xl + wl // 2, yl + hl // 2)) if concate: top.title("concaténation d'automate {0}".format(self.nom)) else: top.title("réunion d'automate {0}".format(self.nom)) Label(top, text="choisir un automate:", font="andalus 12 italic", fg='#10BEBE', bg='#2E2E2E').grid(row=0, column=0, columnspan=2, padx=1, pady=1, sticky=N + E + W + S) nom_auto = StringVar(top) nom_auto.set(list(AutoApp.autos.keys())[0]) choix = tix.ComboBox(top, variable=nom_auto, width=22) #print(choix.config()) for nom_aut in AutoApp.autos.keys(): choix.insert(END, nom_aut) #nom_auto.set(list(AutoApp.autos.keys())[0]) choix.grid(row=0, column=2, columnspan=2, padx=1, pady=1, sticky=N + E + W + S) def click_btn_ok(): top.destroy() if AutoApp.get_automate_par_nom( self.nom) is not None and AutoApp.get_automate_par_nom( nom_auto.get()) is not None: _title = self.nom + " et " + nom_auto.get() if concate: AutoGraphe.concatener(self.automate_courant, AutoApp.get_automate_par_nom( nom_auto.get()).automate_courant, title="concaténation de " + _title) else: AutoGraphe.reunion(self.automate_courant, AutoApp.get_automate_par_nom( nom_auto.get()).automate_courant, title="réunion de " + _title) else: showerror("erreur", "automate non trouvé", parent=self) def click_btn_annuler(): top.destroy() Button(top, text="Ok", command=click_btn_ok, bg='light green', relief='raised', font="andalus 14 bold", height=2, width=7, cursor='hand2').grid(row=1, column=1, padx=1, pady=1, sticky=N + E + W + S) Button(top, text="annuler", command=click_btn_annuler, bg='salmon', relief='raised', font="andalus 14 bold", height=2, width=7, cursor='hand2').grid(row=1, column=2, padx=1, pady=1, sticky=N + E + W + S)
import tkinter.tix as tix top = tix.Tk() lab = tix.Label(top) lab.pack() cb = tix.ComboBox(top, command=lambda s: lab.config(text=s)) for st in ["Fred", "Ginger", "Gene", "Debbie", "Tommy"]: cb.insert("end", st) cb.pick(0) lab['text'] = "Pick a value, any value..." cb.pack() top.mainloop()
#Accueil fenetreAccueil = Tk() fenetreAccueil.title("Premier pas dans l'eau") # JOUR lblJour = Label(fenetreAccueil, text="Jour :").pack() # Permet de faire une saisie de nombre entre 1 et 31 sans que l'utilisateur ecrire dans le champ jourSaisie = Spinbox(fenetreAccueil, from_=1, to=31, state="readonly") jourSaisie.pack() # MOIS lblMois = Label(fenetreAccueil, text="Mois :").pack() # Utilisation de Tix pour faire une liste deroulante fenetreAccueil.tk.eval('package require Tix') cbVar = tix.StringVar() combo = tix.ComboBox(fenetreAccueil,dropdown=1, variable=cbVar) combo.entry.config(state='readonly') #Lecture seul dans la zone de text combo.insert(0, 'Janvier') combo.insert(1, 'Fevrier') combo.insert(2, 'Mars') combo.insert(3, 'Avril') combo.insert(4, 'Mai') combo.insert(5, 'Juin') combo.insert(6, 'Juillet') combo.insert(7, 'Aout') combo.insert(8, 'Septembre') combo.insert(9, 'Octobre') combo.insert(10, 'Novembre') combo.insert(11, 'Decembre') combo.pack()
def build_screen(screen_def, main_window=False): """ Creates a screen for the Tix Scrolled HList that displays the results of the SQL query associated with the "query" key word of the designated screen definition """ if debug: logger.debug("debug = {}".format(debug)) # Check to see if the ConnectionInfo attributes are properly set logger.debug("the connection object = {}".\ format(ConnectionInfo.cx_Oracle_connection_object)) logger.debug("the connect string = {}".\ format(ConnectionInfo.Oracle_connect_string)) logger.debug("the current DB = {}".\ format(ConnectionInfo.current_db) ) logger.debug("mainWindow = {}".format(screens.main_window)) #NOTE: screen_def["window"] is bound to the object created by tix.Tk() window = screen_def["window"] query_displayed = None if main_window: screens.main_window = screen_def['name'] if debug: logger.debug("Main Window = {}".format(screens.main_window)) #-------------------------------------------------------------- # Build the HList widget # Get the number of columns that will be displayed # in the HList num_columns = len(screen_def["columns"]) # Set the desired options for the HList widget hlist_options = 'hlist.width 130 hlist.height 30' + \ ' hlist.font -adobe-helvetica-bold-r-narrow--12-120' + \ ' hlist.background #B8B8B8 hlist.selectMode ' + screen_def["selectMode"] + \ ' hlist.columns %d hlist.header 1' % (num_columns +1,) # Create the HList widget window.tixHList = tix.ScrolledHList(window, options=hlist_options) hlist = window.tixHList.hlist # Set the current screen's dictionary keyword "hlist" to point to the # newly created HList widget. This allows other parts of this module # to access and manipulate it. screen_def["hlist"] = hlist # Create the headers for the HList widget # The value for the screen_def "columns" key word is a list of tuples consisting # of the Oracle column name and its corresponding header name, i.e. the name that # will be displayed in the HList header. Therefore, in the code below column[0] = # the Oracle column name and column[1] = the header name for column in screen_def["columns"]: num_hdr = screen_def["columns"].index(column) hlist.header_create(num_hdr, itemtype=tix.TEXT, text=column[1]) # #-------------------------------------------------------------- # Use ttk's Tk themed widget set to configure # the appearance of ttk buttons style = ttk.Style() style.configure("TButton", foreground="midnight blue", font="Times 10") style.configure('Red.TButton', foreground="dark red", font="Times 10") # Create a balloon tip for the buttons balloon_options = 'font -adobe-helvetica-italic-r-narrow--12-120' + \ ' background #99CCCC' balloon_tip = tix.Balloon(window, background='lightyellow', options=balloon_options) #-------------------------------------------------------------- # Create the "Close", "Refresh" and "Show SQL" buttons # # Create a frame widget to group the buttons together win_buttons_frm = tix.Frame(window) #Create a button to kill the HList's window close_btn = ttk.Button(win_buttons_frm, text="Close", style='Red.TButton', command=lambda: close_window(window)) balloon_tip.bind_widget(close_btn, balloonmsg='Close this window') if screen_def['name'] != 'DBMSOutput': # Create a button to re-run the query that populates # the HList refresh_btn = ttk.Button(win_buttons_frm, text="Refresh", command=lambda: refresh_display(screen_def)) balloon_tip.bind_widget(refresh_btn, balloonmsg="Refresh the window's data") # Create a button to display the query that was run to populate # the HList show_SQL_btn = ttk.Button( win_buttons_frm, text="Show SQL", command=lambda: show_SQL(screen_def, screens.displayed_query)) balloon_tip.bind_widget( show_SQL_btn, balloonmsg='Display the query executed to populate the window') # #-------------------------------------------------------------- #-------------------------------------------------------------- # Create buttons for the external programs #Create a frame to group the external program buttons together prog_buttons_frm = tix.Frame(window) # Create a button to open a SQL*Plus session for the # current user in the currently connected database sqlplus_btn = ttk.Button(prog_buttons_frm, text="SQL*Plus", command=lambda: open_sqlplus(screen_def)) current_db = ConnectionInfo.current_db.upper() current_user = ConnectionInfo.Oracle_connect_string.split("/")[0] balloon_tip.bind_widget(sqlplus_btn, balloonmsg="Open SQL*Plus Session for {}@{}".\ format(current_user,current_db)) # Create a button to pop the text selected in the HList into Notepad edit_btn = ttk.Button(prog_buttons_frm, text=" Notepad ", command=lambda: send_to_editor(screen_def)) balloon_tip.bind_widget(edit_btn, balloonmsg='Pop Selected Text into a Notepad') # #-------------------------------------------------------------- #-------------------------------------------------------------- # Create the sort widgets # if screen_def['name'] != 'DBMSOutput': #Create a frame to group the sort widgets together sort_widgets_frm = tix.Frame(window) sort_lbl = tix.Label(sort_widgets_frm, font='-adobe-helvetica-bold-r-narrow--12-120', text="Sort By:") column_cbo1 = tix.ComboBox(sort_widgets_frm) column_cbo1.entry.config(disabledbackground='white', disabledforeground='black') column_cbo2 = tix.ComboBox(sort_widgets_frm) column_cbo2.entry.config(disabledbackground='white', disabledforeground='black') column_cbo3 = tix.ComboBox(sort_widgets_frm) column_cbo3.entry.config(disabledbackground='white', disabledforeground='black') sort_btn = ttk.Button( sort_widgets_frm, text="Sort", command=lambda: sort_display(screen_def, columns_dict, column_cbo1, column_cbo2, column_cbo3)) balloon_tip.bind_widget(sort_btn, balloonmsg="Sort the window's data") clear_sort_btn = ttk.Button( sort_widgets_frm, text="Clear", style='Red.TButton', command=lambda: clear_sort(column_cbo1, column_cbo2, column_cbo3)) balloon_tip.bind_widget(clear_sort_btn, balloonmsg="Clear the sort selections") #............................................................. # Populate the combo box widgets used for sorting # Build a dictionary with header names as keys and their # corresponding Oracle column names as values for the # keys columns_dict = {} for column in screen_def["columns"]: columns_dict[column[1]] = column[0] if debug: logger.debug("columns_dict=".format(columns_dict)) # For each combobox widget, sequentially add each header name at the end # of the combobox dropdown list. Cast the "header:column" dictionary as # a set to order the header names alphabetically for headerName in sorted(set(columns_dict.keys())): column_cbo1.insert(tix.END, headerName) column_cbo2.insert(tix.END, headerName) column_cbo3.insert(tix.END, headerName) #............................................................. # #-------------------------------------------------------------- # Create a label to display the number of rows returned from the HList's query screen_def["varRows"] = StringVar() lblRows = tix.Label(window, textvariable=screen_def["varRows"], font='-adobe-helvetica-bold-r-narrow--12-120') # Attach the menus appropriate for the window attach_menus(screen_def) #-------------------------------------------------------------- # Arrange all the widgets on the screen # window.tixHList.pack(expand=1, fill=tix.BOTH, padx=10, pady=10, side=tix.TOP) win_buttons_frm.pack(side=tix.RIGHT, padx=5) close_btn.pack(side=RIGHT, pady=5) refresh_btn.pack(side=RIGHT) show_SQL_btn.pack(side=RIGHT) prog_buttons_frm.pack(side=tix.RIGHT, padx=5) sqlplus_btn.pack(side=RIGHT) edit_btn.pack(side=RIGHT) sort_widgets_frm.pack(side=tix.RIGHT, padx=5) sort_lbl.pack(side=tix.LEFT) column_cbo1.pack(side=tix.LEFT) column_cbo2.pack(side=tix.LEFT) column_cbo3.pack(side=tix.LEFT) sort_btn.pack(side=tix.LEFT) clear_sort_btn.pack(side=tix.LEFT) lblRows.pack(side='left', pady=10, padx=5)