python - How to store user GUI entry in another py file -


i have seperated gui code(ui.py) code calculations(calcs.py) based on user's gui entries/selections. basically, enter numbers , make selections , hit start, start button should start calculations , print out stuff. below explanations provided relevant parts of code:

  1. when hit button, below method starts:

    import calcs class application:     def sendguiinput(self):         self.entry1   = self.coeff1.get() #get entry 1         self.entry2   = self.coeff2.get() #get entry 2         self.entry3   = self.coeff3.get() #get entry 3         calcs.createdata(self.entry1, self.entry2) #pass entries 1 , 2 calcs.py calculations 

please note that, app = application(root)

  1. calcs.createdata calculations , calls class other calculations:

     class createdata:      def __init__(self, entry1, entry2):          """some calculations here produce self.somenewvar1 , self.somenewvar2"""          createdata2(self.somenewvar1, self.somenewvar2) 
  2. this i'm having problem. calcs.createdata2 takes 2 variables calcs.createdata, however, needs entry3 application.sendguiinput(). don't want pass entries createdata , createdata createdata2. trying that, having pool of entries ui.py in calcs.py after press button, classes in calcs.py can work without needing ui.py. i'll grateful if can me this. thank in advance.

note: define calcs.createdata2 like;

   class createdata2:        def __init__(self, var1, var2): 

so accepts 2 arguments other self needs entry3 ui.py

so i'm going largely in agreement @cu3po42. if have large numbers of entries coming of arbitrary sizes, use *args keyword unpack , make sure classes can deal arbitrary sizes calculations.

i think best way forward if it's purely size.

if there more detail required, want pool data , store it, or other complexity not sure about. use intermediate db , create classes query db. sql or nosql candidates may need depending on specifics. if don't want delve program using multiple languages (although python works quite sql , nosql) instead use tabular files (csv), standard stored data formats (json) or serialised python objects (pickle). of built in python already.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -