Python Forum
tkinter moving an class object with keybinds
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
tkinter moving an class object with keybinds
#2
First a note about coding style.

Using global statements outside of a class is better done using a function, generally placed at the end of your script.
Placing it all at the top of the script makes it ugly, and difficult to read.

General suggested script structure:
  1. imports
  2. class definitions
  3. Dispatcher (outside of class, at bottom of script)
    this is a function that:
    • Collects and passes needed arguments for clases used
    • Instantiates needed classes with collected argument data.
    • any external processing, like mainloop for tkinter
  4. An entry that will allow the script to be executed on its own,
    without interfering with the ability to import from another script.
    this usually is something like this:
       if __name__ == '__main__':
           dispatch()
       
    dispatch can be replaced with your dispatcher function name.
Reply


Messages In This Thread
RE: tkinter moving an class object with keybinds - by Larz60+ - Feb-10-2021, 11:03 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  tkinter AttributeError: 'GUI' object has no attribute pfdjhfuys 3 1,701 May-18-2023, 03:30 PM
Last Post: pfdjhfuys
  Tkinter object scope riversr54 6 2,122 Feb-17-2023, 05:40 AM
Last Post: deanhystad
Lightbulb Using Tkinter With Concurrent.Futures / ThreadPoolExecutor Class AaronCatolico1 1 1,530 Dec-14-2022, 08:01 PM
Last Post: deanhystad
Lightbulb [Tkinter] Tkinter Class Import Module Issue AaronCatolico1 6 3,287 Sep-06-2022, 03:37 PM
Last Post: AaronCatolico1
  [Tkinter] Redirecting all print statements from all functions inside a class to Tkinter Anan 1 2,723 Apr-24-2021, 08:57 AM
Last Post: ndc85430
  [Tkinter] Troubles with accessing attr from other class zarize 3 2,695 Aug-20-2020, 06:05 PM
Last Post: deanhystad
  [Tkinter] Use function from other class (Tkinter) zarize 8 5,010 Aug-17-2020, 09:47 AM
Last Post: zarize
  [Tkinter] how to draw dynamic moving scale and potting trace point on waveform in tkinter pytho sameer_1985 0 2,066 May-31-2020, 01:52 PM
Last Post: sameer_1985
  Unable fetch fucntion data in class in tkinter jenkins43 2 3,930 Nov-30-2019, 09:47 PM
Last Post: jenkins43
  Tkinter Class pythonenthusiast2 1 2,677 Nov-24-2019, 03:51 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020