Guest User

Untitled

a guest
Feb 20th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. require 'tk'
  2.  
  3.  
  4. class Startbildschirm
  5.  
  6.  
  7. #######################
  8. #### RUN ##############
  9. #######################
  10.  
  11.  
  12. def run
  13. @startbildschirm.overrideredirect(true)
  14. @startbildschirm.mainloop
  15. end
  16.  
  17. ########################
  18. #### initialize ########
  19. ########################
  20.  
  21. def initialize
  22. #root#
  23. @startbildschirm = TkRoot.new(:title => 'Startbildschirm','height' => 1050, 'width' => 1400) do
  24. root.geometry('+0+0')
  25. end
  26. hintergrund()
  27. herunterfahren()
  28. benutzer()
  29. end
  30.  
  31. #############
  32. #hintergrund#
  33. #############
  34.  
  35. def hintergrund
  36. TkLabel.new('height' => 1050, 'width' => 1400) do
  37. place 'x' => -2, 'y' => -2
  38. image1 = TkPhotoImage.new do
  39. file "data/Wald.gif"
  40. end
  41. image image1
  42. end
  43. end
  44.  
  45. ###############
  46. #heruntefahren#
  47. ###############
  48.  
  49. def herunterfahren
  50. button = TkButton.new('height' => 42, 'width' => 42) do
  51. place 'x' => 1350, 'y' => 1000
  52. image1 = TkPhotoImage.new do
  53. file "data/Aus.gif"
  54. end
  55. image image1
  56. end
  57.  
  58. button.bind('ButtonRelease-1') do
  59. exit
  60. end
  61. end
  62.  
  63. ##########
  64. #Benutzer#
  65. ##########
  66.  
  67. def benutzer
  68. @yaml_file = File.new 'data/Benutzer.txt'
  69. @benutzer = YAML.load(@yaml_file)
  70. @yaml_file.close
  71.  
  72. moep = 0
  73. @benutzer.each do
  74. moep += 1
  75. end
  76.  
  77. if moep == 1
  78. zahl1 = 500
  79. elsif moep == 2
  80. zahl1 = 400
  81. elsif moep == 3
  82. zahl1 = 300
  83. elsif moep == 4
  84. zahl1 = 200
  85. end
  86.  
  87.  
  88. @benutzer.each do |benutzer, zahl|
  89. zahl1 += 180
  90. benutzer1 = benutzer
  91. benutzer1 = TkButton.new('height' => 50, 'width' => 49) do
  92. place 'x' => zahl1, 'y' => 500
  93. text "#{benutzer}"
  94. font TkFont.new('times 18 bold')
  95. image1 = TkPhotoImage.new do
  96. file "data/icon.gif"
  97. end
  98. image image1
  99. relief 'flat'
  100. activebackground 'black'
  101. cursor "hand2"
  102. end
  103. benutzer1.bind('ButtonRelease-1') do
  104.  
  105.  
  106. end
  107. TkLabel.new('height' => 1, 'width' => 7) do
  108. place 'x' => zahl1, 'y' => 555
  109. text "#{benutzer}"
  110. background 'green'
  111. font TkFont.new('times 10 bold')
  112. foreground 'red'
  113. end
  114. end
  115. end
  116.  
  117. reymo = Startbildschirm.new
  118. reymo.run
  119.  
  120. end
Add Comment
Please, Sign In to add comment