def __init__(self, parent=None):
super(AddressBook, self).__init__(parent)
nameLabel = QLabel("Name:")
self.nameLine = QLineEdit()
addressLabel = QLabel("Address:")
self.addressText = QTextEdit()
mainLayout = QGridLayout()
mainLayout.addWidget(nameLabel, 0, 0)
mainLayout.addWidget(self.nameLine, 0, 1)
mainLayout.addWidget(addressLabel, 1, 0, Qt.AlignTop)
mainLayout.addWidget(self.addressText, 1, 1)
self.setLayout(mainLayout)
self.setWindowTitle("Simple Address Book")
python类AlignTop()的实例源码
def __init__(self, parent=None):
super(AddressBook, self).__init__(parent)
nameLabel = QLabel("Name:")
self.nameLine = QLineEdit()
addressLabel = QLabel("Address:")
self.addressText = QTextEdit()
mainLayout = QGridLayout()
mainLayout.addWidget(nameLabel, 0, 0)
mainLayout.addWidget(self.nameLine, 0, 1)
mainLayout.addWidget(addressLabel, 1, 0, Qt.AlignTop)
mainLayout.addWidget(self.addressText, 1, 1)
self.setLayout(mainLayout)
self.setWindowTitle("Simple Address Book")
def __init__(self, parent=None):
super(AddressBook, self).__init__(parent)
nameLabel = QLabel("Name:")
self.nameLine = QLineEdit()
addressLabel = QLabel("Address:")
self.addressText = QTextEdit()
mainLayout = QGridLayout()
mainLayout.addWidget(nameLabel, 0, 0)
mainLayout.addWidget(self.nameLine, 0, 1)
mainLayout.addWidget(addressLabel, 1, 0, Qt.AlignTop)
mainLayout.addWidget(self.addressText, 1, 1)
self.setLayout(mainLayout)
self.setWindowTitle("Simple Address Book")
def update_aliases_on_gui(self):
'''Updates aliases on the dialog using the info in the book's aliases dict'''
aliases_widget = QWidget()
aliases_layout = QGridLayout(aliases_widget)
aliases_layout.setAlignment(Qt.AlignTop)
# add aliases for current book
for index, (character, aliases) in enumerate(sorted(self.book.aliases.items())):
label = QLabel(character + ':')
label.setFixedWidth(150)
aliases_layout.addWidget(label, index, 0)
line_edit = QLineEdit(', '.join([self.TITLE_CASE(alias) for alias in aliases]))
line_edit.setFixedWidth(350)
line_edit.textEdited.connect(functools.partial(self.edit_aliases, character))
aliases_layout.addWidget(line_edit, index, 1)
self._scroll_area.setWidget(aliases_widget)
def __init__(self, parent=None):
super(AddressBook, self).__init__(parent)
self.contacts = SortedDict()
self.oldName = ''
self.oldAddress = ''
nameLabel = QLabel("Name:")
self.nameLine = QLineEdit()
self.nameLine.setReadOnly(True)
addressLabel = QLabel("Address:")
self.addressText = QTextEdit()
self.addressText.setReadOnly(True)
self.addButton = QPushButton("&Add")
self.addButton.show()
self.submitButton = QPushButton("&Submit")
self.submitButton.hide()
self.cancelButton = QPushButton("&Cancel")
self.cancelButton.hide()
self.addButton.clicked.connect(self.addContact)
self.submitButton.clicked.connect(self.submitContact)
self.cancelButton.clicked.connect(self.cancel)
buttonLayout1 = QVBoxLayout()
buttonLayout1.addWidget(self.addButton, Qt.AlignTop)
buttonLayout1.addWidget(self.submitButton)
buttonLayout1.addWidget(self.cancelButton)
buttonLayout1.addStretch()
mainLayout = QGridLayout()
mainLayout.addWidget(nameLabel, 0, 0)
mainLayout.addWidget(self.nameLine, 0, 1)
mainLayout.addWidget(addressLabel, 1, 0, Qt.AlignTop)
mainLayout.addWidget(self.addressText, 1, 1)
mainLayout.addLayout(buttonLayout1, 1, 2)
self.setLayout(mainLayout)
self.setWindowTitle("Simple Address Book")
def __init__(self, parent=None):
super(AddressBook, self).__init__(parent)
self.contacts = SortedDict()
self.oldName = ''
self.oldAddress = ''
nameLabel = QLabel("Name:")
self.nameLine = QLineEdit()
self.nameLine.setReadOnly(True)
addressLabel = QLabel("Address:")
self.addressText = QTextEdit()
self.addressText.setReadOnly(True)
self.addButton = QPushButton("&Add")
self.addButton.show()
self.submitButton = QPushButton("&Submit")
self.submitButton.hide()
self.cancelButton = QPushButton("&Cancel")
self.cancelButton.hide()
self.addButton.clicked.connect(self.addContact)
self.submitButton.clicked.connect(self.submitContact)
self.cancelButton.clicked.connect(self.cancel)
buttonLayout1 = QVBoxLayout()
buttonLayout1.addWidget(self.addButton, Qt.AlignTop)
buttonLayout1.addWidget(self.submitButton)
buttonLayout1.addWidget(self.cancelButton)
buttonLayout1.addStretch()
mainLayout = QGridLayout()
mainLayout.addWidget(nameLabel, 0, 0)
mainLayout.addWidget(self.nameLine, 0, 1)
mainLayout.addWidget(addressLabel, 1, 0, Qt.AlignTop)
mainLayout.addWidget(self.addressText, 1, 1)
mainLayout.addLayout(buttonLayout1, 1, 2)
self.setLayout(mainLayout)
self.setWindowTitle("Simple Address Book")
def __init__(self, courseList, socket, parent=None):
QtWidgets.QDialog.__init__(self, parent)
self.ui = uic.loadUi(config.config.ROOT_PATH +'view/adminSelectCourse.ui', self)
self.sock = socket
self.courseList = []
self.courseList = self.courseList + courseList
self.register = object
self.dataPos = -1
pListWidget = QtWidgets.QWidget()
self.ui.scrollArea.setWidgetResizable(True)
self.ui.scrollArea.setWidget(pListWidget)
self.pListLayout = QtWidgets.QGridLayout()
self.pListLayout.setAlignment(Qt.AlignTop)
pListWidget.setLayout(self.pListLayout)
self.makeCourseLayout()
def init_widget(self):
self.setWindowTitle("Layout Basic")
self.setFixedWidth(640)
self.setFixedHeight(480)
self.lb_1.setText("Label 1")
self.lb_2.setText("Label 2")
self.lb_3.setText("Label 3")
self.lb_4.setText("Label 4")
self.lb_5.setText("Label 5")
self.lb_1.setStyleSheet("background-color: yellow")
self.lb_2.setStyleSheet("background-color: red")
self.lb_3.setStyleSheet("background-color: blue")
self.lb_4.setStyleSheet("background-color: pink")
self.lb_5.setStyleSheet("background-color: grey")
self.layout_1.addWidget(self.lb_1)
self.layout_1.addWidget(self.lb_2, alignment=Qt.AlignTop)
self.layout_1.addWidget(self.lb_3, alignment=Qt.AlignBottom)
self.layout_1.addWidget(self.lb_4, alignment=Qt.AlignVCenter)
self.layout_1.addWidget(self.lb_5, alignment=Qt.AlignHCenter)
def make_tab1(self, parent):
tab1 = QWidget(parent)
tab1.value = dict((x[0], 0) for x in parameter_list)
tab1.unit = dict((x[0], "") for x in parameter_list)
tab1.layout = QGridLayout(tab1)
tab1.layout.setAlignment(Qt.AlignTop)
tab1.layout.addWidget(self.tree, 1, 1, 6, 1)
tab1.labels = self.make_labels(tab1, parameter_list)
tab1.inputs = self.make_inputs(tab1, parameter_list)
tab1.boxes = self.make_dropdowns(tab1, parameter_list, self.get_unit)
i = 0
j = 2
for x in parameter_list:
tab1.layout.addWidget(tab1.labels[x[0]], (i % 6) + 1, j)
tab1.layout.addWidget(tab1.inputs[x[0]], (i % 6) + 1, j + 1)
tab1.layout.addWidget(tab1.boxes[x[0]], (i % 6) + 1, j + 2)
i = i + 1
return tab1
def make_tab4(self, parent):
tab4 = QWidget(parent)
tab4.inpos = {}
tab4.inwells = {}
tab4.in_c = 1
tab4.outpos = {}
tab4.outwells = {}
tab4.out_c = 1
tab4.layout = QGridLayout(tab4)
tab4.layout.setVerticalSpacing(20)
tab4.layout.setAlignment(Qt.AlignTop | Qt.AlignCenter)
tab4.add_inwell_but = QPushButton("New Injection Well", tab4)
tab4.add_inwell_but.clicked.connect(self.make_inwell)
tab4.add_outwell_but = QPushButton("New Producer Well", tab4)
tab4.add_outwell_but.clicked.connect(self.make_outwell)
tab4.layout.addWidget(tab4.add_inwell_but, 1, 1)
tab4.layout.addWidget(tab4.add_outwell_but, 2, 1)
return tab4
def make_tab5(self, parent):
tab5 = QWidget(parent)
tab5.value = dict((x[0], 0) for x in mesh)
tab5.unit = dict((x[0], "") for x in mesh)
tab5.layout = QGridLayout(tab5)
tab5.layout.setAlignment(Qt.AlignTop)
tab5.labels = self.make_labels(tab5, mesh)
tab5.inputs = self.make_inputs(tab5, mesh)
tab5.boxes = self.make_dropdowns(tab5, mesh, self.get_unit)
i = 0
for x in mesh:
tab5.layout.addWidget(tab5.labels[x[0]], i, 1)
tab5.layout.addWidget(tab5.inputs[x[0]], i, 2)
tab5.layout.addWidget(tab5.boxes[x[0]], i, 3)
i = i + 1
return tab5
def init_middle_layout(self):
if not self.should_show:
return
vbox = QtWidgets.QVBoxLayout()
self.select_all = QtWidgets.QCheckBox('Select All ')
self.filter_sub_funcs = QtWidgets.QCheckBox('Filter Out "sub_" functions ')
vbox.addWidget(self.filter_sub_funcs)
vbox.addWidget(self.select_all)
format_str = '{} functions'.format(self.total_functions)
self.function_number = QtWidgets.QLabel(format_str)
self.function_number.setAlignment(Qt.AlignTop)
self.middle_layout.addWidget(self.function_number)
self.middle_layout.addStretch()
self.middle_layout.addLayout(vbox)
def init_middle_layout(self):
found = len(self.groups)
total = len(FIRST.Metadata.get_non_jmp_wrapped_functions())
s = 's' if 1 != total else ''
label = 'Matched {0} out of {1} function{2}'
self.select_highest_ranked = QtWidgets.QCheckBox('Select Highest Ranked ')
self.filter_sub_funcs_only = QtWidgets.QCheckBox('Show only "sub_" functions')
vbox = QtWidgets.QVBoxLayout()
vbox.addWidget(self.filter_sub_funcs_only)
vbox.addWidget(self.select_highest_ranked)
self.found_format = label.format('{}', total, s)
self.found_label = QtWidgets.QLabel(self.found_format.format(found))
self.found_label.setAlignment(Qt.AlignTop)
self.middle_layout.addWidget(self.found_label)
self.middle_layout.addStretch()
self.middle_layout.addLayout(vbox)
def __init__(self, parent=None):
super(AddressBook, self).__init__(parent)
self.contacts = SortedDict()
self.oldName = ''
self.oldAddress = ''
nameLabel = QLabel("Name:")
self.nameLine = QLineEdit()
self.nameLine.setReadOnly(True)
addressLabel = QLabel("Address:")
self.addressText = QTextEdit()
self.addressText.setReadOnly(True)
self.addButton = QPushButton("&Add")
self.addButton.show()
self.submitButton = QPushButton("&Submit")
self.submitButton.hide()
self.cancelButton = QPushButton("&Cancel")
self.cancelButton.hide()
self.addButton.clicked.connect(self.addContact)
self.submitButton.clicked.connect(self.submitContact)
self.cancelButton.clicked.connect(self.cancel)
buttonLayout1 = QVBoxLayout()
buttonLayout1.addWidget(self.addButton, Qt.AlignTop)
buttonLayout1.addWidget(self.submitButton)
buttonLayout1.addWidget(self.cancelButton)
buttonLayout1.addStretch()
mainLayout = QGridLayout()
mainLayout.addWidget(nameLabel, 0, 0)
mainLayout.addWidget(self.nameLine, 0, 1)
mainLayout.addWidget(addressLabel, 1, 0, Qt.AlignTop)
mainLayout.addWidget(self.addressText, 1, 1)
mainLayout.addLayout(buttonLayout1, 1, 2)
self.setLayout(mainLayout)
self.setWindowTitle("Simple Address Book")
def req_ui(self):
self.clear_layout(self.rbox)
self.clear_layout(self.hbox)
self.hbox.addStretch()
self.l1.setText('Select which requirements to install')
self.rbox.insertSpacing(1, 35)
self.r1 = QRadioButton("Install basic + audio requirements (recommended)")
self.r1.setChecked(True)
self.r1.setFont(self.reg_font)
self.rbox.addWidget(self.r1, 0, Qt.AlignTop)
self.r2 = QRadioButton("Install basic requirements")
self.r2.setFont(self.reg_font)
self.rbox.addWidget(self.r2, 0, Qt.AlignLeft)
if os.path.exists("lib"):
l5 = QLabel(self)
l5.setText('<font color="#ff0000">Requirements already installed.</font>')
self.rbox.addWidget(l5, 1, Qt.AlignBottom)
b5 = QPushButton("Skip", self)
b5.setMaximumWidth(50)
self.rbox.addWidget(b5, 0, Qt.AlignBottom)
b5.clicked.connect(self.token_ui)
# buttons
self.buttons_panel()
# binds
self.b1.setEnabled(False)
self.b2.clicked.connect(self.if_req)
self.b3.clicked.connect(self.close_prompt)
def token_ui(self):
self.clear_layout(self.rbox)
self.clear_layout(self.hbox)
self.hbox.addStretch()
self.l1.setText("Input your bot's token")
self.rbox.insertSpacing(1, 30)
self.token_print = QLabel(self)
self.token_print.setText("Token: ")
self.rbox.addWidget(self.token_print, 0, Qt.AlignTop)
self.token_edit = QLineEdit(self)
self.token_edit.setMaximumWidth(300)
self.rbox.addWidget(self.token_edit, 0, Qt.AlignTop)
l2 = QLabel("Your token can be found in Discord's "
"<a href='https://discordapp.com/developers/applications/me'>App Page</a>")
l2.setOpenExternalLinks(True)
l2.setFont(self.small_font)
self.rbox.addWidget(l2, 0, Qt.AlignBottom)
if self.settings.token is not None:
l5 = QLabel(self)
l5.setText('<font color="#ff0000">"' + self.settings.token[0:10] + '--"</font>\nis your current token')
self.rbox.addWidget(l5, 1, Qt.AlignBottom)
b5 = QPushButton("Skip", self)
b5.setMaximumWidth(50)
self.rbox.addWidget(b5, 0, Qt.AlignBottom)
b5.clicked.connect(self.prefix_ui)
# buttons
self.buttons_panel()
# token1 = token_edit.text()
# binds
self.b1.setEnabled(False)
self.token_edit.textChanged[str].connect(self.token_on_change)
self.b1.clicked.connect(self.req_ui)
self.b2.clicked.connect(self.token_save)
self.b3.clicked.connect(self.close_prompt)
def admin_ui(self):
self.clear_layout(self.rbox)
self.clear_layout(self.hbox)
self.hbox.addStretch()
self.l1.setText("Set your Administrator roles")
# admin
self.rbox.insertSpacing(1, 30)
self.admin_print = QLabel(self)
self.admin_print.setText("Admin: ")
self.admin_print.setWordWrap(True)
self.rbox.addWidget(self.admin_print, 0, Qt.AlignTop)
self.admin_edit = QLineEdit(self)
self.admin_edit.setPlaceholderText("Blank for default")
self.admin_edit.setMaximumWidth(300)
self.rbox.addWidget(self.admin_edit, 0, Qt.AlignTop)
# mod
self.rbox.insertSpacing(1, 30)
self.mod_print = QLabel(self)
self.mod_print.setText("Mod: ")
self.mod_print.setWordWrap(True)
self.rbox.addWidget(self.mod_print, 0, Qt.AlignTop)
self.mod_edit = QLineEdit(self)
self.mod_edit.setPlaceholderText("Blank for default")
self.mod_edit.setMaximumWidth(300)
self.rbox.addWidget(self.mod_edit, 0, Qt.AlignTop)
# buttons
self.buttons_panel()
# binds
self.b2.setText("Finish")
self.b1.clicked.connect(self.prefix_ui)
self.b2.clicked.connect(self.admin_save)
self.b3.clicked.connect(self.close_prompt)
def showTimer(self) -> None:
self._timerwidget.show()
# noinspection PyArgumentList
self.layout().addWidget(self._timerwidget, 1, 0, Qt.AlignHCenter | Qt.AlignTop)
self._time.start()
self.updateTimer()
self._timer.start(1000)
def run_cmd(self, cmd):
item = QTreeWidgetItem(self.comtree)
item.setText(0, time.strftime("%Y.%m.%d. %H:%M:%S", time.localtime()))
item.setText(1, cmd)
for i in range(3):
item.setTextAlignment(i, Qt.AlignTop)
item.setForeground(1, QtGui.QBrush(green))
item.setForeground(2, QtGui.QBrush(red))
self.comtree.scrollToItem(item)
self.conn.cmd(cmd)
proc_events()
def __init__(self, title, parent):
super(DetailsDialog, self).__init__(parent)
self.items = ("T-shirt", "Badge", "Reference book", "Coffee cup")
nameLabel = QLabel("Name:")
addressLabel = QLabel("Address:")
addressLabel.setAlignment(Qt.AlignLeft | Qt.AlignTop)
self.nameEdit = QLineEdit()
self.addressEdit = QTextEdit()
self.offersCheckBox = QCheckBox(
"Send information about products and special offers:")
self.setupItemsTable()
buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
buttonBox.accepted.connect(self.verify)
buttonBox.rejected.connect(self.reject)
mainLayout = QGridLayout()
mainLayout.addWidget(nameLabel, 0, 0)
mainLayout.addWidget(self.nameEdit, 0, 1)
mainLayout.addWidget(addressLabel, 1, 0)
mainLayout.addWidget(self.addressEdit, 1, 1)
mainLayout.addWidget(self.itemsTable, 0, 2, 2, 1)
mainLayout.addWidget(self.offersCheckBox, 2, 1, 1, 2)
mainLayout.addWidget(buttonBox, 3, 0, 1, 3)
self.setLayout(mainLayout)
self.setWindowTitle(title)
def updateFormatsTable(self, mimeData=None):
self.formatsTable.setRowCount(0)
if mimeData is None:
return
for format in mimeData.formats():
formatItem = QTableWidgetItem(format)
formatItem.setFlags(Qt.ItemIsEnabled)
formatItem.setTextAlignment(Qt.AlignTop | Qt.AlignLeft)
if format == 'text/plain':
text = mimeData.text().strip()
elif format == 'text/html':
text = mimeData.html().strip()
elif format == 'text/uri-list':
text = " ".join([url.toString() for url in mimeData.urls()])
else:
text = " ".join(["%02X" % ord(datum) for datum in mimeData.data(format)])
row = self.formatsTable.rowCount()
self.formatsTable.insertRow(row)
self.formatsTable.setItem(row, 0, QTableWidgetItem(format))
self.formatsTable.setItem(row, 1, QTableWidgetItem(text))
self.formatsTable.resizeColumnToContents(0)
def __init__(self, title, parent):
super(DetailsDialog, self).__init__(parent)
self.items = ("T-shirt", "Badge", "Reference book", "Coffee cup")
nameLabel = QLabel("Name:")
addressLabel = QLabel("Address:")
addressLabel.setAlignment(Qt.AlignLeft | Qt.AlignTop)
self.nameEdit = QLineEdit()
self.addressEdit = QTextEdit()
self.offersCheckBox = QCheckBox(
"Send information about products and special offers:")
self.setupItemsTable()
buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
buttonBox.accepted.connect(self.verify)
buttonBox.rejected.connect(self.reject)
mainLayout = QGridLayout()
mainLayout.addWidget(nameLabel, 0, 0)
mainLayout.addWidget(self.nameEdit, 0, 1)
mainLayout.addWidget(addressLabel, 1, 0)
mainLayout.addWidget(self.addressEdit, 1, 1)
mainLayout.addWidget(self.itemsTable, 0, 2, 2, 1)
mainLayout.addWidget(self.offersCheckBox, 2, 1, 1, 2)
mainLayout.addWidget(buttonBox, 3, 0, 1, 3)
self.setLayout(mainLayout)
self.setWindowTitle(title)
def updateFormatsTable(self, mimeData=None):
self.formatsTable.setRowCount(0)
if mimeData is None:
return
for format in mimeData.formats():
formatItem = QTableWidgetItem(format)
formatItem.setFlags(Qt.ItemIsEnabled)
formatItem.setTextAlignment(Qt.AlignTop | Qt.AlignLeft)
if format == 'text/plain':
text = mimeData.text().strip()
elif format == 'text/html':
text = mimeData.html().strip()
elif format == 'text/uri-list':
text = " ".join([url.toString() for url in mimeData.urls()])
else:
text = " ".join(["%02X" % ord(datum) for datum in mimeData.data(format)])
row = self.formatsTable.rowCount()
self.formatsTable.insertRow(row)
self.formatsTable.setItem(row, 0, QTableWidgetItem(format))
self.formatsTable.setItem(row, 1, QTableWidgetItem(text))
self.formatsTable.resizeColumnToContents(0)
def __init__(self, socket, pui, pCourseList, parent=None):
QtWidgets.QDialog.__init__(self, parent)
self.ui = uic.loadUi(config.config.ROOT_PATH +'view/registerCourse.ui', self)
self.sock = socket
self.pui = pui
self.pCourseList = pCourseList
self.banList = []
self.allowList = []
self.students = []
self.ui.dateEdit.setDate(datetime.datetime.now().date())
pListWidget = QtWidgets.QWidget()
self.ui.scrollArea.setWidgetResizable(True)
self.ui.scrollArea.setWidget(pListWidget)
pListLayout = QtWidgets.QVBoxLayout()
pListLayout.setAlignment(Qt.AlignTop)
pListWidget.setLayout(pListLayout)
for i in range(1, len(config.config.BAN_PROGRAM)):
checkBox = QtWidgets.QCheckBox(config.config.BAN_PROGRAM[i])
checkBox.clicked.connect(self.set_ban_list)
pListLayout.addWidget(checkBox)
sListWidget = QtWidgets.QWidget()
self.ui.scrollArea_2.setWidgetResizable(True)
self.ui.scrollArea_2.setWidget(sListWidget)
sListLayout = QtWidgets.QVBoxLayout()
sListLayout.setAlignment(Qt.AlignTop)
sListWidget.setLayout(sListLayout)
for i in range(1, len(config.config.ALLOW_SITE)):
checkBox = QtWidgets.QCheckBox(config.config.ALLOW_SITE[i])
checkBox.clicked.connect(self.set_allow_list)
sListLayout.addWidget(checkBox)
self.ui.show()
def init_ui(self):
self.setWindowTitle(self.title)
self.setGeometry(self.left, self.top, self.width, self.height)
self.create_layout()
window_layout = QVBoxLayout()
window_layout.addWidget(self.horizontal_groupbox, 1)
window_layout.addWidget(self.scroll_area, 100)
window_layout.setAlignment(self.scroll_area, Qt.AlignTop)
self.setLayout(window_layout)
self.show()
def make_tab2(self, parent):
tab2 = QWidget(parent)
tab2.layout = QGridLayout(tab2)
tab2.layout.setAlignment(Qt.AlignTop)
tab2.oil = QLabel("Oil", tab2)
tab2.oil.value = dict((x[0], 0) for x in fluids)
tab2.oil.unit = dict((x[0], "") for x in fluids)
tab2.oil.labels = self.make_labels(tab2, fluids)
tab2.oil.inputs = self.make_inputs(tab2, fluids)
tab2.oil.boxes = self.make_dropdowns(tab2, fluids, self.get_unit)
tab2.water = QLabel("Water", tab2)
tab2.water.value = dict((x[0], 0) for x in fluids)
tab2.water.unit = dict((x[0], "") for x in fluids)
tab2.water.labels = self.make_labels(tab2, fluids)
tab2.water.inputs = self.make_inputs(tab2, fluids)
tab2.water.boxes = self.make_dropdowns(tab2, fluids, self.get_unit)
tab2.layout.addWidget(tab2.oil, 1, 1)
tab2.layout.addWidget(tab2.water, 1, 4)
i = 2
for x in fluids:
tab2.layout.addWidget(tab2.oil.labels[x[0]], i, 1)
tab2.layout.addWidget(tab2.oil.inputs[x[0]], i, 2)
tab2.layout.addWidget(tab2.oil.boxes[x[0]], i, 3)
tab2.layout.addWidget(tab2.water.labels[x[0]], i, 4)
tab2.layout.addWidget(tab2.water.inputs[x[0]], i, 5)
tab2.layout.addWidget(tab2.water.boxes[x[0]], i, 6)
i = i + 1
return tab2
def make_tab3(self, parent):
tab3 = QWidget(parent)
tab3.layout = QGridLayout(tab3)
tab3.layout.setAlignment(Qt.AlignTop)
tab3.value = {}
tab3.coords = ["X", "Y", "Z"]
tab3.labels = {}
tab3.inputs = {}
tab3.boxes = self.make_dropdowns(tab3, permcamp, self.save_camp)
i = 1
for x in tab3.coords:
tab3.labels[x] = QLabel(x, tab3)
tab3.inputs[x] = QLineEdit(tab3)
tab3.inputs[x].textEdited.connect(self.save_camp)
tab3.boxes[x] = MyComboBox(tab3, start_unit, "Length")
tab3.boxes[x].currentTextChanged.connect(self.save_camp)
tab3.layout.addWidget(tab3.labels[x], i, 1)
tab3.layout.addWidget(tab3.inputs[x], i, 2)
tab3.layout.addWidget(tab3.boxes[x], i, 3)
i += 1
for x in permcamp:
tab3.labels[x[0]] = QLabel(x[0], tab3)
tab3.inputs[x[0]] = QLineEdit(tab3)
tab3.inputs[x[0]].textEdited.connect(self.save_camp)
tab3.layout.addWidget(tab3.labels[x[0]], i, 1)
tab3.layout.addWidget(tab3.inputs[x[0]], i, 2)
tab3.layout.addWidget(tab3.boxes[x[0]], i, 3)
i += 1
return tab3
def __init__(self, title, parent):
super(DetailsDialog, self).__init__(parent)
self.items = ("T-shirt", "Badge", "Reference book", "Coffee cup")
nameLabel = QLabel("Name:")
addressLabel = QLabel("Address:")
addressLabel.setAlignment(Qt.AlignLeft | Qt.AlignTop)
self.nameEdit = QLineEdit()
self.addressEdit = QTextEdit()
self.offersCheckBox = QCheckBox(
"Send information about products and special offers:")
self.setupItemsTable()
buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
buttonBox.accepted.connect(self.verify)
buttonBox.rejected.connect(self.reject)
mainLayout = QGridLayout()
mainLayout.addWidget(nameLabel, 0, 0)
mainLayout.addWidget(self.nameEdit, 0, 1)
mainLayout.addWidget(addressLabel, 1, 0)
mainLayout.addWidget(self.addressEdit, 1, 1)
mainLayout.addWidget(self.itemsTable, 0, 2, 2, 1)
mainLayout.addWidget(self.offersCheckBox, 2, 1, 1, 2)
mainLayout.addWidget(buttonBox, 3, 0, 1, 3)
self.setLayout(mainLayout)
self.setWindowTitle(title)
def updateFormatsTable(self, mimeData=None):
self.formatsTable.setRowCount(0)
if mimeData is None:
return
for format in mimeData.formats():
formatItem = QTableWidgetItem(format)
formatItem.setFlags(Qt.ItemIsEnabled)
formatItem.setTextAlignment(Qt.AlignTop | Qt.AlignLeft)
if format == 'text/plain':
text = mimeData.text().strip()
elif format == 'text/html':
text = mimeData.html().strip()
elif format == 'text/uri-list':
text = " ".join([url.toString() for url in mimeData.urls()])
else:
text = " ".join(["%02X" % ord(datum) for datum in mimeData.data(format)])
row = self.formatsTable.rowCount()
self.formatsTable.insertRow(row)
self.formatsTable.setItem(row, 0, QTableWidgetItem(format))
self.formatsTable.setItem(row, 1, QTableWidgetItem(text))
self.formatsTable.resizeColumnToContents(0)
def init_ui(self):
# v.box
box = QVBoxLayout()
box.setSpacing(5)
box2 = QVBoxLayout()
box2.setSpacing(0)
l1 = QLabel('Red Discord Bot', self)
l1.setFont(QtGui.QFont("Times", 14))
box.addWidget(l1, 0, Qt.AlignTop)
box.insertSpacing(1, 10)
b1 = QPushButton("Start Red", self)
b1.setMinimumWidth(100)
box.addWidget(b1, 0, Qt.AlignHCenter)
b2 = QPushButton("Start Red Loop", self)
b2.setMinimumWidth(100)
box.addWidget(b2, 0, Qt.AlignHCenter)
box.insertSpacing(4, 10)
b3 = QPushButton("Update Red", self)
b3.setMinimumWidth(80)
box2.addWidget(b3, 0, Qt.AlignHCenter)
b4 = QPushButton("Install Requirements", self)
b4.setMinimumWidth(120)
box2.addWidget(b4, 0, Qt.AlignHCenter)
b5 = QPushButton("Maintenance", self)
b5.setMinimumWidth(100)
box2.addWidget(b5, 0, Qt.AlignHCenter)
# b2.setEnabled(False)
box.setAlignment(Qt.AlignHCenter)
box2.addStretch(5)
box.addLayout(box2)
self.setLayout(box)
# binds
b1.clicked.connect(lambda: self.startred(autorestart=False))
b2.clicked.connect(lambda: self.startred(autorestart=True))
b3.clicked.connect(lambda: self.switchwindow(window=UpdateWindow()))
b4.clicked.connect(lambda: self.switchwindow(window=RequirementsWindow()))
b5.clicked.connect(lambda: self.switchwindow(window=MaintenanceWindow()))
# window
self.setFixedSize(220, 210)
self.setWindowIcon(QtGui.QIcon('red.ico'))
self.setWindowTitle('Red Bot')
self.show()