Monday, 15 April 2013

user interface - Python GUI - entry values are not strings but methods? -


I have a small problem with my program: I can not understand that the values ​​entered in the program are re- How to use It says that I can not use float on a method, but I thought that s.get gave me the string, it also seems that it does not use values ​​actually entered, but only the default value is Do you know what is wrong with the code?

import from imported importer from importer import * Import MMP as NMP in the form of import matplotlib.pyplot such as PLT class GUI def (__init __ (self): self.root = Tk () self.labelVariable = StringVar () self.root.title ('Projet informatique') self.initialize () self.root.mainloop () def initialize (self): self.main = frames (self.root) Self.Pack () label = label (self main, textual = self label variable, font = ('courier', 10, 'bold'), anchor = "w", fg = "red", bg = " White ") labeled .pack () self.labelVariable.set (and" demolish population populations V.insert ("end", "model sir") v.insert v.insert ("end", "modale de minus") v.insert (" V.pack (extension = 1, emphasis = both) def de ouble (self, event), v.bind ("double-button- 1", double-button- "double", "event", "modale avec trait") ): Widget = event.widget selection = widget.c c. Selection () value = widget.get (select [0]) self.newWindow (value) def ModifyTextarea (auto, elem, msg, clear = none): Elem.config (state = normal) if it is clear: elem.delete ( 1.0, END) Other: elem.insert (END, msg) elem.config (state = disabled) def newWindow (self, msg): top = local (auto) .root) q1 = frame (top) q1.pack () Top.grab_set () text = text (q1, state = disabled, exportelection = true) text.pack () lbl = label (q1, text = "") lbl (), (), (), (), () , (), (), (), (), (), (), (), (), V1) e2 = entry (q1, textual = v2) e3 = entry (q1, textual = v3) e4 = Entry (Q1, Textual = V4) E5 = Entry (Q1, Textwired = Enable 5) E6 = Entry (q1, Textual = V6) e1.pack () e2.pack () e3.pack () e4.pack () e5.pack () e6.pack () v1.set ("Taux De Merlotte des Lambes "v2.set (" Coefficient de propagation du virus ") v3.set (" check de rémission "v4.set) v4.set v5.set v5.set (" taux de guerrison ") v6.set ("Pas de temps") a = v1.get b = v2.get ze = v3.get t = v4.get n = v5.get dt = v6.get def callback (): print (a, b, ze, T, n, dt) btnquit = button (q1, width = 1, text = "OK", command = callback ()) btnquit.pack () DEF Lambo (A, B, GE, T, N, DT): A = Float (a) b = float (b) ze = float (aj) t = float (t) n = float (n) dt = float (dt) n = t / dtn = I for range (n) T = np.zeros ((n + 1)) in range (0, n): t [0] = 0 t [i + 1] = t [i] + dt s = np. Zeros ((n + 1)) z = np.zeros ((n + 1)) r = np.zeros ((n + 1)) [0] = [i + 1] = s [i ] + Dt * (- B * s [i] * z [nb1s] [0] i]) z [i + 1] = z [i] + dt * (b * s [i] * z [ I] -a * s [i] * z [i] + ze * r [i] r [i + 1] = r [i] + dt * (a * s) * jade [ii] - jae * R [ii]) if s [i + 1] lt; 0 or S [I + 1] & Gt; N: S [i + 1] = 0 brake if z [i + 1]> N or Z [i + 1] & lt; 0: z [i + 1] = 0 break if r [i + 1]

All of these are incorrect:

  a = v1.get b = v2.get Ze = v3.get t = v4.get n = v5.get dt = v6.get  

You do not have to call find function. To call it, add brackets:

  a = v1.get () ...  

FWIW, using stringwars for each of you You do not need the entry widget you can get the value directly from the widget. Using Stringwor often adds additional code and additional objects to manage with a real profit.


No comments:

Post a Comment