Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import gi
- gi.require_version('Gtk', '3.0')
- from gi.repository import Gtk
- class TableWindow(Gtk.Window):
- def __init__(self):
- Gtk.Window.__init__(self, title="Injection Time Calculator")
- table = Gtk.Table(6, 2, True)
- self.add(table)
- sizeLabel = Gtk.Label("WALL SIZE")
- widthLabel = Gtk.Label("WIDTH")
- heightLabel = Gtk.Label("HEIGHT")
- fsLabel = Gtk.Label("FLAT STUD?")
- injLabel = Gtk.Label()
- heightEntry=Gtk.Entry()
- widthEntry=Gtk.Entry()
- sizeBox = Gtk.ComboBoxText()
- sizeBox.append("1","90")
- sizeBox.append("2","140")
- sizeBox.append("3","219")
- fsCheckButton=Gtk.CheckButton()
- calculateButton=Gtk.Button.new_with_label("CALCULATE INJECTION TIME")
- calculateButton.connect("clicked", self.Click)
- table.attach(sizeLabel, 0, 1, 0, 1)
- table.attach(widthLabel, 0, 1, 1, 2)
- table.attach(heightLabel, 0, 1, 2, 3)
- table.attach(fsLabel, 0, 1, 3, 4)
- table.attach(injLabel, 0, 2, 5, 6)
- table.attach(calculateButton, 0, 2, 4, 5)
- table.attach(widthEntry, 1, 2, 1, 2)
- table.attach(heightEntry, 1, 2, 2, 3)
- table.attach(sizeBox, 1, 2, 0, 1)
- table.attach(fsCheckButton, 1, 2, 3, 4)
- global heightEntry
- global widthEntry
- global sizeBox
- global fsCheckButton
- global timeVar
- global injTime
- global injLabel
- def Click(self, calculateButton):
- studWidth=sizeBox.get_active_text()
- areaHeight=heightEntry.get_text()
- areaWidth=widthEntry.get_text()
- if fsCheckButton.get_active():
- if studWidth=="90":
- areaWidth=float(areaWidth)-59
- elif studWidth=="140":
- areaWidth=float(areaWidth)-38
- elif studWidth=="219":
- areaWidth=float(areaWidth)-24.3
- timeVar=float(studWidth)*10.7/140
- injTime=((float(areaWidth)*float(areaHeight)*float(timeVar))/1000000)
- a= str( 'INJECTION TIME IS '+str(injTime)[:7]+' SECONDS OR '+str((round(injTime*5))/5)+' ROUNDED')
- injLabel.set_text(a)
- win = TableWindow()
- win.connect("delete-event", Gtk.main_quit)
- win.show_all()
- Gtk.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement