Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Global not working why?
#11
Of course you cannot get the scratches. A GUI program is event driven. You are trying to write it as if things happen sequentially.
        get_scratches(horses_name)  # Draws the scratched form
        print(scratched_list)  # There are no scratches at this time

The code above expects there to be information in the scratches form as soon as it is created. Obviously this is not going to happen. What your code needs to do is present the form to the user and end. The user will then enter the scratched information and press a button indicating the form is complete. The button press will call a function that uses the scratched information.

A GUI program is not a list of steps to complete. You cannot write a GUI as Do A, B, C, D in order. A GUI program is list of events and the actions that are performed when these events occur. The user specifies the sequence order using the controls provided by your program. If I am creating a graph in Excel, the program does not force me to load data, select columns, insert line graph, select graph format. Instead the program provides controls that allows me to perform those functions. I can load data and then make a graph, then delete the graph or add more data. I, the user, am in control of when the program does what.

Right now your program has only one event: Scratch List Done Button Pressed. The action associated with that event will be all the code that currently resides in def load_track_to_Handi() below the point where the call to get_scratches(horses_name). I would take that code and add it to complete_form().
Reply


Messages In This Thread
Global not working why? - by Milfredo - Oct-02-2020, 07:29 AM
RE: Global not working why? - by ibreeden - Oct-02-2020, 08:08 AM
RE: Global not working why? - by Larz60+ - Oct-02-2020, 10:33 AM
RE: Global not working why? - by scidam - Oct-02-2020, 11:09 AM
RE: Global not working why? - by Milfredo - Oct-03-2020, 01:28 AM
RE: Global not working why? - by scidam - Oct-03-2020, 01:46 AM
RE: Global not working why? - by Milfredo - Oct-04-2020, 06:44 AM
RE: Global not working why? - by bowlofred - Oct-04-2020, 07:21 AM
RE: Global not working why? - by ndc85430 - Oct-04-2020, 10:48 AM
RE: Global not working why? - by hshivaraj - Oct-04-2020, 12:30 PM
RE: Global not working why? - by deanhystad - Oct-04-2020, 12:44 PM
RE: Global not working why? - by Milfredo - Oct-05-2020, 11:45 PM
RE: Global not working why? - by Larz60+ - Oct-06-2020, 12:29 AM
RE: Global not working why? - by Milfredo - Oct-06-2020, 02:37 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Global variables not working hobbyist 9 4,812 Jan-16-2021, 03:17 PM
Last Post: jefsummers
  Global variable does not seem to be global. Columbo 6 3,769 Jul-15-2019, 11:00 PM
Last Post: Columbo

Forum Jump:

User Panel Messages

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