def __init__(self): super(MyWindow, self).__init__() self.resize(347, 347) self.setFixedSize(self.width(), self.height()) self.setWindowTitle(u'KR1 Steam版 V2.2 跳波修改器') self.showMSG = QLabel(self) self.showMSG.setGeometry(QRect(30, 10, 300, 15)) self.showChange = QLabel(self) self.showChange.setGeometry(QRect(200, 10, 147, 15)) self.moneyGroup = QGroupBox(self) self.moneyGroup.setGeometry(QRect(23, 40, 300, 80)) self.moneyGroup.setTitle(u'修改金钱 ') self.moneyLineEdit = QLineEdit(self) self.moneyLineEdit.setValidator(QIntValidator()) self.moneyLineEdit.setGeometry(QRect(40, 65, 180, 35)) self.moneyLineEdit.setText('10000') self.moneyLineEdit.setStyleSheet('color:#4F4F4F;') self.moneyLineEdit.setFont(QFont('Arial', 15)) self.moneyButton = QPushButton(self) self.moneyButton.setGeometry(QRect(238, 64, 65, 37)) self.moneyButton.setText(u'修改') self.moneyButton.clicked.connect(self.moneyModify) self.enemyHealthGroup = QGroupBox(self) self.enemyHealthGroup.setGeometry(QRect(23, 140, 300, 80)) self.enemyHealthGroup.setTitle(u'修改Hard难度敌人血量倍数') self.enemyHealthLineEdit = QLineEdit(self) self.enemyHealthLineEdit.setValidator(QDoubleValidator()) self.enemyHealthLineEdit.setGeometry(QRect(40, 165, 180, 35)) self.enemyHealthLineEdit.setText('2.5') self.enemyHealthLineEdit.setStyleSheet('color:#4F4F4F;') self.enemyHealthLineEdit.setFont(QFont('Arial', 15)) self.enemyHealthButton = QPushButton(self) self.enemyHealthButton.setGeometry(QRect(238, 164, 65, 37)) self.enemyHealthButton.setText(u'修改') self.enemyHealthButton.setEnabled(False) self.enemyHealthLineEdit.setEnabled(False) # self.enemyHealthButton.clicked.connect(self.enemyHealthModify) self.enemyWaveGroup = QGroupBox(self) self.enemyWaveGroup.setGeometry(QRect(23, 240, 300, 80)) self.enemyWaveGroup.setTitle(u'跳波功能 这关共有 0 波敌人') self.enemyWaveLineEdit = QLineEdit(self) self.enemyWaveLineEdit.setValidator(QIntValidator()) self.enemyWaveLineEdit.setGeometry(QRect(40, 265, 180, 35)) self.enemyWaveLineEdit.setText('0') self.enemyWaveLineEdit.setStyleSheet('color:#4F4F4F;') self.enemyWaveLineEdit.setFont(QFont('Arial', 15)) self.enemyWaveButton = QPushButton(self) self.enemyWaveButton.setGeometry(QRect(238, 264, 65, 37)) self.enemyWaveButton.setText(u'修改') self.enemyWaveButton.clicked.connect(self.skipWave) self.checkTotalWave = None # self.widgetList = [self.moneyLineEdit, self.moneyButton, self.enemyHealthLineEdit, self.enemyHealthButton, self.enemyWaveLineEdit, self.enemyWaveButton] self.widgetList = [self.moneyLineEdit, self.moneyButton, self.enemyWaveLineEdit, self.enemyWaveButton] self.checkKRHD = checkKRHD() self.checkKRHD.KRHDID.connect(self.KRModify) self.checkKRHD.start()
def __init__(self, value): super().__init__() self._val = value self._rootLayout = QHBoxLayout() self._xLabel = QLabel("<b>X:</>") self._rootLayout.addWidget(self._xLabel) self._xLineEdit = QLineEdit() self._xLineEdit.textEdited.connect(self._signal_xEdit_textEdited) self._xLineEdit.setAlignment(Qt.AlignRight) self._xLineEdit.setValidator(QIntValidator()) self._rootLayout.addWidget(self._xLineEdit) self._yLabel = QLabel("<b>Y:</>") self._rootLayout.addWidget(self._yLabel) self._yLineEdit = QLineEdit() self._yLineEdit.textEdited.connect(self._signal_yEdit_textEdited) self._yLineEdit.setAlignment(Qt.AlignRight) self._yLineEdit.setValidator(QIntValidator()) self._rootLayout.addWidget(self._yLineEdit) self._rootLayout.setContentsMargins(1, 1, 1, 1) self.setLayout(self._rootLayout) self._pull()
def __init__(self): QDialog.__init__(self) self.setupUi(self) self.validator = QDoubleValidator() self.txtRestricciones.setClearButtonEnabled(True) self.txtVariables.setClearButtonEnabled(True) self.txtRestricciones.setValidator(QIntValidator()) self.txtVariables.setValidator(QIntValidator()) self.scrollContent.setLayout(self.gridData) self.scrollAreaWidgetContents.setLayout(self.func_object) self.btnClose.clicked.connect(self.close) self.txtRestricciones.textChanged['QString'].connect( self.generateInputs) self.txtVariables.textChanged['QString'].connect(self.generateInputs) self.label_3.setVisible(False) self.label_4.setVisible(False) self.btnSolve.clicked.connect(self.solve) self.btnLimpiar.clicked.connect(lambda: self.clearLayout(True))
def init_value_box(self): self.value_box.setEnabled(True) self.value_box.setText('') self.value_box.setInputMask('') self.value_box.setValidator(None) col = self.current_col if not col: return action = self.current_action if not action: return m = self.fm[col] dt = m['datatype'] tt = '' if col == 'identifiers': tt = _('Enter either an identifier type or an ' 'identifier type and value of the form identifier:value') elif col == 'languages': tt = _('Enter a 3 letter ISO language code, like fra for French' ' or deu for German or eng for English. You can also use' ' the full language name, in which case calibre will try to' ' automatically convert it to the language code.') elif dt in ('int', 'float', 'rating'): tt = _('Enter a number') v = QIntValidator if dt == 'int' else QDoubleValidator self.value_box.setValidator(v(self.value_box)) elif dt == 'datetime': if action == 'count_days': self.value_box.setValidator(QIntValidator(self.value_box)) tt = _( 'Enter the maximum days old the item can be. Zero is today. ' 'Dates in the future always match') elif action == 'older count days': self.value_box.setValidator(QIntValidator(self.value_box)) tt = _( 'Enter the minimum days old the item can be. Zero is today. ' 'Dates in the future never match') elif action == 'older future days': self.value_box.setValidator(QIntValidator(self.value_box)) tt = _('Enter the maximum days in the future the item can be. ' 'Zero is today. Dates in the past always match') elif action == 'newer future days': self.value_box.setValidator(QIntValidator(self.value_box)) tt = _('Enter the minimum days in the future the item can be. ' 'Zero is today. Dates in the past never match') else: self.value_box.setInputMask('9999-99-99') tt = _('Enter a date in the format YYYY-MM-DD') else: tt = _('Enter a string.') if 'pattern' in action: tt = _('Enter a regular expression') elif m.get('is_multiple', False): tt += '\n' + _( 'You can match multiple values by separating' ' them with %s') % m['is_multiple']['ui_to_list'] self.value_box.setToolTip(tt) if action in ('is set', 'is not set', 'is true', 'is false', 'is undefined'): self.value_box.setEnabled(False)
def calculate(self, strength): validator = QIntValidator() self.ui.txt_length_passowrd.setValidator(validator) self.ui.txt_length_passowrd.setMaxLength(10) length_of_password = self.ui.txt_length_passowrd.text() lower = "abcdefghijklmnopqrstuvwxyz" upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()" password = "******" if length_of_password == '': QMessageBox.information(self, "Information" , "Please select strength for password.") else: if strength == 'low': for i in range(0, int(length_of_password)): password = password + random.choice(lower) elif strength == 'medium': for i in range(0, int(length_of_password)): password = password + random.choice(upper) elif strength == 'high': for i in range(0, int(length_of_password)): password = password + random.choice(digits) self.ui.txt_password.setText(password) return password
def __init__(self, *args): QWidget.__init__(self, *args) lo = QHBoxLayout(self) lo.setContentsMargins(0, 0, 0, 0) lo.setSpacing(5) # type selector self.wtypesel = QComboBox(self) for i, tp in enumerate(self.ValueTypes): self.wtypesel.addItem(tp.__name__) self.wtypesel.activated[int].connect(self._selectTypeNum) typesel_lab = QLabel("&Type:", self) typesel_lab.setBuddy(self.wtypesel) lo.addWidget(typesel_lab, 0) lo.addWidget(self.wtypesel, 0) self.wvalue = QLineEdit(self) self.wvalue_lab = QLabel("&Value:", self) self.wvalue_lab.setBuddy(self.wvalue) self.wbool = QComboBox(self) self.wbool.addItems(["false", "true"]) self.wbool.setCurrentIndex(1) lo.addWidget(self.wvalue_lab, 0) lo.addWidget(self.wvalue, 1) lo.addWidget(self.wbool, 1) self.wvalue.hide() # make input validators self._validators = {int: QIntValidator(self), float: QDoubleValidator(self)} # select bool type initially self._selectTypeNum(0)
def __init__(self): QWidget.__init__(self) self.layout = QVBoxLayout() self.setLayout(self.layout) self.l = QHBoxLayout() self.layout.addLayout(self.l) self.l = QHBoxLayout() self.layout.addLayout(self.l) self.label = QLabel('epub tag') self.l.addWidget(self.label) self.tags = QLineEdit(self) self.tags.setText(prefs['tags']) self.l.addWidget(self.tags) self.label.setBuddy(self.tags) self.l = QHBoxLayout() self.layout.addLayout(self.l) self.label = QLabel('search result limit:') self.l.addWidget(self.label) self.search_result_count = QLineEdit(self) self.search_result_count.setValidator( QIntValidator(self.search_result_count)) self.search_result_count.setText(prefs['search_result_count']) self.l.addWidget(self.search_result_count) self.label.setBuddy(self.search_result_count)
def __init__(self): QWidget.__init__(self) self.l = QVBoxLayout() self.setLayout(self.l) self.label = QLabel("Voice") self.l.addWidget(self.label) self.voiceOptions = QComboBox() self.l.addWidget(self.voiceOptions) self.rateLabel = QLabel("Rate (-10 to 10)") self.l.addWidget(self.rateLabel) self.rateEdit = QLineEdit() self.rateEdit.setValidator(QIntValidator(-10, 10)) self.rateEdit.setText(str(prefs['rate'])) self.l.addWidget(self.rateEdit) self.volumeLabel = QLabel("Volume (0 to 100)") self.volumeEdit = QLineEdit() self.volumeEdit.setValidator(QIntValidator(0, 100)) self.volumeEdit.setText(str(prefs['volume'])) self.l.addWidget(self.volumeLabel) self.l.addWidget(self.volumeEdit) import win32com.client self.spVoice = win32com.client.Dispatch("SAPI.SpVoice") voices = self.spVoice.GetVoices("", "") for i in range(voices.Count): self.voiceOptions.addItem(voices.Item(i).GetDescription()) if voices.Item(i).GetDescription() == prefs['voice']: self.voiceOptions.setCurrentIndex(i) self.pauseHotKey = HotkeyWidget(prefs, "pause", "Enable Pause/Play hotkey") self.l.addWidget(self.pauseHotKey) self.stopHotKey = HotkeyWidget(prefs, "stop", "Enable Stop hotkey") self.l.addWidget(self.stopHotKey) self.selectHotKey = HotkeyWidget(prefs, "select", "Enable Select Mode hotkey") self.l.addWidget(self.selectHotKey)
def __init__(self): QDialog.__init__(self) self.setupUi(self) self.btnClose.clicked.connect(self.close) self.validator = QDoubleValidator() self.txtDestinos.setClearButtonEnabled(True) self.txtOrigenes.setClearButtonEnabled(True) self.txtDestinos.setValidator(QIntValidator()) self.txtOrigenes.setValidator(QIntValidator()) self.scrollContent.setLayout(self.gridData) self.txtOrigenes.textChanged['QString'].connect(self.generate_inputs) self.txtDestinos.textChanged['QString'].connect(self.generate_inputs) self.resize(720, 480)
def _set_validators(self): """ This methods sets validation rules for the input fields. It should be called only once when the PreferencesDialog is instantiated. :return: Has no return values. """ self.ui.contentWeightInput.setValidator(QDoubleValidator(self)) self.ui.styleWeightInput.setValidator(QDoubleValidator(self)) self.ui.tvWeightInput.setValidator(QDoubleValidator(self)) self.ui.temporalWeightInput.setValidator(QDoubleValidator(self)) self.ui.learningRateInput.setValidator(QDoubleValidator(self)) self.ui.iterationsInput.setValidator(QIntValidator(0, 5000, self))
def setup_buttons(self): # self.le_P.setValidator(QDoubleValidator()) # self.le_D.setValidator(QDoubleValidator()) # self.le_I.setValidator(QDoubleValidator()) self.le_min.setValidator(QDoubleValidator()) self.le_max.setValidator(QDoubleValidator()) self.le_nbOfPoints.setValidator(QIntValidator()) self.le_P.setMaxLength(5) self.le_I.setMaxLength(5) self.le_D.setMaxLength(5)
def init_all_inputs(self): """ 初始化输入框 :return: """ self.panel1_line_edit1.setPlaceholderText('示例:川A123456') # 车牌 self.panel1_line_edit2.setPlaceholderText('示例:宝马325Li') # 品牌型号 self.panel1_date1.setDate(QDate.fromString('2019-01-01', 1)) # 注册时间 self.panel1_date2.setDate(QDate.currentDate()) # 购买时间 self.panel1_line_edit3.setPlaceholderText('示例:蓝色') # 颜色 self.panel1_line_edit4.setPlaceholderText('示例:88888元') # 购买总价 self.panel1_line_edit5.setPlaceholderText('示例:88888元') # 自筹资金 self.panel1_line_edit6.setPlaceholderText('示例:王总') # 合作伙伴1 self.panel1_line_edit7.setPlaceholderText('示例:88888元') # 合作金额1 self.panel1_text_edit1.setPlaceholderText('示例:本车品质较好!') self.panel1_line_edit1.setText('') # 车牌 self.panel1_line_edit2.setText('') # 品牌型号 self.panel1_line_edit3.setText('') self.panel1_line_edit4.setText('') self.panel1_line_edit5.setText('') self.panel1_line_edit6.setText('') self.panel1_line_edit7.setText('') self.panel1_line_edit8.setText('') self.panel1_line_edit9.setText('') self.panel1_line_edit10.setText('') self.panel1_line_edit11.setText('') self.panel1_line_edit12.setText('') self.panel1_line_edit13.setText('') self.panel1_text_edit1.setPlainText('') self.panel1_line_edit4.setValidator(QIntValidator()) self.panel1_line_edit5.setValidator(QIntValidator()) self.panel1_line_edit7.setValidator(QIntValidator()) self.panel1_line_edit9.setValidator(QIntValidator()) self.panel1_line_edit11.setValidator(QIntValidator()) self.panel1_line_edit13.setValidator(QIntValidator())
def __init__(self, degField, minField, secField, maxDegrees): super(DmsHandler, self).__init__() # init validators: self.intDegValidator = QIntValidator(0, maxDegrees, parent=self) self.minValidator = QIntValidator(0, 59, parent=self) self.secValidator = QDoubleValidator(0.0, 59.999, 3, parent=self) self.secValidator.setNotation(QDoubleValidator.StandardNotation) self._degField = degField self._minField = minField self._secField = secField self._maxDegrees = maxDegrees self._degFieldIncrementor = ValueIncrementor(self._degField, maxDegrees, doOverflow=False) self._degFieldIncrementor.fieldDidOverflow.connect( self.fieldDidOverflow) self._degField.setValidator(self.intDegValidator) self._degField.textEdited.connect(self.inputDidChange.emit) self._minFieldIncrementor = ValueIncrementor( self._minField, 59, wrapCallback=self.isWrapAllowedFor) self._minFieldIncrementor.fieldDidOverflow.connect( self.fieldDidOverflow) self._minField.setValidator(self.minValidator) self._minField.textChanged.connect( partial(self.minorFieldDidChange, self._minField)) self._secFieldIncrementor = ValueIncrementor( self._secField, 59, wrapCallback=self.isWrapAllowedFor) self._secFieldIncrementor.fieldDidOverflow.connect( self.fieldDidOverflow) self._secField.setValidator(self.secValidator) self._secField.textChanged.connect( partial(self.minorFieldDidChange, self._secField))
def __init__(self, number_only=None, number_min=None, number_max=None, number_limit=None, parent=None, upper_mode=False, init_value=None, width=None, alignement=None, mode_min=False): super(TextEdit, self).__init__(parent=parent) self.setStyleSheet(line_edit_stylesheet) if width: self.setFixedWidth(width) self.upper_mode = upper_mode self.textChanged.connect(self.on_text_changed) self.number_only = number_only self.number_limit = number_limit self.number_min = number_min self.number_max = number_max self.only_int = None self.mode_min = mode_min self.installEventFilter(self) self.all_selected = False if alignement == "center": self.setAlignment(Qt.AlignCenter) if number_limit: self.only_int = QIntValidator(0, number_limit) if number_min and number_max: self.only_int = QIntValidator(number_min, number_max) if number_only: if not self.only_int: self.only_int = QIntValidator() self.setValidator(self.only_int) if init_value is not None: if init_value == 0: init_value = "00" self.setText(str(init_value))
class AttributeEntryCell (QLineEdit): selected = pyqtSignal([int, int]) edited = pyqtSignal([int, int]) edited_key = pyqtSignal([object, object]) # will be [list, self.type_] validators = { int: QIntValidator(), float: QDoubleValidator(), str: None, } def __init__(self, row, column, type_, key=None): super().__init__() self.row_ = row self.column_ = column self.type_ = type_ self.key = key self.setValidator(self.validators[type_]) self.setFrame(False) self.setAlignment(Qt.AlignCenter) self.editingFinished.connect(self.emit_edited) self.setAcceptDrops(True) def mousePressEvent(self, ev): self.select_all() def focusInEvent(self, ev): self.select_all() def select_all(self): self.selectAll() self.selected.emit(self.row_, self.column_) def emit_edited(self): self.edited.emit(self.row_, self.column_) self.edited_key.emit(self.key, self.type_(self.text())) def dragEnterEvent(self, event): if event.mimeData().hasText() and not event.mimeData().hasUrls(): event.accept() else: event.ignore() def dropEvent(self, event): self.selectAll() self.insert(event.mimeData().text().strip()) self.deselect() self.emit_edited()
def buildCompInputRegion(self, numberOfComponenets=2): """Builds input region based on number of componenets""" # Remove previous widgets from the inputRegion for nameEdit, ratioEdit in zip(self.compNameLineEdits, self.compRatioLineEdits): QObjectCleanupHandler().add(nameEdit) QObjectCleanupHandler().add(ratioEdit) # Empty the lists self.compNameLineEdits = [] self.compRatioLineEdits = [] # Creating new widgets' instances for index in range(numberOfComponenets): self.compNameLineEdits.append(QLineEdit()) self.compRatioLineEdits.append(QLineEdit()) # Setting text alignment for every QLineEdit for nameEdit, ratioEdit in zip(self.compNameLineEdits, self.compRatioLineEdits): nameEdit.setAlignment(Qt.AlignLeft) ratioEdit.setAlignment(Qt.AlignCenter) # Adding widgets to inputBoxes' layout for index, (nameEdit, ratioEdit) in enumerate( zip(self.compNameLineEdits, self.compRatioLineEdits)): self.compInputLayout.addWidget(nameEdit, index, 0) self.compInputLayout.addWidget(ratioEdit, index, 1) # Setting placeholder text for every QLineEdit and QValidators # Preparing validators ratioValidator = QIntValidator() nameValidator = QRegularExpressionValidator() nameValidator.setRegularExpression(QRegularExpression(r"[\w\d]*")) for index, (nameEdit, ratioEdit) in enumerate(zip(self.compNameLineEdits, self.compRatioLineEdits), start=1): strIndex = str(index) # Setting placeholders nameEdit.setPlaceholderText("Name " + strIndex) ratioEdit.setPlaceholderText("Ratio " + strIndex) # Setting validators nameEdit.setValidator(nameValidator) ratioEdit.setValidator(ratioValidator)
def __init__(self, MySQL): super().__init__() self.setupUi(self) self.MySQL = MySQL self.listFunc.currentRowChanged.connect( self.stackedWidget.setCurrentIndex) # list和右边窗口index绑定 self.listFunc.currentRowChanged.connect(self.left_row_changed) # 货物增删查 self.headers = ['货物名', '货物简介', '数目'] self.data_model = QStandardItemModel() self.data_model_2 = QStandardItemModel() self.data = [] self.tv_goods.setModel(self.data_model) self.tv_goods_2.setModel(self.data_model_2) self.tv_goods.horizontalHeader().setSectionResizeMode( QHeaderView.Stretch) self.tv_goods.setEditTriggers(QTableView.NoEditTriggers) # 不可编辑 self.tv_goods.setSelectionBehavior(QTableView.SelectRows) # 选中行 self.tv_goods_2.horizontalHeader().setSectionResizeMode( QHeaderView.Stretch) self.tv_goods_2.setEditTriggers(QTableView.NoEditTriggers) # 不可编辑 self.tv_goods_2.setSelectionBehavior(QTableView.SelectRows) # 选中行 self.onlyInt = QIntValidator() self.le_inout_price.setValidator(self.onlyInt) # 限制只能为int self.le_inout_num.setValidator(self.onlyInt) self.listFunc.setCurrentRow(0) #self.myclear() self.le_filter.textChanged.connect(self.on_le_filter_textChange) self.le_inout_name.textChanged.connect(self.on_le_filter_textChange_2) self.cb_inout_year.currentIndexChanged.connect(self.inout_day_parser) self.cb_inout_month.currentIndexChanged.connect(self.inout_day_parser) ################################# 按钮事件 ############################################# self.btn_confirm_add.clicked.connect(self.on_btn_add_goods) self.btn_remove_select.clicked.connect(self.on_btn_remove_goods) self.btn_inout_confirm.clicked.connect(self.on_btn_inout_confirm)
def __init__(self, parent, minimum, maximum, initial=0): QWidget.__init__(self, parent) self._slider = QScrollBar(Qt.Horizontal, self) self._slider.setMinimum(minimum) self._slider.setMaximum(maximum) self._slider.setSingleStep(1) # self._slider.setTickInterval(1) self._linedit = QLineEdit(self) self._linedit.setValidator(QIntValidator(minimum, maximum, self)) self._linedit.setMinimumWidth(20) self._layout = QHBoxLayout(self) self._layout.setContentsMargins(0, 0, 0, 0) self._layout.addWidget(self._slider, 4) self._layout.addWidget(self._linedit, 1) self._slider.valueChanged.connect(self._update_value) self._linedit.textChanged.connect(self._update_value) self._update_value(initial)
def initUI(self): self.container = QToolBox() self.setWidget(self.container) self.b_save_edit = QPushButton("Save current edit") self.b_save_edit.clicked.connect(self._applySaveEdit) self.container.addItem(OptionBox([self.b_save_edit]), "Save") self.tf_importance_point_count = QLineEdit() self.tf_importance_point_count.setPlaceholderText( "Number of Points to Sample") self.tf_importance_point_count.setValidator( QIntValidator(1, 1000000, self)) self.b_importance_apply = QPushButton("Apply Sampling") self.b_importance_apply.clicked.connect( self._applyFaceImportanceSampling) self.container.addItem( OptionBox( [self.tf_importance_point_count, self.b_importance_apply]), "Importance Sampling (Mesh)") self.tf_poisson_point_count = QLineEdit() self.tf_poisson_point_count.setPlaceholderText( "Number of Points to Sample") self.tf_poisson_point_count.setValidator( QIntValidator(1, 1000000, self)) self.tf_poisson_radius = QLineEdit() self.tf_poisson_radius.setPlaceholderText( "Radius of the poisson disks") self.tf_poisson_radius.setValidator(QDoubleValidator( 0.0, 2.0, 5, self)) self.b_poisson_apply = QPushButton("Apply Sampling") self.b_poisson_apply.clicked.connect(self._applyPoissonDiskSampling) self.container.addItem( OptionBox([ self.tf_poisson_point_count, self.tf_poisson_radius, self.b_poisson_apply ]), "Poisson Sampling (Mesh)") self.tf_montecarlo_point_count = QLineEdit() self.tf_montecarlo_point_count.setPlaceholderText( "Number of Points to Sample") self.tf_montecarlo_point_count.setValidator( QIntValidator(1, 1000000, self)) self.b_montecarlo_apply = QPushButton("Apply Sampling") self.b_montecarlo_apply.clicked.connect(self._applyMontecarloSampling) self.container.addItem( OptionBox( [self.tf_montecarlo_point_count, self.b_montecarlo_apply]), "Montecarlo Sampling (Mesh)") self.tf_centroid_count = QLineEdit() self.tf_centroid_count.setPlaceholderText("Centroid Count") self.tf_centroid_count.setValidator(QIntValidator(1, 1000000, self)) self.b_show_centroids = QPushButton("Apply FPS") self.b_show_centroids.clicked.connect(self._applyFPS) self.container.addItem( OptionBox([self.tf_centroid_count, self.b_show_centroids]), "FPS Sampling (Point)") self.tf_show_pp2_centroids = QLineEdit() self.tf_show_pp2_centroids.setPlaceholderText("Number of Centroids") self.tf_show_pp2_centroids.setValidator(QIntValidator( 1, 1000000, self)) self.tf_show_pp2_centroids_with_ball = QLineEdit() self.tf_show_pp2_centroids_with_ball.setPlaceholderText( "Number of Centroids with plotted radius") self.tf_show_pp2_centroids_with_ball.setValidator( QIntValidator(1, 1000000, self)) self.tf_show_pp2_radius = QLineEdit() self.tf_show_pp2_radius.setPlaceholderText( "Radius of the neighbour area") self.tf_show_pp2_radius.setValidator( QDoubleValidator(0.0, 2.0, 5, self)) self.b_show_pp2_step = QPushButton("Apply Sampling") self.b_show_pp2_step.clicked.connect(self._show_pp2_step) self.container.addItem( OptionBox([ self.tf_show_pp2_centroids, self.tf_show_pp2_centroids_with_ball, self.tf_show_pp2_radius, self.b_show_pp2_step ]), "Show PointNet2 sampling")
def __init__(self, parent): super(QWidget, self).__init__(parent) # Instantiate a reference to an animation self.animation = None # Initialise tab screen self.layout = QVBoxLayout(self) self.tabs = QTabWidget() # Initialise the maze runner self.runner_scene = MazeRunnerScene() self.runner_tab = QGraphicsView() self.runner_tab.setViewportUpdateMode(QGraphicsView.NoViewportUpdate) self.runner_tab.setScene(self.runner_scene) self.runner_load_maze_button = QPushButton(self.runner_tab) self.runner_load_maze_button.setGeometry(QRect(10, 10, 90, 30)) self.runner_load_maze_button.setText("Load Maze") self.runner_load_maze_button.clicked.connect(self.load_maze_on_click) self.runner_search_combobox = QComboBox(self.runner_tab) self.runner_search_combobox.setGeometry(110, 11, 200, 28) # New solvers need to be added to this list and added to start_search in maze-runner/MazeRunner.py search_options = [ 'Breadth First Search', 'Bidirectional BFS', 'Depth First Search', 'Bidirectional DFS', 'Greedy Best First', 'A*', 'Random Sampling' ] self.runner_search_combobox.addItems(search_options) self.runner_start_button = QPushButton(self.runner_tab) self.runner_start_button.setGeometry(QRect(320, 10, 90, 30)) self.runner_start_button.setText("Start") self.runner_start_button.clicked.connect(self.start_search_on_click) self.runner_pause_button = QPushButton(self.runner_tab) self.runner_pause_button.setGeometry(QRect(420, 10, 90, 30)) self.runner_pause_button.setText("Pause") self.runner_pause_button.setCheckable(True) self.runner_pause_button.clicked.connect(self.toggle_pause_runner) self.runner_render_progress_button = QPushButton(self.runner_tab) self.runner_render_progress_button.setGeometry(QRect(520, 10, 150, 30)) self.runner_render_progress_button.setText("Show Progress") self.runner_render_progress_button.setCheckable(True) self.runner_render_progress_button.setChecked(True) self.runner_render_progress_button.clicked.connect( self.toggle_render_runner) self.runner_console_label = QLabel(self.runner_tab) self.runner_console_label.setGeometry(680, 10, 1000, 30) self.runner_console_label.setText('') # Initialise the maze generator self.generator_scene = MazeGeneratorScene() self.generator_tab = QGraphicsView() self.generator_tab.setViewportUpdateMode( QGraphicsView.NoViewportUpdate) self.generator_tab.setScene(self.generator_scene) self.generator_columns_label = QLabel(self.generator_tab) self.generator_columns_label.setText('Columns:') self.generator_columns_label.setGeometry(10, 10, 45, 30) self.generator_columns_line_edit = QLineEdit(self.generator_tab) self.generator_columns_line_edit.setGeometry(QRect(65, 10, 90, 30)) self.generator_columns_line_edit.setValidator(QIntValidator(1, 99)) self.generator_columns_line_edit.setText( str(Config.DEFAULT_MAZE_COLUMNS)) self.generator_rows_label = QLabel(self.generator_tab) self.generator_rows_label.setText('Rows:') self.generator_rows_label.setGeometry(165, 10, 30, 30) self.generator_rows_line_edit = QLineEdit(self.generator_tab) self.generator_rows_line_edit.setGeometry(QRect(205, 10, 90, 30)) self.generator_rows_line_edit.setValidator(QIntValidator(1, 99)) self.generator_rows_line_edit.setText(str(Config.DEFAULT_MAZE_ROWS)) self.generator_start_button = QPushButton(self.generator_tab) self.generator_start_button.setGeometry(QRect(305, 10, 90, 30)) self.generator_start_button.setText("Generate") self.generator_start_button.clicked.connect( self.start_generation_on_click) self.generator_save_button = QPushButton(self.generator_tab) self.generator_save_button.setGeometry(QRect(405, 10, 90, 30)) self.generator_save_button.setText("Save Maze") self.generator_save_button.clicked.connect(self.save_maze_on_click) self.generator_pause_button = QPushButton(self.generator_tab) self.generator_pause_button.setGeometry(QRect(505, 10, 90, 30)) self.generator_pause_button.setText("Pause") self.generator_pause_button.setCheckable(True) self.generator_pause_button.clicked.connect( self.toggle_pause_generator) self.generator_render_progress_button = QPushButton(self.generator_tab) self.generator_render_progress_button.setGeometry( QRect(605, 10, 150, 30)) self.generator_render_progress_button.setText("Show Progress") self.generator_render_progress_button.setCheckable(True) self.generator_render_progress_button.setChecked(True) self.generator_render_progress_button.clicked.connect( self.toggle_render_generator) self.generator_console_label = QLabel(self.generator_tab) self.generator_console_label.setGeometry(765, 10, 1000, 30) self.generator_console_label.setText('') # Add tabs to layout self.tabs.addTab(self.runner_tab, "Maze Runner") self.tabs.addTab(self.generator_tab, "Maze Generator") self.layout.addWidget(self.tabs) self.setLayout(self.layout)
def __init__(self): super().__init__() self.broker = const.BROKER self.brokerEdit = QLineEdit(self.broker) self.brokerEdit.setPlaceholderText("Input mq broker, for example: {}".format(const.BROKER)) self.timeout = const.TIMEOUT self.timeoutEdit = QLineEdit(str(self.timeout)) self.timeoutEdit.setPlaceholderText("Input timeout") self.timeoutEdit.setMaximumWidth(100) self.timeoutEdit.setValidator(QIntValidator(1, 1000)) self.sendButton = QPushButton(const.SEND_BUTTON_SEND_TEXT) self.serviceEdit = QLineEdit() self.serviceEdit.setFocusPolicy(QtCoreQt.NoFocus) self.serviceEdit.setPlaceholderText("Input service name, for example: {}".format(const.SERVICE_INPUT)) self.methodEdit = QLineEdit() self.methodEdit.setFocusPolicy(QtCoreQt.NoFocus) self.methodEdit.setMinimumWidth(400) self.methodEdit.setPlaceholderText("Input method name, for example: {}".format(const.METHOD_INPUT)) # 初始化输出日志组件 self.logTextBox = QTextEditLogger(self) self.logTextBox.widget.setMinimumHeight(150) self.logTextBox.widget.setMaximumHeight(300) self.logTextBox.setFormatter(logging.Formatter("%(asctime)s - %(levelname)s - %(message)s")) logging.getLogger().addHandler(self.logTextBox) logging.getLogger().setLevel(logging.DEBUG) # 初始化代码编辑控件 lexer = QsciLexerJSON() lexer.setHighlightComments(False) lexer.setHighlightEscapeSequences(False) self.paramsEdit = NamekoManQsciScintilla() self.paramsEdit.setLexer(lexer) self.paramsEdit.setUtf8(True) self.paramsEdit.setMarginLineNumbers(0, True) self.paramsEdit.setAutoIndent(True) self.paramsEdit.setTabWidth(4) self.paramsEdit.setFolding(QsciScintilla.BoxedTreeFoldStyle) self.paramsEdit.setFoldMarginColors(QtCoreQt.gray, QtCoreQt.lightGray) self.paramsEdit.setBraceMatching(QsciScintilla.SloppyBraceMatch) self.paramsEdit.setIndentationGuides(QsciScintilla.SC_IV_LOOKBOTH) # 初始化结果显示控件,支持滚动 self.scrollArea = QScrollArea() self.scrollArea.setWidgetResizable(True) self.resultLabel = QLabel("") self.resultLabel.setAlignment(QtCoreQt.AlignCenter) self.resultLabel.adjustSize() self.resultLabel.setWordWrap(True) self.resultLabel.setAlignment(QtCoreQt.AlignLeft) self.resultLabel.setTextInteractionFlags(QtCoreQt.TextSelectableByMouse) self.resultLabel.setText(const.README) self.scrollArea.setWidget(self.resultLabel) self.scrollArea.setMinimumSize(500, 600) # 初始化文件夹树 self.folderBar = FolderWidget() # 使用网格布局进行布局 self.layout = QGridLayout() self.layout.setContentsMargins(10, 0, 10, 0) self.layout.addWidget(self.folderBar, 0, 0, 25, 1) self.layout.addWidget(self.brokerEdit, 0, 1, 1, 1) self.layout.addWidget(self.timeoutEdit, 0, 2, 1, 1) self.layout.addWidget(self.serviceEdit, 1, 1, 1, 2) self.layout.addWidget(self.methodEdit, 2, 1, 1, 2) self.layout.addWidget(self.paramsEdit, 3, 1, 22, 2) self.layout.addWidget(self.sendButton, 0, 3, 1, 1) self.layout.addWidget(self.scrollArea, 1, 3, 24, 1) self.layout.addWidget(self.logTextBox.widget, 25, 0, 1, 4) self.setLayout(self.layout) self.sendButton.clicked.connect(self.onSendRpc) self.folderBar.clickNodeSingal.connect(self.onClickedNode) # 初始化nameko client self.initNameko() self.rpcThread = None self.nodeInfo = None
def __init__(self): super(self.__class__, self).__init__() self.setupUi(self) self.e_post.setValidator(QIntValidator(0, 99999, self))
def __init__(self): """Constructor""" QMainWindow.__init__(self) global_properties = GlobalProperties.get_instance() self.connection_table = ConnectionTableWidget() global_properties.add_listener(self.connection_table) self.setCentralWidget(self.connection_table) self.connection_table.update() self.menu_bar = self.menuBar() self.menu_file = self.menu_bar.addMenu('File') self.menu_file.addAction('New', file_new_clicked) self.menu_file.addAction('Open', self.file_load) self.menu_file.addSeparator() self.menu_file.addAction('Save', self.file_save) self.menu_file.addAction('Save as', self.file_save_as) self.menu_file.addSeparator() self.menu_file.addAction('Exit', sys.exit) self.menu_file = self.menu_bar.addMenu('Connections') self.make_birectional_menu = self.menu_file.addMenu( 'Make bidirectional') self.make_birectional_menu.addAction("with and", make_bidirectional_and) self.make_birectional_menu.addAction("with or", make_bidirectional_or) self.menu_selection = self.menu_bar.addMenu('Selections') self.action_add_selection = self.menu_selection.addAction( 'Add Selection') self.action_add_selection.triggered.connect( create_add_selection_window) self.action_merge_selections = self.menu_selection.addAction( 'Merge Selections') self.action_merge_selections.triggered.connect( create_merge_selectoon_window) self.setMenuBar(self.menu_bar) self.statusBar().showMessage('Welcome to mpdj!', 5000) self.mpdj_options_dock = QDockWidget("MPDJ Options Panel", self) self.mpdj_options_dock_layout = QFormLayout() self.mpdj_docked_widget = QWidget() self.tf_min_global_song_duration = QLineEdit() self.tf_min_global_song_duration.setValidator( QIntValidator(0, 2147483647)) self.mpdj_options_dock_layout.addRow('Global min song duration:', self.tf_min_global_song_duration) self.tf_min_global_song_duration.editingFinished.connect( self.write_min_global_song_duration_to_mpdj) self.tf_max_global_song_duration = QLineEdit() self.tf_max_global_song_duration.setValidator( QIntValidator(0, 2147483647)) self.mpdj_options_dock_layout.addRow('Global max song duration:', self.tf_max_global_song_duration) self.tf_max_global_song_duration.editingFinished.connect( self.write_max_global_song_duration_to_mpdj) self.tf_min_per_selection = QLineEdit() self.tf_min_per_selection.setValidator(QIntValidator(0, 2147483647)) self.mpdj_options_dock_layout.addRow('Min per Node touch:', self.tf_min_per_selection) self.tf_min_per_selection.editingFinished.connect( self.write_min_per_note_to_mpdj) self.tf_max_per_selection = QLineEdit() self.tf_max_per_selection.setValidator(QIntValidator(0, 2147483647)) self.mpdj_options_dock_layout.addRow('Max per Node touch:', self.tf_max_per_selection) self.tf_max_per_selection.editingFinished.connect( self.write_max_per_note_to_mpdj) self.combo_box_minutes_or_titles = QComboBox() self.combo_box_minutes_or_titles.addItems( [unit.gui_representation() for unit in UnitPerNodeTouch]) self.mpdj_options_dock_layout.addRow('Unit:', self.combo_box_minutes_or_titles) self.combo_box_minutes_or_titles.currentTextChanged.connect( self.write_unit_per_node_touch_to_mpdj) self.tf_global_node_max_overflow_minutes = QLineEdit() self.tf_global_node_max_overflow_minutes.setValidator( QIntValidator(0, 2147483647)) self.tf_global_node_max_overflow_minutes.editingFinished.connect( self.write_global_node_max_overflow_to_mpdj) self.cb_global_limit_overflow = QCheckBox() self.cb_global_limit_overflow.stateChanged.connect(lambda: list( map(lambda m: m(), [ lambda: self.tf_global_node_max_overflow_minutes.setDisabled( not self.cb_global_limit_overflow.isChecked()), self. write_limit_overspill_to_mpdj ]))) self.overflow_layoout = QHBoxLayout() self.overflow_layoout.addWidget(self.cb_global_limit_overflow) self.overflow_layoout.addWidget( self.tf_global_node_max_overflow_minutes) self.mpdj_options_dock_layout.addRow("Limit overflow:", self.overflow_layoout) self.mpdj_docked_widget.setLayout(self.mpdj_options_dock_layout) self.mpdj_options_dock.setWidget(self.mpdj_docked_widget) self.addDockWidget(Qt.LeftDockWidgetArea, self.mpdj_options_dock) self.chk_box_graph_is_directed = QCheckBox() self.chk_box_graph_is_directed.stateChanged.connect( self.write_graph_is_directed_to_mpdj) self.mpdj_options_dock_layout.addRow(QLabel('Graph is directed'), self.chk_box_graph_is_directed) self.opened_selection_window = None global_properties.add_listener(self) self.update()
def __init__(self): QWidget.__init__(self) self.main_layout = QVBoxLayout() self.l = QFormLayout() self.l2 = QHBoxLayout() self.l3 = QHBoxLayout() self.group_box = QGroupBox('Ustawienia ogólne') self.group_box2 = QGroupBox('Pobieraj metadane') self.group_box3 = QGroupBox( 'Pobieraj dodatkowe metadane i dołącz je do komentarza') # general settings self.max_results_label = QLabel('Maksymalna liczba wyników') self.max_results_label.setToolTip( 'Maksymalna liczba pobieranych metadanych. Dla książek o nieunikalnych tytułach \ pierwszy wynik może być niepoprawny') self.max_results = QLineEdit(self) self.max_results.setValidator(QIntValidator()) self.max_results.setText(str(PREFS['max_results'])) self.max_results_label.setBuddy(self.max_results) self.l.addRow(self.max_results_label, self.max_results) self.authors_search_label = QLabel('Używaj autorów do wyszukiwań') self.authors_search_label.setToolTip( 'Wyszukuj uwzględniając autorów. Może poprawić trafność wyników, ale błędni autorzy spowodują brak wyników' ) self.authors_search = QCheckBox() self.authors_search.setChecked(PREFS['authors_search']) self.authors_search_label.setBuddy(self.authors_search) self.l.addRow(self.authors_search_label, self.authors_search) self.only_first_author_label = QLabel( 'Używaj tylko pierwszego autora do wyszukiwania') self.only_first_author_label.setToolTip( 'Używaj tylko pierwszego autora do wyszukiwań, obowiązuje tylko gdy wyszukiwanie z autorami jest aktywowane' ) self.only_first_author = QCheckBox() self.only_first_author.setChecked(PREFS['only_first_author']) self.only_first_author_label.setBuddy(self.only_first_author) self.l.addRow(self.only_first_author_label, self.only_first_author) self.covers_label = QLabel('Pobieraj okładki') self.covers = QCheckBox() self.covers.setChecked(PREFS['covers']) self.covers_label.setBuddy(self.covers) self.l.addRow(self.covers_label, self.covers) self.max_covers_label = QLabel('Maksymalna liczba okładek') self.max_covers_label.setToolTip( 'Maksymalna liczba pobieranych okładek') self.max_covers = QLineEdit(self) self.max_covers.setValidator(QIntValidator()) self.max_covers.setText(str(PREFS['max_covers'])) self.max_covers_label.setBuddy(self.max_covers) self.l.addRow(self.max_covers_label, self.max_covers) self.threads_label = QLabel('Wielowątkowe przetwarzanie') self.threads_label.setToolTip( 'Przyśpiesza pracę używając wielu wątków') self.threads = QCheckBox() self.threads.setChecked(PREFS['threads']) self.threads_label.setBuddy(self.threads) self.l.addRow(self.threads_label, self.threads) self.max_threads_label = QLabel('Maksymalna liczba wątków') self.max_threads = QLineEdit(self) self.max_threads.setValidator(QIntValidator()) self.max_threads.setText(str(PREFS['max_threads'])) self.max_threads_label.setBuddy(self.max_threads) self.l.addRow(self.max_threads_label, self.max_threads) self.thread_delay_label = QLabel('Opóźnienie wątku') self.thread_delay_label.setToolTip( 'Czas oczekiwania na uruchomienie kolejnego wątku') self.thread_delay = QLineEdit(self) self.thread_delay.setValidator(QDoubleValidator()) self.thread_delay.setText(str(PREFS['thread_delay'])) self.thread_delay_label.setBuddy(self.thread_delay) self.l.addRow(self.thread_delay_label, self.thread_delay) # metadata settings if 'title' in PREFS.defaults: self.title = QCheckBox('Tytuł') self.title.setChecked(PREFS['title']) self.l2.addWidget(self.title) if 'authors' in PREFS.defaults: self.authors = QCheckBox('Autorzy') self.authors.setChecked(PREFS['authors']) self.l2.addWidget(self.authors) if 'pubdate' in PREFS.defaults: self.pubdate = QCheckBox('Data wydania') self.pubdate.setChecked(PREFS['pubdate']) self.l2.addWidget(self.pubdate) if 'publisher' in PREFS.defaults: self.publisher = QCheckBox('Wydawca') self.publisher.setChecked(PREFS['publisher']) self.l2.addWidget(self.publisher) if 'isbn' in PREFS.defaults: self.isbn = QCheckBox('ISBN') self.isbn.setChecked(PREFS['isbn']) self.l2.addWidget(self.isbn) if 'comments' in PREFS.defaults: self.comments = QCheckBox('Opis') self.comments.setChecked(PREFS['comments']) self.l2.addWidget(self.comments) if 'languages' in PREFS.defaults: self.languages = QCheckBox('Języki') self.languages.setChecked(PREFS['languages']) self.l2.addWidget(self.languages) if 'rating' in PREFS.defaults: self.rating = QCheckBox('Ocena') self.rating.setChecked(PREFS['rating']) self.l2.addWidget(self.rating) if 'tags' in PREFS.defaults: self.tags = QCheckBox('Etykiety (tagi)') self.tags.setChecked(PREFS['tags']) self.l2.addWidget(self.tags) if 'series' in PREFS.defaults: self.series = QCheckBox('Cykle') self.series.setChecked(PREFS['series']) self.l2.addWidget(self.series) if 'identifier' in PREFS.defaults: self.identifier = QCheckBox('Identyfikator') self.identifier.setChecked(PREFS['identifier']) self.l2.addWidget(self.identifier) # custom metadata if 'translators' in PREFS.defaults: self.translators = QCheckBox('Tłumaczenie') self.translators.setChecked(PREFS['translators']) self.l3.addWidget(self.translators) if 'original_title' in PREFS.defaults: self.original_title = QCheckBox('Tytuł oryginału') self.original_title.setChecked(PREFS['original_title']) self.l3.addWidget(self.original_title) if 'categories' in PREFS.defaults: self.categories = QCheckBox('Kategorie') self.categories.setChecked(PREFS['categories']) self.l3.addWidget(self.categories) if 'genres' in PREFS.defaults: self.genres = QCheckBox('Gatunki') self.genres.setChecked(PREFS['genres']) self.l3.addWidget(self.genres) self.group_box.setLayout(self.l) self.group_box2.setLayout(self.l2) self.group_box3.setLayout(self.l3) self.main_layout.addWidget(self.group_box) self.main_layout.addWidget(self.group_box2) self.main_layout.addWidget(self.group_box3) self.main_layout.setAlignment(Qt.AlignTop) self.setLayout(self.main_layout)