Introduction: I have written a 'program' that does some reasonable screen scraping off of a specific website. The program has gotten too large so I have tried to segment it into logical pieces (tkinter logic as a start) but I am having problems. Specifically I need to pass several dictionaries to the module (imported code) that validates some user selection and into the code that navigates through the website. I have also created a variable that is set to 0 when a valid entry has been made by the user (telling the scraper what to do) that needs to be checked in the scraper module that is waiting patiently before it starts. There are multiple threads working as well because I may need to run several session as once.
After struggling with my basic need - the ability to pass variables/dictionaries across modules, especially imported modules, I have read everything I can find and tried small, demo programs. But is till can't get it What I need: An ability to create dictionaries (that have validation information in them) and variables (that signal status and contain information entered by the user in tinkter) that I can make available to all components. I have tried using global, but that fails. I also can't seem to use arguments because the module that tkinter fires up with this command: self.process_button = tk.Button(master, text='Process Request', \ font = ('times', regular_font, 'bold'),\ fg = "blue", command=self.Process_Reservation_Request) does not seem to support the presence of arguments. Demo Program - This currently bombs in part 3 - it can't seem to see the value/space created in part1. Any help or reference that will clearly show me how to solve this problem would be most appreciated. I have read a number of points that recommend against using global anywhere (it does not seem to work with imported code) but I just can't find a recommendation for doing something that seems pretty fundamental. Thanks to an and all that try to help! Part 1 import nice import nice2 global myGlobal myGlobal = "initial value" print(myGlobal) nice.changeGlobal() print (nice.myGlobal) nice2.changeGlobal() print("nice version = ", nice.myGlobal) print("nice2 version = ", nice2.myGlobal) print("mainline=", myGlobal) part 2 - stored as nice.py def changeGlobal(): global myGlobal #print("entering changeGlobal part 1", myGlobal) myGlobal = "hello" print("top of myGlobal", myGlobal) myGlobal="bye" print("changeGlobal =", myGlobal) #changeGlobal() Part3 stored as nice2 myGlobal = "hello" def changeGlobal(): global myGlobal print("first value = ", nice.myGlobal) myGlobal="it worked" print("in changeGlobal2 =", myGlobal) #changeGlobal() _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor