Python PyQt5.QtCore.Qt.WA_DeleteOnClose() Examples

The following are 30 code examples of PyQt5.QtCore.Qt.WA_DeleteOnClose(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module PyQt5.QtCore.Qt , or try the search function .
Example #1
Source File: dropbox.py    From Pythonic with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, parent):

        super().__init__()
        self.mod_path = os.path.dirname(Pythonic.__file__)

        self.setAttribute(Qt.WA_DeleteOnClose)
        self.parent = parent
        self.label = QLabel()
        self.label.setPixmap(QPixmap(join(self.mod_path, 'images/tmp.png')).scaled(160, 80))
        self.setAcceptDrops(True)
        self.type = None
        self.config = None

        self.layout = QHBoxLayout()
        self.layout.setContentsMargins(20, 30, 30, 30)

        self.icon_bar = IconBar()
        self.icon_bar.setVisible(False)

        self.layout.addWidget(self.label)
        self.layout.addWidget(self.icon_bar)

        self.setLayout(self.layout) 
Example #2
Source File: misccommands.py    From qutebrowser with GNU General Public License v3.0 6 votes vote down vote up
def _print_preview(tab: apitypes.Tab) -> None:
    """Show a print preview."""
    def print_callback(ok: bool) -> None:
        if not ok:
            message.error("Printing failed!")

    tab.printing.check_preview_support()
    diag = QPrintPreviewDialog(tab)
    diag.setAttribute(Qt.WA_DeleteOnClose)
    diag.setWindowFlags(
        diag.windowFlags() |  # type: ignore[operator, arg-type]
        Qt.WindowMaximizeButtonHint |
        Qt.WindowMinimizeButtonHint)
    diag.paintRequested.connect(functools.partial(
        tab.printing.to_printer, callback=print_callback))
    diag.exec_() 
Example #3
Source File: CSVImportDialog.py    From urh with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, filename="", parent=None):
        super().__init__(parent)
        self.ui = Ui_DialogCSVImport()
        self.ui.setupUi(self)
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.setWindowFlags(Qt.Window)

        self.ui.btnAutoDefault.hide()

        completer = QCompleter()
        completer.setModel(QDirModel(completer))
        self.ui.lineEditFilename.setCompleter(completer)

        self.filename = None  # type: str
        self.ui.lineEditFilename.setText(filename)
        self.update_file()

        self.ui.tableWidgetPreview.setColumnHidden(self.COLUMNS["T"], True)
        self.update_preview()

        self.create_connects() 
Example #4
Source File: Widgets.py    From Jade-Application-Kit with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, parent, title, msg, on_confirm):
        """
        * :param parent: Parent window
        * :param window_title:str
        * :param msg:str
        * :param on_confirm: Function to execute use parenthesis ()
        """
        super().__init__(parent)
        reply = QMessageBox.question(self, title, msg, QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
        self.setAttribute(Qt.WA_DeleteOnClose, True)
        self.setWindowTitle(title)
        view = Instance.retrieve("view")
        if view:
            self.setWindowIcon(view.icon())
        if reply == QMessageBox.Yes:
            on_confirm()
        else:
            self.destroy()
        self.show() 
Example #5
Source File: network_node_creation_panel.py    From pyNMS with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, controller):
        super().__init__(controller)
        self.controller = controller
        self.setTitle('Node creation')
        self.setMinimumSize(300, 300)
        self.setAcceptDrops(True)
                
        # exit connection lost because of the following lines
        layout = QtWidgets.QGridLayout(self)
        for index, subtype in enumerate(network_node_subtype):
            pixmap = controller.pixmaps['default'][subtype]
            label = QLabel(self)
            label.setMaximumSize(50, 50)
            label.subtype = subtype
            label.setPixmap(pixmap)
            label.setScaledContents(True)
            label.show()
            label.setAttribute(Qt.WA_DeleteOnClose)
            layout.addWidget(label, index // 4, index % 4) 
Example #6
Source File: Widgets.py    From Jade-Application-Kit with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, parent, title, msg, on_confirm):
        """
        * :param parent: Parent window
        * :param window_title:str
        * :param msg:str
        * :param on_confirm: Function to execute use parenthesis ()
        """
        super().__init__(parent)
        reply = QMessageBox.question(self, title, msg, QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
        self.setAttribute(Qt.WA_DeleteOnClose, True)
        self.setWindowTitle(title)
        view = Instance.retrieve("view")
        if view:
            self.setWindowIcon(view.icon())
        if reply == QMessageBox.Yes:
            on_confirm()
        else:
            self.destroy()
        self.show() 
Example #7
Source File: site_panel.py    From pyNMS with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, controller):
        super().__init__(controller)
        self.controller = controller
        self.setTitle('Site management')
        self.setMinimumSize(300, 300)
        self.setAcceptDrops(True)
                
        # exit connection lost because of the following lines
        layout = QtWidgets.QGridLayout(self)
        pixmap = controller.pixmaps['default']['site']
        label = QLabel(self)
        label.setMaximumSize(200, 200)
        label.subtype = 'site'
        label.setPixmap(pixmap)
        label.setScaledContents(True)
        label.show()
        label.setAttribute(Qt.WA_DeleteOnClose)
        layout.addWidget(label, 0, 0) 
