def __init__(self,winTitle='Rotate WP', icon='rotWP.svg'): super(rotWPForm,self).__init__() self.move(QPoint(100,250)) self.setWindowFlags(Qt.WindowStaysOnTopHint) self.setWindowTitle(winTitle) iconPath=join(dirname(abspath(__file__)),"iconz",icon) from PySide.QtGui import QIcon Icon=QIcon() Icon.addFile(iconPath) self.setWindowIcon(Icon) self.grid=QGridLayout() self.setLayout(self.grid) self.radioX=QRadioButton('X') self.radioX.setChecked(True) self.radioY=QRadioButton('Y') self.radioZ=QRadioButton('Z') self.lab1=QLabel('Angle:') self.edit1=QLineEdit('45') self.edit1.setAlignment(Qt.AlignCenter) self.edit1.setValidator(QDoubleValidator()) self.btn1=QPushButton('Rotate working plane') self.btn1.clicked.connect(self.rotate) self.grid.addWidget(self.radioX,0,0,1,1,Qt.AlignCenter) self.grid.addWidget(self.radioY,0,1,1,1,Qt.AlignCenter) self.grid.addWidget(self.radioZ,0,2,1,1,Qt.AlignCenter) self.grid.addWidget(self.lab1,1,0,1,1) self.grid.addWidget(self.edit1,1,1,1,2) self.grid.addWidget(self.btn1,2,0,1,3,Qt.AlignCenter) self.show() self.sg=FreeCADGui.ActiveDocument.ActiveView.getSceneGraph() s=FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft").GetInt("gridSize") sc=[float(x*s) for x in [1,1,.2]] from uCmd import arrow self.arrow =arrow(FreeCAD.DraftWorkingPlane.getPlacement(),scale=sc,offset=s)
def __init__(self,winTitle='Rotate WP', icon='rotWP.svg'): super(rotWPForm,self).__init__() self.move(QPoint(100,250)) self.setWindowFlags(Qt.WindowStaysOnTopHint) self.setWindowTitle(winTitle) iconPath=join(dirname(abspath(__file__)),"icons",icon) from PySide.QtGui import QIcon Icon=QIcon() Icon.addFile(iconPath) self.setWindowIcon(Icon) self.grid=QGridLayout() self.setLayout(self.grid) self.radioX=QRadioButton('X') self.radioX.setChecked(True) self.radioY=QRadioButton('Y') self.radioZ=QRadioButton('Z') self.lab1=QLabel('Angle:') self.edit1=QLineEdit('45') self.edit1.setAlignment(Qt.AlignCenter) self.edit1.setValidator(QDoubleValidator()) self.btn1=QPushButton('Rotate working plane') self.btn1.clicked.connect(self.rotate) self.grid.addWidget(self.radioX,0,0,1,1,Qt.AlignCenter) self.grid.addWidget(self.radioY,0,1,1,1,Qt.AlignCenter) self.grid.addWidget(self.radioZ,0,2,1,1,Qt.AlignCenter) self.grid.addWidget(self.lab1,1,0,1,1) self.grid.addWidget(self.edit1,1,1,1,2) self.grid.addWidget(self.btn1,2,0,1,3,Qt.AlignCenter) self.show() self.sg=FreeCADGui.ActiveDocument.ActiveView.getSceneGraph() s=FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft").GetInt("gridSize") sc=[float(x*s) for x in [1,1,.2]] from polarUtilsCmd import arrow self.arrow =arrow(FreeCAD.DraftWorkingPlane.getPlacement(),scale=sc,offset=s)
def __init__(self,winTitle='Title', PType='Pipe', PRating='SCH-STD', icon='flamingo.svg'): ''' __init__(self,winTitle='Title', PType='Pipe', PRating='SCH-STD') winTitle: the window's title PType: the pipeFeature type PRating: the pipeFeature pressure rating class It lookups in the directory ./tables the file PType+"_"+PRating+".csv", imports it's content in a list of dictionaries -> .pipeDictList and shows a summary in the QListWidget -> .sizeList Also create a property -> PRatingsList with the list of available PRatings for the selected PType. ''' super(protopypeForm,self).__init__() self.move(QPoint(100,250)) self.PType=PType self.PRating=PRating self.setWindowFlags(Qt.WindowStaysOnTopHint) self.setWindowTitle(winTitle) iconPath=join(dirname(abspath(__file__)),"icons",icon) from PySide.QtGui import QIcon Icon=QIcon() Icon.addFile(iconPath) self.setWindowIcon(Icon) self.mainHL=QHBoxLayout() self.setLayout(self.mainHL) self.firstCol=QWidget() self.firstCol.setLayout(QVBoxLayout()) self.mainHL.addWidget(self.firstCol) self.currentRatingLab=QLabel('Rating: '+self.PRating) self.firstCol.layout().addWidget(self.currentRatingLab) self.sizeList=QListWidget() self.firstCol.layout().addWidget(self.sizeList) self.pipeDictList=[] self.fileList=listdir(join(dirname(abspath(__file__)),"tables")) self.fillSizes() self.PRatingsList=[s.lstrip(PType+"_").rstrip(".csv") for s in self.fileList if s.startswith(PType) and s.endswith('.csv')] self.secondCol=QWidget() self.secondCol.setLayout(QVBoxLayout()) self.combo=QComboBox() self.combo.addItem('<none>') try: self.combo.addItems([o.Label for o in FreeCAD.activeDocument().Objects if hasattr(o,'PType') and o.PType=='PypeLine']) except: None self.combo.currentIndexChanged.connect(self.setCurrentPL) if FreeCAD.__activePypeLine__ and FreeCAD.__activePypeLine__ in [self.combo.itemText(i) for i in range(self.combo.count())]: self.combo.setCurrentIndex(self.combo.findText(FreeCAD.__activePypeLine__)) self.secondCol.layout().addWidget(self.combo) self.ratingList=QListWidget() self.ratingList.addItems(self.PRatingsList) self.ratingList.itemClicked.connect(self.changeRating) self.ratingList.setCurrentRow(0) self.secondCol.layout().addWidget(self.ratingList) self.btn1=QPushButton('Insert') self.secondCol.layout().addWidget(self.btn1) self.mainHL.addWidget(self.secondCol) self.resize(350,350) self.mainHL.setContentsMargins(0,0,0,0)
def _init_window(self): """Init window attributes""" self.setWindowTitle('Series list') if os.path.exists(const.ICON_PATH): icon = QIcon() icon.addFile(const.ICON_PATH) else: icon = QIcon.fromTheme('series_list_icon') self.setWindowIcon(icon)
def __init__(self, winTitle='Insert section', icon='flamingo.svg'): ''' __init__(self,winTitle='Title',icon='filename.svg') ''' super(insertSectForm, self).__init__() self.move(QPoint(100, 250)) self.setWindowFlags(Qt.WindowStaysOnTopHint) self.setWindowTitle(winTitle) iconPath = join(dirname(abspath(__file__)), "icons", icon) from PySide.QtGui import QIcon Icon = QIcon() Icon.addFile(iconPath) self.setWindowIcon(Icon) self.mainHL = QHBoxLayout() self.setLayout(self.mainHL) self.firstCol = QWidget() self.firstCol.setLayout(QVBoxLayout()) self.mainHL.addWidget(self.firstCol) self.SType = 'IPE' self.currentRatingLab = QLabel('Section: ' + self.SType) self.firstCol.layout().addWidget(self.currentRatingLab) self.sizeList = QListWidget() self.sizeList.setMaximumWidth(120) self.firstCol.layout().addWidget(self.sizeList) self.sectDictList = [] self.fileList = listdir(join(dirname(abspath(__file__)), "tables")) self.fillSizes() self.PRatingsList = [ s.lstrip("Section_").rstrip(".csv") for s in self.fileList if s.startswith("Section") ] self.secondCol = QWidget() self.secondCol.setLayout(QVBoxLayout()) self.lab1 = QLabel('Section types:') self.secondCol.layout().addWidget(self.lab1) self.ratingList = QListWidget() self.ratingList.setMaximumWidth(100) self.ratingList.addItems(self.PRatingsList) self.ratingList.itemClicked.connect(self.changeRating) self.ratingList.setCurrentRow(0) self.secondCol.layout().addWidget(self.ratingList) self.btn1 = QPushButton('Insert') self.btn1.setMaximumWidth(100) self.btn1.clicked.connect(self.insert) self.secondCol.layout().addWidget(self.btn1) self.mainHL.addWidget(self.secondCol) self.show()
def __init__(self,winTitle='Insert section', icon='flamingo.svg'): ''' __init__(self,winTitle='Title',icon='filename.svg') ''' super(insertSectForm,self).__init__() self.move(QPoint(100,250)) self.setWindowFlags(Qt.WindowStaysOnTopHint) self.setWindowTitle(winTitle) iconPath=join(dirname(abspath(__file__)),"icons",icon) from PySide.QtGui import QIcon Icon=QIcon() Icon.addFile(iconPath) self.setWindowIcon(Icon) self.mainHL=QHBoxLayout() self.setLayout(self.mainHL) self.firstCol=QWidget() self.firstCol.setLayout(QVBoxLayout()) self.mainHL.addWidget(self.firstCol) self.SType='IPE' self.currentRatingLab=QLabel('Section: '+self.SType) self.firstCol.layout().addWidget(self.currentRatingLab) self.sizeList=QListWidget() self.sizeList.setMaximumWidth(120) self.firstCol.layout().addWidget(self.sizeList) self.sectDictList=[] self.fileList=listdir(join(dirname(abspath(__file__)),"tables")) self.fillSizes() self.PRatingsList=[s.lstrip("Section_").rstrip(".csv") for s in self.fileList if s.startswith("Section")] self.secondCol=QWidget() self.secondCol.setLayout(QVBoxLayout()) self.lab1=QLabel('Section types:') self.secondCol.layout().addWidget(self.lab1) self.ratingList=QListWidget() self.ratingList.setMaximumWidth(100) self.ratingList.addItems(self.PRatingsList) self.ratingList.itemClicked.connect(self.changeRating) self.ratingList.setCurrentRow(0) self.secondCol.layout().addWidget(self.ratingList) self.btn1=QPushButton('Insert') self.btn1.setMaximumWidth(100) self.btn1.clicked.connect(self.insert) self.secondCol.layout().addWidget(self.btn1) self.mainHL.addWidget(self.secondCol) self.show()
def __init__(self, winTitle='Title', btn1Text='Button1', btn2Text='Button2', initVal='someVal', units='someUnit', icon='flamingo.svg'): super(prototypeForm, self).__init__() self.setWindowFlags(Qt.WindowStaysOnTopHint) self.setWindowTitle(winTitle) iconPath = join(dirname(abspath(__file__)), "icons", icon) from PySide.QtGui import QIcon Icon = QIcon() Icon.addFile(iconPath) self.setWindowIcon(Icon) self.move(QPoint(100, 250)) self.mainVL = QVBoxLayout() self.setLayout(self.mainVL) self.inputs = QWidget() self.inputs.setLayout(QFormLayout()) self.edit1 = QLineEdit(initVal) self.edit1.setMinimumWidth(40) self.edit1.setAlignment(Qt.AlignHCenter) self.edit1.setMaximumWidth(60) self.inputs.layout().addRow(units, self.edit1) self.mainVL.addWidget(self.inputs) self.radio1 = QRadioButton() self.radio1.setChecked(True) self.radio2 = QRadioButton() self.radios = QWidget() self.radios.setLayout(QFormLayout()) self.radios.layout().setAlignment(Qt.AlignHCenter) self.radios.layout().addRow('move', self.radio1) self.radios.layout().addRow('copy', self.radio2) self.mainVL.addWidget(self.radios) self.btn1 = QPushButton(btn1Text) self.btn1.setDefault(True) self.btn1.setFocus() self.btn2 = QPushButton(btn2Text) self.buttons = QWidget() self.buttons.setLayout(QHBoxLayout()) self.buttons.layout().addWidget(self.btn1) self.buttons.layout().addWidget(self.btn2) self.mainVL.addWidget(self.buttons)
def __init__(self,winTitle='Title',btn1Text='Button1',btn2Text='Button2',initVal='someVal',units='someUnit', icon='flamingo.svg'): super(prototypeForm,self).__init__() self.setWindowFlags(Qt.WindowStaysOnTopHint) self.setWindowTitle(winTitle) iconPath=join(dirname(abspath(__file__)),"icons",icon) from PySide.QtGui import QIcon Icon=QIcon() Icon.addFile(iconPath) self.setWindowIcon(Icon) self.move(QPoint(100,250)) self.mainVL=QVBoxLayout() self.setLayout(self.mainVL) self.inputs=QWidget() self.inputs.setLayout(QFormLayout()) self.edit1=QLineEdit(initVal) self.edit1.setMinimumWidth(40) self.edit1.setAlignment(Qt.AlignHCenter) self.edit1.setMaximumWidth(60) self.inputs.layout().addRow(units,self.edit1) self.mainVL.addWidget(self.inputs) self.radio1=QRadioButton() self.radio1.setChecked(True) self.radio2=QRadioButton() self.radios=QWidget() self.radios.setLayout(QFormLayout()) self.radios.layout().setAlignment(Qt.AlignHCenter) self.radios.layout().addRow('move',self.radio1) self.radios.layout().addRow('copy',self.radio2) self.mainVL.addWidget(self.radios) self.btn1=QPushButton(btn1Text) self.btn1.setDefault(True) self.btn1.setFocus() self.btn2=QPushButton(btn2Text) self.buttons=QWidget() self.buttons.setLayout(QHBoxLayout()) self.buttons.layout().addWidget(self.btn1) self.buttons.layout().addWidget(self.btn2) self.mainVL.addWidget(self.buttons)
def makeQIcon(*filenames): """A Shortcut to construct a QIcon which has multiple images. Try to add all sizes (xx.png & xx-big.png & xx-mega.png) when only one filename supplied.""" ico = QIcon() if len(filenames) == 1: fname = filenames[0] ico.addFile(fname) assert '.' in fname b, ext = fname.rsplit('.') # they fails silently when file not exist ico.addFile(b + '-big.' + ext) ico.addFile(b + '-mega.' + ext) else: for i in filenames: ico.addFile(i) return ico
def __init__(self,winTitle='FrameLine Manager', icon='frameline.svg'): super(frameLineForm,self).__init__() self.move(QPoint(100,250)) self.setWindowFlags(Qt.WindowStaysOnTopHint) self.setWindowTitle(winTitle) from PySide.QtGui import QIcon Icon=QIcon() iconPath=join(dirname(abspath(__file__)),"icons",icon) Icon.addFile(iconPath) self.setWindowIcon(Icon) self.mainHL=QHBoxLayout() self.setLayout(self.mainHL) self.firstCol=QWidget() self.firstCol.setLayout(QVBoxLayout()) self.lab1=QLabel(' Profiles:') self.firstCol.layout().addWidget(self.lab1) self.sectList=QListWidget() self.sectList.setMaximumWidth(120) self.updateSections() self.firstCol.layout().addWidget(self.sectList) self.cb1=QCheckBox(' Copy profile') self.cb1.setChecked(True) self.cb2=QCheckBox(' Move to origin') self.cb2.setChecked(True) self.radios=QWidget() self.radios.setLayout(QFormLayout()) self.radios.layout().setAlignment(Qt.AlignHCenter) self.radios.layout().addRow(self.cb1) self.radios.layout().addRow(self.cb2) self.firstCol.layout().addWidget(self.radios) self.mainHL.addWidget(self.firstCol) self.secondCol=QWidget() self.secondCol.setLayout(QVBoxLayout()) self.current=None self.combo=QComboBox() self.combo.addItem('<new>') #self.combo.activated[str].connect(self.setCurrent) try: self.combo.addItems([o.Label for o in FreeCAD.activeDocument().Objects if hasattr(o,'FType') and o.FType=='FrameLine']) except: None self.combo.setMaximumWidth(100) self.combo.currentIndexChanged.connect(self.setCurrentFL) if FreeCAD.__activeFrameLine__ and FreeCAD.__activeFrameLine__ in [self.combo.itemText(i) for i in range(self.combo.count())]: self.combo.setCurrentIndex(self.combo.findText(FreeCAD.__activeFrameLine__)) self.secondCol.layout().addWidget(self.combo) self.btn0=QPushButton('Insert') self.btn0.setMaximumWidth(100) self.secondCol.layout().addWidget(self.btn0) self.btn0.clicked.connect(self.insert) self.edit1=QLineEdit() self.edit1.setPlaceholderText('<name>') self.edit1.setAlignment(Qt.AlignHCenter) self.edit1.setMaximumWidth(100) self.secondCol.layout().addWidget(self.edit1) self.btn1=QPushButton('Redraw') self.btn1.clicked.connect(self.redraw) self.btn1.setMaximumWidth(100) self.secondCol.layout().addWidget(self.btn1) self.btn2=QPushButton('Get Path') self.btn2.clicked.connect(self.getPath) self.btn2.setMaximumWidth(100) self.secondCol.layout().addWidget(self.btn2) self.btn3=QPushButton('Get Profile') self.btn3.clicked.connect(self.getProfile) self.btn3.setMaximumWidth(100) self.secondCol.layout().addWidget(self.btn3) self.btn4=QPushButton('Clear') self.btn4.clicked.connect(self.clear) self.btn4.setMaximumWidth(100) self.secondCol.layout().addWidget(self.btn4) self.mainHL.addWidget(self.secondCol) self.show()
def __init__(self,winTitle='FrameLine Manager', icon='frameline.svg'): super(frameLineForm,self).__init__() self.move(QPoint(100,250)) self.setWindowFlags(Qt.WindowStaysOnTopHint) self.setWindowTitle(winTitle) from PySide.QtGui import QIcon Icon=QIcon() iconPath=join(dirname(abspath(__file__)),"iconz",icon) Icon.addFile(iconPath) self.setWindowIcon(Icon) self.mainHL=QHBoxLayout() self.setLayout(self.mainHL) self.firstCol=QWidget() self.firstCol.setLayout(QVBoxLayout()) self.lab1=QLabel(' Profiles:') self.firstCol.layout().addWidget(self.lab1) self.sectList=QListWidget() self.sectList.setMaximumWidth(120) self.updateSections() self.firstCol.layout().addWidget(self.sectList) self.cb1=QCheckBox(' Copy profile') self.cb1.setChecked(True) self.cb2=QCheckBox(' Move to origin') self.cb2.setChecked(True) self.radios=QWidget() self.radios.setLayout(QFormLayout()) self.radios.layout().setAlignment(Qt.AlignHCenter) self.radios.layout().addRow(self.cb1) self.radios.layout().addRow(self.cb2) self.firstCol.layout().addWidget(self.radios) self.mainHL.addWidget(self.firstCol) self.secondCol=QWidget() self.secondCol.setLayout(QVBoxLayout()) self.current=None self.combo=QComboBox() self.combo.addItem('<new>') #self.combo.activated[str].connect(self.setCurrent) try: self.combo.addItems([o.Label for o in FreeCAD.activeDocument().Objects if hasattr(o,'FType') and o.FType=='FrameLine']) except: None self.combo.setMaximumWidth(100) self.combo.currentIndexChanged.connect(self.setCurrentFL) if FreeCAD.__activeFrameLine__ and FreeCAD.__activeFrameLine__ in [self.combo.itemText(i) for i in range(self.combo.count())]: self.combo.setCurrentIndex(self.combo.findText(FreeCAD.__activeFrameLine__)) self.secondCol.layout().addWidget(self.combo) self.btn0=QPushButton('Insert') self.btn0.setMaximumWidth(100) self.secondCol.layout().addWidget(self.btn0) self.btn0.clicked.connect(self.insert) self.edit1=QLineEdit() self.edit1.setPlaceholderText('<name>') self.edit1.setAlignment(Qt.AlignHCenter) self.edit1.setMaximumWidth(100) self.secondCol.layout().addWidget(self.edit1) self.btn1=QPushButton('Redraw') self.btn1.clicked.connect(self.redraw) self.btn1.setMaximumWidth(100) self.secondCol.layout().addWidget(self.btn1) self.btn2=QPushButton('Get Path') self.btn2.clicked.connect(self.getPath) self.btn2.setMaximumWidth(100) self.secondCol.layout().addWidget(self.btn2) self.btn3=QPushButton('Get Profile') self.btn3.clicked.connect(self.getProfile) self.btn3.setMaximumWidth(100) self.secondCol.layout().addWidget(self.btn3) self.btn4=QPushButton('Clear') self.btn4.clicked.connect(self.clear) self.btn4.setMaximumWidth(100) self.secondCol.layout().addWidget(self.btn4) self.mainHL.addWidget(self.secondCol) self.show()
def __init__(self,winTitle='Break the pipes', PType='Pipe', PRating='SCH-STD', icon='break.svg'): self.refL=0.0 super(breakForm,self).__init__() self.move(QPoint(100,250)) self.PType=PType self.PRating=PRating self.setWindowFlags(Qt.WindowStaysOnTopHint) self.setWindowTitle(winTitle) iconPath=join(dirname(abspath(__file__)),"icons",icon) from PySide.QtGui import QIcon Icon=QIcon() Icon.addFile(iconPath) self.setWindowIcon(Icon) self.grid=QGridLayout() self.setLayout(self.grid) self.btn0=QPushButton('Length') self.btn0.clicked.connect(self.getL) self.lab0=QLabel('<reference>') self.lab1=QLabel('PypeLine:') self.combo=QComboBox() self.combo.addItem('<none>') try: self.combo.addItems([o.Label for o in FreeCAD.activeDocument().Objects if hasattr(o,'PType') and o.PType=='PypeLine']) except: None self.combo.currentIndexChanged.connect(self.setCurrentPL) if FreeCAD.__activePypeLine__ and FreeCAD.__activePypeLine__ in [self.combo.itemText(i) for i in range(self.combo.count())]: self.combo.setCurrentIndex(self.combo.findText(FreeCAD.__activePypeLine__)) self.edit1=QLineEdit('0') self.edit1.setAlignment(Qt.AlignCenter) self.edit1.editingFinished.connect(self.updateSlider) self.edit2=QLineEdit('0') self.edit2.setAlignment(Qt.AlignCenter) self.edit2.editingFinished.connect(self.calcGapPercent) rx=QRegExp('[0-9,.%]*') val=QRegExpValidator(rx) self.edit1.setValidator(val) self.edit2.setValidator(val) self.lab2=QLabel('Point:') self.btn1=QPushButton('Break') self.btn1.clicked.connect(self.breakPipe) self.btn1.setDefault(True) self.btn1.setFocus() self.lab3=QLabel('Gap:') self.btn2=QPushButton('Get gap') self.btn2.clicked.connect(self.changeGap) self.slider=QSlider(Qt.Horizontal) self.slider.valueChanged.connect(self.changePoint) self.slider.setMaximum(100) self.grid.addWidget(self.btn0,4,0) self.grid.addWidget(self.lab0,4,1,1,1,Qt.AlignCenter) self.grid.addWidget(self.lab1,0,0,1,1,Qt.AlignCenter) self.grid.addWidget(self.combo,0,1,1,1,Qt.AlignCenter) self.grid.addWidget(self.lab2,1,0,1,1,Qt.AlignCenter) self.grid.addWidget(self.edit1,1,1) self.grid.addWidget(self.lab3,2,0,1,1,Qt.AlignCenter) self.grid.addWidget(self.edit2,2,1) self.grid.addWidget(self.btn1,3,0) self.grid.addWidget(self.btn2,3,1) self.grid.addWidget(self.slider,5,0,1,2) self.show()