[ wraith46 @ 29.03.2017. 14:34 ] @
Pravim jednostavnu GUI aplikaciju za sopstvene potrebe. Evo šta sam dosad uradio: Code: # str8.py # Program to count time from a certain event from tkinter import * from datetime import * from threading import * root = Tk() root.title("STR8") root.resizable(width=False, height=False) def main(): print_it() def stop(): root.destroy() def display(): event, today, str8, seconds, minutes, hours, days, weeks, years = calc() Label(root, text="You have been STR8 for:\n", font="Verdana 8 bold").grid(row=0, sticky=W) Label(root, text="Years: " + str(round(years, 2)), font="Verdana 8").grid(row=1, sticky=W) Label(root, text="Weeks: " + str(round(weeks, 2)), font="Verdana 8").grid(row=2, sticky=W) Label(root, text="Days: " + str(round(days, 2)), font="Verdana 8").grid(row=3, sticky=W) Label(root, text="Hours: " + str(round(hours, 2)), font="Verdana 8").grid(row=4, sticky=W) Label(root, text="Minutes: " + str(round(minutes, 2)), font="Verdana 8").grid(row=5, sticky=W) Label(root, text="Seconds: " + str(round(str8.total_seconds())), font="Verdana 8").grid(row=6, sticky=W) Button(root, text="EXIT", font="Verdana 8", height=1, width=19, command=stop).grid(row=7) def calc(): event = datetime(2017, 3, 29, 13, 45, 0) today = datetime.now() str8 = today - event seconds = str8.total_seconds() minutes = str8.total_seconds() / 60 hours = minutes / 60 days = hours / 24 weeks = days / 7 years = weeks / 52 return event, today, str8, seconds, minutes, hours, days, weeks, years def print_it(): t = Timer(1.0, print_it) calc() try: display() except RuntimeError: pass else: t.start() main() root.mainloop() Ono što hoću da uradim, a ne umem (imam nešto iskustva u C#, ali sam u Pythonu newbie) - jeste to da kod malo bolje struktuiram - da ga podelim na dve klase: ClientBased i GuiPart. Interesuje me vaše mišljenje šta biste od definicija vi stavili gde, i zašto. [Ovu poruku je menjao wraith46 dana 29.03.2017. u 16:53 GMT+1] |