Example #8
Source File: internal_node_creation_panel.py    From pyNMS with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, controller):
        super().__init__(controller)
        self.controller = controller
        self.setTitle('Object creation')
        self.setMinimumSize(300, 300)
        self.setAcceptDrops(True)
                
        # exit connection lost because of the following lines
        layout = QtWidgets.QGridLayout(self)
        for index, subtype in enumerate(internal_node_subtype):
            pixmap = controller.pixmaps['default'][subtype]
            label = QLabel(self)
            label.setMaximumSize(100, 100)
            label.subtype = subtype
            label.setPixmap(pixmap)
            label.setScaledContents(True)
            label.show()
            label.setAttribute(Qt.WA_DeleteOnClose)
            layout.addWidget(label, index // 2, index % 2) 
Example #9
Source File: MessageTypeDialog.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, message_type: MessageType, parent=None):
        super().__init__(parent)
        self.ui = Ui_DialogMessageType()
        self.ui.setupUi(self)
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.setWindowFlags(Qt.Window)

        operator_descriptions = list(OPERATION_DESCRIPTION.values())
        operator_descriptions.sort()

        self.setWindowTitle(self.tr("Rules for {}".format(message_type.name)))
        self.message_type = message_type
        self.original_ruleset = copy.deepcopy(message_type.ruleset)
        self.original_assigned_status = message_type.assigned_by_ruleset
        self.ruleset_table_model = RulesetTableModel(message_type.ruleset, operator_descriptions, parent=self)
        self.ui.tblViewRuleset.setModel(self.ruleset_table_model)

        self.ui.btnRemoveRule.setEnabled(len(message_type.ruleset) > 0)
        self.set_ruleset_ui_status()

        self.ui.rbAssignAutomatically.setChecked(self.message_type.assigned_by_ruleset)
        self.ui.rbAssignManually.setChecked(self.message_type.assign_manually)

        self.ui.tblViewRuleset.setItemDelegateForColumn(2, ComboBoxDelegate(["Bit", "Hex", "ASCII"], parent=self))
        self.ui.tblViewRuleset.setItemDelegateForColumn(3, ComboBoxDelegate(operator_descriptions, parent=self))

        for i in range(len(message_type.ruleset)):
            self.open_editors(i)

        self.ui.cbRulesetMode.setCurrentIndex(self.message_type.ruleset.mode.value)

        self.create_connects()
        self.restoreGeometry(settings.read("{}/geometry".format(self.__class__.__name__), type=bytes)) 
Example #10
Source File: debugwindow.py    From Pythonic with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, message, source):

        super().__init__()
    
        self.setAttribute(Qt.WA_DeleteOnClose, True)
        self.source = source
        self.message = message 
Example #11
Source File: demo_app1.py    From face-identification-tpe with MIT License 5 votes vote down vote up
def __init__(self, scores, comp):
        super().__init__()
        self.initUI(scores, comp)
        self.setAttribute(Qt.WA_DeleteOnClose) 
