What does ":" do in this line of code?

self.windows = {
“about”: AboutWindow(self),

“tdr”: TDRWindow(self),
Can somebody kindly explain the above in English ?

the colon (: ) has a special meaning depending on its context. In the context of the dictionary you provided, it separates the keys from the values.

self.windows is a “dictionary,” which you can tell by the {braces}. Dictionaries contain pairs of “keys” and “values”; asking for self.windows['about'] would return AboutWindow(self). If you had a sequence of items in {braces} and didn’t include the “:”, you would get a “set,” which is like a list but each item must be unique.

OK, if I do understand correctly
“windows” class now have a “dictionary” and it has several “keys” assigned / defined.

If I do this

“tdr”: TDRWindow(self),
“DTW”: TDRWindow(self),

I could refer to TDRWindow by tdr or DTW

However I need to add to this dictionary

“DTW”: DTWWindow(self),

and I get

File “/mnt/RAID_124/PYTHON_TEST_PROJECTS_FOLDER/nanovna-saver-clean_CLONE-JULY18_version1/src/NanoVNASaver/NanoVNASaver.py”, line 320, in init
“DTW”: DTWWindow(self),
NameError: name ‘DTWWindow’ is not defined. Did you mean: ‘TDRWindow’?

which tells me I need to “import”


since I was ignorant aboput the "dictionary " I could not figure out the issue .


Yes, you have understood correctly.

The windows object is indeed a dictionary in Python, and it has several keys each assigned to a window object. You can access the window objects via their respective keys.

Regarding the error message you are seeing, the Python interpreter is saying that it doesn’t recognize DTWWindow. This could mean a couple of things:

  1. You might have forgotten to import DTWWindow. If this class is defined in a different module, you’ll need to import it at the top of your file with a line like from mymodule import DTWWindow. Replace mymodule with the actual name of the module (i.e., file or package) where DTWWindow is defined.
  2. It’s possible that there’s a typo in the name DTWWindow. Ensure that this class is defined and spelled correctly in your code or in the module you’re importing it from.
  3. If DTWWindow is defined later in the file, you’ll need to move the definition before it’s used in the dictionary. Python interprets files from top to bottom, so if a class or function is used before it’s defined, Python will raise a NameError.

Once you’ve addressed these issues, the line "DTW": DTWWindow(self), should work correctly. The key "DTW" in your windows dictionary will be associated with an instance of the DTWWindow class.

Is there a way to “start a new discussion” instead using “reply” ?
I just cannot get this “forum” new stuff going - it keeps throwing it back as "undeliverable "…

Is there a way to “start a new discussion” instead using “reply” ?

On the topic front page:

there’s a “+ new topic” button at the top right.

I just cannot get this “forum” new stuff going - it keeps throwing it
back as "undeliverable "…

You could make a new topic just for this, as it sounds like you’re using
the forum via email here.

Cameron Simpson cs@cskk.id.au

Start logging in to the site instead of interacting with it by email. Email is not helping the quality of your posts, they’re poorly formatted and hard to read. You’ve already gotten a lot of advice about how to improve your interaction and experience on the site: Communication issues - #3 by CAM-Gerlach I suggest you start following it.