def generate_toolbutton(self, text, graphic_name): graphic_path = get_graphic_path() button = QToolButton() button.setText(self.tr(text)) button.setIcon(QIcon(os.path.join(graphic_path, graphic_name))) button.setIconSize(QSize(60, 60)) button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) button.setFixedWidth(200) return button
def generate_button(self, text, graphic_name): graphic_path = get_graphic_path() button = QtGui.QToolButton() button.setText(self.tr(text)) button.setIcon(QtGui.QIcon(os.path.join(graphic_path, graphic_name))) button.setIconSize(QtCore.QSize(120, 60)) button.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon) button.setFixedWidth(200) button.clicked.connect(self.startWizard) button.setStyleSheet( 'QToolButton {' 'background-color:#FF9955;' 'border: 2px solid #404040;' 'border-radius: 5px};' # 'FF7F2A' 'QToolButton:hover{' 'background-color:red};' ) return button
def __init__(self, parent=None): super(LoadFilePage, self).__init__(parent) graphic_path = get_graphic_path() # Set up layout self.layout = QVBoxLayout() self.setLayout(self.layout) self.setTitle("Select an input file") self.setSubTitle("Select the files you want to merge and specify the" " merge mode and location to save your file ") vbox = self.layout # setting inputfile variables self.inputfilename1 = '' self.inputfilename2 = '' self.settings.register('inputfilename1', self, useconfig=False) self.settings.register('inputfilename2', self, useconfig=False) # Adding primary input part topLabel = QLabel(self.tr("Choose two odml files to load")) topLabel.setWordWrap(True) vbox.addWidget(topLabel) # Add first horizontal box self.buttonbrowse1 = self.generate_toolbutton("Browse for basic\nodml" "file", 'odmlA.svg') self.buttonbrowse1.clicked.connect(self.browse2open, 1) self.inputfilename1 = '' self.inputfile1 = QLabel(self.inputfilename1) self.inputfile1.setWordWrap(True) hbox1 = QHBoxLayout() hbox1.addWidget(self.buttonbrowse1) hbox1.addWidget(self.inputfile1) hbox1.addStretch() vbox.addLayout(hbox1) # Adding secondary input part # topLabel = QLabel(self.tr("Choose an additional odML file to load")) # topLabel.setWordWrap(True) # vbox.addWidget(topLabel) # Add second horizontal box self.buttonbrowse2 = self.generate_toolbutton("Browse for second,\n" "extending file", 'odmlB.svg') self.buttonbrowse2.clicked.connect(self.browse2open, 2) self.inputfilename2 = '' self.inputfile2 = QLabel(self.inputfilename2) self.inputfile2.setWordWrap(True) hbox2 = QHBoxLayout() hbox2.addWidget(self.buttonbrowse2) hbox2.addWidget(self.inputfile2) hbox2.addStretch() vbox.addLayout(hbox2) vbox.addStretch() # adding first separator horizontalLine = QFrame() horizontalLine.setFrameStyle(QFrame.HLine) horizontalLine.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum) vbox.addWidget(horizontalLine) # adding merge mode part vbox.addWidget(QLabel('Select a mode for merging the two files')) self.rbstrict = QRadioButton('strict merge') self.rbstrict.setIcon(QIcon(os.path.join(graphic_path, 'mergestrict.svg'))) self.rbstrict.setIconSize(QSize(100, 100)) self.rboverwrite = QRadioButton('overwrite') self.rboverwrite.setIcon(QIcon(os.path.join(graphic_path, 'mergeoverwrite.svg'))) self.rboverwrite.setIconSize(QSize(100, 100)) self.settings.register('rbstrict', self.rbstrict) self.settings.register('rboverwrite', self.rboverwrite) self.rbstrict.setChecked(True) hbox3 = QHBoxLayout() hbox3.addWidget(self.rbstrict) hbox3.addSpacing(20) hbox3.addWidget(self.rboverwrite) vbox.addLayout(hbox3) # adding second separator horizontalLine = QFrame() horizontalLine.setFrameStyle(QFrame.HLine) horizontalLine.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum) vbox.addWidget(horizontalLine) # adding save part self.topLabel = QLabel(self.tr("Where do you want to save your file?")) self.topLabel.setWordWrap(True) vbox.addWidget(self.topLabel) self.buttonbrowsesave = QPushButton("Browse") self.buttonbrowsesave.clicked.connect(self.browse2save) self.buttonbrowsesave.setEnabled(False) self.outputfilename = '' self.settings.register('outputfilename', self) self.outputfile = QLabel(self.outputfilename) self.outputfile.setWordWrap(True) self.buttonshow = QPushButton("Open file") self.buttonshow.clicked.connect(self.show_file) self.buttonshow.setEnabled(False) hbox = QHBoxLayout() hbox.addWidget(self.buttonbrowsesave) hbox.addWidget(self.outputfile) hbox.addStretch() vbox.addLayout(hbox) # vbox.addSpacing(10) vbox.addWidget(self.buttonshow) vbox.addStretch() self.issaved = False