Example #12
Source File: pid_dialogs.py    From artisan with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent = None, aw = None):
        super(DTApidDlgControl,self).__init__(parent, aw)
        self.setModal(True)
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.setWindowTitle(QApplication.translate("Form Caption","Delta DTA PID Control",None))
        self.status = QStatusBar()
        self.status.setSizeGripEnabled(False)
        self.status.showMessage(QApplication.translate("StatusBar","Work in Progress",None),5000)
        svlabel = QLabel(QApplication.translate("Label", "SV", None))
        self.svedit = QLineEdit(str(self.aw.dtapid.dtamem["sv"][0]))
        self.svedit.setValidator(self.aw.createCLocaleDoubleValidator(0., 999.,1, self.svedit))
        readsvbutton = QPushButton(QApplication.translate("Button","Read", None))
        writesvbutton = QPushButton(QApplication.translate("Button","Write", None))
        readsvbutton.clicked.connect(self.readsv)
        writesvbutton.clicked.connect(self.writesv)
        tab1Layout = QGridLayout()
        tab1Layout.addWidget(svlabel,0,0)
        tab1Layout.addWidget(self.svedit,0,1)
        tab1Layout.addWidget(readsvbutton,0,2)
        tab1Layout.addWidget(writesvbutton,0,3)
        ############################
        TabWidget = QTabWidget()
        C1Widget = QWidget()
        C1Widget.setLayout(tab1Layout)
        TabWidget.addTab(C1Widget,QApplication.translate("Tab","General",None))
        mainlayout = QVBoxLayout()
        mainlayout.addWidget(self.status,0)
        mainlayout.addWidget(TabWidget,1)
        self.setLayout(mainlayout) 
Example #13
Source File: dialogs.py    From artisan with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent=None, aw = None):
        super(ArtisanDialog,self).__init__(parent)
        self.aw = aw # the Artisan application window
        
        # IMPORTANT NOTE: if dialog items have to be access after it has been closed, this Qt.WA_DeleteOnClose attribute 
        # has to be set to False explicitly in its initializer (like in comportDlg) to avoid the early GC and one might
        # want to use a dialog.deleteLater() call to explicitly have the dialog and its widgets GCe
        # or rather use sip.delete(dialog) if the GC via .deleteLater() is prevented by a link to a parent object (parent not None)
        self.setAttribute(Qt.WA_DeleteOnClose, True)

#        if platf == 'Windows':
# setting those Windows flags could be the reason for some instabilities on Windows
#            windowFlags = self.windowFlags()
#        #windowFlags &= ~Qt.WindowContextHelpButtonHint # remove help button
#        #windowFlags &= ~Qt.WindowMaximizeButtonHint # remove maximise button
#        #windowFlags &= ~Qt.WindowMinMaxButtonsHint  # remove min/max combo
#        #windowFlags |= Qt.WindowMinimizeButtonHint  # Add minimize  button
#        windowFlags |= Qt.WindowSystemMenuHint  # Adds a window system menu, and possibly a close button
#            windowFlags |= Qt.WindowMinMaxButtonsHint  # add min/max combo
#            self.setWindowFlags(windowFlags)

        # configure standard dialog buttons
        self.dialogbuttons = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel,Qt.Horizontal)
        self.dialogbuttons.button(QDialogButtonBox.Ok).setDefault(True)
        self.dialogbuttons.button(QDialogButtonBox.Ok).setAutoDefault(True)
        self.dialogbuttons.button(QDialogButtonBox.Cancel).setDefault(False)
        self.dialogbuttons.button(QDialogButtonBox.Cancel).setAutoDefault(False)
        self.dialogbuttons.button(QDialogButtonBox.Ok).setFocusPolicy(Qt.StrongFocus) # to add to tab focus switch
        if self.aw.locale not in self.aw.qtbase_locales:
            self.dialogbuttons.button(QDialogButtonBox.Ok).setText(QApplication.translate("Button","OK", None))
            self.dialogbuttons.button(QDialogButtonBox.Cancel).setText(QApplication.translate("Button","Cancel",None))
        # add additional CMD-. shortcut to close the dialog
        self.dialogbuttons.button(QDialogButtonBox.Cancel).setShortcut(QKeySequence("Ctrl+."))
        # add additional CMD-W shortcut to close this dialog (ESC on Mac OS X)
        cancelAction = QAction(self, triggered=lambda _:self.dialogbuttons.rejected.emit())
        try:
            cancelAction.setShortcut(QKeySequence.Cancel)
        except:
            pass
        self.dialogbuttons.button(QDialogButtonBox.Cancel).addActions([cancelAction]) 
