def __init__(self, parent=None): super(WelcomeDialog, self).__init__(parent=parent) self._prefs = parent.prefs self._sub_titles = [ ['duck', 'dumb', 'doctor', 'dutch', 'dark', 'dirty', 'debugging'], ['warriors', 'wardrobes', 'waffles', 'wishes', 'worcestershire'], ['are', 'aren\'t', 'ain\'t', 'appears to be'], ['rich', 'real', 'riffle', 'retarded', 'rock'], [ 'as f**k', 'fancy', 'f****d', 'front-ended', 'falafel', 'french fries' ], ] self._update_thread = None # setup size and remove/disable titlebuttons self.desktop_geom = qApp.desktop().availableGeometry() self.setFixedSize(self.desktop_geom.width() * .45, self.desktop_geom.height() * .4) self.setGeometry( QStyle.alignedRect(Qt.LeftToRight, Qt.AlignCenter, self.size(), qApp.desktop().availableGeometry())) self.setSizeGripEnabled(False) self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.setWindowFlag(Qt.WindowContextHelpButtonHint, False) self.setWindowFlag(Qt.WindowCloseButtonHint, True) self.setModal(True) self._recent_list_model = QStandardItemModel(0, 2) self._recent_list_model.setHeaderData(0, Qt.Horizontal, 'Type') self._recent_list_model.setHeaderData(1, Qt.Horizontal, 'Path') self._recent_list = DwarfListView(self) self._recent_list.setModel(self._recent_list_model) self._recent_list.header().setSectionResizeMode( 0, QHeaderView.ResizeToContents) self._recent_list.header().setSectionResizeMode(1, QHeaderView.Stretch) # setup ui elements self.setup_ui() random.seed(a=None, version=2) if not str(__file__).endswith('.pyc'): self.update_commits_thread = DwarfCommitsThread(parent) self.update_commits_thread.on_update_available.connect( self._on_dwarf_isupdate) self.update_commits_thread.start() # center self.setGeometry( QStyle.alignedRect(Qt.LeftToRight, Qt.AlignCenter, self.size(), qApp.desktop().availableGeometry()))
def initWindow(self): self.mainWindowUI = loadUi(self.uiPath, self) self.setAttribute(Qt.WA_DeleteOnClose) self.setGeometry( QStyle.alignedRect(Qt.LeftToRight, Qt.AlignCenter, self.size(), QApplication.desktop().availableGeometry())) self.show()
def report_failed(self): """Show a warning message box if extension(s) could either not be loaded or produced errors while parsing the extension infos.""" from PyQt5.QtCore import QCoreApplication import appinfo import qutil import widgets.dialog dlg = widgets.dialog.Dialog( self.mainwindow(), icon='warning', buttons=('ok',), title=appinfo.appname, message=_( "There were problems loading the extensions.\n" "The following details are also available from the " "Preferences dialog.")) dlg.setMainWidget(FailedTree(self.mainwindow())) qutil.saveDialogSize( dlg, "extensions/error-dialog/size", QSize(600, 300)) dlg.setGeometry(QStyle.alignedRect( Qt.RightToLeft, Qt.AlignCenter, dlg.size(), app.qApp.desktop().availableGeometry())) dlg.exec()
def setup_ui(self): self.setFixedSize(800, 400) main_wrap = QVBoxLayout(self) main_wrap.setContentsMargins(0, 0, 0, 0) self._dev_bar = DeviceBar(self, self.device_type) self._dev_bar.onDeviceUpdated.connect(self._update_device) # not needed on local #if self.device and self.device.type == 'local': #self._dev_bar.setVisible(False) main_wrap.addWidget(self._dev_bar) """frm_lyt = QFormLayout() frm_lyt.setContentsMargins(10, 10, 10, 10) _label = QLabel('Script to load (optional)') frm_lyt.addRow(_label) user_script_path = QLineEdit() load_button = QPushButton('...') frm_lyt.addRow(load_button, user_script_path) main_wrap.addLayout(frm_lyt)""" # procs/spawns lists spawns_vbox = QVBoxLayout() spawns_label = QLabel('SPAWN') spawns_label.setFont(QFont('Anton', 20, QFont.Normal)) spawns_vbox.addWidget(spawns_label) self.spawn_list = SpawnsList(device=self.device) self.spawn_list.onProcessSelected.connect(self._spawn_selected) spawns_vbox.addWidget(self.spawn_list) procs_vbox = QVBoxLayout() procs_label = QLabel('PROCS') procs_label.setFont(QFont('Anton', 20, QFont.Normal)) procs_vbox.addWidget(procs_label) self.proc_list = ProcessList(device=self.device) self.proc_list.onProcessSelected.connect(self._pid_selected) procs_vbox.addWidget(self.proc_list) inner_hbox = QHBoxLayout() inner_hbox.setContentsMargins(10, 10, 10, 10) inner_hbox.addLayout(spawns_vbox) inner_hbox.addLayout(procs_vbox) vbox = QVBoxLayout() vbox.setContentsMargins(0, 0, 0, 0) #vbox.addWidget(self._dev_bar) main_wrap.addLayout(inner_hbox) #self.setLayout(vbox) # center self.setGeometry( QStyle.alignedRect(Qt.LeftToRight, Qt.AlignCenter, self.size(), qApp.desktop().availableGeometry()))
def __init__(self): QWebEngineView.__init__(self) # self.load(image) self.setHtml(html) self.setWindowOpacity(0.7) radius = 10.0 path = QtGui.QPainterPath() self.resize(640, 480) path.addRoundedRect(QtCore.QRectF(self.rect()), radius, radius) mask = QtGui.QRegion(path.toFillPolygon().toPolygon()) self.setMask(mask) self.move(QtGui.QCursor.pos()) self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.FramelessWindowHint # | QtCore.Qt.X11BypassWindowManagerHint ) self.setGeometry( QStyle.alignedRect(QtCore.Qt.LeftToRight, QtCore.Qt.AlignCenter, QtCore.QSize(640, 480), qApp.desktop().availableGeometry())) self.setStyleSheet( 'QWebView{background-color: darkgray; border: 5px solid darkgray}') self.grabMouse() self.grabKeyboard() print(self.keyboardGrabber())
def editorEvent(self, event, model, option, index): # make sure that the item is checkable flags = model.flags(index) if not (flags & Qt.ItemIsUserCheckable) or not ( flags & Qt.ItemIsEnabled): return False # make sure that we have a check state value = index.data(Qt.CheckStateRole) if value is None: return False # make sure that we have the right event type if event.type() == QEvent.MouseButtonRelease: textMargin = QApplication.style().pixelMetric( QStyle.PM_FocusFrameHMargin) + 1 checkRect = QStyle.alignedRect( option.direction, Qt.AlignCenter, option.decorationSize, QRect(option.rect.x() + (2 * textMargin), option.rect.y(), option.rect.width() - (2 * textMargin), option.rect.height())) if not checkRect.contains(event.pos()): return False elif event.type() == QEvent.KeyPress: if (event.key() != Qt.Key_Space and event.key() != Qt.Key_Select): return False else: return False if int(value) == Qt.Checked: state = Qt.Unchecked else: state = Qt.Checked return model.setData(index, state, Qt.CheckStateRole)
def __init__(self, application_context): self.application_context = application_context self.reader = ScreenReader(application_context) QMainWindow.__init__(self) self.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint | Qt.X11BypassWindowManagerHint) self.setGeometry( QStyle.alignedRect(Qt.LeftToRight, Qt.AlignCenter | Qt.AlignRight, QSize(220, 700), qApp.desktop().availableGeometry())) self.setCentralWidget(QWidget(self)) layout = QVBoxLayout() self.centralWidget().setLayout(layout) self.accuracy_label = QLabel() self.damage_label = QLabel() self.tokens_label = QLabel() self.cumulative_probabilities_label = QLabel() self.exact_probabilities_label = QLabel() self.expected_damage_label = QLabel() layout.addWidget(self.accuracy_label, alignment=Qt.AlignCenter) layout.addWidget(self.damage_label, alignment=Qt.AlignCenter) layout.addWidget(self.tokens_label, alignment=Qt.AlignCenter) layout.addWidget(self.cumulative_probabilities_label, alignment=Qt.AlignCenter) layout.addWidget(self.exact_probabilities_label, alignment=Qt.AlignCenter) layout.addWidget(self.expected_damage_label, alignment=Qt.AlignCenter) dummy_character = calculator.Character(0, 0, 0) self.dummy_encounter = calculator.Encounter([dummy_character])
def __init__(self): super(PyFractal, self).__init__() self._fractal = None # Create thread which renders fractals. self._fractalThread = QThread() # Size and center window. self.resize(500, 500) self.setGeometry( QStyle.alignedRect(Qt.LeftToRight, Qt.AlignCenter, self.size(), app.desktop().availableGeometry())) self._controlsLabel = QLabel("Controls") self._fractalDisplay = FractalDisplay(self) self._createZoomControls() self._createFractalControls() # Create main layout. layout = QGridLayout() layout.addWidget(self._fractalSelector, 0, 0) layout.addWidget(self._fractalDisplay, 1, 0) layout.addLayout(self._zoomButtonsLayout, 2, 0) layout.addWidget(self._controlsLabel, 0, 1) layout.addLayout(self._fractalControls, 1, 1) self.setLayout(layout) # Reset to default state. self._reset() self.show()
def __init__(self, parent=None): super(WelcomeDialog, self).__init__(parent=parent) self._prefs = parent.prefs self.recent_list = QListWidget(self) # setup size and remove/disable titlebuttons self.setFixedSize(800, 400) self.setSizeGripEnabled(False) self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.setWindowFlag(Qt.WindowContextHelpButtonHint, False) self.setWindowFlag(Qt.WindowCloseButtonHint, True) self.setModal(True) # setup ui elements self.setup_ui() self.update_commits_thread = DwarfCommitsThread(parent) self.update_commits_thread.on_update_available.connect(self._on_dwarf_isupdate) self.update_commits_thread.start() # center self.setGeometry(QStyle.alignedRect(Qt.LeftToRight, Qt.AlignCenter, self.size(), qApp.desktop().availableGeometry())) saved_sessions = self._prefs.get('dwarf_mru', '{}') saved_sessions = json.loads(saved_sessions) for saved in saved_sessions: self.recent_list.addItem(QListWidgetItem(saved['path']))
def _create_new_window_4(self): widget = QWidget(self, flags=Qt.Window) widget.resize(200, 100) widget.setGeometry( QStyle.alignedRect(Qt.LeftToRight, Qt.AlignCenter, widget.size(), self.geometry())) widget.show()
def showEvent(self, QShowEvent): # pylint: disable=invalid-name """ center dialog update title """ self.setWindowTitle(self.title) self.setGeometry( QStyle.alignedRect(Qt.LeftToRight, Qt.AlignCenter, self.size(), qApp.desktop().availableGeometry())) return super().showEvent(QShowEvent)
def __init__(self, parent=None): super(WelcomeDialog, self).__init__(parent=parent) self._prefs = parent.prefs self._sub_titles = [ ['duck', 'dumb', 'doctor', 'dutch', 'dark', 'dirty', 'debugging'], ['warriors', 'wardrobes', 'waffles', 'wishes', 'worcestershire'], ['are', 'aren\'t', 'ain\'t', 'appears to be'], ['rich', 'real', 'riffle', 'retarded', 'rock'], [ 'as f**k', 'fancy', 'f****d', 'front-ended', 'falafel', 'french fries' ], ] self._update_thread = None # setup size and remove/disable titlebuttons self.desktop_geom = qApp.desktop().availableGeometry() self.setFixedSize(self.desktop_geom.width() * .45, self.desktop_geom.height() * .4) self.setGeometry( QStyle.alignedRect(Qt.LeftToRight, Qt.AlignCenter, self.size(), qApp.desktop().availableGeometry())) self.setSizeGripEnabled(False) self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.setWindowFlag(Qt.WindowContextHelpButtonHint, False) self.setWindowFlag(Qt.WindowCloseButtonHint, True) self.setModal(True) # setup ui elements self.setup_ui() random.seed(a=None, version=2) self.update_commits_thread = DwarfCommitsThread(parent) self.update_commits_thread.on_update_available.connect( self._on_dwarf_isupdate) self.update_commits_thread.start() # center self.setGeometry( QStyle.alignedRect(Qt.LeftToRight, Qt.AlignCenter, self.size(), qApp.desktop().availableGeometry()))
def main(): ipfwGUI = QApplication(sys.argv) gui = simpleIpfwGui() gui.show() # Center main window gui.setGeometry( QStyle.alignedRect(Qt.LeftToRight, Qt.AlignCenter, gui.size(), ipfwGUI.primaryScreen().geometry())) sys.exit(ipfwGUI.exec())
def initWindow(self): self.mainWindowUI = loadUi(self.uiPath, self) self.setAttribute(Qt.WA_DeleteOnClose) self.setGeometry( QStyle.alignedRect(Qt.LeftToRight, Qt.AlignHCenter, self.size(), QApplication.desktop().availableGeometry())) # Initialize Dialogs self.initFileDialog() self.initHelpDialog(helpDialogUIPath) self.initAboutDialog(helpDialogUIPath) self.initCloseDialog(quitDialogUIPath) self.show()
def __init__(self, parent=None): print("@ tab menu : init") super().__init__(parent) self.parent = parent # self.setMinimumSize(600, 600) # self.move(QApplication.desktop().screen().rect().center() - self.rect().center()) self.setMinimumSize( self.parent.tabs.widget(0).taskMenu.width(), QApplication.desktop().screen().rect().height()) # Aligns to right self.setGeometry( QStyle.alignedRect(Qt.LeftToRight, Qt.AlignRight, self.size(), QApplication.desktop().availableGeometry()))
def __init__(self, state, parent=None): super().__init__(parent) super().setupUi(self) self.state = state self.leArquivo.setReadOnly(True) self.btnSelecionar.clicked.connect(self.openFile) self.btnOK.clicked.connect(self.okButtonPressed) self.setGeometry( QStyle.alignedRect(QtCore.Qt.LeftToRight, QtCore.Qt.AlignCenter, self.size(), QtWidgets.qApp.desktop().availableGeometry())) self.btnVoltar.clicked.connect(self.btnVoltarPressed) self.setFixedSize(self.width(), self.height())
def paint(self, painter, option, index): if index.row() == 0 or index.column() == 0: textMargin = QApplication.style().pixelMetric( QStyle.PM_FocusFrameHMargin) + 1 newRect = QStyle.alignedRect( option.direction, Qt.AlignCenter, QSize(option.decorationSize.width() + 5, option.decorationSize.height()), QRect(option.rect.x() + textMargin, option.rect.y(), option.rect.width() - (2 * textMargin), option.rect.height())) option.rect = newRect QStyledItemDelegate.paint(self, painter, option, index)
def __move_window_to_center(self) -> None: """ Moves window to center of the screen. https://wiki.qt.io/How_to_Center_a_Window_on_the_Screen """ desktop_widget = QDesktopWidget() screen_geometry = desktop_widget.screenGeometry( desktop_widget.screenNumber(QCursor.pos())) self.setGeometry( QStyle.alignedRect(Qt.LeftToRight, Qt.AlignCenter, self.window().size(), screen_geometry))
def __init__(self, parent=None): print("@ Intensity Menu : init") super().__init__(parent) self.setWindowTitle("Set Task Intensity") self.parent = parent self.setMinimumSize( self.parent.tabs.widget(0).taskMenu.width(), QApplication.desktop().screen().rect().height()) # Aligns to right self.setGeometry( QStyle.alignedRect(Qt.LeftToRight, Qt.AlignRight, self.size(), QApplication.desktop().availableGeometry())) self.add_intensity_buttons()
def update_size(self): if self.minimize: width, height = 150, 80 self.layout.setContentsMargins(10, 10, 10, 10) else: width, height = 450, 300 self.layout.setContentsMargins(20, 20, 20, 20) desktop: QDesktopWidget = QApplication.instance().desktop() desktop_rect = desktop.availableGeometry() popup_size = QSize(width, height) rect = QStyle.alignedRect(Qt.RightToLeft, Qt.AlignVCenter, popup_size, desktop_rect) self.setGeometry(rect) return desktop_rect, rect
def __init__(self, parent=None): print("@ Recover Menu : init") super().__init__(parent) self.parent = parent self.setWindowTitle("Recover Menu") # set to occupy size of task menu self.setMinimumSize( self.parent.tabs.widget(0).taskMenu.width(), QApplication.desktop().screen().rect().height()) # Aligns to right self.setGeometry( QStyle.alignedRect(Qt.LeftToRight, Qt.AlignRight, self.size(), QApplication.desktop().availableGeometry())) self.layout = QGridLayout() self.init_ui()
def __init__(self, parent=None): super().__init__(parent) super().setupUi(self) self.setFixedSize(self.width(), self.height()) self.btnSair.clicked.connect(self.sair) self.setGeometry( QStyle.alignedRect( QtCore.Qt.LeftToRight, QtCore.Qt.AlignCenter, self.size(), QtWidgets.qApp.desktop().availableGeometry() ) ) self.btnNaoSimular.clicked.connect(self.semSimular) self.btnSimulacoes.clicked.connect(self.simular)
def __init__(self): QMainWindow.__init__(self) self.screenHeight = QtWidgets.qApp.primaryScreen().size().height() self.screenWidth = QtWidgets.qApp.primaryScreen().size().width() self.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint | Qt.X11BypassWindowManagerHint) self.setGeometry( QStyle.alignedRect(Qt.LeftToRight, Qt.AlignLeft, QSize(self.screenWidth, self.screenWidth), qApp.desktop().availableGeometry())) QMainWindow.setWindowOpacity(self, 0.5) self.mouse_start_pos = None self.mouse_curr_pos = None self.coords = None
def __init__(self, flags=None, *args, **kwargs): from PyQt5.QtCore import Qt, QSize from PyQt5.QtWidgets import QPushButton, QLineEdit, QLabel, QGridLayout, QStyle, QApplication from Client.MyQt.Widgets.LoginInput import QLoginInput super().__init__(flags, *args, **kwargs) grid = QGridLayout() for i in range(6): grid.setColumnStretch(i, 1) greeting_label = QLabel("Добро пожаловать\nв Систему учета посещений\nBISITOR") greeting_label.setWordWrap(True) greeting_label.setAlignment(Qt.AlignCenter) grid.addWidget(greeting_label, 0, 1, 1, 4) login_label = QLabel("Логин") login_label.setAlignment(Qt.AlignRight) grid.addWidget(login_label, 1, 0, 1, 1) self.login_input = QLoginInput() grid.addWidget(self.login_input, 1, 1, 1, 5) password_label = QLabel("Пароль") password_label.setAlignment(Qt.AlignRight) grid.addWidget(password_label, 2, 0, 1, 1) self.password_input = QLineEdit() self.password_input.setEchoMode(QLineEdit.Password) grid.addWidget(self.password_input, 2, 1, 1, 5) self.log_in = QPushButton("Войти") self.log_in.clicked.connect(self.auth) grid.addWidget(self.log_in, 3, 1, 1, 4) self.sign_in = QPushButton("Зарегистрироваться") self.sign_in.clicked.connect(self.show_form) grid.addWidget(self.sign_in, 4, 1, 1, 4) self.setLayout(grid) self.setFixedSize(QSize(400, 250)) self.setGeometry(QStyle.alignedRect(Qt.LeftToRight, Qt.AlignCenter, self.size(), QApplication.desktop().availableGeometry())) self.setWindowTitle('СПбГУТ - Система учета посещаемости') self.auth_success.connect(self.on_auth_success)
def initUI(self): self.ui = Ui_Home() self.ui.setupUi(self) self.setGeometry( QStyle.alignedRect(Qt.LeftToRight, Qt.AlignCenter, self.size(), qApp.desktop().availableGeometry())) self.show() self.ui.searchButton.clicked.connect(self.onSearch) self.ui.searchTextbox.returnPressed.connect(self.onSearch) self.ui.torrentList.selectionModel().selectionChanged.connect( self.onTorrentSelect) self.ui.torrentInfoMagnetLink.linkActivated.connect(self.onLinkClick) self.ui.torrentInfoTorrentLink.linkActivated.connect(self.onLinkClick)
def initUI(self): self.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint | Qt.WindowCloseButtonHint) self.setAttribute(Qt.WA_TranslucentBackground) self.setText("Drag me...") self.setFont(QFont("Times", 10, QFont.Bold)) self.setStyleSheet('color: yellow') self.adjustSize() self.setGeometry( QStyle.alignedRect( Qt.LeftToRight, Qt.AlignCenter, self.size(), QApplication.instance().desktop().availableGeometry() ) ) print("popup") self.keep_getting_incubators = False
def __init__(self, parent=None): print("@ Settings Menu : init") super().__init__(parent) self.setWindowTitle("Settings") self.parent = parent self.setMinimumSize( self.parent.tabs.widget(0).taskMenu.width(), QApplication.desktop().screen().rect().height()) # Aligns to right self.setGeometry( QStyle.alignedRect(Qt.LeftToRight, Qt.AlignRight, self.size(), QApplication.desktop().availableGeometry())) self.startup_folder_input = None self.l_task_input = None self.m_task_input = None self.h_task_input = None self.init_ui()
def show(self, desktop): settings = QSettings() try: self.restoreGeometry(settings.value('windows/main/geometry')) except TypeError: geometry = desktop.availableGeometry() size = geometry.size() size = QSize(size.width() * 0.75, size.height() * 0.75) self.setGeometry(QStyle.alignedRect(Qt.LeftToRight, Qt.AlignCenter, size, geometry)) try: self.restoreState(settings.value('windows/main/window-state')) except TypeError: pass try: self._splitter.restoreState(settings.value('windows/main/splitter-state')) except TypeError: pass super().show()
def initui(self): self.setGeometry( QStyle.alignedRect( Qt.LeftToRight, Qt.AlignCenter, self.size(), self._app.desktop().availableGeometry() ) ) self.initmenubar() self.initoptionspanel() self.initinformationpanel() self.initlabels() centralwidget = self.initcentralwidget() self.setCentralWidget(centralwidget) self.statusBar() self.setWindowTitle("Ipap")
def __init__(self): super().__init__() # Some variables need initialising self._doubletimer = QTimer() self._doubletimer.setSingleShot(True) self._mode = "edit" self._changed = False self._lastclicked = None self._copypaste = [] # Size window at half width and third of height of screen, positioned in the middle av_height = QDesktopWidget().availableGeometry(self).size().height() av_width = QDesktopWidget().availableGeometry(self).size().width() self.setGeometry( QStyle.alignedRect( Qt.LeftToRight, Qt.AlignCenter, QSize(int(av_width / 2), int(av_height / 3)), QDesktopWidget().availableGeometry(self), ) ) # Get a keyboard widget instance and set it up a tiny bit global g_oskbwidget g_oskbwidget = oskb.Keyboard() g_oskbwidget.setButtonHandler(self._buttonHandler) g_oskbwidget.setStyleSheet(pkg_resources.resource_string("oskb", "oskbedit.css").decode("utf-8")) # Set up elements on the screen, must be done before _loadFile() layout = QVBoxLayout(self) frame = QWidget() self._kbdlayout = QHBoxLayout() frame.setLayout(self._kbdlayout) self._kbdlayout.addWidget(g_oskbwidget) layout.addWidget(frame) self.setWindowTitle("oskbedit") layout.addWidget(frame) self._menu = QMenuBar() self._menu.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.layout().setMenuBar(self._menu) self.show() # Load the file from the command line, or the blank keyboard if none specified if g_cmdline.keyboard: if not self._loadFile(g_cmdline.keyboard): sys.exit(-1) else: self._loadFile("_new")