Hi,
I'm writing a small application that gets some data from the user and launches a second application related to what process the user is working on. So, sometimes the user needs to choose from different versions of the same aplication. I decided that after the Ok button is pressed in main window, the application searches in some folders and open a second window with the different versions avaliable to that application. My problem is that when I launch the second window with the options my main application continues to run with default options. I press the buttons in the second window and nothing happens.
versionDialog is the class that is called to raise the second window.

thanks for helping

class versionDialog : 
    def escolha (self, item) :
        self.versao = item
        print item
        self.wdw.destroy

    def __init__ (self, message, options) :
        self.wdw = Toplevel()
        self.wdw.transient()
        Label(self.wdw , text= message).pack()
        for item in options :
            Button(self.wdw, text= item, command= self.escolha(item)).pack()

.
.
.
.
.

Dialog = versionDialog("Carregar script em qual versão?", listVersions)
app.version = Dialog.versao
app.launch()

your command for that button is going to cause issues, I've noticed whenever you have command=method_or_function(parameter) it immediately attempts to run that command, I've side stepped this by creating methods that know to grab that parameter.I'm not completely sure about the rest of the issue, I'd need to see more of the code. Here's an example of what I was talking about though:

self.searchlbl=Label(self,text='Search:')
        self.searchlbl.grid(row=2,column=0)
        self.search=ttk.Combobox(self)
        self.search['values']=contact_list
        self.search.bind('<Return>',self.eventsearch_for)
        self.search.focus_set()
        self.submit=ttk.Button(self,text='Search',command=self.search_for)
        self.submit.bind('<Return>',self.eventsearch_for)
        self.submit.grid(row=2,column=5)
    
      def search_for(self):
         self.search1=self.search.get()
         self.search.delete(0,END)
         query_key=self.search1.title()
         if query_key in ab.keys():
            pop_up(query_key)
         else:
            fail('dict',query_key)

Pyguy62 is correct about the button call back. To send arguments to a function from a Tkinter callback you use partial.

from functools import partial
for item in options :
    Button(self.wdw, text= item, command= parital(self.escolha, item=item)).pack()

My problem is that when I launch the second window with the options my main application continues to run with default options

How are you accessing/passing the values from the second window to the first window's program?

Also you probably want to include "takefocus=True" when creating the Toplevel GUI.

Oh I hadn't used the partial tool yet, so it presets the arg without immediately running it?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.