Example #14
Source File: exceptwindow.py    From Pythonic with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, message, position):

        super().__init__()
        self.setMinimumSize(400, 300)
        self.setWindowFlags(Qt.Window)
        self.setAttribute(Qt.WA_DeleteOnClose, True)
        self.message = message
        self.position = position
        self.initUI()
        self.raiseWindow() 
Example #15
Source File: ModulationParametersDialog.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parameters: list, modulation_type: str, parent=None):
        super().__init__(parent)
        self.ui = Ui_DialogModulationParameters()
        self.ui.setupUi(self)
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.setWindowFlags(Qt.Window)

        self.parameters = parameters
        self.num_bits = int(math.log2(len(parameters)))

        if "FSK" in modulation_type:
            self.ui.tblSymbolParameters.setItemDelegateForColumn(1, KillerSpinBoxDelegate(-1e12, 1e12, self))
            self.ui.tblSymbolParameters.horizontalHeaderItem(1).setText("Frequency in Hz")
        elif "ASK" in modulation_type:
            self.ui.tblSymbolParameters.horizontalHeaderItem(1).setText("Amplitude")
            self.ui.tblSymbolParameters.setItemDelegateForColumn(1, SpinBoxDelegate(0, 100, self, "%"))
        elif "PSK" in modulation_type:
            self.ui.tblSymbolParameters.setItemDelegateForColumn(1, SpinBoxDelegate(-360, 360, self, "°"))
            self.ui.tblSymbolParameters.horizontalHeaderItem(1).setText("Phase")

        fmt = "{0:0" + str(self.num_bits) + "b}"
        self.ui.tblSymbolParameters.setRowCount(len(parameters))
        for i, parameter in enumerate(parameters):
            item = QTableWidgetItem(fmt.format(i))
            font = item.font()
            font.setBold(True)
            item.setFont(font)
            item.setFlags(Qt.ItemIsEnabled)
            self.ui.tblSymbolParameters.setItem(i, 0, item)

            item = QTableWidgetItem()
            item.setData(Qt.DisplayRole, self.parameters[i])
            self.ui.tblSymbolParameters.setItem(i, 1, item)
            self.ui.tblSymbolParameters.openPersistentEditor(self.ui.tblSymbolParameters.item(i, 1))

        self.create_connects() 
Example #16
Source File: AdvancedModulationOptionsDialog.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, pause_threshold: int, message_length_divisor: int, parent=None):
        super().__init__(parent)
        self.ui = Ui_DialogAdvancedModSettings()
        self.ui.setupUi(self)
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.setWindowFlags(Qt.Window)

        self.pause_threshold = pause_threshold
        self.message_length_divisor = message_length_divisor

        self.ui.spinBoxPauseThreshold.setValue(pause_threshold)
        self.ui.spinBoxMessageLengthDivisor.setValue(message_length_divisor)

        self.create_connects() 
Example #17
Source File: SendRecvDialog.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, project_manager: ProjectManager, is_tx: bool, continuous_send_mode=False, parent=None, testing_mode=False):
        super().__init__(parent)
        self.is_tx = is_tx
        self.update_interval = 25

        # This flag is needed. Will cause memory leak otherwise.
        self.setAttribute(Qt.WA_DeleteOnClose)

        self.setWindowFlags(Qt.Window)
        self.testing_mode = testing_mode

        self.ui = Ui_SendRecvDialog()
        self.ui.setupUi(self)
        util.set_splitter_stylesheet(self.ui.splitter)

        self.ui.txtEditErrors.setFont(util.get_monospace_font())

        self.graphics_view = None  # type: QGraphicsView

        self.backend_handler = BackendHandler()

        self.ui.btnStop.setEnabled(False)
        self.ui.btnSave.setEnabled(False)

        self.start = 0

        self.device_settings_widget = DeviceSettingsWidget(project_manager, is_tx,
                                                           backend_handler=self.backend_handler,
                                                           continuous_send_mode=continuous_send_mode)
        self.ui.scrollAreaWidgetContents_2.layout().insertWidget(0, self.device_settings_widget)

        if testing_mode:
            self.device_settings_widget.ui.cbDevice.setCurrentText(NetworkSDRInterfacePlugin.NETWORK_SDR_NAME)

        self.timer = QTimer(self)
        self.restoreGeometry(settings.read("{}/geometry".format(self.__class__.__name__), type=bytes))

        self.ui.splitter.setSizes([int(0.4 * self.width()), int(0.6 * self.width())]) 
Example #18
Source File: SignalDetailsDialog.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, signal, parent=None):
        super().__init__(parent)
        self.signal = signal
        self.ui = Ui_SignalDetails()
        self.ui.setupUi(self)
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.setWindowFlags(Qt.Window)

        file = self.signal.filename

        self.ui.lblName.setText(self.signal.name)

        if os.path.isfile(file):
            self.ui.lblFile.setText(file)
            self.ui.lblFileSize.setText(locale.format_string("%.2fMB", os.path.getsize(file) / (1024 ** 2)))
            self.ui.lFileCreated.setText(time.ctime(os.path.getctime(file)))
        else:
            self.ui.lblFile.setText(self.tr("signal file not found"))
            self.ui.lblFileSize.setText("-")
            self.ui.lFileCreated.setText("-")

        self.ui.lblSamplesTotal.setText("{0:n}".format(self.signal.num_samples).replace(",", " "))
        self.ui.dsb_sample_rate.setValue(self.signal.sample_rate)
        self.set_duration()

        self.ui.dsb_sample_rate.valueChanged.connect(self.on_dsb_sample_rate_value_changed)
        self.restoreGeometry(settings.read("{}/geometry".format(self.__class__.__name__), type=bytes)) 
Example #19
Source File: InsertSinePlugin.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def dialog_ui(self) -> QDialog:
        if self.__dialog_ui is None:
            dir_name = os.path.dirname(os.readlink(__file__)) if os.path.islink(__file__) else os.path.dirname(__file__)

            logging.getLogger().setLevel(logging.WARNING)
            self.__dialog_ui = uic.loadUi(os.path.realpath(os.path.join(dir_name, "insert_sine_dialog.ui")))
            logging.getLogger().setLevel(logger.level)

            self.__dialog_ui.setAttribute(Qt.WA_DeleteOnClose)
            self.__dialog_ui.setModal(True)
            self.__dialog_ui.doubleSpinBoxAmplitude.setValue(self.__amplitude)
            self.__dialog_ui.doubleSpinBoxFrequency.setValue(self.__frequency)
            self.__dialog_ui.doubleSpinBoxPhase.setValue(self.__phase)
            self.__dialog_ui.doubleSpinBoxSampleRate.setValue(self.__sample_rate)
            self.__dialog_ui.doubleSpinBoxNSamples.setValue(self.__num_samples)
            self.__dialog_ui.lineEditTime.setValidator(
                QRegExpValidator(QRegExp(r"[0-9]+([nmµ]?|([\.,][0-9]{1,3}[nmµ]?))?$"))
            )

            scene_manager = SceneManager(self.dialog_ui.graphicsViewSineWave)
            self.__dialog_ui.graphicsViewSineWave.scene_manager = scene_manager
            self.insert_indicator = scene_manager.scene.addRect(0, -2, 0, 4,
                                                                QPen(QColor(Qt.transparent), 0),
                                                                QBrush(self.INSERT_INDICATOR_COLOR))
            self.insert_indicator.stackBefore(scene_manager.scene.selection_area)

            self.set_time()

        return self.__dialog_ui 
Example #20
Source File: basic_stack_window.py    From Pythonic with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent):

        super().__init__(parent)
        self.parent = parent
        self.setAttribute(Qt.WA_DeleteOnClose, True)
        self.timestamp = strftime('%H:%M:%S', localtime()) 
Example #21
Source File: elementeditor.py    From Pythonic with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent):
        super().__init__(parent)
        self.setMinimumSize(400, 500)
        self.setWindowFlags(Qt.Window)
        self.setWindowModality(Qt.WindowModal)
        self.setAttribute(Qt.WA_DeleteOnClose, True)

        logging.debug('ElementEditor::__init__() called') 
Example #22
Source File: webpage.py    From qutebrowser with GNU General Public License v3.0 5 votes vote down vote up
def on_print_requested(self, frame):
        """Handle printing when requested via javascript."""
        printdiag = QPrintDialog()
        printdiag.setAttribute(Qt.WA_DeleteOnClose)
        printdiag.open(lambda: frame.print(printdiag.printer())) 
Example #23
Source File: SelectApp.py    From tierpsy-tracker with MIT License 5 votes vote down vote up
def appCall(self, name):
        appFun, label = widget_lists[name]
        ui = appFun()
        ui.setWindowTitle(label)
        ui.show()
        ui.setAttribute(Qt.WA_DeleteOnClose) 
Example #24
Source File: AnalysisProgress.py    From tierpsy-tracker with MIT License 5 votes vote down vote up
def __init__(self, process_thread):
        super(AnalysisProgress, self).__init__()
        self.ui = Ui_AnalysisProgress()
        self.ui.setupUi(self)
        self.ui.progressBar.setValue(0)

        self.setAttribute(Qt.WA_DeleteOnClose)

        self.process_thread = process_thread
        self.startRecieverThread()

        self.process_thread.task_done.connect(self.task_done)
        self.process_thread.task_done.connect(self.reciever.break_run)

        self.process_thread.start() 
Example #25
Source File: Widgets.py    From Jade-Application-Kit with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent, title, msg):
        """
        * :param parent: Parent window
        * :param msg:str
        * :param on_confirm: Function to execute omit parenthesis ()
        """
        super().__init__()
        self.setAttribute(Qt.WA_DeleteOnClose, True)
        self.setWindowTitle(title)
        QMessageBox.information(parent, title, msg, QMessageBox.Ok)
        self.show() 
Example #26
Source File: crashdialog.py    From qutebrowser with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, pages, cmdhist, qobjects, parent=None):
        super().__init__(False, parent)
        self.setAttribute(Qt.WA_DeleteOnClose)
        self._pages = pages
        self._cmdhist = cmdhist
        self._qobjects = qobjects
        self._set_crash_info() 
Example #27
Source File: crashdialog.py    From qutebrowser with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, debug, text, parent=None):
        super().__init__(debug, parent)
        self._log = text
        self.setAttribute(Qt.WA_DeleteOnClose)
        self._set_crash_info()
        self._type, self._func = parse_fatal_stacktrace(self._log) 
Example #28
Source File: msgbox.py    From qutebrowser with GNU General Public License v3.0 5 votes vote down vote up
def msgbox(parent, title, text, *, icon, buttons=QMessageBox.Ok,
           on_finished=None, plain_text=None):
    """Display a QMessageBox with the given icon.

    Args:
        parent: The parent to set for the message box.
        title: The title to set.
        text: The text to set.
        buttons: The buttons to set (QMessageBox::StandardButtons)
        on_finished: A slot to connect to the 'finished' signal.
        plain_text: Whether to force plain text (True) or rich text (False).
                    None (the default) uses Qt's auto detection.

    Return:
        A new QMessageBox.
    """
    if objects.args.no_err_windows:
        print('Message box: {}; {}'.format(title, text), file=sys.stderr)
        return DummyBox()

    box = QMessageBox(parent)
    box.setAttribute(Qt.WA_DeleteOnClose)
    box.setIcon(icon)
    box.setStandardButtons(buttons)
    if on_finished is not None:
        box.finished.connect(on_finished)
    if plain_text:
        box.setTextFormat(Qt.PlainText)
    elif plain_text is not None:
        box.setTextFormat(Qt.RichText)
    box.setWindowTitle(title)
    box.setText(text)
    box.show()
    return box 
Example #29
Source File: GetAllParameters.py    From tierpsy-tracker with MIT License 4 votes vote down vote up
def initUI(self):
        
        grid = QGridLayout()
        
        self.widgetlabels = {}
        for ii, (name, value) in enumerate(default_param.items()):
            row = ii // self.param_per_row * 2
            col = (ii % self.param_per_row)
            

            w = ParamWidget(name, value=value)
            self.widgetlabels[name] = w

            if isinstance(w.widget, QCheckBox):
                grid.addWidget(w.widget, row, col, 2, 1)
                w.widget.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
            else:
                label = QLabel(name)
                grid.addWidget(label, row, col, 1, 1)
                label.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
                if isinstance(w.widget, QGridLayout):
                    grid.addLayout(w.widget, row+1, col, 1, 1)
                else:
                    grid.addWidget(w.widget, row+1, col, 1, 1)
                    w.widget.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
        
        spacer = QSpacerItem(
            40,
            20,
            QSizePolicy.Preferred,
            QSizePolicy.Preferred)


        #add buttons at the end
        self.pushbutton_cancel = QPushButton('Cancel')
        self.pushbutton_OK = QPushButton('OK')
        
        hbox = QHBoxLayout()
        hbox.addStretch(1)
        hbox.addWidget(self.pushbutton_OK)
        hbox.addWidget(self.pushbutton_cancel)

        vbox = QVBoxLayout()
        vbox.addStretch(1)
        vbox.addLayout(grid)
        vbox.addLayout(hbox)
                
        self.setLayout(vbox)

        #set modal so the other window is blocked
        self.setModal(True)
        self.show()
        self.setAttribute(Qt.WA_DeleteOnClose) 
Example #30
Source File: Widgets.py    From Jade-Application-Kit with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self, config):
        super().__init__()
        self.config = config
        if config["window"]["backgroundImage"]:
            # Transparency must be set to True
            self.label = QLabel(self)
            self.setObjectName("JAKWindow")
            self.setBackgroundImage(config["window"]["backgroundImage"])
        self.video_corner = False
        self.center = getScreenGeometry().center()
        self.setWindowTitle(config['window']["title"])
        self.setWindowFlags(config['window']["setFlags"])
        self.setWAttribute(Qt.WA_DeleteOnClose)
        for attr in config['window']["setAttribute"]:
            self.setWAttribute(attr)

        if config['window']["state"]:
            self.setWindowState(config['window']["state"])

        if config['window']["icon"] and os.path.isfile(config['window']["icon"]):
            self.icon = QIcon(config['window']["icon"])
        else:
            print(f"icon not found: {config['window']['icon']}")
            print("loading default icon:")
            self.icon = QIcon.fromTheme("applications-internet")

        view = Instance.retrieve("view")
        if view:
            self.view = view
            self.setCentralWidget(self.view)
            self.view.iconChanged.connect(self._icon_changed)
            if config['webview']["online"]:
                self.view.page().titleChanged.connect(self.status_message)

        if config['window']["transparent"]:
            # Set Background Transparency
            self.setWAttribute(Qt.WA_TranslucentBackground)
            self.setAutoFillBackground(True)

        if config['webview']["online"]:
            # Do not display toolbar or system tray offline
            if config['window']["toolbar"]:
                self.toolbar = JToolbar(self, config['window']["toolbar"], self.icon, config['window']["title"])
                self.addToolBar(self.toolbar)
            self.setMenuBar(Menu(self, config['window']["menus"]))
        else:
            if config['window']["showHelpMenu"]:
                self.setMenuBar(Menu(self, config['window']["menus"]))
                self.view.page().titleChanged.connect(self.status_message)

        if config['window']["SystemTrayIcon"]: 
            self.system_tray = SystemTrayIcon(self.icon, self, config)
                
        if config["debug"]:
            self.showInspector()                       
        self._set_icons()