def __init__(self, media_object, parent=None):
super().__init__(parent)
self.setWindowTitle('Preferences')
self.form = QtWidgets.QFormLayout(self)
server = media_object.container.server
settings = server.container(media_object.key)
self.ids = []
for item in settings['_children']:
itype = item['type']
if itype == 'bool':
input_widget = QtWidgets.QCheckBox()
input_widget.setCheckState(QtCore.Qt.Checked if item['value'] == 'true' else QtCore.Qt.Unchecked)
elif itype == 'enum':
input_widget = QtWidgets.QComboBox()
input_widget.addItems(item['values'].split('|'))
input_widget.setCurrentIndex(int(item['value']))
elif itype == 'text':
input_widget = QtWidgets.QLineEdit(item['value'])
if item['secure'] == 'true':
input_widget.setEchoMode(QtWidgets.QLineEdit.PasswordEchoOnEdit)
else:
input_widget = QtWidgets.QLabel('...')
self.form.addRow(QtWidgets.QLabel(item['label']), input_widget)
self.ids.append((item['id'], input_widget))
self.buttons = QtWidgets.QDialogButtonBox(
QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel, QtCore.Qt.Horizontal, self)
self.form.addRow(self.buttons)
self.buttons.rejected.connect(self.reject)
self.buttons.accepted.connect(self.accept)
if self.exec_() == QtWidgets.QDialog.Accepted:
media_object.container.server.request(media_object.key + '/set', params=self.extract_values())
python类QDialog()的实例源码
def __init__(self, parent=None):
super().__init__(parent)
s = plexdesktop.settings.Settings()
self.setWindowTitle('Preferences')
self.form = QtWidgets.QFormLayout(self)
i = QtWidgets.QComboBox()
i.addItems(plexdesktop.style.Style.Instance().themes)
i.setCurrentIndex(i.findText(s.value('theme')))
self.form.addRow(QtWidgets.QLabel('theme'), i)
bf = QtWidgets.QSpinBox()
bf.setValue(int(s.value('browser_font', 9)))
self.form.addRow(QtWidgets.QLabel('browser font size'), bf)
icon_size = QtWidgets.QLineEdit(str(s.value('thumb_size', 240)))
icon_size.setValidator(QtGui.QIntValidator(0, 300))
self.form.addRow(QtWidgets.QLabel('thumbnail size'), icon_size)
widget_player = QtWidgets.QCheckBox()
widget_player.setCheckState(QtCore.Qt.Checked if bool(int(s.value('widget_player', 0))) else QtCore.Qt.Unchecked)
self.form.addRow(QtWidgets.QLabel('use widget player'), widget_player)
self.buttons = QtWidgets.QDialogButtonBox(
QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel,
QtCore.Qt.Horizontal, self)
self.form.addRow(self.buttons)
self.buttons.rejected.connect(self.reject)
self.buttons.accepted.connect(self.accept)
if self.exec_() == QtWidgets.QDialog.Accepted:
# s = Settings()
theme = i.currentText()
s.setValue('theme', theme)
plexdesktop.style.Style.Instance().theme(theme)
s.setValue('browser_font', bf.value())
s.setValue('thumb_size', int(icon_size.text()))
s.setValue('widget_player', 1 if widget_player.checkState() == QtCore.Qt.Checked else 0)
def flight_info(self, item):
data = item.getData(QtCore.Qt.UserRole)
if isinstance(data, prj.Flight):
dialog = QtWidgets.QDialog(self)
dialog.setLayout(QtWidgets.QVBoxLayout())
dialog.exec_()
print("Flight info: {}".format(item.text()))
else:
print("Info event: Not a flight")
def accept(self, project=None):
"""Runs some basic verification before calling QDialog accept()."""
# Case where project object is passed to accept() (when creating new project)
if isinstance(project, prj.GravityProject):
self.log.debug("Opening new project: {}".format(project.name))
elif not self.project_path:
self.log.error("No valid project selected.")
else:
try:
project = prj.AirborneProject.load(self.project_path)
except FileNotFoundError:
self.log.error("Project could not be loaded from path: {}".format(self.project_path))
return
self.update_recent_files(self.recent_file, {project.name: project.projectdir})
# Show a progress dialog for loading the project (as we generate plots upon load)
progress = QtWidgets.QProgressDialog("Loading Project", "Cancel", 0, len(project), self)
progress.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.FramelessWindowHint | QtCore.Qt.CustomizeWindowHint)
progress.setModal(True)
progress.setMinimumDuration(0)
progress.setCancelButton(None) # Remove the cancel button. Possibly add a slot that has load() check and cancel
progress.setValue(1) # Set an initial value to show the dialog
main_window = MainWindow(project)
main_window.status.connect(progress.setLabelText)
main_window.progress.connect(progress.setValue)
main_window.load()
progress.close() # This isn't necessary if the min/max is set correctly, but just in case.
super().accept()
return main_window
def keyPressEvent(self, event):
""" Rewrite QDialog KeyPressEvent to enable on the fly model deletion
"""
if event.key() == QtCore.Qt.Key_Delete:
item = self.model_list.currentItem()
if not item:
return
if api.mail.delete_model(item.text()):
self.model_list.takeItem(self.model_list.row(item))
def __init__(self, parent=None):
QtWidgets.QDialog.__init__(self, parent=parent)
self.modinfo = None
self.setWindowTitle('Select a module...')
vlyt = QtWidgets.QVBoxLayout()
hlyt = QtWidgets.QHBoxLayout()
self.structtree = VQStructNamespacesView(parent=self)
hbox = QtWidgets.QWidget(parent=self)
ok = QtWidgets.QPushButton("Ok", parent=hbox)
cancel = QtWidgets.QPushButton("Cancel", parent=hbox)
self.structtree.doubleClicked.connect(self.dialog_activated)
ok.clicked.connect(self.dialog_ok)
cancel.clicked.connect(self.dialog_cancel)
hlyt.addStretch(1)
hlyt.addWidget(cancel)
hlyt.addWidget(ok)
hbox.setLayout(hlyt)
vlyt.addWidget(self.structtree)
vlyt.addWidget(hbox)
self.setLayout(vlyt)
self.resize(500, 500)
def main():
app = QtWidgets.QApplication([])
dlg = MemSearchDialog()
font = QtWidgets.QFont('Courier') # 'Consolas', 10)#'Courier New', 10)
dlg.hex_edit.setFont(font)
if dlg.exec_() == QtWidgets.QDialog.Accepted:
print(dlg.pattern)
print(dlg.filename)
def main():
app = QtWidgets.QApplication([])
dlg = MemDumpDialog(0x1234, '5678', 0x9ab)
if dlg.exec_() == QtWidgets.QDialog.Accepted:
print(dlg.filename)
print(dlg.size)
def __init__(self):
super().__init__()
if Wolke.Debug:
print("Initializing Minderpakt...")
self.formVor = QtWidgets.QDialog()
self.uiVor = CharakterMinderpakt.Ui_Dialog()
self.uiVor.setupUi(self.formVor)
self.formVor.setWindowFlags(
QtCore.Qt.Window |
QtCore.Qt.CustomizeWindowHint |
QtCore.Qt.WindowTitleHint |
QtCore.Qt.WindowCloseButtonHint)
self.uiVor.treeWidget.itemSelectionChanged.connect(self.vortClicked)
self.uiVor.treeWidget.header().setSectionResizeMode(0,1)
if len(Wolke.Char.vorteile) > 0:
self.currentVort = Wolke.Char.vorteile[0]
else:
self.currentVort = ""
self.initVorteile()
self.formVor.setWindowModality(QtCore.Qt.ApplicationModal)
self.formVor.show()
self.ret = self.formVor.exec_()
if self.ret == QtWidgets.QDialog.Accepted:
if self.currentVort not in Wolke.DB.vorteile:
self.minderpakt = None
else:
self.minderpakt = self.currentVort
else:
self.minderpakt = None
def __init__(self):
super().__init__()
Dialog = QtWidgets.QDialog()
ui = DatenbankSelectType.Ui_Dialog()
ui.setupUi(Dialog)
Dialog.setWindowFlags(
QtCore.Qt.Window |
QtCore.Qt.CustomizeWindowHint |
QtCore.Qt.WindowTitleHint |
QtCore.Qt.WindowCloseButtonHint)
Dialog.show()
ret = Dialog.exec_()
if ret == QtWidgets.QDialog.Accepted:
if ui.buttonTalent.isChecked():
self.entryType = "Talent"
elif ui.buttonVorteil.isChecked():
self.entryType = "Vorteil"
elif ui.buttonFertigkeit.isChecked():
self.entryType = "Fertigkeit"
elif ui.buttonUebernatuerlich.isChecked():
self.entryType = "Uebernatuerlich"
else:
self.entryType = "Waffe"
else:
self.entryType = None
def __init__(self, vorteil=None):
super().__init__()
if vorteil is None:
vorteil = Fertigkeiten.Vorteil()
vorteilDialog = QtWidgets.QDialog()
ui = DatenbankEditVorteil.Ui_talentDialog()
ui.setupUi(vorteilDialog)
vorteilDialog.setWindowFlags(
QtCore.Qt.Window |
QtCore.Qt.CustomizeWindowHint |
QtCore.Qt.WindowTitleHint |
QtCore.Qt.WindowCloseButtonHint)
ui.nameEdit.setText(vorteil.name)
ui.kostenEdit.setValue(vorteil.kosten)
ui.comboNachkauf.setCurrentText(vorteil.nachkauf)
ui.comboTyp.setCurrentIndex(vorteil.typ)
ui.voraussetzungenEdit.setPlainText(Hilfsmethoden.VorArray2Str(vorteil.voraussetzungen, None))
ui.textEdit.setPlainText(vorteil.text)
ui.checkVariable.setChecked(vorteil.variable!=0)
vorteilDialog.show()
ret = vorteilDialog.exec_()
if ret == QtWidgets.QDialog.Accepted:
self.vorteil = Fertigkeiten.Vorteil()
self.vorteil.name = ui.nameEdit.text()
self.vorteil.kosten = ui.kostenEdit.value()
self.vorteil.nachkauf = ui.comboNachkauf.currentText()
self.vorteil.voraussetzungen = Hilfsmethoden.VorStr2Array(ui.voraussetzungenEdit.toPlainText(),None)
self.vorteil.typ = ui.comboTyp.currentIndex()
self.vorteil.variable = int(ui.checkVariable.isChecked())
self.vorteil.text = ui.textEdit.toPlainText()
else:
self.vorteil = None
def __init__(self, parent=None):
super().__init__()
self.parent = parent
self.resize(400, 75)
self.setWindowFlags(Qt.Tool)
self.move(settings().value("Youtube/position") or QPoint(250, 250))
self.setWindowIcon(QIcon.fromTheme("pisiplayer"))
self.setWindowTitle(self.tr("Youtube'dan Oynat"))
self.setStyleSheet("QDialog {background-color: rgba(255, 255, 255, 200); border-color: rgba(255, 255, 255, 200); border-width: 1px; border-style outset;}")
self.setVisible(False)
vlayout = QVBoxLayout()
self.setLayout(vlayout)
hlayout = QHBoxLayout()
vlayout.addLayout(hlayout)
self.tube_line = QLineEdit(self)
self.tube_line.setMinimumHeight(30)
self.tube_line.setStyleSheet("QLineEdit {background-color: white; color: black; border-radius: 3px;\
border-color: lightgray; border-style: solid; border-width:2px;}")
self.tube_line.setPlaceholderText("https://www.youtube.com/watch?v=mY--4-vzY6E")
hlayout.addWidget(self.tube_line)
self.tube_button = QPushButton(self)
self.tube_button.setMinimumHeight(30)
self.tube_button.setStyleSheet("QPushButton {background-color: #55aaff; color: white; border-width:1px; font-weight: bold; \
border-color: #55aaff; border-style: solid; padding-left: 3px; padding-right: 3px; border-radius: 3px;}")
self.tube_button.setText(self.tr("Video Oynat"))
hlayout.addWidget(self.tube_button)
self.tube_warning = QLabel(self)
self.tube_warning.setVisible(False)
self.tube_warning.setStyleSheet("QLabel {color: rgb(255, 0, 0); font-weight: bold; background-color: white;}")
self.tube_warning.setText(self.tr("Verilen ba?lant? geçersiz!"))
vlayout.addWidget(self.tube_warning)
self.tube_line.returnPressed.connect(self.tube_button.animateClick)
self.tube_button.clicked.connect(self.videoParse)
def Download(self):
import bb_downloader_downloadUi as downloadUi
DownloadDialog = QtWidgets.QDialog(self.MainWindow)
ui = downloadUi.Ui_DownloadDialog(DownloadDialog, self.download_list, self.account)
ui.setupUi(DownloadDialog)
DownloadDialog.exec_()
def setupUI(self):
#------------------------------
# main_layout auto creation for holding all the UI elements
#------------------------------
main_layout = None
if isinstance(self, QtWidgets.QMainWindow):
main_widget = QtWidgets.QWidget()
self.setCentralWidget(main_widget)
main_layout = self.quickLayout('vbox', 'main_layout') # grid for auto fill window size
main_widget.setLayout(main_layout)
else:
# main_layout for QDialog
main_layout = self.quickLayout('vbox', 'main_layout')
self.setLayout(main_layout)
#------------------------------
# user ui creation part
#------------------------------
# + template: qui version since universal tool template v7
# - no extra variable name, all text based creation and reference
self.qui('dict_table | source_txtEdit | result_txtEdit','info_split;v')
self.qui('filePath_input | fileLoad_btn;Load | fileLang_choice | fileExport_btn;Export', 'fileBtn_layout;hbox')
self.qui('info_split | process_btn;Process and Update Memory From UI | fileBtn_layout', 'main_layout')
self.uiList["source_txtEdit"].setWrap(0)
self.uiList["result_txtEdit"].setWrap(0)
#------------- end ui creation --------------------
for name,each in self.uiList.items():
if isinstance(each, QtWidgets.QLayout) and name!='main_layout' and not name.endswith('_grp_layout'):
each.setContentsMargins(0,0,0,0) # clear extra margin some nested layout
#self.quickInfo('Ready')
GearBox_template_1010.py 文件源码
项目:universal_tool_template.py
作者: shiningdesign
项目源码
文件源码
阅读 61
收藏 0
点赞 0
评论 0
def setupUI(self, layout='grid'):
#------------------------------
# main_layout auto creation for holding all the UI elements
#------------------------------
main_layout = None
if isinstance(self, QtWidgets.QMainWindow):
main_widget = QtWidgets.QWidget()
self.setCentralWidget(main_widget)
main_layout = self.quickLayout(layout, 'main_layout') # grid for auto fill window size
main_widget.setLayout(main_layout)
else:
# main_layout for QDialog
main_layout = self.quickLayout(layout, 'main_layout')
self.setLayout(main_layout)
universal_tool_template_0904.py 文件源码
项目:universal_tool_template.py
作者: shiningdesign
项目源码
文件源码
阅读 30
收藏 0
点赞 0
评论 0
def setupUI(self, layout='grid'):
#------------------------------
# main_layout auto creation for holding all the UI elements
#------------------------------
main_layout = None
if isinstance(self, QtWidgets.QMainWindow):
main_widget = QtWidgets.QWidget()
self.setCentralWidget(main_widget)
main_layout = self.quickLayout(layout, 'main_layout') # grid for auto fill window size
main_widget.setLayout(main_layout)
else:
# main_layout for QDialog
main_layout = self.quickLayout(layout, 'main_layout')
self.setLayout(main_layout)
universal_tool_template_0803.py 文件源码
项目:universal_tool_template.py
作者: shiningdesign
项目源码
文件源码
阅读 18
收藏 0
点赞 0
评论 0
def setupWin(self):
self.setWindowTitle(self.name + " - v" + self.version + " - host: " + hostMode)
self.setWindowIcon(self.icon)
# initial win drag position
self.drag_position=QtGui.QCursor.pos()
self.setGeometry(500, 300, 250, 110) # self.resize(250,250)
#------------------------------
# template list: for frameless or always on top option
#------------------------------
# - template : keep ui always on top of all;
# While in Maya, dont set Maya as its parent
'''
self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
'''
# - template: hide ui border frame;
# While in Maya, use QDialog instead, as QMainWindow will make it disappear
'''
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
'''
# - template: best solution for Maya QDialog without parent, for always on-Top frameless ui
'''
self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint)
'''
# - template: for transparent and non-regular shape ui
# note: use it if you set main ui to transparent, and want to use alpha png as irregular shape window
# note: black color better than white for better look of semi trans edge, like pre-mutiply
'''
self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
self.setStyleSheet("background-color: rgba(0, 0, 0,0);")
'''
#############################################
# customized SUPER quick ui function for speed up programming
#############################################
universal_tool_template_0903.py 文件源码
项目:universal_tool_template.py
作者: shiningdesign
项目源码
文件源码
阅读 25
收藏 0
点赞 0
评论 0
def setupUI(self):
#------------------------------
# main_layout auto creation for holding all the UI elements
#------------------------------
main_layout = None
if isinstance(self, QtWidgets.QMainWindow):
main_widget = QtWidgets.QWidget()
self.setCentralWidget(main_widget)
main_layout = self.quickLayout('vbox', 'main_layout') # grid for auto fill window size
main_widget.setLayout(main_layout)
else:
# main_layout for QDialog
main_layout = self.quickLayout('vbox', 'main_layout')
self.setLayout(main_layout)
universal_tool_template_0903.py 文件源码
项目:universal_tool_template.py
作者: shiningdesign
项目源码
文件源码
阅读 23
收藏 0
点赞 0
评论 0
def setupWin(self):
super(self.__class__,self).setupWin()
self.setGeometry(500, 300, 250, 110) # self.resize(250,250)
#------------------------------
# template list: for frameless or always on top option
#------------------------------
# - template : keep ui always on top of all;
# While in Maya, dont set Maya as its parent
'''
self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
'''
# - template: hide ui border frame;
# While in Maya, use QDialog instead, as QMainWindow will make it disappear
'''
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
'''
# - template: best solution for Maya QDialog without parent, for always on-Top frameless ui
'''
self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint)
'''
# - template: for transparent and non-regular shape ui
# note: use it if you set main ui to transparent, and want to use alpha png as irregular shape window
# note: black color better than white for better look of semi trans edge, like pre-mutiply
'''
self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
self.setStyleSheet("background-color: rgba(0, 0, 0,0);")
'''
universal_tool_template_1010.py 文件源码
项目:universal_tool_template.py
作者: shiningdesign
项目源码
文件源码
阅读 26
收藏 0
点赞 0
评论 0
def setupUI(self, layout='grid'):
#------------------------------
# main_layout auto creation for holding all the UI elements
#------------------------------
main_layout = None
if isinstance(self, QtWidgets.QMainWindow):
main_widget = QtWidgets.QWidget()
self.setCentralWidget(main_widget)
main_layout = self.quickLayout(layout, 'main_layout') # grid for auto fill window size
main_widget.setLayout(main_layout)
else:
# main_layout for QDialog
main_layout = self.quickLayout(layout, 'main_layout')
self.setLayout(main_layout)