class Ui_successDialog(object): def setupUi(self, successDialog): if not successDialog.objectName(): successDialog.setObjectName(u"successDialog") successDialog.resize(294, 108) self.successButton = QDialogButtonBox(successDialog) self.successButton.setObjectName(u"successButton") self.successButton.setGeometry(QRect(100, 60, 91, 31)) self.successButton.setOrientation(Qt.Horizontal) self.successButton.setStandardButtons(QDialogButtonBox.Ok) self.successButton.setCenterButtons(True) self.successLabel = QLabel(successDialog) self.successLabel.setObjectName(u"successLabel") self.successLabel.setGeometry(QRect(50, 20, 201, 31)) self.successLabel.setTextFormat(Qt.MarkdownText) self.successLabel.setAlignment(Qt.AlignCenter) self.retranslateUi(successDialog) self.successButton.accepted.connect(successDialog.accept) self.successButton.rejected.connect(successDialog.reject) QMetaObject.connectSlotsByName(successDialog) # setupUi def retranslateUi(self, successDialog): successDialog.setWindowTitle( QCoreApplication.translate("successDialog", u"\u64cd\u4f5c\u6210\u529f", None)) self.successLabel.setText( QCoreApplication.translate("successDialog", u"**\u64cd\u4f5c\u6210\u529f\uff01**", None))
class Dialog(QDialog): def __init__(self, game, parent): super(Dialog, self).__init__(parent) self.Parent = parent self.setWindowTitle('Hypixel Games Randomizer') self.setWindowIcon(QIcon(self.Parent.windowIcon())) self.buttonBox = QDialogButtonBox(self) self.buttonBox.setOrientation(Qt.Horizontal) self.buttonBox.setStandardButtons(QDialogButtonBox.Ok) self.buttonBox.setCenterButtons(True) self.label = QLabel(self) self.label.setAlignment(Qt.AlignHCenter) font = QFont() font.setPointSize(14) font.setFamily('Roboto Th') self.label.setFont(font) self.label.setText('The wheel of games has chosen and\ndecided that you will now play') self.game = QLabel(self) self.game.setText(game) self.game.setAlignment(Qt.AlignHCenter) font.setPointSize(16) font.setFamily('Roboto Th') font.setBold(True) self.game.setFont(font) self.verticalLayout = QVBoxLayout(self) self.verticalLayout.addWidget(self.label) self.verticalLayout.addWidget(self.game) self.verticalLayout.addWidget(self.buttonBox) self.buttonBox.button(QDialogButtonBox.Ok).clicked.connect(self.close)
def __init__(self): """ The central hub for the application. Contains the tree views for compartments, buckets, and objects. Has buttons for uploading files and creating buckets """ super().__init__() self.setWindowTitle("OCI Object Storage: Not Connected") self.setMinimumSize(800, 600) self.profile = 'DEFAULT' self.oci_manager = oci_manager(profile=self.profile) try: self.compartment_tree = self.get_compartment_tree() except: print('Error: Failure to establish connection') self.compartment_tree = self.get_placeholder_tree( 'Compartments', 'Error: Failure to establish connection') else: self.setWindowTitle("OCI Object Storage: {}".format( self.oci_manager.get_namespace())) self.bucket_tree = self.get_placeholder_tree( 'Buckets', 'No compartment selected') self.obj_tree = self.get_placeholder_tree('Objects', 'No bucket selected') self.obj_tree.setHeaderLabels(['Objects', 'Size']) self.obj_tree.resizeColumnToContents(0) self.bucket_tree.itemClicked.connect(self.select_bucket) button = QPushButton('Upload Files') button.clicked.connect(self.select_files) button2 = QPushButton('New Bucket') button2.clicked.connect(self.create_bucket_prompt) button3 = QPushButton('Refresh') button3.clicked.connect(self.refresh) buttonBox = QDialogButtonBox() buttonBox.setOrientation(Qt.Vertical) buttonBox.addButton(button, QDialogButtonBox.ActionRole) buttonBox.addButton(button2, QDialogButtonBox.ActionRole) buttonBox.addButton(button3, QDialogButtonBox.ActionRole) self.layout = QHBoxLayout() self.layout.addWidget(buttonBox) self.layout.setAlignment(buttonBox, Qt.AlignHCenter) self.layout.addWidget(self.compartment_tree) self.layout.addWidget(self.bucket_tree) self.layout.addWidget(self.obj_tree) self.setLayout(self.layout) self.upload_threads = {} self.upload_thread_count = 0 self.progress_threads = {} self.progress_thread_count = 0
class OkDialog(QDialog): def __init__(self, title, message, parent=None): super(OkDialog, self).__init__(parent) self.setWindowTitle(title) self.message = QLabel(message) self.button_box = QDialogButtonBox(self) self.button_box.setOrientation(Qt.Orientation.Horizontal) self.button_box.setStandardButtons(QDialogButtonBox.Ok) self.button_box.accepted.connect(self.accept) layout = QVBoxLayout() layout.addWidget(self.message) layout.addWidget(self.button_box) self.setLayout(layout)
def __init__(self, parent=None) -> None: super().__init__(parent) # Sets the title and size of the dialog box self.setWindowTitle('Connect to a new WIFI') self.resize(200, 100) # Set the window to modal, and the user can only close the main # interface after closing the popover self.setWindowModality(Qt.ApplicationModal) # Table layout used to layout QLabel and QLineEdit and QSpinBox grid = QGridLayout() grid.addWidget(QLabel('SSID', parent=self), 0, 0, 1, 1) self.SSIDName = QLineEdit(parent=self) self.SSIDName.setText('SSID') grid.addWidget(self.SSIDName, 0, 1, 1, 1) grid.addWidget(QLabel('password', parent=self), 1, 0, 1, 1) self.WIFIpassword = QLineEdit(parent=self) self.WIFIpassword.setText('password') grid.addWidget(self.WIFIpassword, 1, 1, 1, 1) grid.addWidget( QLabel( 'Please enter the SSID and password of the new wifi your ' 'device will connect.After connected,\n' 'the device will no longer be on this LAN and info in the list ' 'will be refreshed in 5 mins.', parent=self), 2, 0, 2, 2) # Create ButtonBox, and the user confirms and cancels buttonbox = QDialogButtonBox(parent=self) buttonbox.setOrientation(Qt.Horizontal) buttonbox.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok) buttonbox.accepted.connect(self.accept) buttonbox.rejected.connect(self.reject) # Vertical layout, layout tables and buttons layout = QVBoxLayout() # Add the table layout you created earlier layout.addLayout(grid) # Put a space object to beautify the layout spacer = QSpacerItem(20, 48, QSizePolicy.Minimum, QSizePolicy.Expanding) layout.addItem(spacer) # ButtonBox layout.addWidget(buttonbox) self.setLayout(layout)
class ErrorDialog(QDialog): def __init__(self, parent): super(ErrorDialog, self).__init__(parent) self.Parent = parent self.setWindowTitle('Hypixel Games Randomizer') self.setWindowIcon(QIcon(self.Parent.windowIcon())) self.buttonBox = QDialogButtonBox(self) self.buttonBox.setOrientation(Qt.Horizontal) self.buttonBox.setStandardButtons(QDialogButtonBox.Retry) self.buttonBox.setCenterButtons(True) self.label = QLabel(self) self.label.setAlignment(Qt.AlignHCenter) font = QFont() font.setPointSize(14) font.setFamily('Roboto Th') self.label.setFont(font) self.label.setText('You must choose at least one game\nto be able randomize.') self.verticalLayout = QVBoxLayout(self) self.verticalLayout.addWidget(self.label) self.verticalLayout.addWidget(self.buttonBox) self.buttonBox.button(QDialogButtonBox.Retry).clicked.connect(self.close)
def __init__(self, geo_widget): super().__init__(geo_widget) self.setWindowTitle("Map") self.map_widget = QQuickWidget( resizeMode=QQuickWidget.SizeRootObjectToView) self.map_widget.rootContext().setContextProperty( "controller", geo_widget) filename = os.fspath(Path(__file__).resolve().parent / "coord_map.qml") url = QUrl.fromLocalFile(filename) self.map_widget.setSource(url) button_box = QDialogButtonBox() button_box.setOrientation(Qt.Horizontal) button_box.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok) lay = QVBoxLayout(self) lay.addWidget(self.map_widget) lay.addWidget(button_box) button_box.accepted.connect(self.accept) button_box.rejected.connect(self.reject)
class RenameWindow(QDialog): new_name = Signal(str, str) def __init__(self, filename): super().__init__() self.title = 'Rename File' # self.left = 10 # self.top = 10 # self.width = 200 # self.height = 100 self.filename = filename self.initUI() def initUI(self): self.setWindowTitle(self.title) # self.setGeometry(self.left, self.top, self.width, self.height) self.textbox = QLineEdit(self) self.textbox.setText(self.filename) self.ok_button = QPushButton('Ok') self.ok_button.clicked.connect(self.on_click) self.cancel_button = QPushButton('Cancel') self.cancel_button.clicked.connect(self.reject) self.button_box = QDialogButtonBox() self.button_box.setOrientation(Qt.Horizontal) self.button_box.addButton(self.cancel_button, QDialogButtonBox.RejectRole) self.button_box.addButton(self.ok_button, QDialogButtonBox.AcceptRole) self.layout = QVBoxLayout() self.layout.addWidget(self.textbox) self.layout.addWidget(self.button_box) self.setLayout(self.layout) def on_click(self): self.new_name.emit(self.filename, self.textbox.text()) self.accept()
def __init__(self, parent=None, **info) -> None: super().__init__(parent) all_info = info['info'] print(f'Rear:{all_info}') self.setWindowTitle('result') self.resize(200, 100) self.setWindowModality(Qt.ApplicationModal) grid = QGridLayout() num = 0 for x in all_info.keys(): sub_name = QLabel(parent=self) sub_name.setText(x) grid.addWidget(sub_name, num, 0, 1, 1) sub_ret = QLabel(parent=self) data = all_info[x] if data['error'] == 0: sub_ret.setText('succeed') else: sub_ret.setText('error') grid.addWidget(sub_ret, num, 1, 1, 1) sub_info = QLabel(parent=self) sub_info.setText(str(all_info[x])) grid.addWidget(sub_info, num, 2, 2, 1) num += 1 buttonbox = QDialogButtonBox(parent=self) buttonbox.setOrientation(Qt.Horizontal) buttonbox.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok) buttonbox.accepted.connect(self.accept) buttonbox.rejected.connect(self.reject) layout = QVBoxLayout() layout.addLayout(grid) spacerItem = QSpacerItem(20, 48, QSizePolicy.Minimum, QSizePolicy.Expanding) layout.addItem(spacerItem) layout.addWidget(buttonbox) self.setLayout(layout)
def add_item_to_model(submodel): dialog = QDialog() v_layout = QVBoxLayout() form_layout = QFormLayout() item_type = submodel.custom_table_item item_columns = item_type.columns_names widget_per_column = {} for index, name in item_columns.items(): line_edit = QLineEdit() form_layout.addRow(name, line_edit) widget_per_column[name] = line_edit button_box = QDialogButtonBox() button_box.setObjectName("buttonBox") button_box.setOrientation(Qt.Horizontal) button_box.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok) button_box.accepted.connect(dialog.accept) button_box.rejected.connect(dialog.reject) v_layout.addLayout(form_layout) v_layout.addWidget(button_box) dialog.forms = form_layout dialog.setLayout(v_layout) status = dialog.exec() if status == QDialog.Accepted: new_item = item_type() for index, name in new_item.columns_names.items(): value_of_row = widget_per_column[name].text() new_item.set_column(index, value_of_row) submodel.add_item(new_item) logger.info(f"New item of type {item_type} added")
class TornaSettingsDialog(QDialog): def __init__(self, parent=None, torna_id=None): super(TornaSettingsDialog, self).__init__(parent) self.parent = parent self.setModal(True) self.setWindowTitle("Verseny beállítások") self.torna_id = torna_id self.main_layout = QVBoxLayout() self.setLayout(self.main_layout) if self.torna_id is not None: self.create_torna_selection() self.set_layouts() self.add_variables() self.alapertekek() self.add_buttonbox() def set_layouts(self): self.tartalom_layout = QHBoxLayout() self.main_layout.addLayout(self.tartalom_layout) self.layout = QVBoxLayout() self.gomb_layout = QVBoxLayout() self.tartalom_layout.addLayout(self.layout) self.tartalom_layout.addLayout(self.gomb_layout) def add_variables(self): self.layout.addWidget(QLabel("A verseny megnevezése:")) self.torna_name = QLineEdit() self.torna_name.setPlaceholderText("A verseny megnevezése") self.layout.addWidget(self.torna_name) self.layout.addWidget(QLabel("Legyen csoportkör?")) self.is_roundrobin = QCheckBox() self.is_roundrobin.stateChanged.connect(self.roundrobin_changed) self.layout.addWidget(self.is_roundrobin) self.layout.addWidget(QLabel("Csoportok száma:")) self.csoport_number = CustomSpinBox(1, 16) self.layout.addWidget(self.csoport_number) self.layout.addWidget(QLabel("Játékosok száma csoportonként:")) self.jatekos_per_csoport = CustomSpinBox(3, 8) self.layout.addWidget(self.jatekos_per_csoport) self.layout.addWidget(QLabel("Játéknem:")) self.variant = CustomSpinBox(301, 1001) self.layout.addWidget(self.variant) self.layout.addWidget(QLabel("Set-ek?:")) self.is_sets = QCheckBox() self.is_sets.stateChanged.connect(self.is_sets_changed) self.layout.addWidget(self.is_sets) self.layout.addWidget(QLabel("Set-ek száma:")) self.sets_number = CustomSpinBox(1, 8) self.sets_number.setDisabled(True) self.layout.addWidget(self.sets_number) self.layout.addWidget(QLabel("Leg-ek száma:")) self.legs_number = CustomSpinBox(2, 30) self.layout.addWidget(self.legs_number) self.layout.addWidget(QLabel("Best of...")) self.is_best = QCheckBox() self.layout.addWidget(self.is_best) self.layout.addWidget(QLabel("Döntetlen")) self.is_draw = QCheckBox() self.is_draw.stateChanged.connect(self.is_draw_changed) self.layout.addWidget(self.is_draw) self.layout.addWidget(QLabel("Pont(Győzelem):")) self.pont_win = CustomSpinBox(2, 5) self.layout.addWidget(self.pont_win) self.layout.addWidget(QLabel("Pont(Döntetlen):")) self.pont_draw = CustomSpinBox(1, 3) self.pont_draw.setDisabled(True) self.layout.addWidget(self.pont_draw) self.layout.addWidget(QLabel("Pont(Vereség):")) self.pont_lost = CustomSpinBox(0, 2) self.layout.addWidget(self.pont_lost) self.layout.addWidget(QLabel("Főág")) self.is_single_elim = QCheckBox() self.is_single_elim.stateChanged.connect(self.is_single_changed) self.layout.addWidget(self.is_single_elim) self.layout.addWidget(QLabel("Főág száma:")) self.num_single = CustomSpinBox(4, 128) self.num_single.setDisabled(True) self.layout.addWidget(self.num_single) self.layout.addWidget(QLabel("Leg-ek száma a főágon:")) self.leg_num_single = CustomSpinBox(3, 20) self.leg_num_single.setDisabled(True) self.layout.addWidget(self.leg_num_single) self.layout.addWidget(QLabel("Leg-ek száma az elődöntőben:")) self.leg_num_semifinal = CustomSpinBox(4, 20) self.leg_num_semifinal.setDisabled(True) self.layout.addWidget(self.leg_num_semifinal) self.layout.addWidget(QLabel("Leg-ek száma a döntőben:")) self.leg_num_final = CustomSpinBox(5, 20) self.leg_num_final.setDisabled(True) self.layout.addWidget(self.leg_num_final) self.layout.addWidget(QLabel("3. hely kijátszva")) self.is_3place = QCheckBox() self.is_3place.stateChanged.connect(self.is_3place_changed) self.is_3place.setDisabled(True) self.layout.addWidget(self.is_3place) self.layout.addWidget(QLabel("Leg-ek száma a 3. helyért:")) self.leg_num_3place = CustomSpinBox(4, 20) self.leg_num_3place.setDisabled(True) self.layout.addWidget(self.leg_num_3place) def create_torna_selection(self): self.tournaments = QComboBox() self.tournaments.setModelColumn(0) self.tournaments.currentIndexChanged.connect(self.torna_valasztas) self.main_layout.addWidget(self.tournaments) self.load_torna() def load_torna(self): torna = QSqlQueryModel() query = QSqlQuery("select * from torna_settings where aktiv=2") torna.setQuery(query) if torna.record(0).value(0): for i in range(torna.rowCount()): self.tournaments.addItem( torna.record(i).value(1), torna.record(i).value(0)) # a value(0) a torna_id else: print("Nincs aktív torna") def torna_valasztas(self, i): self.torna_id = self.tournaments.itemData(i) self.alapertekek() def alapertekek(self): if not self.torna_id: self.torna_name.clear() self.is_roundrobin.setChecked(True) self.csoport_number.setValue(1) self.jatekos_per_csoport.setValue(4) self.variant.setValue(501) self.is_sets.setChecked(False) self.sets_number.setValue(1) self.legs_number.setValue(2) self.is_best.setChecked(False) self.is_draw.setChecked(False) self.pont_win.setValue(2) self.pont_draw.setValue(1) self.pont_lost.setValue(0) self.is_single_elim.setChecked(False) self.num_single.setValue(8) self.leg_num_single.setValue(3) self.leg_num_semifinal.setValue(4) self.leg_num_final.setValue(5) self.is_3place.setChecked(False) self.leg_num_3place.setValue(4) else: model = QSqlTableModel(db=db) model.setTable("torna_settings") model.setFilter(f"torna_id={self.torna_id}") model.select() # print(model.record(0)) self.torna_name.setText(model.record(0).value(1)) self.is_roundrobin.setChecked(model.record(0).value(2)) self.csoport_number.setValue(model.record(0).value(3)) self.jatekos_per_csoport.setValue(model.record(0).value(4)) self.variant.setValue(int(model.record(0).value(5))) self.is_sets.setChecked(model.record(0).value(6)) self.sets_number.setValue(model.record(0).value(7)) self.legs_number.setValue(model.record(0).value(8)) self.is_best.setChecked(model.record(0).value(9)) self.is_draw.setChecked(model.record(0).value(10)) self.pont_win.setValue(model.record(0).value(11)) self.pont_draw.setValue(model.record(0).value(12)) self.pont_lost.setValue(model.record(0).value(13)) self.is_single_elim.setChecked(model.record(0).value(14)) self.num_single.setValue(model.record(0).value(15)) self.leg_num_single.setValue(model.record(0).value(17)) self.leg_num_semifinal.setValue(model.record(0).value(18)) self.leg_num_final.setValue(model.record(0).value(20)) self.is_3place.setChecked(model.record(0).value(16)) self.leg_num_3place.setValue(model.record(0).value(19)) def add_buttonbox(self): self.buttonbox = QDialogButtonBox() self.buttonbox.setOrientation(Qt.Vertical) self.buttonbox.addButton("Mentés", QDialogButtonBox.ActionRole) self.buttonbox.addButton("Alaphelyzet", QDialogButtonBox.ActionRole) # self.gomb_members = QPushButton("Résztvevők") # self.gomb_members.setDisabled(True) # self.buttonbox.addButton(self.gomb_members, QDialogButtonBox.ActionRole) # self.gomb_tabella = QPushButton("Tabella") # self.gomb_tabella.setDisabled(True) # self.buttonbox.addButton(self.gomb_tabella, QDialogButtonBox.ActionRole) self.buttonbox.addButton("Mégsem", QDialogButtonBox.ActionRole) self.buttonbox.clicked.connect(self.buttonbox_click) self.gomb_layout.addWidget(self.buttonbox) def roundrobin_changed(self, state): if state == Qt.Checked: self.csoport_number.setDisabled(False) self.jatekos_per_csoport.setDisabled(False) else: self.csoport_number.setDisabled(True) self.jatekos_per_csoport.setDisabled(True) def is_sets_changed(self, state): if state == Qt.Checked: self.sets_number.setDisabled(False) else: self.sets_number.setDisabled(True) def is_draw_changed(self, state): if state == Qt.Checked: self.pont_draw.setDisabled(False) else: self.pont_draw.setDisabled(True) def is_single_changed(self, state): # a főághoz kapcsolódó paraméterek tiltása/engedélyezése if state == Qt.Checked: self.num_single.setDisabled(False) self.is_3place.setDisabled(False) self.leg_num_single.setDisabled(False) self.leg_num_semifinal.setDisabled(False) if self.is_3place.isChecked(): self.leg_num_3place.setDisabled(False) else: self.leg_num_3place.setDisabled(True) self.leg_num_final.setDisabled(False) else: self.num_single.setDisabled(True) self.is_3place.setDisabled(True) self.leg_num_single.setDisabled(True) self.leg_num_semifinal.setDisabled(True) self.leg_num_3place.setDisabled(True) self.leg_num_final.setDisabled(True) def is_3place_changed(self, state): if state == Qt.Checked: self.leg_num_3place.setDisabled(False) else: self.leg_num_3place.setDisabled(True) def buttonbox_click(self, b): if b.text() == "Mentés": self.save() elif b.text() == "Alaphelyzet": self.alapertekek() # elif b.text() == "Résztvevők": # self.members() # elif b.text() == "Tabella": # self.tabella() elif b.text() == "Mégsem": self.reject() else: pass def save(self): if not self.torna_id: self.insert_torna_settings() else: self.update_torna_settings() self.close() def insert_torna_settings(self): van_ilyen_nev = False if len(self.torna_name.text()) != 0: torna_id_model = QSqlQueryModel() query = QSqlQuery( "select torna_id, torna_name from torna_settings", db=db) torna_id_model.setQuery(query) for i in range(torna_id_model.rowCount()): if torna_id_model.record(i).value(1) == self.torna_name.text(): msg = QMessageBox(self) msg.setStyleSheet("fonz-size: 20px") msg.setWindowTitle("Név ütközés!") msg.setText( '<html style="font-size: 14px; color: red">Már van ilyen nevű verseny!<br></html>' + '<html style="font-size: 16px">Kérem adjon a versenynek egyedi nevet!</html>' ) msg.exec_() van_ilyen_nev = True if not van_ilyen_nev: torna_settings_model = QSqlTableModel( db=db ) # !!!!!!! Ha több db van, akkor itt konkrétan meg kell adni torna_settings_model.setTable("torna_settings") record = torna_settings_model.record() record.setValue(1, self.torna_name.text()) if self.is_roundrobin.isChecked(): record.setValue(2, 1) else: record.setValue(2, 0) record.setValue(3, self.csoport_number.value()) record.setValue(4, self.jatekos_per_csoport.value()) record.setValue(5, self.variant.value()) if self.is_sets.isChecked(): record.setValue(6, 1) else: record.setValue(6, 0) record.setValue(7, self.sets_number.value()) record.setValue(8, self.legs_number.value()) # print(record.value(2)) if self.is_best.isChecked(): record.setValue(9, 1) else: record.setValue(9, 0) if self.is_draw.isChecked(): record.setValue(10, 1) else: record.setValue(10, 0) record.setValue(11, self.pont_win.value()) record.setValue(12, self.pont_draw.value()) record.setValue(13, self.pont_lost.value()) if self.is_single_elim.isChecked(): record.setValue(14, 1) else: record.setValue(14, 0) record.setValue(15, self.num_single.value()) if self.is_3place.isChecked(): record.setValue(16, 1) else: record.setValue(16, 0) record.setValue(17, self.leg_num_single.value()) record.setValue(18, self.leg_num_semifinal.value()) record.setValue(19, self.leg_num_3place.value()) record.setValue(20, self.leg_num_final.value()) record.setValue(21, 2) # aktiv flag: 0: vége, 1: folyamatban, 2: szerkesztés alatt # print(record) if torna_settings_model.insertRecord(-1, record): torna_settings_model.submitAll() else: db.rollback() torna_id_model2 = QSqlQueryModel() query2 = QSqlQuery( f"select torna_id from torna_settings where torna_name='{self.torna_name.text()}'", db=db) torna_id_model2.setQuery(query2) self.torna_id = int(torna_id_model2.record(0).value(0)) self.gomb_members.setDisabled(False) else: msg = QMessageBox(self) msg.setStyleSheet("fonz-size: 20px") msg.setWindowTitle("Hiányzik a verseny neve!") msg.setText( '<html style="font-size: 14px; color: red">A létrehozott versenynek kell egy elnevezés!<br></html>' + '<html style="font-size: 16px">Kérem adja meg a verseny nevét!</html>' ) msg.exec_() def update_torna_settings(self): torna_settings_model = QSqlTableModel(db=db) torna_settings_model.setTable("torna_settings") record = torna_settings_model.record() torna_settings_model.select() # for x in range(torna_settings_model.rowCount()): # record.setGenerated(x, False) record.setValue(0, self.torna_id) record.setValue(1, self.torna_name.text()) if self.is_roundrobin.isChecked(): record.setValue(2, 1) else: record.setValue(2, 0) record.setValue(3, self.csoport_number.value()) record.setValue(4, self.jatekos_per_csoport.value()) record.setValue(5, self.variant.value()) if self.is_sets.isChecked(): record.setValue(6, 1) else: record.setValue(6, 0) record.setValue(7, self.sets_number.value()) record.setValue(8, self.legs_number.value()) if self.is_best.isChecked(): record.setValue(9, 1) else: record.setValue(9, 0) if self.is_draw.isChecked(): record.setValue(10, 1) else: record.setValue(10, 0) record.setValue(11, self.pont_win.value()) record.setValue(12, self.pont_draw.value()) record.setValue(13, self.pont_lost.value()) if self.is_single_elim.isChecked(): record.setValue(14, 1) else: record.setValue(14, 0) record.setValue(15, self.num_single.value()) if self.is_3place.isChecked(): record.setValue(16, 1) else: record.setValue(16, 0) record.setValue(17, self.leg_num_single.value()) record.setValue(18, self.leg_num_semifinal.value()) record.setValue(19, self.leg_num_3place.value()) record.setValue(20, self.leg_num_final.value()) record.setValue(21, 2) for i in range(torna_settings_model.rowCount()): if torna_settings_model.record(i).value(0) == self.torna_id: # print(torna_settings_model.record(i).value(0), ":", i) record_number = i # print(record) if torna_settings_model.setRecord(record_number, record): torna_settings_model.submitAll() else: db.rollback() # def members(self): # # todo Itt kell a verseny résztvevőit öszerakni # pass # # def tabella(self): # # todo Itt kell a sorsolást, tabella összeállítást megcsinálni # pass def accept(self): # todo Ez majd csak a bezáráshoz kell super().accept() def reject(self): print("CANCEL") super().reject()
class ConfigWindow(QWidget): def __init__(self, current_profile): """ The ConfigWindow is a widget dedicated to reading and editing the OCI config file and provides functionality to create, edit, and switch profiles on the fly, updating the view of the main window. :param current_profile: The profile the ConfigWindow should be initialized with :type current_profile: string """ super().__init__() # self.main_window = None self.setWindowTitle("Profile Settings") self.setMinimumSize(600, 200) #Looks for the config file in '~/.oci/config' and reads it into config self.DEFAULT_LOCATION = os.path.expanduser( os.path.join('~', '.oci', 'config')) self.config = configparser.ConfigParser(interpolation=None) self.config.read(self.DEFAULT_LOCATION) self.current_profile = current_profile #Set up necessary dropdown and LineEdit widgets self.dropdown = self.get_profiles_dropdown() self.tenancy = QLineEdit() self.tenancy.setPlaceholderText("Tenancy OCID") self.region = QLineEdit() self.region.setPlaceholderText("Region") self.user = QLineEdit() self.user.setPlaceholderText("User OCID") self.fingerprint = QLineEdit() self.fingerprint.setPlaceholderText("Fingerprint") self.key_file = QLineEdit() self.key_file.setPlaceholderText("Key File Path") self.passphrase = QLineEdit() self.passphrase.setEchoMode(QLineEdit.Password) self.passphrase.setPlaceholderText("Passphrase") self.save_button = QPushButton('Save') self.save_button.clicked.connect(self.save_signal) #Set the profile to the current_profile passed in upon init self.change_profile(current_profile) self.dropdown.setCurrentText(current_profile) #Add all widgets to a vertical layout self.layout = QVBoxLayout() self.layout.addWidget(self.dropdown) self.layout.addWidget(self.tenancy) self.layout.addWidget(self.region) self.layout.addWidget(self.user) self.layout.addWidget(self.key_file) self.layout.addWidget(self.fingerprint) self.layout.addWidget(self.passphrase) self.layout.addWidget(self.save_button) self.setLayout(self.layout) def get_profiles_dropdown(self): """ :return: A dropdown menu widget that lists all profiles including the default profile from the OCI config file When index changes, it will call the change_profile signal function :rtype: :class: 'Qt.QtWidgets.QComboBox' """ dropdown = QComboBox() dropdown.addItems(['DEFAULT'] + self.config.sections()) dropdown.addItem("Add New Profile...") dropdown.currentIndexChanged.connect(self.change_profile_signal) return dropdown def change_profile_signal(self, item): """ Slot to change profile. If the item index is at 0, then it is the default profile. If it is the last index, then that means create a new profile :param item: The index of the item from the dropdown widget :type item: int """ if item > len(self.config.sections()): self.create_new_profile() elif item == 0: self.change_profile('DEFAULT') else: self.change_profile(self.config.sections()[item - 1]) def change_profile(self, profile_name): """ Changes the profile that the ConfigWindow is set for and also changes it for the MainWindow :param profile_name: the name of the profile to switch to :type profile_name: string TODO: Adhere to signal/slot convention """ self.current_profile = profile_name profile = self.config[profile_name] for line, key in zip([self.tenancy, self.region, self.user, self.fingerprint, self.key_file, self.passphrase],\ ['tenancy', 'region', 'user', 'fingerprint', 'key_file', 'pass_phrase']): if key in profile: line.setText(profile[key]) else: line.setText("") if self.main_window: self.main_window.change_profile(self.current_profile) def create_new_profile(self): """ Layout to create a new profile. Removes the dropdown widget and changes the buttons """ self.layout.removeItem(self.layout.itemAt(0)) self.dropdown.setParent(None) self.new_profile_name = QLineEdit() self.new_profile_name.setPlaceholderText("Profile Name") self.layout.insertWidget(0, self.new_profile_name) self.tenancy.setText("") self.region.setText("") self.user.setText("") self.fingerprint.setText("") self.key_file.setText("") self.passphrase.setText("") self.create_button = QPushButton('Create') self.create_button.clicked.connect(self.create_signal) self.cancel_button = QPushButton('Cancel') self.cancel_button.clicked.connect(self.cancel_signal) self.buttonBox = QDialogButtonBox() self.buttonBox.setOrientation(Qt.Horizontal) self.buttonBox.addButton(self.create_button, QDialogButtonBox.ActionRole) self.buttonBox.addButton(self.cancel_button, QDialogButtonBox.ActionRole) self.layout.removeItem(self.layout.itemAt(7)) self.save_button.setParent(None) self.layout.addWidget(self.buttonBox) def create_signal(self): """ Create a new profile with the given information in the LineEdit widgets. Saves to the OCI config file """ profile_name = self.new_profile_name.text() self.config[profile_name] = {} self.config[profile_name]['tenancy'] = self.tenancy.text() self.config[profile_name]['region'] = self.region.text() self.config[profile_name]['user'] = self.user.text() self.config[profile_name]['fingerprint'] = self.fingerprint.text() self.config[profile_name]['key_file'] = self.key_file.text() self.config[profile_name]['pass_phrase'] = self.passphrase.text() with open(self.DEFAULT_LOCATION, 'w') as configfile: self.config.write(configfile) self.current_profile = profile_name self.cancel_signal() def save_signal(self): """ Saves edits on a currently existing profile. Saves to the OCI config file """ self.config[self.current_profile]['tenancy'] = self.tenancy.text() self.config[self.current_profile]['region'] = self.region.text() self.config[self.current_profile]['user'] = self.user.text() self.config[ self.current_profile]['fingerprint'] = self.fingerprint.text() self.config[self.current_profile]['key_file'] = self.key_file.text() self.config[ self.current_profile]['pass_phrase'] = self.passphrase.text() with open(self.DEFAULT_LOCATION, 'w') as configfile: self.config.write(configfile) def cancel_signal(self): """ Cancels the creation a new profile and reverts layout to default layout """ self.layout.removeItem(self.layout.itemAt(0)) self.new_profile_name.setParent(None) self.dropdown = self.get_profiles_dropdown() self.layout.insertWidget(0, self.dropdown) self.layout.removeItem(self.layout.itemAt(7)) self.buttonBox.setParent(None) self.change_profile(self.current_profile) self.dropdown.setCurrentText(self.current_profile) self.layout.addWidget(self.save_button)
class ProgressWindow(QWidget): cancel_signal = Signal(int) def __init__(self, files, filesizes, thread_id, download=False): super().__init__() print(len(files[0]), len(filesizes)) print(files[0]) self.files_uploaded = 0 self.files_len = len(files[0]) self.files = files self.filesizes = filesizes self.divider = 1024**byte_type[self.filesizes[self.files_uploaded][1][1]] self.max = round(self.filesizes[self.files_uploaded][0]/self.divider) self.download = download self.thread_id = thread_id self.count = 0 self.initUI() def initUI(self): self.file_label = QLabel() # self.file_label.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Fixed) # self.file_label.setFrameShape(QFrame.Box) # self.file_label.setAlignment(Qt.AlignHCenter) # self.file_label.setStyleSheet("border-style: solid; border-width: 2px;") if self.download: self.setWindowTitle('Downloading Files ({}/{})'.format(self.files_uploaded, len(self.files[0]))) self.file_label.setText("Downloading {}".format(self.files[0][self.files_len - 1].split('/')[-1])) else: self.setWindowTitle('Uploading Files ({}/{})'.format(self.files_uploaded, len(self.files[0]))) self.file_label.setText("Uploading {}".format(self.files[0][self.files_len - 1].split('/')[-1])) self.size_label = QLabel(" ".join(self.filesizes[self.files_uploaded][1])) self.size_label.setAlignment(Qt.AlignRight) self.layout = QVBoxLayout() self.cancel = QPushButton() self.cancel.setText("Cancel") self.cancel.clicked.connect(self.cancel_handler) self.ok = QPushButton() self.ok.setText("OK") self.ok.setEnabled(False) self.ok.clicked.connect(self.hide) self.retry = QPushButton() self.retry.setText("Retry") self.retry.setEnabled(False) self.button_box = QDialogButtonBox() self.button_box.setOrientation(Qt.Horizontal) self.button_box.addButton(self.ok, QDialogButtonBox.ActionRole) self.button_box.addButton(self.cancel, QDialogButtonBox.ActionRole) self.button_box.addButton(self.retry, QDialogButtonBox.ActionRole) self.progress = QProgressBar(self) self.progress.setMaximum(self.max) self.progress.setValue(0) # print(self.file_label.textFormat(), self.file_label.lineWidth(), self.file_label.margin(), self.file_label.frameSize()) # self.file_label.show() # self.file_label.setBuddy(self.progress) self.layout.addWidget(self.file_label) self.layout.addWidget(self.progress) self.layout.addWidget(self.size_label) self.layout.addWidget(self.button_box) self.retry_label = QLabel() self.retry_label.setText("Connection failed") self.retry_label.setStyleSheet("QLabel {color: red; }") self.layout.addWidget(self.retry_label) self.retry_label.setVisible(False) self.setLayout(self.layout) def test(self): self.calc = TestProgress() self.calc.countChanged.connect(self.set_progress) self.calc.start() def next_file(self, *args): # print(self.files[0]) self.retry_label.setVisible(False) self.retry.setEnabled(False) if self.files_uploaded < self.files_len: self.files_uploaded += 1 if self.download: self.setWindowTitle("Downloading Files ({}/{})".format(self.files_uploaded, self.files_len)) else: self.setWindowTitle("Uploading Files ({}/{})".format(self.files_uploaded, self.files_len)) if self.files_uploaded < self.files_len: self.count = 0 self.progress.setValue(0) if self.download: self.file_label.setText("Downloading {}".format(self.files[0][(self.files_len - 1) - self.files_uploaded].split('/')[-1])) else: self.file_label.setText("Uploading {}".format(self.files[0][(self.files_len - 1) - self.files_uploaded].split('/')[-1])) self.size_label.setText(" ".join(self.filesizes[(self.files_len - 1) - self.files_uploaded][1])) self.divider = 1024**byte_type[self.filesizes[(self.files_len - 1) - self.files_uploaded][1][1]] self.max = round(self.filesizes[(self.files_len - 1) - self.files_uploaded][0]/self.divider) self.progress.setMaximum(self.max) else: if self.download: self.file_label.setText("All downloads complete") else: self.file_label.setText("All uploads complete") self.size_label.setText("") self.progress.setValue(self.max) self.ok.setEnabled(True) self.cancel.setEnabled(False) def set_progress(self, count): # print("{} bytes uploaded".format(count)) self.count += (count/self.divider) self.progress.setValue(self.count) def connection_failed(self): self.connection_failed_label = QLabel() self.connection_failed_label.setText("Connection failed") def cancel_handler(self): self.cancel_signal.emit(self.thread_id) self.hide() def retry_handler(self): print("Retry handler") self.retry_label.setVisible(True) self.retry.setEnabled(True) if self.download: self.count = 0 self.progress.setValue(self.count)
class QCartConnectDialog(QDialog): def __init__(self): super(QCartConnectDialog, self).__init__() self.accepted = False self._init_widgets() def accept(self): self.accepted = True super().accept() def reject(self): self.accepted = False super().reject() def handleRadioButtons(self): if self.connectRad.isChecked(): self.hostText.setEnabled(True) self.portText.setEnabled(True) self.hostText.setText("") self.portText.setText("") else: self.hostText.setEnabled(False) self.portText.setEnabled(False) self.hostText.setText("NEW") self.portText.setText("NEW") def _init_widgets(self): self.resize(530, 180) main_layout = QVBoxLayout() frame = QFrame() frame.setFrameShape(QFrame.NoFrame) frame.setFrameShadow(QFrame.Plain) frameLayout = QVBoxLayout() self.connectRad = QRadioButton(frame) self.createRad = QRadioButton(frame) self.connectRad.setChecked(True) self.connectRad.toggled.connect(self.handleRadioButtons) self.createRad.toggled.connect(self.handleRadioButtons) frameLayout.addWidget(self.connectRad) internalFrame = QFrame() internalFrameLayout = QHBoxLayout(internalFrame) hostLabel = QLabel() portLabel = QLabel() self.hostText = QLineEdit() self.portText = QLineEdit() internalFrameLayout.addWidget(hostLabel) internalFrameLayout.addWidget(self.hostText) internalFrameLayout.addWidget(portLabel) internalFrameLayout.addWidget(self.portText) self.portText.setMaximumSize(QSize(80, 200)) internalFrame.setLayout(internalFrameLayout) frameLayout.addWidget(internalFrame) frameLayout.addWidget(self.createRad) frame.setLayout(frameLayout) self.buttonBox = QDialogButtonBox(self) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok) self.buttonBox.accepted.connect(self.accept) self.buttonBox.rejected.connect(self.reject) main_layout.addWidget(frame) main_layout.addWidget(self.buttonBox) self.setLayout(main_layout) self.setWindowTitle("Cartprograph Connect") self.connectRad.setText("Connect to Existing Cartprograph Server") self.createRad.setText("Create New Cartprograph Server") hostLabel.setText("Host") portLabel.setText("Port") @classmethod def launch(cls): dialog = cls() dialog.exec_() if dialog.accepted: return True, dialog.hostText.text(), dialog.portText.text() return False, None, None
class Ui_spellDialog(object): def setupUi(self, spellDialog): if spellDialog.objectName(): spellDialog.setObjectName(u"spellDialog") spellDialog.resize(400, 372) self.verticalLayout = QVBoxLayout(spellDialog) self.verticalLayout.setObjectName(u"verticalLayout") self.formLayout = QFormLayout() self.formLayout.setObjectName(u"formLayout") self.preparedLabel = QLabel(spellDialog) self.preparedLabel.setObjectName(u"preparedLabel") self.formLayout.setWidget(0, QFormLayout.LabelRole, self.preparedLabel) self.preparedCheckBox = QCheckBox(spellDialog) self.preparedCheckBox.setObjectName(u"preparedCheckBox") self.formLayout.setWidget(0, QFormLayout.FieldRole, self.preparedCheckBox) self.levelLabel = QLabel(spellDialog) self.levelLabel.setObjectName(u"levelLabel") self.formLayout.setWidget(1, QFormLayout.LabelRole, self.levelLabel) self.levelSpinBox = QSpinBox(spellDialog) self.levelSpinBox.setObjectName(u"levelSpinBox") self.formLayout.setWidget(1, QFormLayout.FieldRole, self.levelSpinBox) self.spellNameLabel = QLabel(spellDialog) self.spellNameLabel.setObjectName(u"spellNameLabel") self.formLayout.setWidget(2, QFormLayout.LabelRole, self.spellNameLabel) self.spellNameLineEdit = QLineEdit(spellDialog) self.spellNameLineEdit.setObjectName(u"spellNameLineEdit") self.formLayout.setWidget(2, QFormLayout.FieldRole, self.spellNameLineEdit) self.sourceLabel = QLabel(spellDialog) self.sourceLabel.setObjectName(u"sourceLabel") self.formLayout.setWidget(3, QFormLayout.LabelRole, self.sourceLabel) self.sourceLineEdit = QLineEdit(spellDialog) self.sourceLineEdit.setObjectName(u"sourceLineEdit") self.formLayout.setWidget(3, QFormLayout.FieldRole, self.sourceLineEdit) self.saveAttackLabel = QLabel(spellDialog) self.saveAttackLabel.setObjectName(u"saveAttackLabel") self.formLayout.setWidget(4, QFormLayout.LabelRole, self.saveAttackLabel) self.saveAttackLineEdit = QLineEdit(spellDialog) self.saveAttackLineEdit.setObjectName(u"saveAttackLineEdit") self.formLayout.setWidget(4, QFormLayout.FieldRole, self.saveAttackLineEdit) self.timeLabel = QLabel(spellDialog) self.timeLabel.setObjectName(u"timeLabel") self.formLayout.setWidget(5, QFormLayout.LabelRole, self.timeLabel) self.timeLineEdit = QLineEdit(spellDialog) self.timeLineEdit.setObjectName(u"timeLineEdit") self.formLayout.setWidget(5, QFormLayout.FieldRole, self.timeLineEdit) self.rangeLabel = QLabel(spellDialog) self.rangeLabel.setObjectName(u"rangeLabel") self.formLayout.setWidget(6, QFormLayout.LabelRole, self.rangeLabel) self.rangeLineEdit = QLineEdit(spellDialog) self.rangeLineEdit.setObjectName(u"rangeLineEdit") self.formLayout.setWidget(6, QFormLayout.FieldRole, self.rangeLineEdit) self.componentsLabel = QLabel(spellDialog) self.componentsLabel.setObjectName(u"componentsLabel") self.formLayout.setWidget(7, QFormLayout.LabelRole, self.componentsLabel) self.componentsLineEdit = QLineEdit(spellDialog) self.componentsLineEdit.setObjectName(u"componentsLineEdit") self.formLayout.setWidget(7, QFormLayout.FieldRole, self.componentsLineEdit) self.durationLabel = QLabel(spellDialog) self.durationLabel.setObjectName(u"durationLabel") self.formLayout.setWidget(8, QFormLayout.LabelRole, self.durationLabel) self.durationLineEdit = QLineEdit(spellDialog) self.durationLineEdit.setObjectName(u"durationLineEdit") self.formLayout.setWidget(8, QFormLayout.FieldRole, self.durationLineEdit) self.pageReferenceLabel = QLabel(spellDialog) self.pageReferenceLabel.setObjectName(u"pageReferenceLabel") self.formLayout.setWidget(9, QFormLayout.LabelRole, self.pageReferenceLabel) self.pageReferenceLineEdit = QLineEdit(spellDialog) self.pageReferenceLineEdit.setObjectName(u"pageReferenceLineEdit") self.formLayout.setWidget(9, QFormLayout.FieldRole, self.pageReferenceLineEdit) self.notesLabel = QLabel(spellDialog) self.notesLabel.setObjectName(u"notesLabel") self.formLayout.setWidget(10, QFormLayout.LabelRole, self.notesLabel) self.notesLineEdit = QLineEdit(spellDialog) self.notesLineEdit.setObjectName(u"notesLineEdit") self.formLayout.setWidget(10, QFormLayout.FieldRole, self.notesLineEdit) self.verticalLayout.addLayout(self.formLayout) self.buttonBox = QDialogButtonBox(spellDialog) self.buttonBox.setObjectName(u"buttonBox") self.buttonBox.setOrientation(Qt.Horizontal) self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok) self.verticalLayout.addWidget(self.buttonBox) self.retranslateUi(spellDialog) self.buttonBox.accepted.connect(spellDialog.accept) self.buttonBox.rejected.connect(spellDialog.reject) QMetaObject.connectSlotsByName(spellDialog) # setupUi def retranslateUi(self, spellDialog): spellDialog.setWindowTitle( QCoreApplication.translate("spellDialog", u"dialog", None)) self.preparedLabel.setText( QCoreApplication.translate("spellDialog", u"Prepared", None)) self.levelLabel.setText( QCoreApplication.translate("spellDialog", u"Level", None)) self.spellNameLabel.setText( QCoreApplication.translate("spellDialog", u"Spell Name", None)) self.sourceLabel.setText( QCoreApplication.translate("spellDialog", u"Source", None)) self.saveAttackLabel.setText( QCoreApplication.translate("spellDialog", u"Save/Attack", None)) self.timeLabel.setText( QCoreApplication.translate("spellDialog", u"Time", None)) self.rangeLabel.setText( QCoreApplication.translate("spellDialog", u"Range", None)) self.componentsLabel.setText( QCoreApplication.translate("spellDialog", u"Components", None)) self.durationLabel.setText( QCoreApplication.translate("spellDialog", u"Duration", None)) self.pageReferenceLabel.setText( QCoreApplication.translate("spellDialog", u"Page Reference", None)) self.notesLabel.setText( QCoreApplication.translate("spellDialog", u"Notes", None))
def _create_button_box(self) -> QDialogButtonBox: button_box = QDialogButtonBox(self) button_box.setOrientation(Qt.Horizontal) button_box.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok) return button_box
class Ui_EquipmentDialog(object): def setupUi(self, EquipmentDialog): if EquipmentDialog.objectName(): EquipmentDialog.setObjectName(u"EquipmentDialog") EquipmentDialog.setWindowModality(Qt.WindowModal) EquipmentDialog.resize(400, 162) self.verticalLayout = QVBoxLayout(EquipmentDialog) self.verticalLayout.setObjectName(u"verticalLayout") self.formLayout = QFormLayout() self.formLayout.setObjectName(u"formLayout") self.nameLabel = QLabel(EquipmentDialog) self.nameLabel.setObjectName(u"nameLabel") self.formLayout.setWidget(0, QFormLayout.LabelRole, self.nameLabel) self.nameLineEdit = QLineEdit(EquipmentDialog) self.nameLineEdit.setObjectName(u"nameLineEdit") self.formLayout.setWidget(0, QFormLayout.FieldRole, self.nameLineEdit) self.amountLabel = QLabel(EquipmentDialog) self.amountLabel.setObjectName(u"amountLabel") self.formLayout.setWidget(1, QFormLayout.LabelRole, self.amountLabel) self.amountSpinBox = QSpinBox(EquipmentDialog) self.amountSpinBox.setObjectName(u"amountSpinBox") self.formLayout.setWidget(1, QFormLayout.FieldRole, self.amountSpinBox) self.weightLabel = QLabel(EquipmentDialog) self.weightLabel.setObjectName(u"weightLabel") self.formLayout.setWidget(2, QFormLayout.LabelRole, self.weightLabel) self.weightLineEdit = QLineEdit(EquipmentDialog) self.weightLineEdit.setObjectName(u"weightLineEdit") self.formLayout.setWidget(2, QFormLayout.FieldRole, self.weightLineEdit) self.attunedLabel = QLabel(EquipmentDialog) self.attunedLabel.setObjectName(u"attunedLabel") self.formLayout.setWidget(3, QFormLayout.LabelRole, self.attunedLabel) self.attunedCheckBox = QCheckBox(EquipmentDialog) self.attunedCheckBox.setObjectName(u"attunedCheckBox") self.formLayout.setWidget(3, QFormLayout.FieldRole, self.attunedCheckBox) self.verticalLayout.addLayout(self.formLayout) self.buttonBox = QDialogButtonBox(EquipmentDialog) self.buttonBox.setObjectName(u"buttonBox") self.buttonBox.setOrientation(Qt.Horizontal) self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok) self.verticalLayout.addWidget(self.buttonBox) self.retranslateUi(EquipmentDialog) self.buttonBox.accepted.connect(EquipmentDialog.accept) self.buttonBox.rejected.connect(EquipmentDialog.reject) QMetaObject.connectSlotsByName(EquipmentDialog) # setupUi def retranslateUi(self, EquipmentDialog): EquipmentDialog.setWindowTitle( QCoreApplication.translate("EquipmentDialog", u"dialog", None)) self.nameLabel.setText( QCoreApplication.translate("EquipmentDialog", u"Name", None)) self.amountLabel.setText( QCoreApplication.translate("EquipmentDialog", u"Amount", None)) self.weightLabel.setText( QCoreApplication.translate("EquipmentDialog", u"Weight", None)) self.attunedLabel.setText( QCoreApplication.translate("EquipmentDialog", u"Attuned", None))
def __init__(self, parent=None, **reserved_vrg) -> None: super().__init__(parent) if 'min' in reserved_vrg: min = str(reserved_vrg['min']) sec = str(reserved_vrg['sec']) pulse = reserved_vrg['pulse'] sec_sta = reserved_vrg['sec_sta'] else: min = '59' sec = '59' sec_sta = True pulse = True # Sets the title and size of the dialog box self.setWindowTitle('Inching Settings') self.resize(200, 200) # Set the window to modal, and the user can only return to the main # interface after closing the popover self.setWindowModality(Qt.ApplicationModal) # Table layout used to layout QLabel and QLineEdit and QSpinBox grid = QGridLayout() self.rb01 = QRadioButton('Inching ON', self) self.rb02 = QRadioButton('Inching OFF', self) self.bg0 = QButtonGroup(self) self.bg0.addButton(self.rb01, 11) self.bg0.addButton(self.rb02, 12) if pulse: self.rb01.setChecked(True) self.set_sta = True else: self.rb02.setChecked(True) self.set_sta = False self.bg0.buttonClicked.connect(self.rbclicked) grid.addWidget(self.rb01, 0, 0, 1, 1) grid.addWidget(self.rb02, 0, 1, 1, 1) grid.addWidget(QLabel('mins(number)', parent=self), 1, 0, 1, 1) self.minute = QLineEdit(parent=self) self.minute.setText(min) grid.addWidget(self.minute, 1, 1, 1, 1) grid.addWidget(QLabel('secs(number)', parent=self), 2, 0, 1, 1) self.second = QLineEdit(parent=self) self.second.setText(sec) grid.addWidget(self.second, 2, 1, 1, 1) self.rb11 = QRadioButton('+0.5s', self) self.rb12 = QRadioButton('+0s', self) self.bg1 = QButtonGroup(self) self.bg1.addButton(self.rb11, 21) self.bg1.addButton(self.rb12, 22) grid.addWidget(self.rb11, 3, 0, 1, 1) grid.addWidget(self.rb12, 3, 1, 1, 1) if sec_sta: self.rb11.setChecked(True) self.second_point = True else: self.rb12.setChecked(True) self.second_point = False self.bg1.buttonClicked.connect(self.rbclicked) grid.addWidget( QLabel( 'Inching duration range is 0:0.5 ~ 59:59.5\n' 'with the interval of 0.5 sec.', parent=self), 4, 0, 2, 2) # Create ButtonBox, and the user confirms and cancels buttonbox = QDialogButtonBox(parent=self) buttonbox.setOrientation(Qt.Horizontal) # Set to horizontal buttonbox.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok) # Connect the signal to the slot buttonbox.accepted.connect(self.accept) buttonbox.rejected.connect(self.reject) # Vertical layout, layout tables and buttons layout = QVBoxLayout() # Add the table layout you created earlier layout.addLayout(grid) # Put a space object to beautify the layout spacer_item = QSpacerItem(20, 48, QSizePolicy.Minimum, QSizePolicy.Expanding) layout.addItem(spacer_item) # ButtonBox layout.addWidget(buttonbox) self.setLayout(layout)
class PdfDialog(QDialog): def __init__(self, parent, importers_stringlist): super(PdfDialog, self).__init__(parent) self.resize(320, 240) self.importer_selected = 0 self.verticalLayout = QVBoxLayout(self) self.verticalLayout.setObjectName("verticalLayout") self.formLayout = QFormLayout() self.formLayout.setObjectName("formLayout") self.selected_file_label = QLabel(self) self.selected_file_label.setObjectName("selected_file_label") self.formLayout.setWidget(0, QFormLayout.LabelRole, self.selected_file_label) self.importer_label = QLabel(self) self.importer_label.setObjectName("importer_label") self.formLayout.setWidget(1, QFormLayout.LabelRole, self.importer_label) self.importer_combo_box = QComboBox(self) self.importer_combo_box.setObjectName("importer_combo_box") self.importer_combo_box.addItems(importers_stringlist) def set_importer_selected(x): self.importer_selected = x self.importer_combo_box.currentIndexChanged.connect( set_importer_selected) self.formLayout.setWidget(1, QFormLayout.FieldRole, self.importer_combo_box) self.selected_label = QLabel(self) self.selected_label.setObjectName("selected_label") self.formLayout.setWidget(0, QFormLayout.FieldRole, self.selected_label) self.importer_status = QLabel(self) self.importer_status.setObjectName("importer_status") self.formLayout.setWidget(2, QFormLayout.FieldRole, self.importer_status) self.verticalLayout.addLayout(self.formLayout) self.buttonBox = QDialogButtonBox(self) self.buttonBox.setObjectName("buttonBox") self.buttonBox.setOrientation(Qt.Horizontal) self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok) self.verticalLayout.addWidget(self.buttonBox) self.retranslateUi(self) self.buttonBox.accepted.connect(self.accept) self.buttonBox.rejected.connect(self.reject) QMetaObject.connectSlotsByName(self) # setupUi def retranslateUi(self, dialog): dialog.setWindowTitle( QCoreApplication.translate("dialog", "Import Character Sheet", None)) self.selected_file_label.setText( QCoreApplication.translate("dialog", "Selected File", None)) self.importer_label.setText( QCoreApplication.translate("dialog", "Importer", None)) self.selected_label.setText( QCoreApplication.translate("dialog", "TextLabel", None)) self.importer_status.setText( QCoreApplication.translate("dialog", "TextLabel", None))