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:
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)
calcs.createdatacalculations , calls class other calculations:class createdata: def __init__(self, entry1, entry2): """some calculations here produce self.somenewvar1 , self.somenewvar2""" createdata2(self.somenewvar1, self.somenewvar2)this i'm having problem.
calcs.createdata2takes 2 variablescalcs.createdata, however, needsentry3application.sendguiinput(). don't want pass entriescreatedata,createdatacreatedata2. trying that, having pool of entriesui.pyincalcs.pyafter press button, classes incalcs.pycan work without needingui.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
Post a Comment