Error with SimpleNameValueDialog

\ 21x21

1:40 PM (1 hour ago)

I am trying to show a SimpleNameValueDialog in response to a button click but unfortunately it’s giving me the error message below:

Traceback (most recent call last):
File “”, line 68, in ShowMessage5
style=wx.DEFAULT_DIALOG_STYLE, fields=data)
File “D:\Anaconda3\lib\site-packages\wx\lib\”, line 53, in init
File “D:\Anaconda3\lib\site-packages\wx\lib\”, line 71, in createFields
File “D:\Anaconda3\lib\site-packages\wx\lib\”, line 87, in destroyFields
for name, widgets in self._fields.iteritems():
AttributeError: ‘dict’ object has no attribute ‘iteritems’

and this is the code responsible for creating the dialog

data = [("user", "Username", None), ("pass", "Password", None)] dial = nvdlg.SimpleNameValueDialog(self, wx.ID_ANY, 'Login Window', style=wx.DEFAULT_DIALOG_STYLE, fields=data) dial.ShowModal()

i don’t get where is the error as i am following the guidelines for the fields as written in the documentation

A simple dialog that can prompt for values for any arbitrary set of name/value pairs, where the fields are defined by a list of info passed to the constructor. A dictionary of initial values can also be passed. Each item in the fields list is a tuple of 3 items, which are:

  • a string to be used for the attribute name for storing the value
  • a string to be used for the label
  • None, or a dictionary of kwargs to be passed to the wx.TextCtrl ctor

As stated in the traceback, the error is in It’s just a Py2 --> Py3 bug that has slipped through.

I’ve got a fix locally in the pipeline, but in the meantime if you edit that line and change iteritems to items then that will take care of it for you. There are some other instances of iteritems there that will need changed too.

I posted the same on google group and this was my response after @Tim Roberts helped me out. Thank you for ur response and all the efforts

first I would like to Thank you for your help …
i made the changes as you indicated in your response but it raised the same error in a different location so i made a couple more changes in the file until it worked.
here are the changes just for record:

  • I made the same adjustment in line 95 of the file
def loadValues(self, values):
        for name, value in values.items():
            if name in self._fields.keys():
                setattr(self, name, value)
  • The second change was done in the init method of the class I changed “initialValues = None” to “intialValues = {}”
class SimpleNameValueDialog(wx.Dialog):
    def __init__(self, parent, id=-1, title="", pos=wx.DefaultPosition,
                 size=wx.DefaultSize, style=wx.DEFAULT_DIALOG_STYLE,
                 fields=[], initialValues={},
                 captionTitle="", captionDescr=""):

Thanks once again for guidance