Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require "rubygems"
- gem "rubyscript2exe"
- require "rubyscript2exe"
- #bindet Tk in Rubyscript2exe ein
- RUBYSCRIPT2EXE.tk = true
- #ohne Konsole
- RUBYSCRIPT2EXE.rubyw = true
- require 'tk'
- class Mama
- #TK Fenster wird gestartet
- def run
- @window.mainloop
- end
- def initialize
- #Erstellt das Hauptfenster
- @window = TkRoot.new(:title => 'Lebensmittel-Verwaltung', 'height' => 674, 'width' => 1000) do
- root.geometry('+100+100')
- end
- bild_label()
- lebensmittelverwatltung_label()
- button_add()
- button_deleate()
- liste()
- button_end()
- text()
- end
- #Label mit Lebensmittelbild
- def bild_label
- image1 = TkPhotoImage.new { file "bilder/Lebensmittel.gif" }
- TkLabel.new('height' => 674, 'width' => 1000) do
- place 'x' => 0, 'y' => 0
- image image1
- end
- end
- #Label mit der Aufschgrift: Mamas Lebensmittel Verwaltung
- def lebensmittelverwatltung_label
- TkLabel.new('height' => 1, 'width' => 26) do
- text 'Mamas Lebensmittel-Verwaltung'
- place 'x' => 145, 'y' => 0
- font TkFont.new('Comic 35 bold')
- relief 'raised'
- foreground 'Lime Green'
- background 'Orange Red'
- end
- end
- #Button zum öffnen des imports
- def button_add
- image1 = TkPhotoImage.new { file "bilder/add.gif" }
- a = TkButton.new('height' => 94, 'width' => 94) do
- place 'x' => 279, 'y' => 480
- image image1
- cursor "hand2"
- relief 'groove'
- end
- a.bind('ButtonRelease-1') do
- delat_lvl()
- @win1.state = 'withdrawn'
- add_lvl()
- button_end1('Green Yellow')
- end
- end
- #Button um etwas herauszunehmen
- def button_deleate
- image1 = TkPhotoImage.new { file "bilder/delate.gif" }
- a = TkButton.new('height' => 94, 'width' => 94) do
- place 'x' => 741, 'y' => 480
- image image1
- cursor "hand2"
- relief 'groove'
- end
- a.bind('ButtonRelease-1') do
- add_lvl()
- @win.state = 'withdrawn'
- delat_lvl()
- button_end1('blue')
- end
- end
- #Button um Programm zu beenden
- def button_end
- image1 = TkPhotoImage.new { file "bilder/exit.gif" }
- bt = TkButton.new('height' => 30, 'width' => 30) do
- place 'x' => 965, 'y' => 1
- image image1
- cursor "hand2"
- relief 'flat'
- end
- bt.bind('ButtonRelease-1') do
- @window.destroy
- end
- end
- #2. End Button um Konfigurationen zu beenden
- def button_end1(lol)
- image1 = TkPhotoImage.new { file "bilder/exit2.gif" }
- image2 = TkPhotoImage.new { file "bilder/lb.gif" }
- @bt = TkButton.new('height' => 20, 'width' => 244) do
- place 'x' => 10, 'y' => 640
- image image1
- cursor "hand2"
- relief 'flat'
- background "#{lol}"
- end
- @bt.bind('1') do
- delat_lvl()
- add_lvl()
- @win.state = 'withdrawn'
- @win1.state = 'withdrawn'
- @bt.configure('image', image2)
- end
- end
- #Liste mit Inhalt
- def liste
- @lis = TkListbox.new('height' => 14, 'width' => 49) do
- selectmode 'single'
- place 'x' => 279, 'y' => 90
- font TkFont.new('Comic 15 bold')
- background 'Forest green'
- end
- scrol = TkScrollbar.new do
- orient 'vertical'
- command { |*args| lis.yview *args }
- place 'x' => 824, 'y' => 90, 'height' => 357
- end
- scrol.set(0, 0)
- @lis.yscrollcommand do |first, last|
- scrol.set(first, last)
- end
- end
- #Topp lvl add
- def add_lvl
- begin
- @win.destroy
- rescue
- end
- @win = TkToplevel.new(:title => 'hinzufuegen', 'height' => 560, 'width' => 250) do
- relief 'ridge'
- geometry('+114+206')
- background 'Green Yellow'
- end
- @win.overrideredirect(true)
- @e1 = TkEntry.new(@win) do
- place 'x' => 50, 'y' => 130
- end
- @e4 = TkEntry.new(@win) do
- place 'x' => 50, 'y' => 200
- end
- TkLabel.new(@win) do
- place 'x' => 50, 'y' => 15
- text 'Import'
- background 'blue'
- relief 'groove'
- font TkFont.new('Comic 30 bold')
- foreground 'Green Yellow'
- end
- TkLabel.new(@win) do
- place 'x' => 50, 'y' => 102
- text 'Lebensmittel:'
- background 'Brown'
- relief 'groove'
- font TkFont.new('Comic 10 bold')
- foreground 'yellow'
- end
- TkLabel.new(@win) do
- place 'x' => 50, 'y' => 174
- text 'Anzahl:'
- background 'Brown'
- relief 'groove'
- font TkFont.new('Comic 10 bold')
- foreground 'yellow'
- end
- image1 = TkPhotoImage.new { file "bilder/ok.gif" }
- @bt12 = TkButton.new(@win) do
- place 'x' => 60, 'y' => 300
- image image1
- end
- @bt12.bind('ButtonRelease-1') do
- @leb1 = @e1.value
- @leb77 = @e4.value.to_i
- if File.exist?("data/#{@leb1}.txt")
- File.open("data/#{@leb1}.txt") do |file|
- file.each do |line|
- @leb222 = line
- end
- file.close
- end
- File.open("data/#{@leb1}.txt", "w+") do |file|
- lol = @leb222.to_i
- ac = @leb77
- @leb100 = "#{lol + ac}"
- file.puts "#{@leb100}"
- file.close
- end
- else
- File.open("data/#{@leb1}.txt", "w+") do |file|
- lol = @leb222.to_i
- ac = @leb77
- @leb100 = "#{lol + ac}"
- file.puts "#{@leb100}"
- file.close
- end
- end
- end
- end
- # Top lvl deleat
- def delat_lvl
- begin
- @win1.destroy
- rescue
- end
- @win1 = TkToplevel.new(:title => 'hinzufuegen', 'height' => 560, 'width' => 250) do
- relief 'ridge'
- geometry('+114+206')
- background 'Blue'
- end
- @win1.overrideredirect(true)
- @e2 = TkEntry.new(@win1) do
- place 'x' => 50, 'y' => 130
- end
- @e3 = TkEntry.new(@win1) do
- place 'x' => 50, 'y' => 200
- end
- #Export
- TkLabel.new(@win1) do
- place 'x' => 50, 'y' => 15
- text 'Export'
- background 'Green Yellow'
- relief 'groove'
- font TkFont.new('Comic 30 bold')
- foreground 'blue'
- end
- TkLabel.new(@win1) do
- place 'x' => 50, 'y' => 102
- text 'Lebensmittel:'
- background 'Brown'
- relief 'groove'
- font TkFont.new('Comic 10 bold')
- foreground 'yellow'
- end
- TkLabel.new(@win1) do
- place 'x' => 50, 'y' => 174
- text 'Anzahl:'
- background 'Brown'
- relief 'groove'
- font TkFont.new('Comic 10 bold')
- foreground 'yellow'
- end
- image1 = TkPhotoImage.new { file "bilder/okk.gif" }
- @bt13 = TkButton.new(@win1) do
- place 'x' => 60, 'y' => 300
- image image1
- end
- @bt13.bind('ButtonRelease-1') do
- @leb6 = @e2.value
- @leb7 = @e3.value.to_i
- File.open("data/#{@leb6}.txt") do |file|
- file.each do |line|
- @leb22 = line
- end
- file.close
- end
- if File.exist?("data/#{@leb6}.txt")
- File.open("data/#{@leb6}.txt", "w") do |file|
- lol = @leb22.to_i
- ac = @leb7
- @leb10 = "#{lol - ac}"
- file.puts "#{@leb10}"
- file.close
- end
- else
- msgBox = Tk.messageBox(
- 'type' => "ok",
- 'icon' => "info",
- 'title' => "Nicht Foraethig",
- 'message' => "Dieses Produkt ist leider nicht im Lager"
- )
- end
- end
- end
- def text
- File.open("data/.") do |file|
- @jojo = file.to_s
- end
- File.open("complet.txt", "w+") do |file|
- file.puts "#{@jojo}"
- end
- end
- end
- los = Mama.new
- los.run
Add Comment
Please, Sign In to add comment