FlatCAMTool.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. ############################################################
  2. # FlatCAM: 2D Post-processing for Manufacturing #
  3. # http://flatcam.org #
  4. # Author: Juan Pablo Caram (c) #
  5. # Date: 2/5/2014 #
  6. # MIT Licence #
  7. ############################################################
  8. from PyQt4 import QtGui
  9. class FlatCAMTool(QtGui.QWidget):
  10. toolName = "FlatCAM Generic Tool"
  11. def __init__(self, app, parent=None):
  12. """
  13. :param app: The application this tool will run in.
  14. :type app: App
  15. :param parent: Qt Parent
  16. :return: FlatCAMTool
  17. """
  18. QtGui.QWidget.__init__(self, parent)
  19. # self.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Maximum)
  20. self.layout = QtGui.QVBoxLayout()
  21. self.setLayout(self.layout)
  22. self.app = app
  23. self.menuAction = None
  24. def install(self, icon=None):
  25. if icon is None:
  26. self.menuAction = self.app.ui.menutool.addAction(self.toolName)
  27. else:
  28. self.menuAction = self.app.ui.menutool.addAction(icon, self.toolName)
  29. self.menuAction.triggered.connect(self.run)
  30. def run(self):
  31. # Remove anything else in the GUI
  32. self.app.ui.tool_scroll_area.takeWidget()
  33. # Put ourself in the GUI
  34. self.app.ui.tool_scroll_area.setWidget(self)
  35. # Switch notebook to tool page
  36. self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab)
  37. self.show()