The solution to my problem is probably very simple, but I am having great problems solving it.
I have a MainWindow Class calling a Dialog. I send the contents of a list from a loop to the Dialog lineEdit for a user to accept or change as required and return the result.

Here is the snippits of code:

class TrackTitles(QDialog,ui_Dialog_2.Ui_Dialog):
   
   def __init__(self, TrackNames, parent=None):
      super(TrackTitles, self).__init__(parent)
      self.TrackNames = TrackNames
      self.setupUi(self)
      self.NewTrackTitle = None
      self.connect(self.btn_Cancel,   SIGNAL("clicked()"),self.close)
      self.connect(self.btn_OK,       SIGNAL("clicked()"),self._accept)
      self.connect(self.lineEdit,     SIGNAL("returnPressed()"), self._accept)
      self.connect(self.btn_Reset,    SIGNAL("clicked()"),self._reset)
      self.TrackNo = self.TrackNames[0]
      self.CurrentTrackTitle = self.TrackNames[1]
      self.lineEdit.setText(self.CurrentTrackTitle)

      
   def _accept(self):
      
      self.NewTrackTitle = self.lineEdit.text()
      
          
   def _reset(self):
      
      print 'RESET Code here'
      
      
      return
   
   
      
###################################################################################

class MainWindow(QMainWindow,ui_music.Ui_MainWindow):


############ Lots of code here


      for no,trak in enumerate(self.trackTitles):
         Dlg = TrackTitles([str(no+1),trak],self)
         print 'NewTrackTitle ',Dlg.NewTrackTitle

The result is a load of None's - this could be a habit.
Tkinter has a wait_window facility. Is there any way to cause the TrackTitle to wait for the OK button to be clicked before returning?

Thank you in anticipation.
Graham

I would use the Track object as type of trackTitles in MainWindow.
My opinion, take what it is worth:

You are mixing "procedural style of input (not event driven style) with function return values and print", with object style "set the objects variables" style. I hope it is only for debugging, but could you maybe show in higher level what as happening in this section of code.

I would not put loop showing dialog for every line. I would react for user request when he want to edit selected line or lines. I would tricker update event to MainWindow from method dealing with OK after edit in edit window.

Think in higher level interface between things. Think whole program as one object having interactive parts, user event come from event loop (which should basically be only loop with interaction) when they come, except when we have error to report in message window. In object oriented way you do not pass information inside objects, you pass in object to process and edits go directly to that object passed in.

I do not have super strong experience in OO design, so correct me if I am wrong, you experts.

Edited 6 Years Ago by pyTony: n/a

Hi
Thank you tonyjv. I have had a new look at the complete program and it now does what I want.
Thanks again
Graham

This question has already been answered. Start a new discussion instead.