Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Importing classes?
#4
You need to put your code into functions and classes, so that it doesn't run automatically when you import it. So your afairesh module would have a function in it, call it do_something. You would import afairesh at the top of the GUI module, and all it would do is define the afairesh.do_something function. Then, when the correct button is pushed, you would call afairesh.do_something(), and that would run the code.

And on line 72 you use global popup. There is no reason to use global within a class. Or at least no good reason, there are lots of bad reasons. Either pass popup to the method directly as a parameter, or make popup an attribute of the class, and use self.popup to refer to it.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
Importing classes? - by frequency - Dec-30-2018, 02:21 PM
RE: Importing classes? - by ichabod801 - Dec-30-2018, 02:29 PM
RE: Importing classes? - by frequency - Dec-30-2018, 02:42 PM
RE: Importing classes? - by ichabod801 - Dec-30-2018, 03:01 PM
RE: Importing classes? - by frequency - Dec-30-2018, 03:10 PM
RE: Importing classes? - by ichabod801 - Dec-30-2018, 03:22 PM
RE: Importing classes? - by frequency - Dec-30-2018, 07:04 PM
RE: Importing classes? - by frequency - Dec-30-2018, 08:20 PM
RE: Importing classes? - by ichabod801 - Dec-30-2018, 08:27 PM
RE: Importing classes? - by frequency - Dec-31-2018, 03:34 PM
RE: Importing classes? - by frequency - Dec-31-2018, 04:48 PM
RE: Importing classes? - by ichabod801 - Dec-31-2018, 07:21 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Pygame importing classes Padalinkiller1 2 3,828 Nov-15-2017, 02:08 PM
Last Post: Padalinkiller1
  Problems with importing classes in different folder Xeraphim 3 3,439 Nov-08-2017, 03:20 PM
Last Post: Larz60+
  Using classes? Can I just use classes to structure code? muteboy 5 5,156 Nov-01-2017, 04:20 PM
Last Post: metulburr

Forum Jump:

User Panel Messages

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