New answers tagged

1

It is often good practice to put the main program controller in an if __name__ == "__main__": so that in case you would want to import this program in another file you would not open the window up immediately, only if you run this file directly. In your case, that controller would be the last three lines: ... self.aggression = aggression ...


5

A little for the styling of the GUI Add an icon to your application Tkinter has made it very easy to add an icon to any of our windows, it's a single line that makes your GUI look good. All you need to do is go to a website like this one and download any .ico file of size 16x16, I haven't tested it with other sizes and formats, but usually, you'll find ...


5

PEP-8 To maintain consistency while writing code, Python code follows the PEP-8 naming convention. For example Source Function names should be lowercase, with words separated by underscores as necessary to improve readability. Variable names follow the same convention as function names. The library that you are currently using, which is tkinter also ...


3

Consider using PEP-484 type hints for your function signatures. Use a linter like pyflakes, flake8 or black that will give you a number of suggestions about your code format. Move your TKINTER SCRIPT into one or more functions, instead of in global scope. Use pathlib, so that this: script_directory+"/mycsv.csv can be Path(script_directory) / 'mycsv.csv'...


Top 50 recent answers are included