Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1.  
  2. import gi
  3. gi.require_version('Gtk', '3.0')
  4. from gi.repository import Gtk
  5.  
  6. class TableWindow(Gtk.Window):
  7.  
  8. def __init__(self):
  9.  
  10. Gtk.Window.__init__(self, title="Injection Time Calculator")
  11.  
  12. table = Gtk.Table(6, 2, True)
  13. self.add(table)
  14.  
  15. sizeLabel = Gtk.Label("WALL SIZE")
  16. widthLabel = Gtk.Label("WIDTH")
  17. heightLabel = Gtk.Label("HEIGHT")
  18. fsLabel = Gtk.Label("FLAT STUD?")
  19. injLabel = Gtk.Label()
  20.  
  21. heightEntry=Gtk.Entry()
  22. widthEntry=Gtk.Entry()
  23.  
  24. sizeBox = Gtk.ComboBoxText()
  25.  
  26. sizeBox.append("1","90")
  27. sizeBox.append("2","140")
  28. sizeBox.append("3","219")
  29.  
  30. fsCheckButton=Gtk.CheckButton()
  31.  
  32. calculateButton=Gtk.Button.new_with_label("CALCULATE INJECTION TIME")
  33. calculateButton.connect("clicked", self.Click)
  34.  
  35.  
  36. table.attach(sizeLabel, 0, 1, 0, 1)
  37. table.attach(widthLabel, 0, 1, 1, 2)
  38. table.attach(heightLabel, 0, 1, 2, 3)
  39. table.attach(fsLabel, 0, 1, 3, 4)
  40. table.attach(injLabel, 0, 2, 5, 6)
  41.  
  42. table.attach(calculateButton, 0, 2, 4, 5)
  43.  
  44. table.attach(widthEntry, 1, 2, 1, 2)
  45. table.attach(heightEntry, 1, 2, 2, 3)
  46.  
  47. table.attach(sizeBox, 1, 2, 0, 1)
  48.  
  49. table.attach(fsCheckButton, 1, 2, 3, 4)
  50.  
  51. global heightEntry
  52. global widthEntry
  53. global sizeBox
  54. global fsCheckButton
  55. global timeVar
  56. global injTime
  57. global injLabel
  58.  
  59. def Click(self, calculateButton):
  60. studWidth=sizeBox.get_active_text()
  61.  
  62. areaHeight=heightEntry.get_text()
  63. areaWidth=widthEntry.get_text()
  64.  
  65. if fsCheckButton.get_active():
  66. if studWidth=="90":
  67. areaWidth=float(areaWidth)-59
  68. elif studWidth=="140":
  69. areaWidth=float(areaWidth)-38
  70. elif studWidth=="219":
  71. areaWidth=float(areaWidth)-24.3
  72. timeVar=float(studWidth)*10.7/140
  73. injTime=((float(areaWidth)*float(areaHeight)*float(timeVar))/1000000)
  74. a= str( 'INJECTION TIME IS '+str(injTime)[:7]+' SECONDS OR '+str((round(injTime*5))/5)+' ROUNDED')
  75. injLabel.set_text(a)
  76.  
  77. win = TableWindow()
  78. win.connect("delete-event", Gtk.main_quit)
  79. win.show_all()
  80. Gtk.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement