Advertisement
Techpad

Changelog 12

May 4th, 2021
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. import tkinter as tk
  2.  
  3. _root = frame1
  4.  
  5. with open("T:/TechOS/Virtual/Info/Version.info", "r") as f:
  6. version = f.read()
  7. changes = {}
  8.  
  9. with open("T:/TechOS/Virtual/Info/Changelog.txt", "r") as f:
  10. changelog = f.read()
  11. for line in changelog.splitlines():
  12. changeid = line.split(":", 1)[0]
  13. update = changeid.split(".", 1)[0]
  14. number = int(changeid.split(".", 1)[1])
  15. change = line.split(":", 1)[1]
  16. if number == 0:
  17. changes[update] = []
  18. else:
  19. pass
  20. changes[update].append(change)
  21.  
  22. title = tk.Label(_root, bg='white', fg='#00afff', text="What's New in TechOS", font='TkDefaultFont 20')
  23. title.pack(side='top', anchor='nw', padx=5, pady=5)
  24.  
  25. header = tk.Label(_root, bg='white', text="Version", font='TkDefaultFont 15')
  26. header.pack(side='top', anchor='nw', padx=5, pady=5)
  27.  
  28. content = tk.Label(_root, bg='white', justify='left', padx=10, pady=10, wraplength=500)
  29. content.pack(side='top', anchor='nw')
  30.  
  31. def loadversion(vs):
  32. global changes, header, content
  33. header.config(text=f"Version {vs}")
  34. conts = ""
  35. for i in changes[vs]:
  36. conts += "- " + i + "\n\n"
  37. content.config(text=conts)
  38.  
  39. def prev():
  40. global version, changes, loadversion
  41. preversion = str(int(version) - 1)
  42. try:
  43. if changes[preversion]:
  44. version = preversion
  45. loadversion(version)
  46. else:
  47. pass
  48. except KeyError:
  49. pass
  50.  
  51. def nxt():
  52. global version, changes, loadversion
  53. nxtversion = str(int(version) + 1)
  54. try:
  55. if changes[nxtversion]:
  56. version = nxtversion
  57. loadversion(version)
  58. else:
  59. pass
  60. except KeyError:
  61. pass
  62.  
  63. previous = tk.Button(_root, bg='white', bd=0, activebackground='lightgray', text='< Previous Version', padx=5, pady=5, command=prev)
  64. previous.pack(side='left', anchor='sw')
  65.  
  66. next = tk.Button(_root, bg='white', bd=0, activebackground='lightgray', text='Next Version >', padx=5, pady=5, command=nxt)
  67. next.pack(side='right', anchor='se')
  68.  
  69. loadversion(version)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement