def __init__(self, title='Popup', message='', params={}, parent=None): QtGui.QWidget.__init__(self, parent) width = 300 height = 200 resolution = QDesktopWidget().screenGeometry() self.setGeometry(resolution.width() - width, resolution.height() - height, width, height) pos_x = resolution.width() / 2 - width / 2 pos_y = resolution.height() / 2 - height / 2 self.move(pos_x, pos_y) self.setWindowTitle(title) self.setWindowFlags(self.windowFlags() | QtCore.Qt.WindowStaysOnTopHint) self.setToolTip(title) self.setObjectName("toolTipWindow") self.setStyleSheet( Resources.read(join('assets', 'styles', 'tooltip.pss'))) self.CComamnd = QtGui.QLabel(message) #self.CComamnd.setFixedHeight(50) self.CComamnd.setAlignment(QtCore.Qt.AlignTop | QtCore.Qt.AlignLeft) self.CComamnd.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse) self.CComamnd.setObjectName('command') layout = QtGui.QVBoxLayout() layout.addWidget(self.CComamnd) self.setLayout(layout) QtGui.QToolTip.setFont(QtGui.QFont('OldEnglish', 10)) self.show()
def __init__(self, title='Popup', message='', params={}, parent=None): QtGui.QWidget.__init__(self, parent) width = 300 height = 200 resolution = QDesktopWidget().screenGeometry() self.setGeometry(resolution.width() - width, resolution.height() - height, width, height) pos_x = resolution.width() / 2 - width / 2 pos_y = resolution.height() / 2 - height / 2 self.move(pos_x, pos_y) self.setWindowTitle(title) self.setWindowFlags(self.windowFlags() | QtCore.Qt.WindowStaysOnTopHint) self.setToolTip(title) self.setObjectName("toolTipWindow") self.setStyleSheet(Resources.read(join('assets', 'styles', 'tooltip.pss'))) self.CComamnd = QtGui.QLabel(message) #self.CComamnd.setFixedHeight(50) self.CComamnd.setAlignment(QtCore.Qt.AlignTop | QtCore.Qt.AlignLeft) self.CComamnd.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse) self.CComamnd.setObjectName('command') layout = QtGui.QVBoxLayout() layout.addWidget(self.CComamnd) self.setLayout(layout) QtGui.QToolTip.setFont(QtGui.QFont('OldEnglish', 10)) self.show()
def popUp(self): """Popup from the tray""" # Reposition the window r = QDesktopWidget().availableGeometry() s = self.size() pos = getConfig(u"pos") if pos == u"Top right": x = r.left() + r.width()-s.width() y = r.top() elif pos == u"Top left": x = r.left() y = r.top() elif pos == u"Bottom right": x = r.left() + r.width()-s.width() y = r.top() + r.height()-s.height() elif pos == u"Bottom left": x = r.left() y = r.top() + r.height()-s.height() else: x = r.left() + r.width()/2 - s.width()/2 y = r.top() + r.height()/2 - s.height()/2 self.move(x, y) # Show it self.show() QCoreApplication.processEvents() self.raise_() self.activateWindow() # Focus the search box self.ui.lineEditQuery.selectAll() self.ui.lineEditQuery.setFocus()
def popUp(self): """Popup from the tray""" # Reposition the window r = QDesktopWidget().availableGeometry() s = self.size() pos = getConfig("pos") if pos == "Top right": x = r.left() + r.width() - s.width() y = r.top() elif pos == "Top left": x = r.left() y = r.top() elif pos == "Bottom right": x = r.left() + r.width() - s.width() y = r.top() + r.height() - s.height() elif pos == "Bottom left": x = r.left() y = r.top() + r.height() - s.height() else: x = r.left() + r.width() / 2 - s.width() / 2 y = r.top() + r.height() / 2 - s.height() / 2 self.move(x, y) # Show it self.show() QCoreApplication.processEvents() self.raise_() self.activateWindow() # Focus the search box self.ui.lineEditQuery.selectAll() self.ui.lineEditQuery.setFocus()
def __init__(self, in_file, parent=None): self.in_file = in_file try: s = open(self.in_file, 'r').read() bits = s.split('\n') ln = 0 for lin in bits: if len(lin) > ln: ln = len(lin) ln2 = len(bits) except: if self.in_file[self.in_file.rfind('.'):] == '.ini': s = '' else: s = '' ln = 36 ln2 = 5 QtGui.QDialog.__init__(self, parent) self.saveButton = QtGui.QPushButton(self.tr('&Save')) self.cancelButton = QtGui.QPushButton(self.tr('Cancel')) buttonLayout = QtGui.QHBoxLayout() buttonLayout.addStretch(1) buttonLayout.addWidget(self.saveButton) buttonLayout.addWidget(self.cancelButton) self.connect(self.saveButton, QtCore.SIGNAL('clicked()'), self, QtCore.SLOT('accept()')) self.connect(self.cancelButton, QtCore.SIGNAL('clicked()'), self, QtCore.SLOT('reject()')) self.widget = QtGui.QPlainTextEdit() highlight = inisyntax.IniHighlighter(self.widget.document()) if sys.platform == 'linux2': self.widget.setFont(QtGui.QFont('Ubuntu Mono 13', 12)) else: self.widget.setFont(QtGui.QFont('Courier New', 12)) fnt = self.widget.fontMetrics() ln = (ln + 5) * fnt.maxWidth() ln2 = (ln2 + 4) * fnt.height() screen = QDesktopWidget().availableGeometry() if ln > screen.width() * .67: ln = int(screen.width() * .67) if ln2 > screen.height() * .67: ln2 = int(screen.height() * .67) self.widget.resize(ln, ln2) self.widget.setPlainText(s) layout = QtGui.QVBoxLayout() layout.addWidget(self.widget) layout.addLayout(buttonLayout) self.setLayout(layout) self.setWindowTitle('SIREN - Edit - ' + self.in_file[self.in_file.rfind('/') + 1:]) self.setWindowIcon(QtGui.QIcon('sen_icon32.ico')) size = self.geometry() self.setGeometry(1, 1, ln + 10, ln2 + 35) size = self.geometry() self.move((screen.width() - size.width()) / 2, (screen.height() - size.height()) / 2) self.widget.show()
def setGeom(self, width, height): resolution = QDesktopWidget().screenGeometry() width = min(resolution.width(), width) height = min(resolution.height(), height) self.setGeometry(resolution.width() - width, resolution.height() - height, width, height) #self.resize(500, 500) pos_x = resolution.width() - width pos_y = resolution.height() - height #20 self.move(pos_x, pos_y)
def moveAfterShow(self): resolution = QDesktopWidget().screenGeometry() LGeom = self.leftText.geometry() RGeom = self.rightText.geometry() MaxWidth = LGeom.width() + RGeom.width() MaxHeight = LGeom.height() + RGeom.height() width = min(resolution.width(), MaxWidth) height = min(resolution.height(), MaxHeight) self.setGeom(width + 100, height + 50) pos_x = resolution.width() - width pos_y = resolution.height() - height #20 self.move(pos_x, pos_y)
def __init__(self): """ The Settings constructor initializes the default settings values, which is provided as a fallback, should the config file somehow go missing. We use the ``qApp`` instance of The running ``QApplication`` to register organization and application name, as well as the application version. """ QSettings.__init__(self) # This is the path prefix where we store all luma related # files (serverlist, templates, filter bookmarks etc.) self.__configPrefix = '' # Defaults for section: mainwindow self.__maximize = False self.__size = QSize(750, 500) screen = QDesktopWidget().screenGeometry() self.__position = QPoint((screen.width() - self.__size.width()) / 2, (screen.height() - self.__size.height()) / 2) # Defaults for section: i18n self.__language = u'en' # Defaults for section: logger self.__showLoggerOnStart = False self.__showLogger = False self.__showErrors = True self.__showDebug = True self.__showInfo = True
def __init__(self, new_version = 0, update_link = None): super(MainForm, self).__init__() uic.loadUi('UI/LeechMain.ui', self) dw = QDesktopWidget() x = dw.width() * 0.7 y = dw.height() * 0.7 self.session = requests.session() self.btn_start.clicked.connect(self.start_leech) self.btn_start.setIcon(QtGui.QIcon('UI/start.png')) self.btn_start.setIconSize(QtCore.QSize(24, 24)) # self.download_table.cellClicked.connect(self.show_download_folder) self.download_index = 0 self.upload_index = 0 self.download_table.setSelectionBehavior(Qt.QAbstractItemView.SelectRows) self.upload_table.setSelectionBehavior(Qt.QAbstractItemView.SelectRows) self.btn_stop.clicked.connect(self.stop_leech) self.btn_stop.setIcon(QtGui.QIcon('UI/delete.png')) self.btn_stop.setIconSize(QtCore.QSize(24, 24)) self.setFixedSize(x, y) self.current_folder = os.getcwd() self.btn_new_version.clicked.connect(self.normal_update) self.new_version = new_version self.update_link = update_link if float(self.new_version) == 0: self.btn_new_version.setText("Program is up to date") else: self.update_link = update_link self.btn_new_version.setText("Update to version " + str(new_version))
def __init__(self): """ The Settings constructor initializes the default settings values, which is provided as a fallback, should the config file somehow go missing. We use the ``qApp`` instance of The running ``QApplication`` to register organization and application name, as well as the application version. """ QSettings.__init__(self) # This is the path prefix where we store all luma related # files (serverlist, templates, filter bookmarks etc.) self.__configPrefix = '' # Defaults for section: mainwindow self.__maximize = False self.__size = QSize(750, 500) screen = QDesktopWidget().screenGeometry() self.__position = QPoint((screen.width() - self.__size.width()) / 2, (screen.height() - self.__size.height()) / 2) # Defaults for section: i18n self.__language = u'en' # Defaults for section: logger self.__showLoggerOnStart = False self.__showLogger = False self.__showErrors = True self.__showDebug = True self.__showInfo = True
def __init__(self, parent=None): QMainWindow.__init__(self, parent) self.setWindowFlags(Qt.Window) self._mdi_area = QMdiArea() self._mdi_area.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) self._mdi_area.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.setCentralWidget(self._mdi_area) # set the size of mid_area and DocumentViewManager based on the # screen size. screen = QDesktopWidget().availableGeometry() self._mdi_area.resize(screen.width() - 30, screen.height() - 80) self.resize(self._mdi_area.size()) self._mdi_area.subWindowActivated.connect(self.update_actions) self._viewer_mapper = QSignalMapper(self) self._viewer_mapper.mapped[QWidget].connect(self.set_active_sub_window) win_title = QApplication.translate( "DocumentViewManager", "Document Viewer" ) self.setWindowTitle(win_title) self.setUnifiedTitleAndToolBarOnMac(True) self.statusBar().showMessage( QApplication.translate( "DocumentViewManager", "Ready" ) ) self._doc_viewers = {} self._create_menu_actions() self.update_actions()
def __init__(self, *args): QApplication.__init__(self, *args) self.main = MainWindow() self.main.show() resolution = QDesktopWidget().screenGeometry() self.main.move( (resolution.width() / 2) - (self.main.frameSize().width() / 2), (resolution.height() / 2) - (self.main.frameSize().height() / 2))
def _center_on_screen(self): assert isinstance(self, QWidget) desktop = QDesktopWidget().availableGeometry() self.move( (desktop.width() / 2) - (self.frameSize().width() / 2), (desktop.height() / 2) - (self.frameSize().height() / 2), )
def setup(self, jid, talks, messages): self.ui = Ui_conversationWindow() self.talks = talks self.messages = messages self.ui.setupUi(jid, self) desktopSize=QDesktopWidget().screenGeometry() top=(desktopSize.height()/2)-(450/2) left=(desktopSize.width()/2)-(300/2) self.move(left, top)
def initUI(self): screen = QDesktopWidget().screenGeometry() self.width = screen.width() self.height = screen.height() self.setGeometry(0, 0, self.width, self.height) self.setWindowFlags(Qt.FramelessWindowHint) self.show()
def __init__(self, parent): super(aboutWidget, self).__init__() #Set popup self.setWindowFlags(Qt.Popup) self.resize(parent.meter.width(), 307) self.setWindowOpacity(0.5) #Move aboutWidget if parent.isFullScreen(): resolution = QDesktopWidget().screenGeometry() self.move( (resolution.width() / 2) - (self.frameSize().width() / 2), (resolution.height() / 2) - (self.frameSize().height() / 2)) else: point = parent.meter.rect().topRight() global_point = parent.meter.mapToGlobal(point) self.move(global_point - QPoint(self.width(), 0)) #Create vertical layout vbox = QVBoxLayout(self) #Set align and margins if parent.isFullScreen(): vbox.setAlignment(Qt.AlignLeft) vbox.setContentsMargins(150, 0, 0, 0) else: vbox.setAlignment(Qt.AlignHCenter) vbox.setContentsMargins(0, 0, 0, 0) vbox.setSpacing(0) #LABELS #name and version label_name = QLabel('%s (%s)' % (__prj__, __version__)) label_name.setObjectName('name') #label_url label_url = QLabel( 'Source: <a style="color:orange" href="%s">Github repository</a>' % (__source__)) #label_license label_license = QLabel('License: %s' % (__license__)) #label_author label_author = QLabel(__author__) label_author.setObjectName('author') #Add widget to vbox vbox.addWidget(label_name) vbox.addWidget(label_license) vbox.addWidget(label_url) vbox.addWidget(label_author) self.setLayout(vbox)
def __init__(self, parent=None): super(MainWindow, self).__init__(parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) desktopSize = QDesktopWidget().screenGeometry() top=(desktopSize.height()/2)-(450/2) left=(desktopSize.width()/2)-(300/2) self.move(left, top) self.connect(self.ui.friendsListWidget, QtCore.SIGNAL('itemDoubleClicked (QListWidgetItem *)'), self.openConversation) self.talks = dict() self.messages = collections.defaultdict(list)
def resizeAfterShow(self): resolution = QDesktopWidget().screenGeometry() LGeom = self.leftText.geometry() RGeom = self.rightText.geometry() MaxWidth = LGeom.width() + RGeom.width() MaxHeight = LGeom.height() + RGeom.height() width = min(resolution.width() - 300, MaxWidth) height = min(resolution.height() - 100, MaxHeight) self.setGeom(width, height) self.leftText.setWordWrap(True) self.rightText.setWordWrap(True) self.setMinimumSize(width, height) self.setMaximumSize(width, height) self.setMinimumSize(50, 50) self.setMaximumSize(resolution.width(), resolution.height())
def __init__(self, parent): super(aboutWidget, self).__init__() #Set popup self.setWindowFlags(Qt.Popup) self.resize(parent.meter.width(), 307) self.setWindowOpacity(0.5) #Move aboutWidget if parent.isFullScreen(): resolution = QDesktopWidget().screenGeometry() self.move((resolution.width() / 2) - (self.frameSize().width() / 2), (resolution.height() / 2) - (self.frameSize().height() / 2)) else: point = parent.meter.rect().topRight() global_point = parent.meter.mapToGlobal(point) self.move(global_point - QPoint(self.width(), 0)) #Create vertical layout vbox = QVBoxLayout(self) #Set align and margins if parent.isFullScreen(): vbox.setAlignment(Qt.AlignLeft) vbox.setContentsMargins(150, 0, 0, 0) else: vbox.setAlignment(Qt.AlignHCenter) vbox.setContentsMargins(0, 0, 0, 0) vbox.setSpacing(0) #LABELS #name and version label_name = QLabel('%s (%s)' % (__prj__, __version__)) label_name.setObjectName('name') #label_url label_url = QLabel( 'Source: <a style="color:orange" href="%s">Github repository</a>' % (__source__)) #label_license label_license = QLabel('License: %s' % (__license__)) #label_author label_author = QLabel(__author__) label_author.setObjectName('author') #Add widget to vbox vbox.addWidget(label_name) vbox.addWidget(label_license) vbox.addWidget(label_url) vbox.addWidget(label_author) self.setLayout(vbox)
def __init__(self, title='Tooltip', command='', res='This is a QWidget', id=None, parent=None): QtGui.QWidget.__init__(self, parent) self.id = id #self.t = ToolTipAnimation() #self.t.start() width = 300 height = 200 resolution = QDesktopWidget().screenGeometry() self.setGeometry(resolution.width() - width, resolution.height() - height, width, height) pos_x = resolution.width() - width * (TooltipManage.getCountToolTips() / 3 + 1) pos_y = resolution.height() - height * (TooltipManage.getCountToolTips() % 3 + 1) self.move(pos_x, pos_y) self.setWindowTitle(title) self.setWindowFlags(self.windowFlags() | QtCore.Qt.WindowStaysOnTopHint) self.setWindowFlags(QtCore.Qt.CustomizeWindowHint) self.setToolTip('This is a QWidget') self.setObjectName("toolTipWindow") self.setStyleSheet(Resources.read(join('resources', 'styles', 'tooltip.pss'))) self.CComamnd = QtGui.QLabel(command+':') self.CComamnd.setFixedHeight(50) self.CComamnd.setAlignment(QtCore.Qt.AlignTop | QtCore.Qt.AlignLeft) self.CComamnd.setObjectName('command') self.CLineView = QtGui.QLabel(res) self.CLineView.setAlignment(QtCore.Qt.AlignTop | QtCore.Qt.AlignLeft) self.CLineView.setContentsMargins(15, 0, 0, 0) self.CLineView.setObjectName('commandResult') layout = QtGui.QVBoxLayout() layout.addWidget(self.CComamnd) layout.addWidget(self.CLineView) self.setLayout(layout) QtGui.QToolTip.setFont(QtGui.QFont('OldEnglish', 10))
def center(self): """ Move the Document viewer to the center of the screen. """ # Get the current screens' dimensions... screen = QDesktopWidget().availableGeometry() # ... and get this windows' dimensions mdi_area_size = self.frameGeometry() # The horizontal position hpos = (screen.width() - mdi_area_size.width()) / 2 # vertical position vpos = (screen.height() - mdi_area_size.height()) / 2 # repositions the window self.move(hpos, vpos)
def centerWindow(window): rect = QDesktopWidget().screenGeometry() width = 0 heigth = 0 if rect.width <= 640: width = 620 elif rect.width <= 800: width = 720 else: width = 960 if rect.height <= 480: height = 450 elif rect.height <= 600: height = 520 else: height = 680 window.resize(width, height) window.move(rect.width()/2 - window.width()/2, rect.height()/2 - window.height()/2)
def __init__(self, parent=None): super(Client, self).__init__(parent) self.tab_widget = TabClass.TabWidget(self) self.setWindowTitle('Book Library') self.setCentralWidget(self.tab_widget) dw = QDesktopWidget() x = dw.width() * 0.7 y = dw.height() * 0.7 self.resize(x, y) self.make_menu() self.show()
def centerWindow(window): rect = QDesktopWidget().screenGeometry() width = 0 heigth = 0 if rect.width <= 640: width = 620 elif rect.width <= 800: width = 720 else: width = 960 if rect.height <= 480: height = 450 elif rect.height <= 600: height = 520 else: height = 680 window.resize(width, height) window.move(rect.width() / 2 - window.width() / 2, rect.height() / 2 - window.height() / 2)
def __init__(self, parent, diffText): QDialog.__init__(self, parent) self.prm = self.parent().prm self.currLocale = self.parent().prm['currentLocale'] self.currLocale.setNumberOptions( self.currLocale.OmitGroupSeparator | self.currLocale.RejectGroupSeparator) self.vBoxSizer = QVBoxLayout() self.browser = QTextBrowser() self.browser.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.browser.append(diffText) self.browser.verticalScrollBar().setValue( self.browser.verticalScrollBar().minimum()) cursor = self.browser.textCursor() cursor.setPosition(0) self.browser.setTextCursor(cursor) font = QFont() font.setFamily("Arial") font.setPointSize(12) self.browser.setFont(font) self.vBoxSizer.addWidget(self.browser) buttonBox = QDialogButtonBox(QDialogButtonBox.Ok) buttonBox.accepted.connect(self.accept) self.vBoxSizer.addWidget(buttonBox) self.setLayout(self.vBoxSizer) self.setWindowTitle(self.tr("Diff")) screen = QDesktopWidget().screenGeometry() wd = screen.width() / 4 ht = screen.height() / 3 self.resize(wd, ht) self.show()
def __init__(self, parent, diffText): QDialog.__init__(self, parent) self.prm = self.parent().prm self.currLocale = self.parent().prm['currentLocale'] self.currLocale.setNumberOptions(self.currLocale.OmitGroupSeparator | self.currLocale.RejectGroupSeparator) self.vBoxSizer = QVBoxLayout() self.browser = QTextBrowser() self.browser.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.browser.append(diffText) self.browser.verticalScrollBar().setValue(self.browser.verticalScrollBar().minimum()) cursor = self.browser.textCursor(); cursor.setPosition(0); self.browser.setTextCursor(cursor); font = QFont() font.setFamily("Arial") font.setPointSize(12) self.browser.setFont(font) self.vBoxSizer.addWidget(self.browser) buttonBox = QDialogButtonBox(QDialogButtonBox.Ok) buttonBox.accepted.connect(self.accept) self.vBoxSizer.addWidget(buttonBox) self.setLayout(self.vBoxSizer) self.setWindowTitle(self.tr("Diff")) screen = QDesktopWidget().screenGeometry() wd = screen.width()/4 ht = screen.height()/3 self.resize(wd, ht) self.show()
class MainWindow(QMainWindow): def __init__(self, view, scene, root, *args): QMainWindow.__init__(self, view) self.desktop_size = QDesktopWidget().screenGeometry() self.resize(self.desktop_size.width(), self.desktop_size.height()) self.view = view self.scene = scene self.root = root self.cell_spacing = 10.0 self.columns = 3 self.rows = 2 self.cell_rects = [] winSize = self.desktop_size self.frame_width = (winSize.width() - self.cell_spacing * (self.columns + 1)) / self.columns self.frame_height = (winSize.height() - self.cell_spacing * (self.rows + 1)) / self.rows for row in range(self.rows): for col in range(self.columns): x = self.cell_spacing * (col + 1) + self.frame_width * col y = self.cell_spacing * (row + 1) + self.frame_height * row self.cell_rects.append( QRectF(x, y, self.frame_width, self.frame_height)) self.view.setRenderHints(QPainter.Antialiasing | QPainter.SmoothPixmapTransform) self.scene.setSceneRect(QRectF(0, 0, winSize.width(), winSize.height())) self.frames = None self.current = None self.index = 0 self.lock = threading.Lock() self.new_frames = None self.updateAlbum() def read_metadata(self, filename): try: image = Image.open(filename) iptc = IptcImagePlugin.getiptcinfo(image) metadata = { k.strip(): v.strip() for (k, v) in [kv.decode("utf-8").split(':') for kv in iptc[(2, 25)]] } return metadata except Exception as ex: try: tags = None with open(filename, 'rb') as image_file: tags = exifread.process_file(image_file, debug=True) if tags and 'Image ApplicationNotes' in tags: xml = str(tags['Image ApplicationNotes']) xml = ET.fromstring(xml) items = xml.findall( './/{http://www.w3.org/1999/02/22-rdf-syntax-ns#}Bag/{http://www.w3.org/1999/02/22-rdf-syntax-ns#}li' ) items = [item.text.split(':') for item in items] items = [(a.strip(), b.strip()) for a, b in items] metadata = dict(items) return metadata except Exception as ex2: pass return None def scan(self): new_files = [] for r, dirs, files in os.walk(os.path.abspath(self.root)): for name in files: if os.path.splitext(name)[1].lower() in ('.jpg', '.png', '.jpeg'): new_files.append(os.path.join(r, name)) metadata = {} for fname in new_files: try: md = self.read_metadata(fname) if 'Name' in md: metadata[fname] = md except: pass new_files = self.sort(new_files, metadata) frames = [] for filename in new_files: frame = SlideshowFrame( self, QRectF(0, 0, self.frame_width, self.frame_height), filename, metadata.get(filename)) frames.append(frame) with self.lock: self.new_frames = frames def sort(self, new_files, metadata): with_metadata = [(metadata[filename], filename) for filename in new_files if filename in metadata] without_metadata = [ filename for filename in new_files if not filename in metadata ] with_last_name = [(meta['Name'].split()[-1], filename) for meta, filename in with_metadata] with_last_name.sort() return [filename for meta, filename in with_last_name] + without_metadata def updateAlbum(self, *args): if GooglePhotos(self.root).sync() or not self.frames: print('Updating Album') self.scan() print('Done') def nextImageSet(self): with self.lock: if self.new_frames: self.frames = self.new_frames self.new_frames = None self.index = 0 if self.frames: self.current = [ self.frames[(self.index + i) % len(self.frames)] for i in range(self.rows * self.columns) ] self.index = (self.index + self.rows * self.columns) % len( self.frames) def nextImage(self, *args): if self.current: for frame in self.current: frame.hide() self.nextImageSet() if self.current: for frame, position in zip(self.current, self.cell_rects): frame.move(position.x(), position.y()) frame.show()
def center(self): """ Centers GUI on screen """ screen = QDesktopWidget().screenGeometry() size = self.geometry() self.move((screen.width() - size.width()) / 2, (screen.height() - size.height()) / 2)
def __init__(self, parent=None): super(QuestionDlg,self).__init__(parent) # self.setStyleSheet("background-image:url('image/panelbg.jpg'); border: 2px; border-radius 2px;") # self.createDb() # return self.db = QSqlDatabase.addDatabase("QSQLITE"); self.db.setDatabaseName("studentNew.db") if not self.db.open(): QMessageBox.warning(None, "错误", "数据库连接失败: %s" % self.db.lastError().text()) sys.exit(1) self.g_curClassName = "" self.deleteTmpdata() self.setWindowFlags(Qt.CustomizeWindowHint) # self.setStyleSheet("border: 2px; border-radius 2px;") # self.setWindowFlags(Qt.FramelessWindowHint) self.setStyleSheet("background-color: rgba(132, 171, 208, 200);") self.tabWidget=QTabWidget(self) self.tabWidget.currentChanged.connect(self.changeTab) # tabWidget.setTabShape(QTabWidget.Triangular) self.tabWidget.setStyleSheet("QTabWidget::pane{border-width:1px;border-color:rgb(48, 104, 151);\ border-style: outset;background-color: rgb(132, 171, 208);\ background: transparent;} \ QTabWidget::tab-bar{border-width:0px;}\ QTabBar::tab { height: 60px; width: 260px; color:rgb(0, 0, 255); font-size:20px; font-weight:bold;} \ QTabBar::tab:hover{background:rgb(255,255, 255, 100);} \ QTabBar::tab:selected{border-color:green;background-color:white;color:green;}") # tabWidget.setStyleSheet("QTabBar::tab:hover{background:rgb(255,255, 255, 100);}") self.btngroup = QButtonGroup() self.popMenu = QMenu(self) entry1 = self.popMenu.addAction("正确") self.connect(entry1,SIGNAL('triggered()'), lambda : self.answerRight()) entry2 = self.popMenu.addAction("错误") self.connect(entry2,SIGNAL('triggered()'), lambda : self.answerWrong()) entry3 = self.popMenu.addAction("替换") self.connect(entry3,SIGNAL('triggered()'), lambda : self.resetStudent()) # Create the first tab page. self.w1=QWidget() self.w1.setAccessibleName("w1tab") self.genOneTab() # Create the second tab page. self.w2=QWidget() self.w2.setAccessibleName("w2tab") self.genTwoTab() self.tabWidget.addTab(self.w1,"") self.tabWidget.addTab(self.w2,"班级学生信息管理") self.tabWidget.resize(940,700) btnclose = QPushButton(self) btnclose.setToolTip("关闭") btnclose.setText("╳") btnclose.setGeometry(915, 5, 20, 20) btnclose.setStyleSheet("background-color:rgb(0,100,0); color:rgb(255,255,255)") btnclose.clicked.connect(self.close) btnMinimized = QPushButton(self) btnMinimized.setToolTip("最小化") btnMinimized.setText("▁") btnMinimized.setGeometry(890, 5, 20, 20) btnMinimized.setStyleSheet("background-color:rgb(0,100,0); color:rgb(255,255,255)") btnMinimized.clicked.connect(lambda: self.showMinimized()) self.btnSysMenu = QPushButton(self) # self.btnSysMenu.setText("▼") self.btnSysMenu.setGeometry(865, 5, 20, 20) self.btnSysMenu.setToolTip("系统设置") self.btnSysMenu.clicked.connect(lambda: self.showMinimized()) menufont = QFont("宋体", 10) popMenu = QMenu(self) entry1 = popMenu.addAction("所有学生提问信息清零") entry1.setFont(menufont) self.connect(entry1,SIGNAL('triggered()'), self.initStudent) entry2 = popMenu.addAction("清除本堂课提问人员") entry2.setFont(menufont) self.connect(entry2,SIGNAL('triggered()'), self.deleteTmpdata) entry3 = popMenu.addAction("关于...") entry3.setFont(menufont) self.connect(entry3,SIGNAL('triggered()'), self.aboutMe) entry4 = popMenu.addAction("导出...") entry4.setFont(menufont) self.connect(entry4,SIGNAL('triggered()'), self.exportNotice) self.btnSysMenu.setMenu(popMenu) self.btnSysMenu.setStyleSheet("QPushButton::menu-indicator {image: url('image/sysmenu.png');subcontrol-position: right center;} ") # self.btnSysMenu.setStyleSheet("background-color:rgb(0,100,0); color:rgb(255,255,255);") authorinfo = QLabel(self.tabWidget) # authorinfo.setToolTip("关闭") authorinfo.setText("程序设计:汕头市大华路第一小学 赵小娜,有任何问题请反馈至[email protected]。") authorinfo.setGeometry(20, 665, 470, 26) authorinfo.setFont(QFont('Courier New')) authorinfo.setStyleSheet("background-color:rgba(255, 255, 255,160); font-size:12px;border: 1px solid rgb(60,200,255,200);color:rgba(0,0,0,220);border-radius:12px;") self.setWindowTitle("课堂随机提问") self.setWindowIcon(QIcon("image/start.ico")) self.setGeometry(100, 20, 940, 700) # self.changeTab() screen = QDesktopWidget().screenGeometry() size = self.geometry() self.move((screen.width()-size.width())/2, (screen.height()-size.height())/2) self.btn_start.setMyarg('start') # print(self.btn_start.getMyarg()) self.connect(self.btn_start, SIGNAL("clicked()"), self.startChoice) # self.connect(self.w1title, SIGNAL("currentIndexChanged(int)"), self.changeTitle) # self.connect(self.btn_start2, SIGNAL("clicked()"), self.startChoice) # self.connect(self.w2title, SIGNAL("currentIndexChanged(int)"), self.changeTitle) self.btngroup.buttonClicked[int].connect(self.btns_click)
class Nurve(QMainWindow): def __init__(self, parent= None): super(Nurve, self).__init__(parent) self.current_images = [] self.setWindowTitle("Nurve - Alpha 0.0.1") self.image_tabs_widget = QTabWidget() self.setCentralWidget(self.image_tabs_widget) openAction = QAction("&Open Image", self) openAction.setShortcut("Ctrl+O") openAction.setStatusTip('Open a new image') openAction.triggered.connect(self.open_image) self.statusBar() self.mainMenu = self.menuBar() self.fileMenu = self.mainMenu.addMenu('&File') self.fileMenu.addAction(openAction) self.menuBar() self.screen_size = QDesktopWidget().screenGeometry() def open_image(self, checked=False, path=None): if path is None: dlg = QFileDialog() dlg.setFileMode(QFileDialog.ExistingFile) dlg.setFilter("Image Files (*.NEF *.TIFF *.TIF)") filenames = [] if dlg.exec_(): filenames = dlg.selectedFiles() if len(filenames) >= 1: path = unicode(filenames[0]) else: #TODO: add messagebox return if os.path.isfile(path): filename = os.path.basename(path) if path not in self.current_images: im = cv2.imread(path, -1) widget = QImageWidget() visualization = im.copy() if visualization .shape[0] > self.screen_size.height(): visualization = self.image_resize(visualization , height=self.screen_size.height()-200) if visualization .shape[1] > self.screen_size.width(): visualization = self.image_resize(visualization , width=self.screen_size.width()-200) widget.set_opencv_image(visualization ) new_image = {"filename": filename, "path": path, "data":im, "widget": widget} self.create_image_tab(new_image) else: #TODO: Go to tab pass self.current_images.append(new_image) self.statusBar().showMessage("Opened file %s"%filename) else: mb = QMessageBox("ERROR in path", "Path to file \n%s\ncould not be found."%path, QMessageBox.Warning, QMessageBox.Ok, 0, 0) mb.exec_() def image_resize(self, image, width=None, height=None, inter=cv2.INTER_AREA): # initialize the dimensions of the image to be resized and # grab the image size dim = None (h, w) = image.shape[:2] # if both the width and height are None, then return the # original image if width is None and height is None: return image # check to see if the width is None if width is None: # calculate the ratio of the height and construct the # dimensions r = height / float(h) dim = (int(w * r), height) # otherwise, the height is None else: # calculate the ratio of the width and construct the # dimensions r = width / float(w) dim = (width, int(h * r)) # resize the image resized = cv2.resize(image, dim, interpolation=inter) return resized def create_image_tab(self, image_struct): self.image_tabs_widget.addTab(image_struct["widget"], QString(image_struct["filename"]))
def __init__(self, parent=None): QMainWindow.__init__(self, parent) screen = QDesktopWidget().screenGeometry() self.setGeometry(80, 100, int((1/2)*screen.width()), int((4/10)*screen.height())) self.main_frame = QFrame() self.cw = QFrame() self.cw.setFrameStyle(QFrame.StyledPanel|QFrame.Sunken) self.main_sizer = QVBoxLayout() self.hbox1_sizer = QHBoxLayout() self.setWindowTitle(self.tr("Consonance Rating")) ## self.sessionRunning = False self.listenerID = "" self.currentTrial = 1 self.intervals_db = pd.read_csv(os.path.abspath(os.path.dirname(__file__)) + "/resources/intervals_database.csv", sep=";") # self.rootNotes = np.array([110, 130.81, 185]) # self.intervalsCents = np.array([100, # 500, # 600, # 700, # 800, # 1100]) #self.rootNotes = np.array([110, 185]) self.rootNotes = np.array([146.83, 155.56, 164.81, 174.61, 185, 196, 207.65, 220]) self.intervalsCents = np.array([600, 700 ]) self.diadDur = 1980 self.diadRamps = 10 self.diadTotLev = np.array([40, 80]) self.diadFilterType = "lowpass" self.diadFilterCutoffs = (2500,) self.diadLowHarm = 1 self.diadHighHarm = 50 self.diadNote1Chan = "Both" self.diadNote2Chan = "Both" self.fs = 48000 self.maxLevel = self.getPhonesCal() self.noise1SL = -200 self.noise1LowFreq = 0 self.noise1HighFreq = 2000 self.noise1Type = "Pink" self.noise2Type = "Pink" self.noise2SL = np.array([0, 40]) self.noise2LowFreq = 4000 self.noise2HighFreq = 8000 self.noise1RefHz = 100 self.noise2RefHz = 4000 self.preTrialNoiseRefHz = 1000 self.preTrialNoiseLowFreq = 20 self.preTrialNoiseHighFreq = 8000 self.preTrialNoiseDur = 1980 self.preTrialNoiseRamps = 10 self.preTrialNoiseSL = np.array([0, 40]) self.preTrialNoiseType = "Pink" self.preTrialNoiseChannel = "Both" self.preTrialNoiseDiadISI = 500 self.noiseChannel = "Both" self.nPracticeTrialsXStim = 4 self.nTrialsXStim = 2 self.nTrials = len(self.rootNotes)*len(self.intervalsCents)*len(self.diadTotLev)*(self.nTrialsXStim) + self.nPracticeTrialsXStim*len(self.intervalsCents)*len(self.diadTotLev) print(self.nTrials) practiceTrials = [] mainTrials = [] for rootNote in self.rootNotes: for intervalCents in self.intervalsCents: for n in range(self.nTrialsXStim): mainTrials.append((rootNote, intervalCents, "main", self.diadTotLev[0], self.noise2SL[0], self.preTrialNoiseSL[0])) for intervalCents in self.intervalsCents: for n in range(self.nPracticeTrialsXStim): practiceTrials.append((random.choice(self.rootNotes), intervalCents, "practice", self.diadTotLev[0], self.noise2SL[0], self.preTrialNoiseSL[0])) random.shuffle(practiceTrials) random.shuffle(mainTrials) practiceTrials2 = [] mainTrials2 = [] for rootNote in self.rootNotes: for intervalCents in self.intervalsCents: for n in range(self.nTrialsXStim): mainTrials2.append((rootNote, intervalCents, "main", self.diadTotLev[1], self.noise2SL[1], self.preTrialNoiseSL[1])) for intervalCents in self.intervalsCents: for n in range(self.nPracticeTrialsXStim): practiceTrials2.append((random.choice(self.rootNotes), intervalCents, "practice", self.diadTotLev[1], self.noise2SL[1], self.preTrialNoiseSL[1])) random.shuffle(practiceTrials2) random.shuffle(mainTrials2) #root note #interval cents #practice or main #dialTotLev #noise2SL #preTrialNoiseSL #remove some practice trials #practiceTrials = practiceTrials[0:4] #practiceTrials2 = practiceTrials2[0:4] self.trialList = [] if random.choice([0,1]) == 0: self.trialList.extend(practiceTrials) self.trialList.extend(practiceTrials2) else: self.trialList.extend(practiceTrials2) self.trialList.extend(practiceTrials) if random.choice([0,1]) == 0: self.trialList.extend(mainTrials) self.trialList.extend(mainTrials2) else: self.trialList.extend(mainTrials2) self.trialList.extend(mainTrials) print(len(self.trialList)) self.menubar = self.menuBar() self.fileMenu = self.menubar.addMenu(self.tr('-')) self.editPhonesAction = QAction(self.tr('Phones Calibration'), self) self.fileMenu.addAction(self.editPhonesAction) self.editPhonesAction.triggered.connect(self.onEditPhones) self.setupListenerButton = QPushButton(self.tr("Setup Listener"), self) self.setupListenerButton.clicked.connect(self.onClickSetupListenerButton) self.setupListenerButton.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) # self.setupListenerButton.setToolTip(self.tr("Choose file to save results")) # self.setupListenerButton.setWhatsThis(self.tr("Choose where to save the result files")) self.setupListenerButton.setStyleSheet('font-size: 32pt; font-weight: bold') self.hbox1_sizer.addWidget(self.setupListenerButton) self.main_sizer.addLayout(self.hbox1_sizer) #statusButtonFont = QFont("Arial", 26); self.statusButton = QPushButton(self.tr("Start"), self) self.statusButton.clicked.connect(self.onClickStatusButton) self.statusButton.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) self.main_sizer.addWidget(self.statusButton) #self.statusButton.setFont(statusButtonFont) self.statusButton.setStyleSheet('font-size: 32pt; font-weight: bold') self.statusButton.hide() self.cw.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) borderWidth = 4 self.main_sizer.addItem(QSpacerItem(20, 60, QSizePolicy.Fixed)) self.overallRatingSliderValue = QLabel(self.tr("0"), self) self.main_sizer.addWidget(self.overallRatingSliderValue) self.overallRatingSliderValue.setStyleSheet('font-size: 22pt; font-weight: normal') self.overallRatingSliderValue.setAlignment(Qt.AlignCenter) self.main_sizer.addItem(QSpacerItem(20,60, QSizePolicy.Fixed)) sliderFont = QFont("Ubuntu", 18) self.overallRatingSlider = Qwt.QwtSlider(self, Qt.Horizontal, Qwt.QwtSlider.BottomScale) self.overallRatingSlider.setFont(sliderFont) self.overallRatingSlider.setScale(-3.0,3.0, 1) self.overallRatingSlider.setRange(-3.0,3.0) self.overallRatingSlider.valueChanged[float].connect(self.sliderChanged) self.overallRatingSlider.setMinimumSize(800, 20) self.overallRatingSlider.setBorderWidth(borderWidth) self.main_sizer.addWidget(self.overallRatingSlider) self.main_sizer.addItem(QSpacerItem(20,30, QSizePolicy.Fixed)) self.gauge = QProgressBar(self) self.gauge.setRange(0, 100) self.main_sizer.addWidget(self.gauge) self.cw.setLayout(self.main_sizer) self.setCentralWidget(self.cw) self.show()
def MoveToScreenCenter(self): screen = QDesktopWidget().screenGeometry() mysize = self.geometry() hpos = ( screen.width() - mysize.width() ) / 2 vpos = ( screen.height() - mysize.height() ) / 2 self.move(hpos, vpos)
def init_ui(self, db): """Initializes main window. """ self.db = db editor = XmlEditor() self.setCentralWidget(editor) editor.textChanged.connect(partial(fb_changed, self, db)) self.editor = editor act_new = QAction(QIcon('icons/new.png'), 'New', self) act_new.setShortcut('Ctrl+N') act_new.setStatusTip('Create new file') act_new.triggered.connect(partial(fb_new, self, db)) act_open = QAction(QIcon('icons/open.png'), 'Open...', self) act_open.setShortcut('Ctrl+O') act_open.setStatusTip('Open file') act_open.triggered.connect(partial(fb_open, self, db)) act_save = QAction(QIcon('icons/save.png'), 'Save', self) act_save.setShortcut('Ctrl+S') act_save.setStatusTip('Save file') act_save.triggered.connect(partial(fb_save, self, db)) act_saveas = QAction(QIcon('icons/saveas.png'), 'Save As...', self) act_saveas.setShortcut('Ctrl+Alt+S') act_saveas.setStatusTip('Save file as') act_saveas.triggered.connect(partial(fb_save_as, self, db, True)) act_exit = QAction(QIcon('icons/exit.png'), 'Exit', self) act_exit.setShortcut('Ctrl+Q') act_exit.setStatusTip('Exit application') act_exit.triggered.connect(partial(fb_exit, self, db)) act_addlicense = QAction(QIcon('icons/add.png'), 'Add License', self) act_addlicense.setShortcut('Ctrl+Alt+L') act_addlicense.setStatusTip('Add new license') act_addlicense.triggered.connect(partial(fb_add_license, self, db)) act_addpackage = QAction(QIcon('icons/add.png'), 'Add Package', self) act_addpackage.setShortcut('Ctrl+Alt+P') act_addpackage.setStatusTip('Add new package') act_addpackage.triggered.connect(partial(fb_add_package, self, db)) act_addversion = QAction(QIcon('icons/add.png'), 'Add Version', self) act_addversion.setShortcut('Ctrl+Alt+V') act_addversion.setStatusTip('Add new version') act_addversion.triggered.connect(partial(fb_add_version, self, db)) act_clone = QAction(QIcon('icons/clone.png'), 'Clone Item', self) act_clone.setShortcut('Ctrl+Alt+C') act_clone.setStatusTip('Clone item') act_clone.triggered.connect(partial(fb_clone_item, self, db)) act_delete = QAction(QIcon('icons/delete.png'), 'Delete Item', self) act_delete.setShortcut('Ctrl+Alt+D') act_delete.setStatusTip('Delete item') act_delete.triggered.connect(partial(fb_delete_item, self, db)) act_home = QAction(QIcon('icons/www.png'), 'Npackd Home Page', self) act_home.setStatusTip('Npackd home page') act_home.triggered.connect(partial(webbrowser.open, 'https://npackd.appspot.com')) act_doc_repo = QAction(QIcon('icons/www.png'), 'Repository Format', self) act_doc_repo.setShortcut('F1') act_doc_repo.setStatusTip('Online help') act_doc_repo.triggered.connect(partial(webbrowser.open, 'https://code.google.com/p/windows-package-manager/wiki/RepositoryFormat')) act_doc_scripts = QAction(QIcon('icons/www.png'), 'Installation Scripts', self) act_doc_scripts.setStatusTip('Online help') act_doc_scripts.triggered.connect(partial(webbrowser.open, 'https://code.google.com/p/windows-package-manager/wiki/InstallationScripts')) act_example = QAction(QIcon('icons/www.png'), 'Sample Repository', self) act_example.setStatusTip('Example of repository') act_example.triggered.connect(partial(webbrowser.open, 'https://npackd.appspot.com/rep/xml?tag=stable')) act_about = QAction(QIcon('icons/about.png'), 'About...', self) act_about.setStatusTip('About Repo Editor') act_about.triggered.connect(partial(self.show_about, db)) self.statusBar() mnu_bar = self.menuBar() mnu_file = mnu_bar.addMenu('&File') mnu_file.addAction(act_new) mnu_file.addAction(act_open) mnu_file.addAction(act_save) mnu_file.addAction(act_saveas) mnu_file.addSeparator() mnu_file.addAction(act_exit) mnu_edit = mnu_bar.addMenu('&Edit') mnu_edit.addAction(act_addlicense) mnu_edit.addAction(act_addpackage) mnu_edit.addAction(act_addversion) mnu_edit.addSeparator() mnu_edit.addAction(act_clone) mnu_edit.addAction(act_delete) mnu_licenses = mnu_bar.addMenu('&Licences') mnu_packages = mnu_bar.addMenu('&Packages') mnu_versions = mnu_bar.addMenu('&Versions') mnu_help = mnu_bar.addMenu('&Help') mnu_help.addAction(act_home) mnu_help.addAction(act_doc_repo) mnu_help.addAction(act_doc_scripts) mnu_help.addAction(act_example) mnu_help.addSeparator() mnu_help.addAction(act_about) self.dynamic_menus['license'] = (mnu_licenses, fb_select_license) self.dynamic_menus['package'] = (mnu_packages, fb_select_package) self.dynamic_menus['version'] = (mnu_versions, fb_select_version) screen = QDesktopWidget().screenGeometry() w = 1000 h = 400 self.setGeometry((screen.width() - w)//2, (screen.height() - h)//2, w, h) self.setWindowIcon(QIcon('icons/repoeditor.png')) fb_new(self, db) self.show()
def center_window(window): """Center a window on the screen.""" s = QDesktopWidget().screenGeometry() g = window.geometry() window.move((s.width() - g.width()) // 2, (s.height() - g.height()) // 2)
def __init__(self, parent): QDialog.__init__(self, parent) self.prm = self.parent().prm self.currLocale = self.parent().prm['currentLocale'] self.currLocale.setNumberOptions(self.currLocale.OmitGroupSeparator | self.currLocale.RejectGroupSeparator) screen = QDesktopWidget().screenGeometry() self.resize(screen.width()/2.5,screen.height()/3) self.isPlaying = False #self.audioManager = audioManager(self) #self.playThread = threadedPlayer(self) self.sizer = QGridLayout() self.v1Sizer = QVBoxLayout() self.v2Sizer = QVBoxLayout() self.calibSizer = QGridLayout() self.phonesTableWidget = QTableWidget() self.phonesTableWidget.setColumnCount(4) self.phonesTableWidget.setSelectionBehavior(QAbstractItemView.SelectRows) self.phonesTableWidget.setSelectionMode(QAbstractItemView.ExtendedSelection) self.phonesTableWidget.setHorizontalHeaderLabels([self.tr('Phones'), self.tr('Max Level'), self.tr('Default'), 'id']) self.phonesTableWidget.hideColumn(3) self.phonesTableWidget.cellDoubleClicked[int,int].connect(self.onCellDoubleClicked) #RENAME Phones BUTTON self.renamePhonesButton = QPushButton(self.tr("Rename Phones"), self) self.renamePhonesButton.clicked.connect(self.onEditLabel) #Change Level Phones BUTTON self.changeLevelPhonesButton = QPushButton(self.tr("Change Max Level"), self) self.changeLevelPhonesButton.clicked.connect(self.onEditMaxLevel) #ADD Phones BUTTON self.addPhonesButton = QPushButton(self.tr("Add Phones"), self) self.addPhonesButton.clicked.connect(self.onClickAddPhonesButton) #REMOVE Phones BUTTON self.removePhonesButton = QPushButton(self.tr("Remove Phones"), self) self.removePhonesButton.clicked.connect(self.onClickRemovePhonesButton) #Set Default Phones BUTTON self.setDefaultPhonesButton = QPushButton(self.tr("Set Default"), self) self.setDefaultPhonesButton.clicked.connect(self.onEditDefault) self.v1Sizer.addWidget(self.renamePhonesButton) self.v1Sizer.addWidget(self.changeLevelPhonesButton) self.v1Sizer.addWidget(self.addPhonesButton) self.v1Sizer.addWidget(self.removePhonesButton) self.v1Sizer.addWidget(self.setDefaultPhonesButton) self.v1Sizer.addStretch() self.phonesList = {} for i in range(len(self.prm['phones']['phonesChoices'])): currCount = i+1 thisID = self.prm['phones']['phonesID'][i] self.phonesList[thisID] = {} self.phonesList[thisID]['label'] = self.prm['phones']['phonesChoices'][i] self.phonesList[thisID]['maxLevel'] = self.prm['phones']['phonesMaxLevel'][i] self.phonesList[thisID]['default'] = self.prm['phones']['defaultPhones'][i] self.phonesTableWidget.setRowCount(currCount) newItem = QTableWidgetItem(self.phonesList[thisID]['label']) newItem.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) self.phonesTableWidget.setItem(currCount-1, 0, newItem) newItem = QTableWidgetItem(self.currLocale.toString(self.phonesList[thisID]['maxLevel'])) newItem.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) self.phonesTableWidget.setItem(currCount-1, 1, newItem) newItem = QTableWidgetItem(self.phonesList[thisID]['default']) newItem.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) self.phonesTableWidget.setItem(currCount-1, 2, newItem) self.phonesList[thisID]['qid'] = QTableWidgetItem(thisID) self.phonesTableWidget.setItem(currCount-1, 3, self.phonesList[thisID]['qid']) ##CALIBRATION TONE n = 0 self.calLabel = QLabel(self.tr('Calibration Tone:'), self) self.calibSizer.addWidget(self.calLabel, n, 0, 1, 2) n = n+1 self.toneFreqLabel = QLabel(self.tr('Frequency (Hz)'), self) self.toneFreqTF = QLineEdit("1000") self.toneFreqTF.setValidator(QDoubleValidator(self)) self.calibSizer.addWidget(self.toneFreqLabel, n, 0) self.calibSizer.addWidget(self.toneFreqTF, n, 1) n = n+1 self.toneLevLabel = QLabel(self.tr('Level (dB)'), self) self.toneLevTF = QLineEdit("60") self.toneLevTF.setValidator(QDoubleValidator(self)) self.calibSizer.addWidget(self.toneLevLabel, n, 0) self.calibSizer.addWidget(self.toneLevTF, n, 1) n = n+1 self.toneDurLabel = QLabel(self.tr('Duration (ms)'), self) self.toneDurTF = QLineEdit("4980") self.toneDurTF.setValidator(QDoubleValidator(self)) self.calibSizer.addWidget(self.toneDurLabel, n, 0) self.calibSizer.addWidget(self.toneDurTF, n, 1) n = n+1 self.toneRampsLabel = QLabel(self.tr('Ramps (ms)'), self) self.toneRampsTF = QLineEdit("10") self.toneRampsTF.setValidator(QDoubleValidator(self)) self.calibSizer.addWidget(self.toneRampsLabel, n, 0) self.calibSizer.addWidget(self.toneRampsTF, n, 1) n = n+1 self.earLabel = QLabel(self.tr('Ear:'), self) self.earChooser = QComboBox() self.earChooser.addItems([self.tr("Right"), self.tr("Left"), self.tr("Both")]) self.calibSizer.addWidget(self.earLabel, n, 0) self.calibSizer.addWidget(self.earChooser, n, 1) n = n+1 self.playCalibButton = QPushButton(self.tr("Play"), self) self.playCalibButton.clicked.connect(self.onClickPlayCalibButton) self.playCalibButton.setIcon(QIcon.fromTheme("media-playback-start", QIcon(":/media-playback-start"))) self.calibSizer.addWidget(self.playCalibButton, n, 0, 1, 2) n = n+1 self.stopCalibButton = QPushButton(self.tr("Stop"), self) self.stopCalibButton.clicked.connect(self.onClickStopCalibButton) self.stopCalibButton.setIcon(QIcon.fromTheme("media-playback-stop", QIcon(":/media-playback-stop"))) self.calibSizer.addWidget(self.stopCalibButton, n, 0, 1, 2) if self.prm['pref']['sound']['playCommand'] in ["alsaaudio","pyaudio"]: self.stopCalibButton.show() else: self.stopCalibButton.hide() buttonBox = QDialogButtonBox(QDialogButtonBox.Apply|QDialogButtonBox.Ok|QDialogButtonBox.Cancel) buttonBox.accepted.connect(self.accept) buttonBox.rejected.connect(self.reject) buttonBox.button(QDialogButtonBox.Apply).clicked.connect(self.permanentApply) self.sizer.addLayout(self.v1Sizer, 0, 0) self.v2Sizer.addLayout(self.calibSizer) self.v2Sizer.addStretch() self.sizer.addWidget(self.phonesTableWidget, 0, 1) self.sizer.addLayout(self.v2Sizer, 0, 2) self.sizer.addWidget(buttonBox, 1,1,1,2) self.sizer.setColumnStretch(1,2) self.setLayout(self.sizer) self.setWindowTitle(self.tr("Edit Phones")) self.show()
def __init__(self, parent): QDialog.__init__(self, parent) self.prm = self.parent().prm self.currLocale = self.parent().prm['currentLocale'] self.currLocale.setNumberOptions( self.currLocale.OmitGroupSeparator | self.currLocale.RejectGroupSeparator) screen = QDesktopWidget().screenGeometry() self.resize(screen.width() / 2.5, screen.height() / 3) self.isPlaying = False #self.audioManager = audioManager(self) #self.playThread = threadedPlayer(self) self.sizer = QGridLayout() self.v1Sizer = QVBoxLayout() self.v2Sizer = QVBoxLayout() self.calibSizer = QGridLayout() self.phonesTableWidget = QTableWidget() self.phonesTableWidget.setColumnCount(4) self.phonesTableWidget.setSelectionBehavior( QAbstractItemView.SelectRows) self.phonesTableWidget.setSelectionMode( QAbstractItemView.ExtendedSelection) self.phonesTableWidget.setHorizontalHeaderLabels([ self.tr('Phones'), self.tr('Max Level'), self.tr('Default'), 'id' ]) self.phonesTableWidget.hideColumn(3) self.phonesTableWidget.cellDoubleClicked[int, int].connect( self.onCellDoubleClicked) #RENAME Phones BUTTON self.renamePhonesButton = QPushButton(self.tr("Rename Phones"), self) self.renamePhonesButton.clicked.connect(self.onEditLabel) #Change Level Phones BUTTON self.changeLevelPhonesButton = QPushButton(self.tr("Change Max Level"), self) self.changeLevelPhonesButton.clicked.connect(self.onEditMaxLevel) #ADD Phones BUTTON self.addPhonesButton = QPushButton(self.tr("Add Phones"), self) self.addPhonesButton.clicked.connect(self.onClickAddPhonesButton) #REMOVE Phones BUTTON self.removePhonesButton = QPushButton(self.tr("Remove Phones"), self) self.removePhonesButton.clicked.connect(self.onClickRemovePhonesButton) #Set Default Phones BUTTON self.setDefaultPhonesButton = QPushButton(self.tr("Set Default"), self) self.setDefaultPhonesButton.clicked.connect(self.onEditDefault) self.v1Sizer.addWidget(self.renamePhonesButton) self.v1Sizer.addWidget(self.changeLevelPhonesButton) self.v1Sizer.addWidget(self.addPhonesButton) self.v1Sizer.addWidget(self.removePhonesButton) self.v1Sizer.addWidget(self.setDefaultPhonesButton) self.v1Sizer.addStretch() self.phonesList = {} for i in range(len(self.prm['phones']['phonesChoices'])): currCount = i + 1 thisID = self.prm['phones']['phonesID'][i] self.phonesList[thisID] = {} self.phonesList[thisID]['label'] = self.prm['phones'][ 'phonesChoices'][i] self.phonesList[thisID]['maxLevel'] = self.prm['phones'][ 'phonesMaxLevel'][i] self.phonesList[thisID]['default'] = self.prm['phones'][ 'defaultPhones'][i] self.phonesTableWidget.setRowCount(currCount) newItem = QTableWidgetItem(self.phonesList[thisID]['label']) newItem.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) self.phonesTableWidget.setItem(currCount - 1, 0, newItem) newItem = QTableWidgetItem( self.currLocale.toString(self.phonesList[thisID]['maxLevel'])) newItem.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) self.phonesTableWidget.setItem(currCount - 1, 1, newItem) newItem = QTableWidgetItem(self.phonesList[thisID]['default']) newItem.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) self.phonesTableWidget.setItem(currCount - 1, 2, newItem) self.phonesList[thisID]['qid'] = QTableWidgetItem(thisID) self.phonesTableWidget.setItem(currCount - 1, 3, self.phonesList[thisID]['qid']) ##CALIBRATION TONE n = 0 self.calLabel = QLabel(self.tr('Calibration Tone:'), self) self.calibSizer.addWidget(self.calLabel, n, 0, 1, 2) n = n + 1 self.toneFreqLabel = QLabel(self.tr('Frequency (Hz)'), self) self.toneFreqTF = QLineEdit("1000") self.toneFreqTF.setValidator(QDoubleValidator(self)) self.calibSizer.addWidget(self.toneFreqLabel, n, 0) self.calibSizer.addWidget(self.toneFreqTF, n, 1) n = n + 1 self.toneLevLabel = QLabel(self.tr('Level (dB)'), self) self.toneLevTF = QLineEdit("60") self.toneLevTF.setValidator(QDoubleValidator(self)) self.calibSizer.addWidget(self.toneLevLabel, n, 0) self.calibSizer.addWidget(self.toneLevTF, n, 1) n = n + 1 self.toneDurLabel = QLabel(self.tr('Duration (ms)'), self) self.toneDurTF = QLineEdit("980") self.toneDurTF.setValidator(QDoubleValidator(self)) self.calibSizer.addWidget(self.toneDurLabel, n, 0) self.calibSizer.addWidget(self.toneDurTF, n, 1) n = n + 1 self.toneRampsLabel = QLabel(self.tr('Ramps (ms)'), self) self.toneRampsTF = QLineEdit("10") self.toneRampsTF.setValidator(QDoubleValidator(self)) self.calibSizer.addWidget(self.toneRampsLabel, n, 0) self.calibSizer.addWidget(self.toneRampsTF, n, 1) n = n + 1 self.earLabel = QLabel(self.tr('Ear:'), self) self.earChooser = QComboBox() self.earChooser.addItems( [self.tr("Right"), self.tr("Left"), self.tr("Both")]) self.calibSizer.addWidget(self.earLabel, n, 0) self.calibSizer.addWidget(self.earChooser, n, 1) n = n + 1 self.playCalibButton = QPushButton(self.tr("Play"), self) self.playCalibButton.clicked.connect(self.onClickPlayCalibButton) self.playCalibButton.setIcon( QIcon.fromTheme("media-playback-start", QIcon(":/media-playback-start"))) self.calibSizer.addWidget(self.playCalibButton, n, 0, 1, 2) n = n + 1 self.stopCalibButton = QPushButton(self.tr("Stop"), self) self.stopCalibButton.clicked.connect(self.onClickStopCalibButton) self.stopCalibButton.setIcon( QIcon.fromTheme("media-playback-stop", QIcon(":/media-playback-stop"))) self.calibSizer.addWidget(self.stopCalibButton, n, 0, 1, 2) if self.prm['pref']['sound']['playCommand'] in [ "alsaaudio", "pyaudio" ]: self.stopCalibButton.show() else: self.stopCalibButton.hide() buttonBox = QDialogButtonBox(QDialogButtonBox.Apply | QDialogButtonBox.Ok | QDialogButtonBox.Cancel) buttonBox.accepted.connect(self.accept) buttonBox.rejected.connect(self.reject) buttonBox.button(QDialogButtonBox.Apply).clicked.connect( self.permanentApply) self.sizer.addLayout(self.v1Sizer, 0, 0) self.v2Sizer.addLayout(self.calibSizer) self.v2Sizer.addStretch() self.sizer.addWidget(self.phonesTableWidget, 0, 1) self.sizer.addLayout(self.v2Sizer, 0, 2) self.sizer.addWidget(buttonBox, 1, 1, 1, 2) self.sizer.setColumnStretch(1, 2) self.setLayout(self.sizer) self.setWindowTitle(self.tr("Edit Phones")) self.show()
def center_on_screen(self): resolution = QDesktopWidget().screenGeometry() self.move((resolution.width() / 2) - (self.frameSize().width() / 2), (resolution.height() / 2) - (self.frameSize().height() / 2))
def __init__(self, parent, sndType): QDialog.__init__(self, parent) self.prm = parent.prm self.currLocale = self.parent().prm['data']['currentLocale'] self.currLocale.setNumberOptions(self.currLocale.OmitGroupSeparator | self.currLocale.RejectGroupSeparator) self.vbl = QVBoxLayout() self.hbl = QHBoxLayout() self.grid_0 = QGridLayout() self.grid_1 = QGridLayout() if sndType == "Harmonic Complex": self.execString = "harm_compl" elif sndType == "Silence": self.execString = "silence" elif sndType == "FM Tone": self.execString = "fm_tone" elif sndType == "AM Tone": self.execString = "am_tone" self.nrows = 0 #SOUND LABEL soundLabelLabel = QLabel(self.tr('Sound Label: ')) self.soundLabelWidget = QLineEdit(self.tr(sndType)) self.grid_0.addWidget(soundLabelLabel, self.nrows, 0) self.grid_0.addWidget(self.soundLabelWidget, self.nrows, 1) self.nrows = self.nrows + 1 #SAMPLING RATE sampRateLabel = QLabel(self.tr('Sampling Rate')) defaultSampRate = 48000 self.sampRateWidget = QLineEdit(self.currLocale.toString(defaultSampRate)) self.sampRateWidget.setValidator(QIntValidator(self)) self.grid_0.addWidget(sampRateLabel, self.nrows, 0) self.grid_0.addWidget(self.sampRateWidget, self.nrows, 1) self.nrows = self.nrows + 1 methodToCall = getattr(self, "select_default_parameters_" + self.execString) self.sndPrm = methodToCall() self.setDefaultParameters() buttonBox = QDialogButtonBox(QDialogButtonBox.Ok| QDialogButtonBox.Cancel) buttonBox.accepted.connect(self.accept) buttonBox.rejected.connect(self.reject) self.grid_0.setAlignment(Qt.AlignTop) self.grid_1.setAlignment(Qt.AlignTop) self.hbl.addLayout(self.grid_0) self.hbl.addLayout(self.grid_1) self.scrollAreaWidgetContents = QWidget()#QFrame() #self.scrollAreaWidgetContents.setFrameStyle(QFrame.StyledPanel|QFrame.Sunken) self.scrollAreaWidgetContents.setLayout(self.hbl) self.scrollArea = QScrollArea() #self.scrollArea.setWidgetResizable(True) self.scrollArea.setWidget(self.scrollAreaWidgetContents) self.scrollAreaWidgetContents.layout().setSizeConstraint(QLayout.SetFixedSize) self.vbl.addWidget(self.scrollArea) self.vbl.addWidget(buttonBox) self.setLayout(self.vbl) screen = QDesktopWidget().screenGeometry() self.resize(int(0.3*screen.width()), int(0.5*screen.height())) self.setWindowTitle(self.tr("Generate Sound"))
def set_window_position(self): """ align window on screen """ resolution = QDesktopWidget().screenGeometry() xpos = resolution.width()*0.97 - self.frameSize().width() ypos = resolution.height()/2 - self.frameSize().height()/2 self.move(xpos, ypos)
def __setup_gui__(self, Dialog): global f f = open(filename, "a") f.write("Setup of gui.\n") f.close() Dialog.setObjectName("Dialog") Dialog.resize(270, 145) self.setWindowTitle("Map Layer") screen = QDesktopWidget().screenGeometry() size = self.geometry() self.move((screen.width() - size.width()) / 2, (screen.height() - size.height()) / 2) self.Render = QPushButton("Render", Dialog) self.Render.setGeometry(QRect(85, 90, 100, 25)) self.Render.setObjectName("Render") self.comboBox = QComboBox(Dialog) self.comboBox.setGeometry(QRect(100, 34, 115, 18)) self.comboBox.setEditable(False) self.comboBox.setMaxVisibleItems(11) self.comboBox.setInsertPolicy(QComboBox.InsertAtBottom) self.comboBox.setObjectName("comboBox") self.comboBox.addItems([ "Google Roadmap", "Google Terrain", "Google Satellite", "Google Hybrid", "Yahoo Roadmap", "Yahoo Satellite", "Yahoo Hybrid", "Bing Roadmap", "Bing Satellite", "Bing Hybrid", "Open Street Maps" ]) self.comboBox.setCurrentIndex(10) self.label1 = QLabel("Source:", Dialog) self.label1.setGeometry(QRect(55, 35, 35, 16)) self.label1.setObjectName("label1") self.slider = QSlider(Dialog) self.slider.setOrientation(Qt.Horizontal) self.slider.setMinimum(1) self.slider.setMaximum(12) self.slider.setValue(4) self.slider.setGeometry(QRect(110, 61, 114, 16)) self.label2 = QLabel("Quality: " + str(self.slider.value()), Dialog) self.label2.setGeometry(QRect(47, 61, 54, 16)) self.label2.setObjectName("label2") self.doubleSpinBox = QDoubleSpinBox(Dialog) self.doubleSpinBox.setGeometry(QRect(160, 5, 40, 20)) self.doubleSpinBox.setDecimals(0) self.doubleSpinBox.setObjectName("doubleSpinBox") self.doubleSpinBox.setMinimum(10.0) self.doubleSpinBox.setValue(20.0) self.doubleSpinBox.setEnabled(False) self.checkBox = QCheckBox("Auto refresh", Dialog) self.checkBox.setGeometry(QRect(50, 6, 100, 20)) self.checkBox.setLayoutDirection(Qt.RightToLeft) self.checkBox.setObjectName("checkBox") self.progressBar = QProgressBar(Dialog) self.progressBar.setGeometry(QRect(5, 130, 260, 10)) self.progressBar.setProperty("value", 0) self.progressBar.setTextVisible(False) self.progressBar.setObjectName("progressBar") self.progressBar.setVisible(False) QObject.connect(self.Render, SIGNAL("clicked()"), Dialog.__repaint__) QMetaObject.connectSlotsByName(Dialog) QObject.connect(self.slider, SIGNAL("valueChanged(int)"), self.__update_slider_label__) QObject.connect(self.comboBox, SIGNAL("activated(int)"), self.__combobox_changed__) self.timerRepaint = QTimer() QObject.connect(self.checkBox, SIGNAL("clicked()"), self.__activate_timer__) QObject.connect(self.timerRepaint, SIGNAL("timeout()"), self.__on_timer__) f = open(filename, "a") f.write("End of setup of gui.\n") f.close()
rootObject.saveFile.connect(saveFile) rootObject.encodeCmd.connect(encodeCmd) rootObject.abortEncode.connect(abortEncode) rootObject.openLogClicked.connect(openLog) # Set home dir in qml rootObject.setHomeDir(home) # Create encode process cmdProcess = MyQProcess() QObject.connect(cmdProcess,SIGNAL("finished(int)"),cmdProcess,SLOT("finishEncode()")) QObject.connect(cmdProcess,SIGNAL("readyReadStandardOutput()"),cmdProcess,SLOT("readStdOutput()")) QObject.connect(cmdProcess,SIGNAL("readyReadStandardError()"),cmdProcess,SLOT("readStdError()")) QObject.connect(cmdProcess,SIGNAL("error()"),cmdProcess,SLOT("errorEncode()")) # Outputfile outputfile = QString("empty") # Display the user interface and allow the user to interact with it. view.setGeometry(0, 0, 480, 575) view.setFixedSize(480, 575) view.setWindowTitle(QCoreApplication.translate(None, 'Encode')) screen = QDesktopWidget().screenGeometry() size = view.geometry() view.move((screen.width()-size.width())/2, (screen.height()-size.height())/2) view.show() #view.showFullScreen() app.exec_()
def center(self): screen = QDesktopWidget().screenGeometry() size = self.geometry() self.resize(0.8 * screen.height(), 0.8 * screen.height()) self.move(screen.width() - (1.15 * size.width()), 0.05 * size.height())
def __init__(self, font, parent=None): super(MainWindow, self).__init__(parent) self.font = font self.setWindowTitle("Meridien") central_widget = QWidget(self) self.setCentralWidget(central_widget) #Center on screen resolution = QDesktopWidget().screenGeometry() self.move((resolution.width() / 2) - (self.frameSize().width() / 2), (resolution.height() / 2) - (self.frameSize().height() / 2)) """ Setting up menu bar """ close_action = QAction('Close', self) close_action.setShortcut("Ctrl+Q") close_action.setStatusTip('Leave the app') close_action.triggered.connect(lambda: self.close()) open_refinement_folder = QAction('Open Refinement Folder', self) open_refinement_folder.triggered.connect(self.open_refinement_folder) self.mainMenu = self.menuBar() self.fileMenu = self.mainMenu.addMenu('&File') self.fileMenu.addAction(open_refinement_folder) self.fileMenu.addAction(close_action) self.refinement_folder = "" create_new_fsc_plot = QAction('&New FSC plot', self) create_new_fsc_plot.triggered.connect( self.event_ontriggered_show_fsc_plot) create_new_overview_plot = QAction('&New resolution overview plot', self) create_new_overview_plot.triggered.connect( self.event_show_resolution_overview_plot) self.plotMenu = self.mainMenu.addMenu('&Plot') self.plotMenu.addAction(create_new_fsc_plot) self.plotMenu.addAction(create_new_overview_plot) """ Setup other components """ self.layout = QGridLayout(central_widget) self.setMenuBar(self.mainMenu) self.tree = QTreeWidget(self) self.tree.setHeaderHidden(True) self.layout.addWidget(self.tree, 1, 0) self.root_items_path_dictionary = {} # Threads self.threadpool = QThreadPool() self.thread_list = [] thr = QThread(self) thr.start() self.reader = DriverFileReader() self.reader.moveToThread(thr) self.thread_list.append(thr) self.timer = QTimer(self) # Connect signals self.reader.sig_sendfolders.connect(self.fill_tree) self.reader.sig_sendfsc.connect(self.show_dialog_fsc) self.tree.itemChanged.connect(self._event_select_deselect_all) self.sig_update_tree.connect(self.update_tree) self.sig_show_overview_plot.connect( self.event_show_resolution_overview_plot) self.show() self.open_refinement_folder() self.monitor = None
def setupMainWindow(self): self.resize(800, 600) screen = QDesktopWidget().screenGeometry() size = self.geometry() self.move(( screen.width()-size.width())/2, (screen.height()-size.height())/2) self.setWindowTitle( '{} - {}'.format(self.settings.notebookName, __appname__)) self.viewedList.setFixedHeight(25) self.noteSplitter.addWidget(self.notesEdit) self.noteSplitter.addWidget(self.notesView) mainSplitter = QSplitter(Qt.Vertical) mainSplitter.setChildrenCollapsible(False) mainSplitter.addWidget(self.viewedList) mainSplitter.addWidget(self.noteSplitter) mainSplitter.addWidget(self.findBar) self.setCentralWidget(mainSplitter) self.searchEdit.returnPressed.connect(self.searchNote) self.quickNoteNav.returnPressed.connect(self.openFuncWrapper) searchLayout = QVBoxLayout() searchLayout.addWidget(self.searchEdit) searchLayout.addWidget(self.searchView) self.searchTab.setLayout(searchLayout) self.tocTree.header().close() indexLayout = QVBoxLayout(self.notesTab) indexLayout.addWidget(self.quickNoteNav) indexLayout.addWidget(self.notesTree) self.dockIndex.setObjectName("Index") self.dockIndex.setWidget(self.notesTab) self.dockSearch.setObjectName("Search") self.dockSearch.setWidget(self.searchTab) self.dockToc.setObjectName("TOC") self.dockToc.setWidget(self.tocTree) self.dockAttachment.setObjectName("Attachment") self.dockAttachment.setWidget(self.attachmentView) self.setDockOptions(QMainWindow.VerticalTabs) self.addDockWidget(Qt.LeftDockWidgetArea, self.dockIndex) self.addDockWidget(Qt.LeftDockWidgetArea, self.dockSearch) self.addDockWidget(Qt.LeftDockWidgetArea, self.dockToc) self.addDockWidget(Qt.LeftDockWidgetArea, self.dockAttachment) self.tabifyDockWidget(self.dockIndex, self.dockSearch) self.tabifyDockWidget(self.dockSearch, self.dockToc) self.tabifyDockWidget(self.dockToc, self.dockAttachment) self.setTabPosition(Qt.LeftDockWidgetArea, QTabWidget.North) self.dockIndex.raise_() # Put dockIndex on top of the tab stack menuBar = QMenuBar(self) self.setMenuBar(menuBar) menuFile = menuBar.addMenu(self.tr('&File')) menuEdit = menuBar.addMenu(self.tr('&Edit')) menuView = menuBar.addMenu(self.tr('&View')) menuHelp = menuBar.addMenu(self.tr('&Help')) # menuFile menuFile.addAction(self.actions['newPage']) menuFile.addAction(self.actions['newSubpage']) menuFile.addAction(self.actions['NBSettings']) menuFile.addAction(self.actions['MDSettings']) menuFile.addAction(self.actions['importPage']) menuFile.addAction(self.actions['openNotebook']) menuFile.addAction(self.actions['reIndex']) menuFile.addSeparator() menuFile.addAction(self.actions['save']) menuFile.addAction(self.actions['saveAs']) menuFile.addAction(self.actions['print_']) menuExport = menuFile.addMenu(self.tr('&Export')) menuExport.addAction(self.actions['html']) menuFile.addSeparator() menuFile.addAction(self.actions['renamePage']) menuFile.addAction(self.actions['delPage']) menuFile.addSeparator() menuFile.addAction(self.actions['quit']) # menuEdit menuEdit.addAction(self.actions['undo']) menuEdit.addAction(self.actions['redo']) menuEdit.addAction(self.actions['findText']) menuEdit.addSeparator() menuEdit.addAction(self.actions['sortLines']) menuEdit.addAction(self.actions['insertImage']) # menuView menuView.addAction(self.actions['edit']) menuView.addAction(self.actions['split']) menuView.addAction(self.actions['flipEditAndView']) menuShowHide = menuView.addMenu(self.tr('Show/Hide')) menuShowHide.addAction(self.dockIndex.toggleViewAction()) menuShowHide.addAction(self.dockSearch.toggleViewAction()) menuShowHide.addAction(self.dockToc.toggleViewAction()) menuShowHide.addAction(self.dockAttachment.toggleViewAction()) #menuMode = menuView.addMenu(self.tr('Mode')) #menuMode.addAction(self.actionLeftAndRight) #menuMode.addAction(self.actionUpAndDown) # menuHelp menuHelp.addAction(self.actions['readme']) menuHelp.addAction(self.actions['changelog']) menuHelp.addAction(self.actions['aboutQt']) toolBar = QToolBar(self.tr("toolbar"), self) toolBar.setObjectName("toolbar") # needed in saveState() toolBar.setIconSize(QSize(16, 16)) toolBar.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) self.addToolBar(Qt.TopToolBarArea, toolBar) toolBar.addAction(self.actions['edit']) toolBar.addAction(self.actions['split']) self.findEdit.returnPressed.connect(self.findText) self.findBar.addWidget(self.findEdit) self.findBar.addWidget(self.checkBox) self.findBar.addAction(self.actions['findPrev']) self.findBar.addAction(self.actions['find']) self.findBar.setVisible(False) self.findBar.visibilityChanged.connect(self.findBarVisibilityChanged) self.setStatusBar(self.statusBar) self.statusBar.addWidget(self.statusLabel, 1) self.notesTree.currentItemChanged.connect( self.currentItemChangedWrapper) self.tocTree.itemClicked.connect(self.tocNavigate) self.notesEdit.textChanged.connect(self.noteEditted) self.notesEdit.document( ).modificationChanged.connect(self.modificationChanged) self.updateRecentViewedNotes() notes = self.settings.recentViewedNotes() if len(notes) != 0: item = self.notesTree.pageToItem(notes[0]) self.notesTree.setCurrentItem(item)
def center(self): """ Centers the current window """ screen = QDesktopWidget().screenGeometry() size = self.geometry() self.move((screen.width() - size.width()) / 2, (screen.height() - size.height()) / 2)
def setupMainWindow(self): self.resize(800, 600) screen = QDesktopWidget().screenGeometry() size = self.geometry() self.move((screen.width() - size.width()) / 2, (screen.height() - size.height()) / 2) self.setWindowTitle('{} - {}'.format(self.settings.notebookName, __appname__)) self.viewedList.setFixedHeight(25) self.noteSplitter.addWidget(self.notesEdit) self.noteSplitter.addWidget(self.notesView) mainSplitter = QSplitter(Qt.Vertical) mainSplitter.setChildrenCollapsible(False) mainSplitter.addWidget(self.viewedList) mainSplitter.addWidget(self.noteSplitter) mainSplitter.addWidget(self.findBar) self.setCentralWidget(mainSplitter) self.searchEdit.returnPressed.connect(self.searchNote) self.quickNoteNav.returnPressed.connect(self.openFuncWrapper) searchLayout = QVBoxLayout() searchLayout.addWidget(self.searchEdit) searchLayout.addWidget(self.searchView) self.searchTab.setLayout(searchLayout) indexLayout = QVBoxLayout(self.notesTab) indexLayout.addWidget(self.quickNoteNav) indexLayout.addWidget(self.notesTree) self.dockIndex.setObjectName("Index") self.dockIndex.setWidget(self.notesTab) self.dockSearch.setObjectName("Search") self.dockSearch.setWidget(self.searchTab) self.dockToc.setObjectName("TOC") self.dockToc.setWidget(self.tocTree) self.dockAttachment.setObjectName("Attachment") self.dockAttachment.setWidget(self.attachmentView) self.setDockOptions(QMainWindow.VerticalTabs) self.addDockWidget(Qt.LeftDockWidgetArea, self.dockIndex) self.addDockWidget(Qt.LeftDockWidgetArea, self.dockSearch) self.addDockWidget(Qt.LeftDockWidgetArea, self.dockToc) self.addDockWidget(Qt.LeftDockWidgetArea, self.dockAttachment) self.tabifyDockWidget(self.dockIndex, self.dockSearch) self.tabifyDockWidget(self.dockSearch, self.dockToc) self.tabifyDockWidget(self.dockToc, self.dockAttachment) self.setTabPosition(Qt.LeftDockWidgetArea, QTabWidget.North) self.dockIndex.raise_() # Put dockIndex on top of the tab stack menuBar = QMenuBar(self) self.setMenuBar(menuBar) menuFile = menuBar.addMenu(self.tr('&File')) menuEdit = menuBar.addMenu(self.tr('&Edit')) menuView = menuBar.addMenu(self.tr('&View')) menuHelp = menuBar.addMenu(self.tr('&Help')) # menuFile menuFile.addAction(self.actions['newPage']) menuFile.addAction(self.actions['newSubpage']) menuFile.addAction(self.actions['NBSettings']) menuFile.addAction(self.actions['MDSettings']) menuFile.addAction(self.actions['importPage']) menuFile.addAction(self.actions['openNotebook']) menuFile.addAction(self.actions['reIndex']) menuFile.addSeparator() menuFile.addAction(self.actions['save']) menuFile.addAction(self.actions['saveAs']) menuFile.addAction(self.actions['print_']) menuExport = menuFile.addMenu(self.tr('&Export')) menuExport.addAction(self.actions['html']) menuFile.addSeparator() menuFile.addAction(self.actions['renamePage']) menuFile.addAction(self.actions['delPage']) menuFile.addSeparator() menuFile.addAction(self.actions['quit']) # menuEdit menuEdit.addAction(self.actions['undo']) menuEdit.addAction(self.actions['redo']) menuEdit.addAction(self.actions['findText']) menuEdit.addAction(self.actions['findRepl']) menuEdit.addSeparator() menuEdit.addAction(self.actions['sortLines']) menuEdit.addAction(self.actions['insertImage']) # menuView menuView.addAction(self.actions['edit']) menuView.addAction(self.actions['split']) menuView.addAction(self.actions['flipEditAndView']) menuShowHide = menuView.addMenu(self.tr('Show/Hide')) menuShowHide.addAction(self.dockIndex.toggleViewAction()) menuShowHide.addAction(self.dockSearch.toggleViewAction()) menuShowHide.addAction(self.dockToc.toggleViewAction()) menuShowHide.addAction(self.dockAttachment.toggleViewAction()) #menuMode = menuView.addMenu(self.tr('Mode')) #menuMode.addAction(self.actionLeftAndRight) #menuMode.addAction(self.actionUpAndDown) # menuHelp menuHelp.addAction(self.actions['readme']) menuHelp.addAction(self.actions['changelog']) menuHelp.addAction(self.actions['aboutQt']) toolBar = QToolBar(self.tr("toolbar"), self) toolBar.setObjectName("toolbar") # needed in saveState() #toolBar.setIconSize(QSize(16, 16)) toolBar.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) self.addToolBar(Qt.TopToolBarArea, toolBar) toolBar.addAction(self.actions['edit']) toolBar.addAction(self.actions['split']) self.findEdit.returnPressed.connect(self.findText) self.findBar.addWidget(self.findEdit) self.findBar.addWidget(self.checkBox) self.findBar.addAction(self.actions['findPrev']) self.findBar.addAction(self.actions['find']) self.findBar.setVisible(False) self.findBar.visibilityChanged.connect(self.findBarVisibilityChanged) self.setStatusBar(self.statusBar) self.statusBar.addWidget(self.statusLabel, 1) self.notesTree.currentItemChanged.connect( self.currentItemChangedWrapper) self.notesTree.nvwCallback = self.newNoteDisplay self.notesTree.nvwtCallback = self.newPlainTextNoteDisplay self.tocTree.itemClicked.connect(self.tocNavigate) self.notesEdit.textChanged.connect(self.noteEditted) self.notesEdit.document().modificationChanged.connect( self.modificationChanged) self.updateRecentViewedNotes() notes = self.settings.recentViewedNotes() if len(notes) != 0: item = self.notesTree.pageToItem(notes[0]) self.notesTree.setCurrentItem(item)
def centerOnScreen(w): resolution = QDesktopWidget().screenGeometry() w.move((resolution.width() / 2) - (w.frameSize().width() / 2), (resolution.height() / 2) - (w.frameSize().height() / 2))
# Set home dir in qml rootObject.setHomeDir(home) # Create encode process cmdProcess = MyQProcess() QObject.connect(cmdProcess, SIGNAL("finished(int)"), cmdProcess, SLOT("finishEncode()")) QObject.connect(cmdProcess, SIGNAL("readyReadStandardOutput()"), cmdProcess, SLOT("readStdOutput()")) QObject.connect(cmdProcess, SIGNAL("readyReadStandardError()"), cmdProcess, SLOT("readStdError()")) QObject.connect(cmdProcess, SIGNAL("error()"), cmdProcess, SLOT("errorEncode()")) # Outputfile outputfile = QString("empty") # Display the user interface and allow the user to interact with it. view.setGeometry(0, 0, 480, 575) view.setFixedSize(480, 575) view.setWindowTitle(QCoreApplication.translate(None, 'Encode')) screen = QDesktopWidget().screenGeometry() size = view.geometry() view.move((screen.width() - size.width()) / 2, (screen.height() - size.height()) / 2) view.show() #view.showFullScreen() app.exec_()
def __init__(self,parent=None): super(QuestionDlg,self).__init__(parent) # self.setStyleSheet("background-image:url('image/panelbg.jpg'); border: 2px; border-radius 2px;") self.setWindowFlags(Qt.CustomizeWindowHint) # self.setStyleSheet("border: 2px; border-radius 2px;") # self.setWindowFlags(Qt.FramelessWindowHint) self.setStyleSheet("background-color: rgba(132, 171, 208, 200);") tabWidget=QTabWidget(self) tabWidget.currentChanged.connect(self.changeTab) # tabWidget.setTabShape(QTabWidget.Triangular) tabWidget.setStyleSheet("QTabWidget::pane{border-width:1px;border-color:rgb(48, 104, 151);\ border-style: outset;background-color: rgb(132, 171, 208);\ background: transparent;} \ QTabWidget::tab-bar{border-width:0px;}\ QTabBar::tab { height: 60px; width: 260px; color:rgb(0, 0, 255); font-size:20px; font-weight:bold;} \ QTabBar::tab:hover{background:rgb(255,255, 255, 100);} \ QTabBar::tab:selected{border-color:green;background-color:white;color:green;}") # tabWidget.setStyleSheet("QTabBar::tab:hover{background:rgb(255,255, 255, 100);}") self.btngroup = QButtonGroup() self.popMenu = QMenu(self) entry1 = self.popMenu.addAction("正确") self.connect(entry1,SIGNAL('triggered()'), lambda : self.answerRight()) entry2 = self.popMenu.addAction("错误") self.connect(entry2,SIGNAL('triggered()'), lambda : self.answerWrong()) entry3 = self.popMenu.addAction("替换") self.connect(entry3,SIGNAL('triggered()'), lambda : self.resetStudent()) w1=QWidget() w1.setAccessibleName("w1tab") self.w1title = QLabel() self.btn_start = MyButton("开始") self.choicenum_text = QComboBox() self.choicenum_text.setObjectName('w1combonums') # self.w1title.setStyleSheet("background-image:url('image/panelbg.jpg');") titleLayout, btnlayout, bottomlayout = self.genOneTab(tabtitle = self.w1title, tabbtn=self.btn_start, tabnums=self.choicenum_text) tab1layout = QVBoxLayout() tab1layout.addLayout(titleLayout) tab1layout.addLayout(btnlayout) tab1layout.addLayout(bottomlayout) w1.setLayout(tab1layout) w1.setStyleSheet("background-color: QLinearGradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ffffff, stop: 1 #228888);") w2=QWidget() w2.setAccessibleName("w2tab") self.w2title = QLabel() self.btn_start2 = QPushButton("开始") self.choicenum_text2 = QComboBox() self.choicenum_text2.setObjectName('w2combonums') titleLayout2, btnlayout2, bottomlayout2 = self.genOneTab(tabtitle = self.w2title, tabbtn=self.btn_start2, tabnums=self.choicenum_text2, strwhere = "where studentsn like '04%' ") tab2layout = QVBoxLayout() tab2layout.addLayout(titleLayout2) tab2layout.addLayout(btnlayout2) tab2layout.addLayout(bottomlayout2) w2.setLayout(tab2layout) w2.setStyleSheet("background-color: QLinearGradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ffffff, stop: 1 #228888);") tabWidget.addTab(w1,"三(3)班") tabWidget.addTab(w2,"三(4)班") tabWidget.resize(740,700) # print(tabWidget.parentWidget()) btnclose = QPushButton(self) btnclose.setToolTip("关闭") btnclose.setText("╳") btnclose.setGeometry(715, 5, 20, 20) btnclose.setStyleSheet("background-color:rgb(0,100,0); color:rgb(255,255,255)") btnclose.clicked.connect(self.close) btnMinimized = QPushButton(self) btnMinimized.setToolTip("最小化") btnMinimized.setText("▁") btnMinimized.setGeometry(690, 5, 20, 20) btnMinimized.setStyleSheet("background-color:rgb(0,100,0); color:rgb(255,255,255)") btnMinimized.clicked.connect(lambda: self.showMinimized()) self.btnSysMenu = QPushButton(self) # self.btnSysMenu.setText("▼") self.btnSysMenu.setGeometry(665, 5, 20, 20) self.btnSysMenu.setToolTip("系统设置") self.btnSysMenu.clicked.connect(lambda: self.showMinimized()) menufont = QFont("宋体", 10) popMenu = QMenu(self) entry1 = popMenu.addAction("初始化") entry1.setFont(menufont) self.connect(entry1,SIGNAL('triggered()'), self.initStudent) entry2 = popMenu.addAction("清除提问人员") entry2.setFont(menufont) self.connect(entry2,SIGNAL('triggered()'), self.deleteTmpdata) self.btnSysMenu.setMenu(popMenu) self.btnSysMenu.setStyleSheet("QPushButton::menu-indicator {image: url('image/sysmenu.png');subcontrol-position: right center;} ") # self.btnSysMenu.setStyleSheet("background-color:rgb(0,100,0); color:rgb(255,255,255);") authorinfo = QLabel(tabWidget) # authorinfo.setToolTip("关闭") authorinfo.setText("汕头市大华一小:赵小娜") authorinfo.setGeometry(20, 665, 235, 26) authorinfo.setStyleSheet("background-color:rgba(255, 255, 255,160); font-size:20px;border: 1px solid rgb(60,200,255,200);color:rgba(0,0,0,220);border-radius:12px;") self.setWindowTitle("课堂随机提问") self.setWindowIcon(QIcon("image/start.ico")) self.setGeometry(100, 20, 740, 700) screen = QDesktopWidget().screenGeometry() size = self.geometry() self.move((screen.width()-size.width())/2, (screen.height()-size.height())/2) self.btn_start.setMyarg('start') # print(self.btn_start.getMyarg()) self.connect(self.btn_start, SIGNAL("clicked()"), self.startChoice) # self.connect(self.w1title, SIGNAL("currentIndexChanged(int)"), self.changeTitle) self.connect(self.btn_start2, SIGNAL("clicked()"), self.startChoice) # self.connect(self.w2title, SIGNAL("currentIndexChanged(int)"), self.changeTitle) self.btngroup.buttonClicked[int].connect(self.btns_click)
def center_window(window): """Center a window on the screen.""" s = QDesktopWidget().screenGeometry() g = window.geometry() window.move((s.width() - g.width()) // 2, (s.height() - g.height()) // 2)
def center(self): screen = QDesktopWidget().screenGeometry() size = self.geometry() self.move((screen.width() - size.width()) / 2, (screen.height() - size.height()) / 2)
def __init__( self, ressource_directory, validation_callback: callable, exit_callback: callable, play_callback: callable, screen_id=-1, nb_player=1, nb_life=3, timer_proportions=(0.14, 0.25), life_proportions=(0.12, 0.75), player_proportions=(1, 0.7), player_spacing_proportion=0.33, border_proportion=0.03, multi_life_spacing_proportion=0.12, alpha_color="FF00FF", validate_keys=(65, 32, 16777220, 43), # keys : 'a', space, enter, '+' dev_mode=False): if dev_mode: # TODO utiliser logger print(" Initalisation TwistCanWindow (en mode développeur)") # ----- Init de la fenêtre ----- self.main_app = QApplication(sys.argv) self.main_app.setOverrideCursor(Qt.BlankCursor) # ----- Analyse des paramètres du constructeur ----- # Ajouter le '#' dans les html color if type(alpha_color) == str and len(alpha_color) == 6: alpha_color = "#" + alpha_color self.validate_keys = validate_keys self.validation_callback = validation_callback self.play_callback = play_callback self.exit_callback = exit_callback # récupérer les dimension de l'écran selectioné if screen_id < 0: screen_id = QDesktopWidget().screenCount() screen_size = QDesktopWidget().screenGeometry(screen_id).size() border_size = screen_size.width() * border_proportion timer_size = QSize( round((screen_size.width() - border_size * 2) * timer_proportions[0]), round((screen_size.height() - border_size * 2) * timer_proportions[1])) player_size = QSize( round(screen_size.width() * player_proportions[0]), round(screen_size.height() * player_proportions[1])) life_size = QSize( round( (screen_size.width() - border_size * 2) * life_proportions[0]), round((screen_size.height() - border_size * 2) * life_proportions[1])) # ----- Construction de l'interface ----- # Pose widget if dev_mode: print(" Initialisation Background") self.pose_widget = PoseWidget( ressource_directory, screen_size, player_size, player_spacing_proportion, alpha_color=alpha_color, key_press_event_callback=self.keyPressEventCallback, dev_mode=dev_mode) self.pose_widget.setWindowTitle("TwistCam") # self.setWindowIcon(QtGui.QIcon('web.png')) print("Déplacement du jeu sur l'écran le plus a droite [==>]") # TODO impove avec l'id du screen self.pose_widget.move(QDesktopWidget().width() - 1, 0) self.pose_widget.showFullScreen() # Pose Layout main_layout = QVBoxLayout() main_layout.setSpacing(0) main_layout.setContentsMargins(border_size, border_size, border_size, border_size) self.pose_widget.setLayout(main_layout) # Timer push_right_layout = QBoxLayout(QBoxLayout.RightToLeft) main_layout.addLayout(push_right_layout) self.timer = TimerWidget( ressource_directory, timer_size, dev_mode=dev_mode ) # TODO setup clock_dim and clock_color from config push_right_layout.addWidget(self.timer) push_right_layout.setSpacing(0) push_right_layout.addSpacing(screen_size.width() - 2 * border_size - timer_size.width()) # Lifes if nb_player == 1: # setup special pour 1 seul joueur push_right_layout_2 = QBoxLayout(QBoxLayout.RightToLeft) push_right_layout_2.setSpacing(0) main_layout.addLayout(push_right_layout_2) self.lifes = [ LifeWidget(ressource_directory, life_size, nb_life, dev_mode=dev_mode) ] push_right_layout_2.addWidget(self.lifes[0]) push_right_layout_2.addSpacing(screen_size.width() - 2 * border_size - life_size.width() - (timer_size.width() - life_size.width())) else: multi_life_layout = QHBoxLayout() life_size.setWidth(self.pose_widget.player_pixel_spacing * nb_player) life_offset = (screen_size.width() - 2 * border_size - life_size.width()) * 0.5 multi_life_layout.setContentsMargins(life_offset, 0, life_offset, 0) multi_life_layout.setSpacing( self.pose_widget.player_pixel_spacing * multi_life_spacing_proportion) self.lifes = [ LifeWidget(ressource_directory, QSize( self.pose_widget.player_pixel_spacing * (1 - multi_life_spacing_proportion), life_size.height()), nb_life, dev_mode=dev_mode) for k in range(nb_player) ] for life in self.lifes: multi_life_layout.addWidget(life) main_layout.addSpacing(screen_size.height() - 2 * border_size - timer_size.height() - life_size.height()) main_layout.addLayout(multi_life_layout) # ----- Signaux ----- self.s = self.Signaux(self)
def centerDialog(dialog): size=dialog.size() desktopSize=QDesktopWidget().screenGeometry() top=(desktopSize.height()/2)-(size.height()/2) left=(desktopSize.width()/2)-(size.width()/2) dialog.move(left, top)
def center(self): screen = QDesktopWidget().screenGeometry() size = self.geometry() # self.move((screen.width() - size.width()) / 2, # (screen.height() - size.height()) / 2) self.move((screen.width()), (screen.height() - size.height()))
def __init__(self, parent=None): QWidget.__init__(self, parent) #self.setupUi(self) self.setWindowTitle(u'大图检测') #self.setFixedSize(1280,720) screen = QDesktopWidget().screenGeometry() #self.resize(screen.width(), screen.height()) self.setFixedSize(screen.width() - 100, screen.height() - 100) self.center() ##########################背景层,使用绝对坐标######################## palette = QPalette() self.setBackgroundandSize(self, './background.png', self.backgroundRole(), screen.height(), screen.width()) ##########################标题部分,用的一张图片###################### title = QLabel() self.setBackgroundandSize(title, './titlebg.png', QPalette.Window, 100, 706) hboxTilte = QHBoxLayout() hboxTilte.addWidget(title) ##############################下方左侧############################# #########并列部分 btnSelFile = QPushButton(u"选择文件") self.setBackgroundandSize(btnSelFile, './yellowbar.png', QPalette.Button, 23, 76) btnSelFile.setFlat(True) #边缘消失 editSelFile = QLineEdit(u"file:///") self.setBackgroundandSize(editSelFile, './greybar.png', QPalette.Base, 23, 115) hboxSelFile = QHBoxLayout() hboxSelFile.addWidget(btnSelFile) hboxSelFile.addWidget(editSelFile) self.connect( btnSelFile, SIGNAL("clicked()"), lambda: self.button_openfile_click( Application.btncontrol, editSelFile, previewImg)) hboxPicSize = QHBoxLayout() self.addRow(hboxPicSize, u"大图尺寸", u"宽:xxx 高:xxx", Application.leftSide) hboxOnlineNodes = QHBoxLayout() self.addRow(hboxOnlineNodes, u"联机集群节点数", u"xxx", Application.leftSide, smaller=True) hboxUsedNodes = QHBoxLayout() self.addRow(hboxUsedNodes, u"使用集群节点数", u"xxx", Application.leftSide, smaller=True) ########原图预览 previewTxt = QLabel(u"原图预览") previewTxt.setFixedHeight(25) previewTxt.setFont(QFont("Times New Roman", 12)) palette.setColor(QPalette.WindowText, Qt.yellow) previewTxt.setPalette(palette) previewTxt.setAlignment(Qt.AlignCenter) previewImg = QLabel() previewImg.setFixedHeight(0.3 * screen.height()) previewImg.setFixedWidth(0.2 * screen.width()) previewImg.setAutoFillBackground(True) previewImg.setAlignment(Qt.AlignCenter) image = QPixmap("./rawpic.png").scaled(previewImg.width(), previewImg.height()) previewImg.setPixmap(image) #self.setBackgroundandSize(previewImg,'./rawpic.png',QPalette.Window,128,196) ########终端显示 statusTxt = QLabel(u"集群终端状态") statusTxt.setFixedHeight(25) statusTxt.setFont(QFont("Times New Roman", 12)) palette.setColor(QPalette.WindowText, Qt.yellow) statusTxt.setPalette(palette) statusTxt.setAlignment(Qt.AlignCenter) #statusImg = QLabel() #statusImg.setFixedHeight(0.3 * screen.height()) #statusImg.setFixedWidth(0.2 * screen.width()) #statusImg.setAutoFillBackground(True) #statusImg.setAlignment(Qt.AlignCenter) #palette.setColor(statusImg.backgroundRole(), Qt.black) #statusImg.setPalette(palette) #statusImg.setText("hello!") self.statusEdit = QTextEdit("python gui.py") statusEdit = self.statusEdit statusEdit.setFixedHeight(0.3 * screen.height()) statusEdit.setFixedWidth(0.2 * screen.width()) statusEdit.setAutoFillBackground(True) statusEdit.setAlignment(Qt.AlignLeft) palette.setColor(QPalette.Base, Qt.black) palette.setColor(QPalette.Text, Qt.yellow) statusEdit.setPalette(palette) #self.setBackgroundandSize(statusImg, './rawpic.png', QPalette.Window, 128, 196) ########以垂直的结构显示 vboxleft = QVBoxLayout() vboxleft.addLayout(hboxSelFile) vboxleft.addLayout(hboxPicSize) vboxleft.addLayout(hboxOnlineNodes) vboxleft.addLayout(hboxUsedNodes) vboxleft.addWidget(previewTxt) vboxleft.addWidget(previewImg) vboxleft.addWidget(statusTxt) #vboxleft.addWidget(statusImg) vboxleft.addWidget(statusEdit) ###########################下方中间部分########################## ########控制按钮 Application.btncontrol = QPushButton(u"将大图发送至集群") Application.btncontrol.setFont(QFont("Times New Roman", 12)) Application.btncontrol.setEnabled(False) Application.btncontrol.setFixedHeight(25) Application.btncontrol.setFixedWidth(200) self.connect(Application.btncontrol, SIGNAL("clicked()"), self.button_control_click) ########显示处理后的图片 mid = QLabel() mid.setFixedHeight(440) mid.setFixedWidth(550) # palette.setColor(QPalette.Window, Qt.red) # mid.setAutoFillBackground(True) # mid.setPalette(palette) ########中间部分垂直布局 vboxmid = QVBoxLayout() vboxmid.addWidget(Application.btncontrol) vboxmid.addWidget(mid) ##########################下方右侧部分############################ ########三个返回值 hboxTime = QHBoxLayout() self.addRow(hboxTime, u"运行时间", u"xxx", Application.rightSide) hboxPlanes = QHBoxLayout() self.addRow(hboxPlanes, u"飞机目标数", u"xxx", Application.rightSide) hboxShips = QHBoxLayout() self.addRow(hboxShips, u"舰船目标数", u"xxx", Application.rightSide) btnCoordFile = QPushButton(u"展示结果图") #self.setBackgroundandSize(btnCoordFile, './yellowbar2.png', QPalette.Button, 23, 115) btnCoordFile.setFlat(True) # 边缘消失 self.connect(btnCoordFile, SIGNAL("clicked()"), self.button_show_click) ###飞机船照片路径 ########显示处理后的图片 #coordFilePath = QLabel(u"file:///") #self.setBackgroundandSize(coordFilePath, './greybar.png', QPalette.Window, 23, 115) hboxCoordFile = QHBoxLayout() #hboxCoordFile.addWidget(coordFilePath) hboxCoordFile.addWidget(btnCoordFile) ########飞机 self.planeImg = QLabel() planeImg = self.planeImg #planeImg.setAlignment(Qt.AlignCenter) #self.setBackgroundandSize(planeImg,'./rawpic2a.png',QPalette.Window,128,196) planeImg.setFixedHeight(0.3 * screen.height()) planeImg.setFixedWidth(0.2 * screen.width()) planeImg.setAutoFillBackground(True) planeImg.setAlignment(Qt.AlignCenter) planeimage = QPixmap("./rawpic2a.png").scaled(planeImg.width(), planeImg.height()) planeImg.setPixmap(planeimage) ########船 self.shipImg = QLabel() shipImg = self.shipImg #shipImg.setAlignment(Qt.AlignCenter) #self.setBackgroundandSize(shipImg, './rawpic2b.png', QPalette.Window, 128, 196) shipImg.setFixedHeight(0.3 * screen.height()) shipImg.setFixedWidth(0.2 * screen.width()) shipImg.setAutoFillBackground(True) shipImg.setAlignment(Qt.AlignCenter) self.shipimage = QPixmap("./rawpic2b.png").scaled( shipImg.width(), shipImg.height()) shipImg.setPixmap(self.shipimage) ########下方右侧布局 vboxright = QVBoxLayout() vboxright.addLayout(hboxTime) vboxright.addLayout(hboxPlanes) vboxright.addLayout(hboxShips) vboxright.addLayout(hboxCoordFile) vboxright.addWidget(planeImg) vboxright.addWidget(shipImg) ##########################整体布局############################ ########下方左中右 hboxbody = QHBoxLayout() hboxbody.addLayout(vboxleft) hboxbody.addStretch(1) hboxbody.addLayout(vboxmid) hboxbody.addStretch(1) hboxbody.addLayout(vboxright) ########上下两部分 vbox = QVBoxLayout() vbox.addLayout(hboxTilte) vbox.addStretch(0) vbox.addLayout(hboxbody) vbox.addStretch(1) self.setLayout(vbox)