示例#1
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.show_case_editor_signal.connect(self.show_case_editor, Qt.QueuedConnection)
        ui_dir_path = os.path.dirname(__file__)
        ui_file_path = os.path.join(ui_dir_path, 'mainwindow.ui')
        uic.loadUi(ui_file_path, self)
        # todo 更改窗体大小
        screen = QDesktopWidget().screenGeometry()
        self.resize(screen.width() / 2, screen.height() / 2)
        self.setMinimumSize(700, 350)
        self.setWindowTitle("uitest")
        self.move((screen.width() - self.width()) / 2, (screen.height() - self.height()) / 2)  # draw centered
        # Add tab "Case"
        case_manager_widget = CaseManagerWidget(self.show_case_editor_signal,
                                                self.tester)
        self.tabWidget.addTab(case_manager_widget, "Case")

        # Add tab "Run"
        case_run_widget = RunWidget(self.tester)
        self.tabWidget.addTab(case_run_widget, "Run")

        # Add tab "Report"
        case_report_widget = RunnerEventWidget()
        self.tabWidget.addTab(case_report_widget, "Report")

        # Add tab "Setting"
        case_setting_widget = SettingWidget()
        self.tabWidget.addTab(case_setting_widget, "Setting")

        self.refresh_case_data_signal.connect(case_manager_widget.refresh)
        self.message_box = QMessageBox()
        self.start_rpc_server()
        self.is_editor_close_cancel = False
示例#2
0
 def autosize_window(self):
     screen = QDesktopWidget().screenGeometry()
     w = int(screen.width() * 0.8)
     h = int(screen.height() * 0.8)
     self.resize(w, h)
     size = self.geometry()
     self.move(
         (screen.width() - size.width()) / 2,
         (screen.height() - size.height()) / 2
     )
示例#3
0
文件: main.py 项目: lordmauve/mu
 def autosize_window(self):
     """
     Makes the editor 80% of the width*height of the screen and centres it.
     """
     screen = QDesktopWidget().screenGeometry()
     w = int(screen.width() * 0.8)
     h = int(screen.height() * 0.8)
     self.resize(w, h)
     size = self.geometry()
     self.move((screen.width() - size.width()) / 2,
               (screen.height() - size.height()) / 2)
示例#4
0
class BackgroundToolBar(QToolBar):
    def __init__(self, *args, **kwargs):
        super(BackgroundToolBar, self).__init__(*args, **kwargs)
        self.setIconSize(QSize(22, 22))
        self.shownOnce = False
        self.desktopWidget = QDesktopWidget()
        self.setWindowFlags(Qt.FramelessWindowHint|Qt.WindowStaysOnTopHint)
    def halfScreenHeight(self):
        return int((self.desktopWidget.height()-self.height())/2)
    def halfScreenWidth(self):
        return int((self.desktopWidget.width()-self.width())/2)
    def show(self):
        super(BackgroundToolBar, self).show()
        if not self.shownOnce:
            self.move(self.desktopWidget.width()-self.width(), self.halfScreenHeight())
            self.shownOnce = True
    def mousePressEvent(self, ev):
        if ev.button() != Qt.LeftButton:
            return QToolBar.mousePressEvent(self, ev)
        else:
            if not QApplication.instance().keyboardModifiers() in (Qt.ControlModifier, Qt.ShiftModifier, Qt.AltModifier):
                QApplication.setOverrideCursor(Qt.SizeAllCursor)
            self.mouseX = ev.globalX()
            self.origX = self.x()
            self.mouseY = ev.globalY()
            self.origY = self.y()
    def mouseMoveEvent(self, ev):
        if self.mouseX and self.mouseY and not self.isMaximized():
            self.move(self.origX + ev.globalX() - self.mouseX,
self.origY + ev.globalY() - self.mouseY)
    def mouseReleaseEvent(self, ev):
        QApplication.restoreOverrideCursor()
        x = False
        y = False
        if self.x() + self.width() > self.desktopWidget.width():
            self.move(self.desktopWidget.width()-self.width(), self.y())
            x = True
        elif self.x() < 0:
            self.move(0, self.y())
            x = True
        if x and self.halfScreenHeight() - 64 <= self.y() <= self.halfScreenHeight() + 64:
                self.move(self.x(), self.halfScreenHeight())
        if self.y() < 0:
            self.move(self.x(), 0)
            y = True
        elif self.y() + self.height() > self.desktopWidget.height():
            self.move(self.x(), self.desktopWidget.height()-self.height())
            y = True
        if y and self.halfScreenWidth() - 64 <= self.x() <= self.halfScreenWidth() + 64:
            self.move(self.halfScreenWidth(), self.y())
        return QToolBar.mouseReleaseEvent(self, ev)
示例#5
0
 def __init__(self, parent=None):
     QWidget.__init__(self, parent)
     self.setWindowTitle('Center')
     self.resize(250,150)
     screen = QDesktopWidget().screenGeometry()
     size=self.geometry()
     self.move((screen.width()-size.width())/2,(screen.height()-size.height())/2)
示例#6
0
        def __init__(self, parent=None, id="~"):
            """
            init
            """
            QWidget.__init__(self, parent)
            self.setupUi(self)

            # center this window
            screen = QDesktopWidget().screenGeometry()
            size = self.geometry()
            self.move((screen.width() - size.width()) / 2, (screen.height() - size.height()) / 2)

            self.id = id
            self.flagBtn = RichFlagButton(self)
            self.linelayout.addWidget(self.flagBtn)
            self.desc = HtmlWYSIWYG()
            self.desc.setMinimumHeight(200)
            self.desclayout.addWidget(self.desc)

            if not self.id == "~":
                restore = YeahdocDatasSupply().bc_read1(self.id)
                self.flagBtn.setIcon(QIcon(getPath("iconDir", "yeahdoc/flag/%s" % str(restore['img']))))
                self.flagBtn.setText(restore['img'])
                self.title.setText(restore['title'])
                self.desc.fill(restore['desc'])

            QObject.connect(self.btn, SIGNAL("clicked (QAbstractButton *)"), self.__evt_btn_click)
示例#7
0
 def center_window(self):
     """Puts the field widget in the center of the main window."""
     self.setCentralWidget(self.field_ui)
     screen = QDesktopWidget().screenGeometry()
     size = self.geometry()
     self.move((screen.width() - size.width()) / 2,
               (screen.height() - size.height()) / 2)
示例#8
0
    def __init__(self, parent=None):
        QMainWindow.__init__(self, parent)
        self.setWindowTitle('Shortcut')
        self.setWindowIcon(QIcon(os.path.join(os.curdir, 'icons/Shortcut.ico')))
        self.resize(300, 400)
        screenRect = QDesktopWidget().screenGeometry()
        self.move((screenRect.width() - self.width()) / 2, (screenRect.height() - self.height()) / 2)

        self.mainWidget = QWidget()
        self.gridlayout = QGridLayout()
        self.mainWidget.setLayout(self.gridlayout)
        self.setCentralWidget(self.mainWidget)

        try:
            configloader = ConfigLoader()
        except ConfigError as e:
            QMessageBox.about(self, 'Config Error', str(e))
            return

        for i, (title, action) in enumerate(configloader.config.items()):
            if 'open' in action[0]:
                button = OpenButton(title, action[1])
            elif 'edit' in action[0]:
                button = EditButton(title, action[1], action[2])
            elif 'cmd' in action[0]:
                button = CmdButton(title, action[1])
            else:
                continue

            colnum = 2
            self.gridlayout.addWidget(button, i / colnum, i % colnum)
示例#9
0
 def fitImageToScreen(self, pixmap):
     """Fit pixmap to screen.
     """
     resolution = QDesktopWidget().screenGeometry()
     h, w = resolution.width(), resolution.height()
     w = min(pixmap.width(), w)
     h = min(pixmap.height(), h)
     return pixmap.scaled(QtCore.QSize(w, h), QtCore.Qt.KeepAspectRatio)
示例#10
0
 def init_ui(self):
     self.setWindowOpacity(.7)
     self.setWindowTitle('翻译小能手')
     self.resize(200, 100)
     screen = QDesktopWidget().screenGeometry()
     size = self.geometry()
     self.move((screen.width() - size.width())/2, (screen.height() - size.height())/2)
     self.textEdit = QTextEdit()
     self.setCentralWidget(self.textEdit)
示例#11
0
    def center(self):
        """
        Centering main window relative to screen geometry
        """

        screen = QDesktopWidget().screenGeometry()
        size = self.geometry()
        self.move((screen.width()-size.width())/2,
                  (screen.height()-size.height())/2)
示例#12
0
 def display_window(self):
     #
     self.setGeometry(0, 0, 500, 500)
     resolution = QDesktopWidget().screenGeometry()
     self.move((resolution.width() / 2) - (self.frameSize().width() / 2),
               (resolution.height() / 2) - (self.frameSize().height() / 2))
     self.setWindowTitle('Eight Puzzle')
     self.setWindowIcon(QIcon('Images/eight_puzzle.ico'))
     self.setStyleSheet('background-color: #363B57;')
     self.show()
示例#13
0
    def __init__(self, parent=None):
        QDialog.__init__(self, parent)
        self.setupUi(self)

        # center this window
        screen = QDesktopWidget().screenGeometry()
        size = self.geometry()
        self.move((screen.width() - size.width()) / 2, (screen.height() - size.height()) / 2)

        self.title.setText("<img width='48' src='%s'/><b>%s-%s</b>" % (getPath("iconDir", "logo.png"), Name, Version))
示例#14
0
    def set_window(self):
        """
        Sets the basic window properties.
        """

        # Set window icon
        self.setWindowIcon(qta.icon("ei.magnet", color=Theme.PrimaryColor))

        # Adjust window dimensions to desktop dimensions
        screen = QDesktopWidget().screenGeometry()
        self.setGeometry(0, 0, screen.width(), screen.height())
示例#15
0
 def __init__(self):
     super().__init__()
     watched_bk_pic_path = './source/pic/watched_bk.png'
     search_1_pic_path = './source/pic/next.png'
     search_2_pic_path = './source/pic/next_1.png'
     search_3_pic_path = './source/pic/next_2.png'
     hgzy_font_path = './source/font/HGZYT_CNKI.TTF'
     rem_ico_path = './source/pic/rem.png'
     self.pix = QPixmap(watched_bk_pic_path)
     self.resize(self.pix.width(), self.pix.height())
     self.pix = self.pix.scaled(int(self.pix.width()),
                                int(self.pix.height()))
     self.setMask(self.pix.mask())
     screen = QDesktopWidget().screenGeometry()
     self.move((screen.width() - self.pix.width()) / 2,
               (screen.height() - self.pix.height()) / 2)
     self.setWindowFlags(
         Qt.FramelessWindowHint)  # | QtCore.Qt.WindowStaysOnTopHint
     self.setAttribute(Qt.WA_TranslucentBackground)  # 窗口透明抗锯齿
     rem_icon = QIcon(QPixmap(rem_ico_path))
     self.setWindowIcon(rem_icon)
     self.m_DragPosition = None
     fontId = QFontDatabase.addApplicationFont(hgzy_font_path)
     fontName = QFontDatabase.applicationFontFamilies(fontId)[0]
     self.watchedlist = QDListWidget(self)
     self.watchedlist.setObjectName('WatchedListWidget')
     self.watchedlist.setGeometry(17, 280,
                                  self.pix.width() - 34,
                                  self.pix.height() - 280 - 50)
     self.watchedlist.setStyleSheet(
         '#WatchedListWidget{background:transparent;}')
     self.watchedlist.setFont(QFont(fontName, 15, QFont.Light))
     self.watchedlist.setIconSize(QSize(100, 100))
     self.ShowData()
     self.search = QPushButton(self)
     self.search.setObjectName('Search')
     self.search.setStyleSheet(
         "#Search{border-image: url(%s)}"
         "#Search:hover{border-image: url(%s)}"
         "#Search:pressed{border-image: url(%s)}" %
         (search_1_pic_path, search_2_pic_path, search_3_pic_path))
     self.search.setGeometry(self.pix.width() - self.search.width(),
                             self.pix.height() - self.search.height() - 10,
                             self.search.width() - 20, self.search.height())
     self.choose = Choose(self.x() + self.width(), self.y() + self.height())
     self.choose_show = False
     self.choose_info = {}
     self.search.clicked.connect(self.SearchBt)
     self.detail = Detail(self.x(), self.y())
     self.detail_show = False
     self.watchedlist.itemDoubleClicked.connect(self.DetailBt)
     self.watchedlist.installEventFilter(self)
     self.rightclick = WatchedRightclick()
     self.watchedshow = False
示例#16
0
    def move_window(self):
        shape = QDesktopWidget().screenGeometry()

        w = shape.width()
        h = shape.height()
        win_w = self.frameGeometry().width()
        win_h = self.frameGeometry().height()

        x = w - win_w
        y = 50
        self.move(x, y)
示例#17
0
	def move_window(self):
		shape=QDesktopWidget().screenGeometry()

		w=shape.width()
		h=shape.height()
		win_w=self.frameGeometry().width()
		win_h=self.frameGeometry().height()

		x=w-win_w
		y=50
		self.move(x,y)
示例#18
0
    def init_ui(self):
        """
        init ui, include: resize window
        :return:
        """
        screen = QDesktopWidget().screenGeometry()
        self.resize(screen.width() / 2, screen.height() / 2)
        self.init_btn_icon()

        self.id_line_edit.hide()  # hide line_edit
        self.case_name_line_edit.setPlaceholderText("Case Name")
示例#19
0
 def __init__(self):
     super().__init__()
     self.hide()
     size = self.size()
     screenGeometry = QDesktopWidget().screenGeometry(-1).size()
     self.setGeometry((screenGeometry.width() - size.width()) // 2,
                      (screenGeometry.height() - size.height()) // 2,
                      size.width(), size.height())
     self.path = ''
     uic.loadUi('Menu.ui', self)
     self.initUI()
示例#20
0
class GlassCam(QLabel):
    def __init__(self):
        super(GlassCam, self).__init__()
        self.m_drag = None
        self.m_DragPosition = None
        self.setFixedSize(300, 300)
        self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint)
        self.screen = QDesktopWidget()
        self.setStyleSheet('''
            GlassCam {
                background-color: #202020;
            }
        ''')

    def show_(self):
        self.show()

    def hide_(self):
        self.hide()

    def mousePressEvent(self, e):
        if e.button() == Qt.LeftButton:
            self.m_drag = True
            self.m_DragPosition = e.globalPos() - self.pos()
            e.accept()

    def mouseReleaseEvent(self, e):
        if e.button() == Qt.LeftButton:
            self.m_drag = False
            current = e.globalPos() - self.m_DragPosition
            position = current + QPoint(150, 150)
            x = 0 if position.x() < int(self.screen.width() /
                                        2) else self.screen.width() - 300
            y = 0 if position.y() < int(self.screen.height() /
                                        2) else self.screen.height() - 300
            self.move(QPoint(x, y))

    def mouseMoveEvent(self, e):
        if Qt.LeftButton and self.m_drag:
            self.move(e.globalPos() - self.m_DragPosition)
            e.accept()
示例#21
0
    def initUI(self):
        # Look and feel
        antiAliasedFont = QApplication.font()
        antiAliasedFont.setStyleStrategy(QFont.PreferAntialias)
        QApplication.setFont(antiAliasedFont)

        self.setWindowTitle('Open Chess')
        path = constants.RESOURCES_PATH + '/icon.png'
        self.setWindowIcon(QIcon(path))

        # Geometry
        """This will make the window the correct aspect ratio"""
        screenGeo = QDesktopWidget().availableGeometry()
        idealWidth = constants.IDEAL_RESOLUTION['width']
        idealHeight = constants.IDEAL_RESOLUTION['height']
        # TODO: maybe there is a good way to get this value?
        guessedFrame = 2
        titlebarHeight = QApplication.style().pixelMetric(
                            QStyle.PM_TitleBarHeight) + guessedFrame
        widthDisparity = screenGeo.width() - idealWidth
        heightDisparity = screenGeo.height() - idealHeight
        if widthDisparity < 0 and widthDisparity < heightDisparity:
            width = idealWidth + widthDisparity
            ratio = float(idealHeight) / idealWidth
            height = int(ratio * (idealWidth + widthDisparity))
            self.setGeometry(0, 0, width - guessedFrame * 2,
                             height - titlebarHeight)
        elif heightDisparity < 0 and heightDisparity < widthDisparity:
            ratio = float(idealWidth) / idealHeight
            width = int(ratio * (idealHeight + heightDisparity))
            height = idealHeight + heightDisparity
            self.setGeometry(0, 0, width - guessedFrame * 2,
                             height - titlebarHeight)
        else:
            self.setGeometry(0, 0, idealWidth, idealHeight)
        print("window geometry is", self.geometry())

        # Widget
        self.centralWidget = CentralWidget(self)
        self.setCentralWidget(self.centralWidget)

        self.createActions()
        self.createMenus()

        # Center the window on the desktop
        # TODO: Add option for setting startup xy and saving layout in general
        # qr = self.frameGeometry()
        # cp = QDesktopWidget().geometry().center()
        # qr.moveCenter(cp)
        frameGeo = self.geometry()
        frameGeo.setHeight(frameGeo.height() + titlebarHeight + guessedFrame)
        frameGeo.setWidth(frameGeo.width() + guessedFrame * 2)
        self.move(QDesktopWidget().screenGeometry().center() - frameGeo.center())
示例#22
0
        def start(self):
            shape = QDesktopWidget().screenGeometry()

            w = shape.width()
            h = shape.height()
            win_w = self.frameGeometry().width()
            win_h = self.frameGeometry().height()

            x = w - win_w
            y = 0
            self.move(x, y)
            self.show()
示例#23
0
 def __init__(self, parent=None):
     super(WinForm, self).__init__(parent)
     self.setWindowTitle("Widget Test")
     self.resize(400, 300)
     screen = QDesktopWidget().size()
     size = self.size()
     self.move((screen.width() - size.width()) / 2,
               (screen.height() - size.height()) / 2)
     self.menubar = QMenuBar(self)
     self.menu = QMenu('File')
     self.menubar.addAction(self.menu.menuAction())
     self.setMenuBar(self.menubar)
示例#24
0
    def setupUi(self, MainWindow):
        self.init_function()
        MainWindow.setObjectName("MainWindow")
        MainWindow.setWindowModality(QtCore.Qt.NonModal)
        MainWindow.resize(1024, 768)
        MainWindow.setFixedSize(MainWindow.width(), MainWindow.height())
        MainWindow.setWindowFlags(QtCore.Qt.CustomizeWindowHint
                                  | QtCore.Qt.WindowCloseButtonHint
                                  | QtCore.Qt.WindowMinimizeButtonHint)

        screen = QDesktopWidget().screenGeometry()
        size = self.geometry()
        self.move((screen.width() - size.width()) // 2,
                  (screen.height() - size.height()) // 2)

        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        # 游戏主框架
        self.stackedWidget = QtWidgets.QStackedWidget(self.centralwidget)
        self.stackedWidget.setGeometry(QtCore.QRect(10, 10, 691, 731))
        self.stackedWidget.setFrameShape(QtWidgets.QFrame.Box)
        self.stackedWidget.setObjectName("stackedWidget")
        self.page = QtWidgets.QWidget()
        self.page.setObjectName("page")
        self.uhf = UiHallFrame(self.page, self.user)
        self.stackedWidget.addWidget(self.page)
        self.page_2 = QtWidgets.QWidget()
        self.page_2.setObjectName("page_2")
        self.ugf = UiGameFrame(self.page_2)
        self.stackedWidget.addWidget(self.page_2)
        # 聊天框架
        self.ucf = UiChatFrame(self.centralwidget)
        # UiChatFrame.__init__(self.centralwidget)
        # 用户信息框架
        self.uusf = UiUserShowFrame(self.centralwidget)
        # 用户列表框架
        self.uulf = UiUserListFrame(self.centralwidget)
        self.uulf.sign_userlist_to_menu.connect(self.custom_menu)
        # 创建设置窗口
        self.set_dialog = Ui_DialogSet(self)
        # 创建emoji窗口
        self.emoji_dialog = Ui_DialogEmoji(self)
        # 创建用户信息窗口
        self.userinfo_dialog = Ui_DialogUserInfo(self)

        MainWindow.setCentralWidget(self.centralwidget)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        self.init_game()
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
示例#25
0
    def control_init(self):
        screen = QDesktopWidget().screenGeometry()
        self.move(0, screen.height() * 0.3)

        self.username_line.textChanged.connect(self.check_input_func)
        self.password_line.textChanged.connect(self.check_input_func)
        self.auto_verification.toggled.connect(self.tuokuai_verification)
        self.manual_verification.toggled.connect(self.tuokuai_verification)

        self.dl_active_button.setEnabled(False)
        self.dl_active_button.clicked.connect(self.check_active_button)
        self.dl_active_button.clicked.connect(self.closewin)
示例#26
0
    def __init__(self):
        super().__init__()
        q = QDesktopWidget().availableGeometry()  # Работать с окнами экрана
        r_w, r_h = q.width(), q.height()  # Размеры окна
        self.setGeometry(r_w / 2 - WIDTH / 2, r_h / 2 - HEIGHT / 2, WIDTH,
                         HEIGHT)  # Установить окно по центру

        self.tabs = QTabWidget()
        self.tab1 = File_Readme()
        self.tabs.addTab(self.tab1, "1-ый этап")
        self.setCentralWidget(self.tabs)
        self.setStyleSheet(style_2)
    def __init__(self):
        super(Ui, self).__init__()
        uic.loadUi('ui.ui', self)
        self.setWindowFlags((QtCore.Qt.FramelessWindowHint))

        # Posicionamiento
        this = self.geometry()
        ag = QDesktopWidget().availableGeometry()
        sg = QDesktopWidget().screenGeometry()
        ANCHO_PANTALLA = sg.width()
        ALTO_PANTALLA = sg.height()
        ancho_ventana = this.width()
        alto_ventana = this.height()
        print("Available: " + str(ag.width()) + "x" + str(ag.height()) +
              " Screen Geometry: " + str(ANCHO_PANTALLA) + "x" +
              str(ALTO_PANTALLA) + " This: " + str(this.width()) + "x" +
              str(this.height()))
        x = ag.width() - ancho_ventana
        y = 2 * ag.height() - ALTO_PANTALLA - this.height()
        print(str(x) + "x" + str(y))
        self.move(x, y)
示例#28
0
 def center(self):
     """
     计算和移动窗口
     :return: None
     """
     # 获取屏幕坐标系
     screen = QDesktopWidget().screenGeometry()
     # 获取窗口坐标系
     size = self.geometry()
     newLeft = (screen.width() - size.width()) / 2
     newTop = (screen.height() - size.height()) / 2
     self.move(newLeft, newTop)
示例#29
0
 def __init__(self):
     super().__init__()
     self.setupUi(self)
     self.Listadd()
     self.step = 0
     self.loop = 1
     self.flag = self.listtag = self.fulltag = True
     self.player = vlc.MediaPlayer()
     screen = QDesktopWidget().screenGeometry()
     size = self.geometry()
     self.move(int((screen.width() - size.width()) / 2),
               int((screen.height() - size.height()) / 2))
示例#30
0
    def start(self):
        shape = QDesktopWidget().screenGeometry()

        w = shape.width()
        h = shape.height()
        win_w = self.frameGeometry().width()
        win_h = self.frameGeometry().height()

        x = w - win_w
        y = 0
        self.move(x, y)
        self.show()
示例#31
0
文件: gui.py 项目: mananapr/akari
class imageViewer(QLabel):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("Image Viewer")
        # List of images to be shown in fullscreen
        self.imageViewer_list = []
        # Index of the current image in the imageViewer_list
        self.imageNumber = None

    def set_imageViewerList(self, imgList):
        self.imageViewer_list = imgList

    def set_imageNumber(self, imageNumber):
        self.imageNumber = imageNumber

    """
        Override funtion to add keybindings for image navigation
        Right arrow key for next image
        Left arrow key for previous image
        q to exit
    """

    def keyPressEvent(self, event):
        key = event.key()
        if key == Qt.Key_Right:
            try:
                self.addImage(self.imageViewer_list[self.imageNumber + 1])
                self.imageNumber = self.imageNumber + 1
            except:
                self.imageNumber = 0
                self.addImage(self.imageViewer_list[self.imageNumber])
        elif key == Qt.Key_Left:
            try:
                self.addImage(self.imageViewer_list[self.imageNumber - 1])
                self.imageNumber = self.imageNumber - 1
            except:
                self.imageNumber = len(self.imageViewer_list) - 1
                self.addImage(self.imageViewer_list[self.imageNumber])
        elif key == Qt.Key_Q:
            self.hide()

    """
        Sets `image` as the current image in the fullscreen view
    """

    def addImage(self, image):
        pixmap = QPixmap(image)
        self.screenSize = QDesktopWidget().screenGeometry(0)
        self.setPixmap(
            pixmap.scaled(self.screenSize.width(), self.screenSize.height(),
                          Qt.KeepAspectRatio))
        self.setAlignment(Qt.AlignCenter)
        self.setStyleSheet("QLabel { background-color : black; }")
示例#32
0
    def createBoundingBox(self):
        '''
            Creates bounding box to be used in one of the enxt algorithms
        '''
        im = convert_from_path(self.path, fmt='jpeg', first_page=1, last_page=1)[0]

        im.save("temp\\temp.jpg")

        #get original sizes
        width, height = im.size
        
        im.close()
        
        
        geo = QDesktopWidget().availableGeometry()
        
        #transform for convinience
        if (geo.height() < height):
            width *=  (geo.height()/height) * 0.9
            height = geo.height() * 0.9

        #save for reversing later
        self.scaled_im_width = int(width)
        self.scaled_im_height = int(height)
            
        
        self.pic.setGeometry(0 , 0, width, height)
        self.selector.setFixedSize(width, height)

        #load picture
        self.pic.setPixmap(QPixmap("temp\\temp.jpg").scaledToHeight(height))

        qr = self.selector.frameGeometry()
        cp = QDesktopWidget().availableGeometry().center()
        qr.moveCenter(cp)
        self.selector.move(qr.topLeft())
        
        self.selector.show()

        return
示例#33
0
    def setOrigin(self, index):
        q = QDesktopWidget().screenGeometry()

        if (index == 0):
            self.UpdateMetrixM(q.width() - self.width(), 0)
        elif (index == 1):
            self.UpdateMetrixM(q.width() - self.width(),
                               (q.height() * 0.5) - (self.height() * 0.5))
        elif (index == 2):
            self.UpdateMetrixM(q.width() - self.width(),
                               q.height() - self.height())
        elif (index == 3):
            self.UpdateMetrixM(q.width() * 0.5 - self.width() * 0.5, 0)
        elif (index == 4):
            self.UpdateMetrixM(q.width() * 0.5 - self.width() * 0.5,
                               (q.height() * 0.5) - (self.height() * 0.5))
        elif (index == 5):
            self.UpdateMetrixM(q.width() * 0.5 - self.width() * 0.5,
                               q.height() - self.height())
        elif (index == 6):
            self.UpdateMetrixM(0, 0)
        elif (index == 7):
            self.UpdateMetrixM(0, (q.height() * 0.5) - (self.height() * 0.5))
        elif (index == 8):
            self.UpdateMetrixM(0, q.height() - self.height())
示例#34
0
    def __init__(self):
        """ QMainWindow 에서는 QHBoxLayout, QVBoxLayout 같은 layout 사용못함.
            QWidget, QDialog 와 달리 QMainWindow 는 자체적으로 layout 가지고 있다. central widget 을 반드시 필요로함.
            https://freeprog.tistory.com/326"""
        super().__init__()
        
        # self.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.WindowTitleHint)  # | Qt.FramelessWindowHint)  항상 위에
        # 우하단 위젯
        rect = QDesktopWidget().availableGeometry()   # 작업표시줄 제외한 화면크기 반환
        max_x = rect.width()
        max_y = rect.height()
        # 브라우저 높이에 따른 크롬 실행환경 변경 flag
        global flag_window_height
        if max_y <= 900:
            flag_window_height = False

        width, height = 350 , 220
        # width, height = 350 , 250
        left = max_x - width 
        top = max_y - height 

        self.setGeometry(left, top, width, height)

        # 탭 위젯
        tab1 = Ui_nts_ligin(self)
        tab2 = Ui_nts_task(self)
        tab3 = Ui_web_task(self)

        tabs = QTabWidget()
        tabs.addTab(tab1, '홈택스 로그인')
        tabs.addTab(tab2, '홈택스 작업')
        tabs.addTab(tab3, '웹 작업')

        self.setCentralWidget(tabs)         
        self.setWindowTitle('ATM(자동화)')
        self.setWindowFlags(Qt.FramelessWindowHint)   # windowtitle 제외
        #>>> 메뉴바 https://wikidocs.net/21866
        exitAction = QAction(QIcon('exit.png'), '종료', self)
        exitAction.setShortcut('Ctrl+Q')
        exitAction.setStatusTip('Exit application')
        exitAction.triggered.connect(qApp.quit)

        # self.statusBar()

        menubar = self.menuBar()
        menubar.setNativeMenuBar(False)
        fileMenu = menubar.addMenu('&메뉴')
        fileMenu.addAction(exitAction)
        #<<< 메뉴바
        self.statusBar().showMessage('Ready')

        self.show()
示例#35
0
    def __init__(self,is_keyboard):
        super(MainWindow,self).__init__()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.freq = 50
        #move the control panel to the center of the monitor
        screen = QDesktopWidget().screenGeometry()
        size = self.geometry()
        self.move((screen.width() - size.width()) / 4 * 3,
                  (screen.height() - size.height()) / 2)

        #define the light-control sender
        self._sender = CommSender("localhost", 5888)

        #init the control panel parameters:
        self.ui.data_record_interval_spinbox.setMaximum(1000)
        self.ui.data_num_spinbox.setMaximum(1000)
        self.ui.x_coord_factor_spinbox.setMaximum(1000)
        self.ui.obst_freq_spinbox.setMaximum(500)
        self.ui.obst_freq_spinbox.setMinimum(1)

        self.ui.obst_fall_speed_spinbox.setValue(5)
        self.ui.left_dir_speed_spinbox.setValue(40)
        self.ui.right_dir_speed_spinbox.setValue(40)
        self.ui.obst_freq_spinbox.setValue(5)
        self.ui.x_max_spinbox.setValue(15)
        self.ui.x_max_actual.setText(str(1.5))
        self.ui.data_num_spinbox.setValue(100)
        self.ui.data_num_display.setText(str(100))
        self.ui.x_coord_factor_spinbox.setValue(300)
        self.ui.x_coord_factor_display.setText(str(300))

        #buttons:
        self.ui.manual_start.setEnabled(True)
        self.ui.manual_pause.setEnabled(False)
        self.ui.manual_reset.setEnabled(False)

        # init the signals exchanging center:
        self.signal_center = SignalCenter()
        self.is_keyboard = self.signal_center.is_keyboard
        self.signal_center.is_keyboard = is_keyboard # whether to control via keyboard
        self.signal_center.is_running= False # whether the game is paused or started
        #game-related:
        self.plane_game = plane.PlaneGame(signal_center=self.signal_center,
                                          keyboard_control=False)
        self.plane_game.plane_game_init(signal_center=self.signal_center)
        # self.game_thread = QThread()
        # self.game_thread.started.connect(self.plane_game.run_game)
        # self.game_thread.finished.connect(self.game_thread.deleteLater)
        # self.plane_game.moveToThread(self.game_thread)
        # self.game_thread.start()
        _thread.start_new_thread(self.plane_game.run_game,(self.signal_center,)) # start the game thread
示例#36
0
def main():
    """Create an instance of the music player and use QApplication to show the GUI.

    QDesktopWidget() is used to move the application to the center of the user's screen.
    """
    application = QApplication(sys.argv)
    window = MusicPlayer()
    desktop = QDesktopWidget().availableGeometry()
    width = (desktop.width() - window.width()) / 2
    height = (desktop.height() - window.height()) / 2
    window.show()
    window.move(width, height)
    sys.exit(application.exec_())
示例#37
0
    def center(self):
        """设置窗口居中"""

        # 获取屏幕坐标
        screen = QDesktopWidget().screenGeometry()

        # 获取窗口坐标
        size = self.geometry()

        new_width = (screen.width() - size.width()) / 2
        new_height = (screen.height() - size.height()) / 2

        self.move(new_width, new_height)
示例#38
0
class OknoStart(QDialog):
    def __init__(self):
        super().__init__()
        self.__screen = QDesktopWidget().screenGeometry()
        self.__wys = self.__screen.height() / 6
        self.__szer = self.__screen.width() / 3
        self.setGeometry(self.__screen.width() / 2 - self.__szer / 2,
                         self.__screen.height() / 2 - self.__wys / 2,
                         self.__szer, self.__wys)
        self.setWindowTitle("Podaj wymiary świata: ")
        self.e1 = QLineEdit()
        self.e1.setValidator(QIntValidator())
        self.e1.setMaxLength(2)

        self.e2 = QLineEdit()
        self.e2.setValidator(QIntValidator())
        self.e2.setMaxLength(2)

        ok = QPushButton("OK", self)
        ok.setMaximumWidth(self.__szer / 5)
        ok.clicked.connect(self.ok_click)

        flo = QFormLayout()
        flo.addRow("Szerokość: ", self.e1)
        flo.addRow("Wysokość: ", self.e2)
        flo.addWidget(ok)

        self.setLayout(flo)
        self.show()

    def ok_click(self):
        cols = int(self.e1.text())
        rows = int(self.e2.text())

        if cols > 1 and rows > 1:
            Swiat(rows, cols)
        else:
            print("Nie udało sie utworzyć świata o podanych wymiarach!")
        self.close()
示例#39
0
文件: main.py 项目: lelebilu/project
    def __init__(self):
        super().__init__()

        self.pix = QPixmap('origin.png')
        self.resize(138, 191)
        self.pix = self.pix.scaled(int(114), int(176))
        self.setMask(self.pix.mask())
        self.setWindowFlags(Qt.FramelessWindowHint
                            | QtCore.Qt.WindowStaysOnTopHint)  # 设置无边框和置顶窗口样式
        screen = QDesktopWidget().screenGeometry()
        size = self.geometry()
        self.move((screen.width() - size.width()) / 2, (screen.height() - 210))
        self.checkcd()
def main():
    application = QApplication(sys.argv)
    window = Template()

    ConnectStyleSheetInspector(main_window=window,
                               shortcut=QKeySequence(Qt.CTRL + Qt.SHIFT +
                                                     Qt.Key_F12))
    desktop = QDesktopWidget().availableGeometry()
    width = (desktop.width() - window.width()) / 2
    height = (desktop.height() - window.height()) / 2
    window.show()
    window.move(width, height)
    sys.exit(application.exec_())
示例#41
0
def main():
    """Create an instance of the music player and use QApplication to show the GUI.

    QDesktopWidget() is used to move the application to the center of the user's screen.
    """
    application = QApplication(sys.argv)
    window = MusicPlayer()
    desktop = QDesktopWidget().availableGeometry()
    width = (desktop.width() - window.width()) / 2
    height = (desktop.height() - window.height()) / 2
    window.show()
    window.move(width, height)
    sys.exit(application.exec_())
示例#42
0
    def __init__(self):

        # Inherits from the QDialog class
        super().__init__()

        screenShape = QDesktopWidget().screenGeometry()
        self.setGeometry(int(screenShape.width() * 400 / 1366),
                         int(screenShape.height() * 300 / 768),
                         int(screenShape.width() * 400 / 1366),
                         int(screenShape.height() * 400 / 768))

        self.setWindowTitle('Post Processing')

        self.label = QLabel('Post Processing in progress' + '\n' +
                            'Please close this window and wait' +
                            '\n It may take several minutes')

        self.layout = QVBoxLayout()
        self.layout.addWidget(self.label)
        self.setLayout(self.layout)
        self.setStyleSheet(
            "background-color: rgb(161,183,36); font: 24pt 'Helvetica'; ")
示例#43
0
文件: main.py 项目: innotax/AutoDz
    def __init__(self, title="QMessageBox", msg=None):
        super().__init__()
        self.title = title
        self.msg = msg

        rect = QDesktopWidget().availableGeometry()  # 작업표시줄 제외한 화면크기 반환
        max_x = rect.width()
        max_y = rect.height()

        self.width = 320
        self.height = 550
        self.left = max_x - self.width
        self.top = max_y - self.height
示例#44
0
 def normal(self):
     #退出悬浮窗
     self.hide()
     self.resize(900, 500)
     screen = QDesktopWidget().screenGeometry()
     size = self.geometry()
     self.move((screen.width() - size.width()) / 2,
               (screen.height() - size.height()) / 3)
     self.setWindowFlags(Qt.Widget)
     self.lcd3.setVisible(True)
     self.splider.setVisible(True)
     self.label.setVisible(True)
     self.show()
示例#45
0
    def initUI(self):
        # 设置背景图片
        window_pale = QPalette()
        window_pale.setBrush(
            self.backgroundRole(),
            QBrush(QPixmap("F:\\mytols\\resources\\IMG_0100.jpg")))
        # window_pale.setColor(QPalette.Background, Qt.transparent)
        self.setPalette(window_pale)

        # 设置背景透明度(要全透明必须设置成无边框)
        # self.setAttribute(Qt.WA_TranslucentBackground,True)

        # 窗口无边框
        # self.setWindowFlags(Qt.FramelessWindowHint)

        # 界面透明度
        # self.setWindowOpacity(0.5)

        # 设置窗口标题
        self.setWindowTitle("我是一个进度条😎")
        # 设置窗口图标
        self.setWindowIcon(QIcon("F:\\mytols\\resources\\IMG_0100.jpg"))
        # 获取屏幕大小
        screen_size = QDesktopWidget().screenGeometry()
        # 设置窗口的大小为屏幕的一半,resize方法窗口默认居中
        self.resize(screen_size.width() / 2, screen_size.height() / 2)
        # 构建计时器
        self.timer = QBasicTimer()
        # 计数
        self.step = 0

        # 构建一个进度条
        self.pbar = QProgressBar(self)
        # 从窗口的左上角的(30,50)开始,显示一个250*25的进度条,其中进度条的百分比文本部分长度为40
        self.pbar.setGeometry(30, 50, 220, 25)
        # 设置开始按钮
        self.btn1 = QPushButton("开始", self)
        self.btn2 = QPushButton("复位", self)
        # 按钮位置
        self.btn1.move(30, 90)  # QPushButton大小为90*27
        self.btn2.move(120, 90)
        # 设置按钮点击关联到进度条,进而控制进度条的开始和停止
        # self.btn1.clicked.connect(lambda:self.doAction()) # 如果connect里的函数加括号,需使用lambda函数
        self.btn1.clicked.connect(self.doAction)
        self.btn2.clicked.connect(self.reset)
        self.btn3 = QPushButton("EXIT", self)
        # self.btn3.move(10,50)
        self.btn3.move(self.geometry().width() - 115,
                       self.geometry().height() - 50)
        # self.btn3.clicked.connect(self.go_quit)
        self.btn3.clicked.connect(QApplication.instance().quit)  # 退出程序
示例#46
0
    def __init__(self, name=None, zig_zag=False):
        super().__init__()

        self.name = name

        q = QDesktopWidget().availableGeometry()
        self.cell_size = min(q.width() // self.WIDTH,
                             q.height() // (2 + self.HEIGHT))
        self.resize((self.WIDTH + 10) * self.cell_size, q.height())
        self.next_game_mode = zig_zag
        self.init_game()

        self.pause_btn = QPushButton('PAUSE', self)
        self.pause_btn.move(self.cell_size * (2 + self.WIDTH),
                            9 * self.cell_size)
        self.pause_btn.resize(2 * self.cell_size, 2 * self.cell_size)
        self.pause_btn.clicked.connect(self.pause)
        self.pause_btn.setToolTip('<b>Ctrl+P</b>')

        self.new_game_btn = QPushButton('NEW\nGAME', self)
        self.new_game_btn.move(self.cell_size * (2 + self.WIDTH),
                               11 * self.cell_size)
        self.new_game_btn.resize(2 * self.cell_size, 2 * self.cell_size)
        self.new_game_btn.clicked.connect(self.new_game)
        self.new_game_btn.setToolTip('<b>Ctrl+N</b>')

        self.game_mode_btn = QPushButton('ZIGZAG\nMODE', self)
        self.game_mode_btn.move(self.cell_size * (2 + self.WIDTH),
                                13 * self.cell_size)
        self.game_mode_btn.resize(2 * self.cell_size, 2 * self.cell_size)
        self.game_mode_btn.clicked.connect(self.change_mode)
        self.game_mode_btn.setStyleSheet(
            'QPushButton {background-color: #FF0000;}')
        self.game_mode_btn.setToolTip('<b>Ctrl+Z</b>')

        self.setFocus()

        self.show()
示例#47
0
 def windows_setting(self):
     screen = QDesktopWidget().screenGeometry()
     width = screen.width() / 4
     self.move(screen.width() - width, 0)
     self.resize(width, screen.height())
     self.ui.click_button.setGeometry(
         QtCore.QRect(0, 0, width, screen.height()))
     lcd_show_size_x = 280
     lcd_show_size_y = 160
     self.ui.lcd_show.setGeometry(QtCore.QRect(width / 2 - lcd_show_size_x / 2, \
            (screen.height() / 2 - lcd_show_size_y / 2) - lcd_show_size_y, lcd_show_size_x, lcd_show_size_y))
     log_reset_size_x = 280
     log_reset_size_y = 60
     self.ui.log_reset.setGeometry(QtCore.QRect(width / 2 - log_reset_size_x / 2, \
            log_reset_size_y / 2, log_reset_size_x, log_reset_size_y))
     enable_size_x = 120
     enable_size_y = 20
     self.ui.enable.setGeometry(QtCore.QRect(width / 2 - enable_size_x / 2 - 70, \
            enable_size_y / 2, enable_size_x, enable_size_y))
     disable_size_x = 120
     disable_size_y = 20
     self.ui.disable.setGeometry(QtCore.QRect(width / 2 - disable_size_x / 2 + 70, \
            disable_size_y / 2, disable_size_x, disable_size_y))
示例#48
0
def init_gui():
    pg.setConfigOptions(antialias=True)
    app = QtGui.QApplication([])
    app = app.instance()

    win = pg.QtGui.QMainWindow()
    dims = QDesktopWidget().availableGeometry(win)
    win.setWindowTitle('Audio Visualization')
    cw = QtGui.QWidget()
    win.setCentralWidget(cw)
    layout = QtGui.QVBoxLayout()
    cw.setLayout(layout)
    win.resize(int(0.7 * dims.width()), int(0.7 * dims.height()))
    return app, win, layout
示例#49
0
    def iniciador(self):
        self.setWindowTitle('League of Progra')
        x = QDesktopWidget().screenGeometry()
        self.geometry = (x.width() * 0.85, x.height() * 0.85)
        self.setFixedSize(*self.geometry)

        self.pressed_keys = []
        self.identificators = []
        self.setMouseTracking(True)

        self.menu_signal.connect(self.menu)

        menu = Menu(self.menu_signal)
        self.setCentralWidget(menu)
    def __init__(self, parent):
        super(EditScreenshot, self).__init__(parent= parent)
        self.parent = parent
        self.painter = QPainter()
        orgSize = self.parent.screenPixmap.size()
        availableSize = QDesktopWidget().availableGeometry().size()
        print("imagesize: " + str(orgSize) + " availableSize: " + str(availableSize))
        if orgSize.width() > availableSize.width() or orgSize.height() > availableSize.height():
            image = self.parent.screenPixmap.scaled(availableSize, Qt.KeepAspectRatio, Qt.SmoothTransformation).toImage()
        else:
            image = self.parent.screenPixmap.toImage()

        self.imageHolder = ImageHolder(image)
        self.imageHolder.resize(image.size())
        self.imageHolder.setMinimumSize(image.size())
        self.imageHolder.show()

        mainLayout = QVBoxLayout()

        closeBtn = QPushButton("Close")
        closeBtn.clicked.connect(self.close)
        saveBtn = QPushButton("Save Changes")
        saveBtn.clicked.connect(self.saveChanges)

        scroll = QScrollArea()
        scroll.setWidgetResizable(True)
        scroll.setWidget(self.imageHolder)

        btnLayout = QHBoxLayout()
        btnLayout.addStretch()
        btnLayout.addWidget(saveBtn)
        btnLayout.addWidget(closeBtn)

        mainLayout.addLayout(btnLayout)
        mainLayout.addWidget(scroll)

        save = QShortcut(QKeySequence("Ctrl+s"), self)
        save.activated.connect(self.saveChanges)

        self.setLayout(mainLayout)
        self.resize(QDesktopWidget().availableGeometry().size())
        self.setWindowTitle("Edit Screenshot")
示例#51
0
 def check_resolution(self):
     logging.debug('[ENTER] check_resolution(), resolution=%s' % self.resolution)
     # check resolution min, max...
     w, h = parse_resolution(self.resolution)
     if w != -1 and h != -1:
         minw, minh = MINIMUM_RESOLUTION
         screen = QDesktopWidget().screenGeometry()
         maxw, maxh = screen.width(), screen.height()
         logging.debug('check_resolution() => current width=%d, current_height=%d, min width=%d, '
                       'min height=%d, max width=%d, max height=%d' % (w, h, minw, minh, maxw, maxh))
         if w < minw or h < minh:
             msg = 'Bad resolution (width must be superior to %d and height must be superior to %d) (current %d x %d)' % (
                 minw, minh, w, h)
             self.errors.append(msg)
             logging.error(msg)
         if w > maxw or h > maxh:
             msg = 'Bad resolution (width must be inferior to screen width resolution %d and height must be inferior to screen height resolution %d) (current %d x %d)' % (
                 maxw, maxh, w, h)
             self.errors.append(msg)
             logging.error(msg)
     logging.debug('[EXIT] check_resolution(), resolution=%s' % self.fullscreen)
示例#52
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.dBCommandLineHelper = DBCommandLineHelper()
        ui_dir_path = os.path.dirname(__file__)
        ui_file_path = os.path.join(ui_dir_path, 'add_case.ui')
        uic.loadUi(ui_file_path, self)

        screen = QDesktopWidget().screenGeometry()
        self.resize(screen.width() / 5 * 2, screen.height() / 5 * 2)

        self.search_button = SearchButton()
        self.tag_names_line_edit = TagLineEdit("tag_names_line_edit", self.search_button)
        self.tag_names_line_edit_adapter()
        self.tag_list = None

        self.result_widget = RunnerTableWidget(self.dBCommandLineHelper.query_case_all(), [])
        self.result_table_layout.insertWidget(0, self.result_widget)

        self.message_box = QMessageBox()

        self.search_button.clicked.connect(self.search_event)
        self.selectcasebtn.clicked.connect(self.select_event)
        self.casecancelbtn.clicked.connect(self.close)
示例#53
0
	def set_window(self,window,name):
		global wlist
		for i in range(0,len(wlist)):
			if wlist[i].name==name:
				shape=QDesktopWidget().screenGeometry()

				desktop_w=shape.width()
				desktop_h=shape.height()

				w=window.width()
				h=window.height()

				x=int(wlist[i].x)
				y=int(wlist[i].y)
				if (x+w>desktop_w):
					x=0
					print("Reset with")
				if (y+h>desktop_h):
					y=0
					print("Reset height")

				window.move(x,y)
				break
示例#54
0
    def set_as_wallpaper(self, option):
        """Set current image as wallpaper."""

        # TODO: mac version, testing

        path = QStandardPaths.writableLocation(QStandardPaths.TempLocation)
        image = self.model.get_image()
        desktop_geometry = QDesktopWidget().screenGeometry()

        # Scale image according to option
        if option == 2:
            # Fit to desktop width
            image = image.scaledToWidth(desktop_geometry.width(), Qt.SmoothTransformation)
        elif option == 3:
            # Fit to desktop height
            image = image.scaledToHeight(desktop_geometry.height(), Qt.SmoothTransformation)

        image.save(path + "/hr_wallpaper.bmp") # Save new image
                
        if os.name == 'nt': # Windows
            import win32api, win32con, win32gui

            if self.model.get_image_path() is not None:
                tiled = "1" if option == 1 else "0"
                
                key = win32api.RegOpenKeyEx(win32con.HKEY_CURRENT_USER,"Control Panel\\Desktop",0,win32con.KEY_SET_VALUE)
                win32api.RegSetValueEx(key, "WallpaperStyle", 0, win32con.REG_SZ, "0")
                win32api.RegSetValueEx(key, "TileWallpaper", 0, win32con.REG_SZ, tiled)
                win32gui.SystemParametersInfo(win32con.SPI_SETDESKWALLPAPER, path, win32con.SPIF_UPDATEINIFILE | win32con.SPIF_SENDCHANGE)
            
        else: # Linux
            if self.model.image_path is not None:
                wallpaper_option = 'wallpaper' if option == 0 else 'centered'

                call('gconftool-2 -t str -s /desktop/gnome/background/picture_filename'.split() + [path + "/hr_wallpaper.bmp"], stdout=PIPE, stderr=PIPE)
                call('gconftool-2 -t str -s /desktop/gnome/background/picture_options'.split() + [wallpaper_option], stdout=PIPE, stderr=PIPE)
示例#55
0
    def _build_gui(self):
        # Storages
        buttons = self._buttons

        # Unpack dimension data
        x, y, width, height = CACHE['dimension']

        # If position have not been set before
        if x is NotImplemented:
            screen = QDesktopWidget().screenGeometry()
            x, y = (screen.width() - width) / 2, (screen.height() - height) / 2
        # Set window position and dimension
        self.setGeometry(x, y, width, height)
        self.setFixedWidth(width)

        # Create layout for the entire application and zero-out
        self.layout = main_layout = QVBoxLayout()
        main_layout.setSpacing(0)
        main_layout.setContentsMargins(0, 0, 0, 0)

        # Create and add scrollable area for streams
        self._scroll_area = posts = QScrollArea()
        posts.setWidgetResizable(True)
        posts.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        posts.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        posts.setFrameShape(QFrame.NoFrame)

        # Create a main-stream widget
        main_stream = QWidget()
        main_stream.setFixedWidth(width)

        # TODO: rename self._posts to something meaningful
        self._posts = posts_layout = QVBoxLayout()
        posts_layout.setSpacing(POST_SPACING_FULL)
        posts_layout.setContentsMargins(0, 0, 0, 0)

        # HACK: in both scroll arrows the 'padding_left' value is a hack.
        #       The reason why the arrows are not aligned to the horizontal
        #       center is unknown as it looks like everything is set up properly

        # Add scroll-up icon and text
        self._scroll_up = CoubletButtonWidget(icon=CONSTANTS['icon_scroll_up'],
                                              label='SCROLL UP TO REFRESH',
                                              font=CONSTANTS['text_font_generic'],
                                              palette=CONSTANTS['text_color_light'],
                                              order=ICON_AND_LABEL,
                                              orientation=VERTICAL,
                                              spacing=SMALL_PADDING,
                                              padding_top=POST_SPACING_FULL,
                                              padding_left=8)
        posts_layout.addWidget(self._scroll_up, alignment=Qt.AlignHCenter)
        # Dynamic space
        posts_layout.addStretch(0)
        # Add scroll-down icon and text
        self._scroll_down = CoubletButtonWidget(icon=CONSTANTS['icon_scroll_down'],
                                                label='SCROLL DOWN TO LOAD MORE',
                                                font=CONSTANTS['text_font_generic'],
                                                palette=CONSTANTS['text_color_light'],
                                                order=LABEL_AND_ICON,
                                                orientation=VERTICAL,
                                                spacing=SMALL_PADDING,
                                                padding_bottom=POST_SPACING_FULL,
                                                padding_left=8)
        posts_layout.addWidget(self._scroll_down, alignment=Qt.AlignHCenter)

        # Set posts' layout to stream, add stream to main layout
        main_stream.setLayout(posts_layout)
        posts.setWidget(main_stream)
        main_layout.addWidget(posts)

        # Create menu-bar
        menu_bar = QWidget()
        menu_bar.setPalette(CONSTANTS['panel_color_darker'])
        menu_bar.setAutoFillBackground(True)

        # Create layout for menu-bar and zero-out
        menu_bar_layout = QVBoxLayout()
        menu_bar_layout.setSpacing(0)
        menu_bar_layout.setContentsMargins(0, 0, 0, 0)

        # Create layout for menu buttons and zero-out
        menu_buttons_layout = QHBoxLayout()
        menu_buttons_layout.setSpacing(0)
        menu_buttons_layout.setContentsMargins(0, 0, 0, 0)

        # Add menu-buttons to menu-bar
        menu_bar_layout.addSpacing(2*SMALL_PADDING)
        menu_bar_layout.addLayout(menu_buttons_layout)
        menu_bar_layout.addSpacing(2*SMALL_PADDING)

        # Assign layout and add menu-bar to app
        menu_bar.setLayout(menu_bar_layout)
        main_layout.addWidget(menu_bar)

        # Add buttons and spacess to menu-buttons layout
        menu_buttons_layout.addSpacing(2*SMALL_PADDING)
        # get default double-click interval
        for i, menu_item in enumerate(CoubAPI.STREAM_NAMES):
            # If not the first item, add
            # auto-stretching before it
            if i:
                menu_buttons_layout.addStretch(0)

            # Add menu item
            icon_name = 'icon_' + menu_item
            click = CoubletMouseEventHandler(l_single=lambda n=i: self.on_menu_button_pressed(n))
            menu_button = CoubletButtonWidget(icon=CONSTANTS[icon_name],
                                              icon_selected=CONSTANTS[icon_name + '_selected'],
                                              label=menu_item.upper(),
                                              order=ICON_AND_LABEL,
                                              orientation=HORIZONTAL,
                                              font=CONSTANTS['text_font_generic'],
                                              palette=CONSTANTS['text_color_light'],
                                              palette_selected=CONSTANTS['text_color_light_selected'],
                                              spacing=SMALL_PADDING,
                                              mouse_event_handler=click)
            buttons.append(menu_button)
            menu_buttons_layout.addWidget(menu_button)
        # Tail padding
        menu_buttons_layout.addSpacing(2*SMALL_PADDING)

        self.setLayout(main_layout)
        self.setPalette(CONSTANTS['panel_color_dark'])
示例#56
0
    def __init__(self,dbPath,tblName='',parent=None):

        self.app=QApplication(sys.argv)
        self.SqliteDbTypes=['integer','real','text','blob']
        self.DbPath,self.CurrentTable=dbPath,tblName
        #连接数据库
        self.Db=sqlite3.connect(self.DbPath)
        #构建Gui组件
        super(SqliteDbTableEditer,self).__init__(parent)
        self.setWindowTitle('Sqlite数据库表修改器')
        screen=QDesktopWidget().availableGeometry(0)
        self.setGeometry(screen.width()/3/2-1,
                         screen.height()/5/2-1,
                         screen.width()*2/3,
                         screen.height()*4/5
                         )
        #lay
        lay=QVBoxLayout()
        self.setLayout(lay)
        #数据库表设置控件
        ##layDb
        layDb=QHBoxLayout()
        lay.addLayout(layDb)
        ###lblDb
        lblDb=QLabel('数据库:')
        layDb.addWidget(lblDb)
        ###self.leDb
        self.leDb=QLineEdit()
        self.leDb.setText(self.DbPath)
        layDb.addWidget(self.leDb)
        ###btnDb
        btnChangeDb=QPushButton('浏览')
        btnChangeDb.clicked.connect(self.btnChangeDb_Clicked)
        layDb.addWidget(btnChangeDb)
        ###lblTbl
        lblTbl=QLabel('数据表:')
        layDb.addWidget(lblTbl)
        ###self.cbbTbls
        self.cbbTbls=QComboBox()
        tbls=list(map(lambda x:x[1],
                      list(filter(lambda x:x[0]=='table',
                                  self.Db.execute(
                                      'Select * From sqlite_master'
                                      ).fetchall()
                                  )
                           )
                      )
                  )
        self.cbbTbls.addItems(tbls)
        if self.CurrentTable!='' :
            self.cbbTbls.setCurrentIndex(tbls.index(self.CurrentTable))
        else:
            self.CurrentTable=tbls[0]
            self.makeTableInfo()
            self.cbbTbls.setCurrentIndex(0)
        layDb.addWidget(self.cbbTbls)
        ###lblRename
        lblRename=QLabel('重命名为:')
        layDb.addWidget(lblRename)
        ###self.leRename
        self.leRename=QLineEdit()
        self.leRename.setFixedWidth(100)
        layDb.addWidget(self.leRename)
        ###btnRename
        btnRenameTable=QPushButton('重命名')
        btnRenameTable.clicked.connect(self.btnRenameTable_Clicked)
        layDb.addWidget(btnRenameTable)
        ###btnDeleteTable
        btnDeleteTable=QPushButton('删除表')
        btnDeleteTable.clicked.connect(self.btnDeleteTable_Clicked)
        layDb.addWidget(btnDeleteTable)
        ###btnShow
        self.btnShow=QPushButton('查看表结构')
        self.btnShow.clicked.connect(self.btnShow_Clicked)
        layDb.addWidget(self.btnShow)
        ###设置TableView控件self.tv,以呈现表数据
        self.tv=QTableView()
        lay.addWidget(self.tv)
        ###self.model基本初始化
        self.model=QSqlTableModel(self,QSqlDatabase.addDatabase('QSQLITE'))
        self.model.setEditStrategy(QSqlTableModel.OnFieldChange)
        ###self.tv链接到数据源
        self.tv.setModel(self.model)
        ###self.model数据初始化
        self.model.database().setDatabaseName(self.DbPath)
        self.model.database().open()
        self.model.setTable(self.CurrentTable)
        self.model.select()
        self.cbbTbls.currentIndexChanged.connect(self.changeTable)
        ##layBtns
        layBtns=QHBoxLayout()
        lay.addLayout(layBtns)
        ###btnAddColumn
        btnAddColumn=QPushButton('添加列')
        btnAddColumn.setToolTip('给当前表添加列')
        btnAddColumn.clicked.connect(self.btnAddColumn_Clicked)
        layBtns.addWidget(btnAddColumn)
        ###btnDeleteColumn
        btnDeleteColumn=QPushButton('删除列')
        btnDeleteColumn.setToolTip('删除当前表的列')
        btnDeleteColumn.clicked.connect(self.btnDeleteColumn_Clicked)
        layBtns.addWidget(btnDeleteColumn)
        ###btnRenameColumn
        btnRenameColumn=QPushButton('重命名列')
        btnRenameColumn.setToolTip('重命名当前表的列')
        btnRenameColumn.clicked.connect(self.btnRenameColumn_Clicked)
        layBtns.addWidget(btnRenameColumn)
        ###btnModifyColumnType
        btnModifyColumnType=QPushButton('修改列数据类型')
        btnModifyColumnType.setToolTip('修改当前表的列的数据类型')
        btnModifyColumnType.clicked.connect(self.btnModifyColumnType_Clicked)
        layBtns.addWidget(btnModifyColumnType)
        ###btnModifyColumnConstraint
        btnModifyColumnConstraint=QPushButton('修改列约束')
        btnModifyColumnConstraint.setToolTip('修改当前表的列的约束')
        btnModifyColumnConstraint.clicked.connect(
            self.btnModifyColumnConstraint_Clicked)
        layBtns.addWidget(btnModifyColumnConstraint)
        ###btnOrderColumns
        btnOrderColumns=QPushButton('调整列顺序')
        btnOrderColumns.setToolTip('调整当前表的列的顺序')
        btnOrderColumns.clicked.connect(self.btnOrderColumns_Clicked)
        layBtns.addWidget(btnOrderColumns)
        ###btnModifyTableStruct
        btnModifyTableStruct=QPushButton('修改表结构')
        btnModifyTableStruct.setToolTip('功能:1.增加列;2.删除列;'
                                        +'3.修改列名;4.修改列类型;'
                                        +'5.修改列约束;6.调整列顺序'
                                        )
        btnModifyTableStruct.clicked.connect(self.btnModifyTableStruct_Clicked)
        layBtns.addWidget(btnModifyTableStruct)
        ###btnInsertRow
        btnInsertRow=QPushButton('插入行')
        btnInsertRow.setToolTip('将在数据表最后增加一行新记录')
        btnInsertRow.clicked.connect(self.btnInsertRow_Clicked)
        layBtns.addWidget(btnInsertRow)
        ###btnDeleteRows
        btnDeleteRows=QPushButton('删除行')
        btnDeleteRows.setToolTip('删除所有选中项所在的行')
        btnDeleteRows.clicked.connect(self.btnDeleteRows_Clicked)
        layBtns.addWidget(btnDeleteRows)
        ###btnQuery
        btnQuery=QPushButton('查询数据')
        btnQuery.setToolTip('对当前表或数据库进行查询,查询语句将被直接链接到self.model上')
        btnQuery.clicked.connect(self.btnQuery_Clicked)
        layBtns.addWidget(btnQuery)

        self.show()
        self.app.exec_()
示例#57
0
文件: window.py 项目: daffodil/retext
	def __init__(self, parent=None):
		QMainWindow.__init__(self, parent)
		self.resize(950, 700)
		screenRect = QDesktopWidget().screenGeometry()
		if globalSettings.windowGeometry:
			self.restoreGeometry(globalSettings.windowGeometry)
		else:
			self.move((screenRect.width()-self.width())/2, (screenRect.height()-self.height())/2)
		if not screenRect.contains(self.geometry()):
			self.showMaximized()
		if globalSettings.iconTheme:
			QIcon.setThemeName(globalSettings.iconTheme)
		if QIcon.themeName() in ('hicolor', ''):
			if not QFile.exists(icon_path + 'document-new.png'):
				QIcon.setThemeName(get_icon_theme())
		if QFile.exists(icon_path+'retext.png'):
			self.setWindowIcon(QIcon(icon_path+'retext.png'))
		elif QFile.exists('/usr/share/pixmaps/retext.png'):
			self.setWindowIcon(QIcon('/usr/share/pixmaps/retext.png'))
		else:
			self.setWindowIcon(QIcon.fromTheme('retext',
				QIcon.fromTheme('accessories-text-editor')))
		self.tabWidget = QTabWidget(self)
		self.initTabWidget()
		self.setCentralWidget(self.tabWidget)
		self.tabWidget.currentChanged.connect(self.changeIndex)
		self.tabWidget.tabCloseRequested.connect(self.closeTab)
		toolBar = QToolBar(self.tr('File toolbar'), self)
		self.addToolBar(Qt.TopToolBarArea, toolBar)
		self.editBar = QToolBar(self.tr('Edit toolbar'), self)
		self.addToolBar(Qt.TopToolBarArea, self.editBar)
		self.searchBar = QToolBar(self.tr('Search toolbar'), self)
		self.addToolBar(Qt.BottomToolBarArea, self.searchBar)
		toolBar.setVisible(not globalSettings.hideToolBar)
		self.editBar.setVisible(not globalSettings.hideToolBar)
		self.actionNew = self.act(self.tr('New'), 'document-new',
			self.createNew, shct=QKeySequence.New)
		self.actionNew.setPriority(QAction.LowPriority)
		self.actionOpen = self.act(self.tr('Open'), 'document-open',
			self.openFile, shct=QKeySequence.Open)
		self.actionOpen.setPriority(QAction.LowPriority)
		self.actionSetEncoding = self.act(self.tr('Set encoding'),
			trig=self.showEncodingDialog)
		self.actionSetEncoding.setEnabled(False)
		self.actionReload = self.act(self.tr('Reload'), 'view-refresh',
			lambda: self.currentTab.readTextFromFile())
		self.actionReload.setEnabled(False)
		self.actionSave = self.act(self.tr('Save'), 'document-save',
			self.saveFile, shct=QKeySequence.Save)
		self.actionSave.setEnabled(False)
		self.actionSave.setPriority(QAction.LowPriority)
		self.actionSaveAs = self.act(self.tr('Save as'), 'document-save-as',
			self.saveFileAs, shct=QKeySequence.SaveAs)
		self.actionNextTab = self.act(self.tr('Next tab'), 'go-next',
			lambda: self.switchTab(1), shct=Qt.CTRL+Qt.Key_PageDown)
		self.actionPrevTab = self.act(self.tr('Previous tab'), 'go-previous',
			lambda: self.switchTab(-1), shct=Qt.CTRL+Qt.Key_PageUp)
		self.actionPrint = self.act(self.tr('Print'), 'document-print',
			self.printFile, shct=QKeySequence.Print)
		self.actionPrint.setPriority(QAction.LowPriority)
		self.actionPrintPreview = self.act(self.tr('Print preview'), 'document-print-preview',
			self.printPreview)
		self.actionViewHtml = self.act(self.tr('View HTML code'), 'text-html', self.viewHtml)
		self.actionChangeEditorFont = self.act(self.tr('Change editor font'),
			trig=self.changeEditorFont)
		self.actionChangePreviewFont = self.act(self.tr('Change preview font'),
			trig=self.changePreviewFont)
		self.actionSearch = self.act(self.tr('Find text'), 'edit-find', shct=QKeySequence.Find)
		self.actionSearch.setCheckable(True)
		self.actionSearch.triggered[bool].connect(self.searchBar.setVisible)
		self.searchBar.visibilityChanged.connect(self.searchBarVisibilityChanged)
		self.actionPreview = self.act(self.tr('Preview'), shct=Qt.CTRL+Qt.Key_E,
			trigbool=self.preview)
		if QIcon.hasThemeIcon('document-preview'):
			self.actionPreview.setIcon(QIcon.fromTheme('document-preview'))
		elif QIcon.hasThemeIcon('preview-file'):
			self.actionPreview.setIcon(QIcon.fromTheme('preview-file'))
		elif QIcon.hasThemeIcon('x-office-document'):
			self.actionPreview.setIcon(QIcon.fromTheme('x-office-document'))
		else:
			self.actionPreview.setIcon(QIcon(icon_path+'document-preview.png'))
		self.actionLivePreview = self.act(self.tr('Live preview'), shct=Qt.CTRL+Qt.Key_L,
		trigbool=self.enableLivePreview)
		menuPreview = QMenu()
		menuPreview.addAction(self.actionLivePreview)
		self.actionPreview.setMenu(menuPreview)
		self.actionTableMode = self.act(self.tr('Table mode'), shct=Qt.CTRL+Qt.Key_T,
			trigbool=lambda x: self.currentTab.editBox.enableTableMode(x))
		if ReTextFakeVimHandler:
			self.actionFakeVimMode = self.act(self.tr('FakeVim mode'),
				shct=Qt.CTRL+Qt.ALT+Qt.Key_V, trigbool=self.enableFakeVimMode)
			if globalSettings.useFakeVim:
				self.actionFakeVimMode.setChecked(True)
				self.enableFakeVimMode(True)
		self.actionFullScreen = self.act(self.tr('Fullscreen mode'), 'view-fullscreen',
			shct=Qt.Key_F11, trigbool=self.enableFullScreen)
		self.actionFullScreen.setPriority(QAction.LowPriority)
		self.actionConfig = self.act(self.tr('Preferences'), icon='preferences-system',
			trig=self.openConfigDialog)
		self.actionConfig.setMenuRole(QAction.PreferencesRole)
		self.actionSaveHtml = self.act('HTML', 'text-html', self.saveFileHtml)
		self.actionPdf = self.act('PDF', 'application-pdf', self.savePdf)
		self.actionOdf = self.act('ODT', 'x-office-document', self.saveOdf)
		self.getExportExtensionsList()
		self.actionQuit = self.act(self.tr('Quit'), 'application-exit', shct=QKeySequence.Quit)
		self.actionQuit.setMenuRole(QAction.QuitRole)
		self.actionQuit.triggered.connect(self.close)
		self.actionUndo = self.act(self.tr('Undo'), 'edit-undo',
			lambda: self.currentTab.editBox.undo(), shct=QKeySequence.Undo)
		self.actionRedo = self.act(self.tr('Redo'), 'edit-redo',
			lambda: self.currentTab.editBox.redo(), shct=QKeySequence.Redo)
		self.actionCopy = self.act(self.tr('Copy'), 'edit-copy',
			lambda: self.currentTab.editBox.copy(), shct=QKeySequence.Copy)
		self.actionCut = self.act(self.tr('Cut'), 'edit-cut',
			lambda: self.currentTab.editBox.cut(), shct=QKeySequence.Cut)
		self.actionPaste = self.act(self.tr('Paste'), 'edit-paste',
			lambda: self.currentTab.editBox.paste(), shct=QKeySequence.Paste)
		self.actionUndo.setEnabled(False)
		self.actionRedo.setEnabled(False)
		self.actionCopy.setEnabled(False)
		self.actionCut.setEnabled(False)
		qApp = QApplication.instance()
		qApp.clipboard().dataChanged.connect(self.clipboardDataChanged)
		self.clipboardDataChanged()
		if enchant_available:
			self.actionEnableSC = self.act(self.tr('Enable'), trigbool=self.enableSpellCheck)
			self.actionSetLocale = self.act(self.tr('Set locale'), trig=self.changeLocale)
		self.actionWebKit = self.act(self.tr('Use WebKit renderer'), trigbool=self.enableWebKit)
		self.actionWebKit.setChecked(globalSettings.useWebKit)
		self.actionShow = self.act(self.tr('Show directory'), 'system-file-manager', self.showInDir)
		self.actionFind = self.act(self.tr('Next'), 'go-next', self.find,
			shct=QKeySequence.FindNext)
		self.actionFindPrev = self.act(self.tr('Previous'), 'go-previous',
			lambda: self.find(back=True), shct=QKeySequence.FindPrevious)
		self.actionCloseSearch = self.act(self.tr('Close'), 'window-close',
			lambda: self.searchBar.setVisible(False))
		self.actionCloseSearch.setPriority(QAction.LowPriority)
		self.actionHelp = self.act(self.tr('Get help online'), 'help-contents', self.openHelp)
		self.aboutWindowTitle = self.tr('About ReText')
		self.actionAbout = self.act(self.aboutWindowTitle, 'help-about', self.aboutDialog)
		self.actionAbout.setMenuRole(QAction.AboutRole)
		self.actionAboutQt = self.act(self.tr('About Qt'))
		self.actionAboutQt.setMenuRole(QAction.AboutQtRole)
		self.actionAboutQt.triggered.connect(qApp.aboutQt)
		availableMarkups = markups.get_available_markups()
		if not availableMarkups:
			print('Warning: no markups are available!')
		self.defaultMarkup = availableMarkups[0] if availableMarkups else None
		if globalSettings.defaultMarkup:
			mc = markups.find_markup_class_by_name(globalSettings.defaultMarkup)
			if mc and mc.available():
				self.defaultMarkup = mc
		if len(availableMarkups) > 1:
			self.chooseGroup = QActionGroup(self)
			markupActions = []
			for markup in availableMarkups:
				markupAction = self.act(markup.name, trigbool=self.markupFunction(markup))
				if markup == self.defaultMarkup:
					markupAction.setChecked(True)
				self.chooseGroup.addAction(markupAction)
				markupActions.append(markupAction)
		self.actionBold = self.act(self.tr('Bold'), shct=QKeySequence.Bold,
			trig=lambda: self.insertFormatting('bold'))
		self.actionItalic = self.act(self.tr('Italic'), shct=QKeySequence.Italic,
			trig=lambda: self.insertFormatting('italic'))
		self.actionUnderline = self.act(self.tr('Underline'), shct=QKeySequence.Underline,
			trig=lambda: self.insertFormatting('underline'))
		self.usefulTags = ('header', 'italic', 'bold', 'underline', 'numbering',
			'bullets', 'image', 'link', 'inline code', 'code block', 'blockquote')
		self.usefulChars = ('deg', 'divide', 'dollar', 'hellip', 'laquo', 'larr',
			'lsquo', 'mdash', 'middot', 'minus', 'nbsp', 'ndash', 'raquo',
			'rarr', 'rsquo', 'times')
		self.formattingBox = QComboBox(self.editBar)
		self.formattingBox.addItem(self.tr('Formatting'))
		self.formattingBox.addItems(self.usefulTags)
		self.formattingBox.activated[str].connect(self.insertFormatting)
		self.symbolBox = QComboBox(self.editBar)
		self.symbolBox.addItem(self.tr('Symbols'))
		self.symbolBox.addItems(self.usefulChars)
		self.symbolBox.activated.connect(self.insertSymbol)
		self.updateStyleSheet()
		menubar = self.menuBar()
		menuFile = menubar.addMenu(self.tr('File'))
		menuEdit = menubar.addMenu(self.tr('Edit'))
		menuHelp = menubar.addMenu(self.tr('Help'))
		menuFile.addAction(self.actionNew)
		menuFile.addAction(self.actionOpen)
		self.menuRecentFiles = menuFile.addMenu(self.tr('Open recent'))
		self.menuRecentFiles.aboutToShow.connect(self.updateRecentFiles)
		menuFile.addAction(self.actionShow)
		menuFile.addAction(self.actionSetEncoding)
		menuFile.addAction(self.actionReload)
		menuFile.addSeparator()
		menuFile.addAction(self.actionSave)
		menuFile.addAction(self.actionSaveAs)
		menuFile.addSeparator()
		menuFile.addAction(self.actionNextTab)
		menuFile.addAction(self.actionPrevTab)
		menuFile.addSeparator()
		menuExport = menuFile.addMenu(self.tr('Export'))
		menuExport.addAction(self.actionSaveHtml)
		menuExport.addAction(self.actionOdf)
		menuExport.addAction(self.actionPdf)
		if self.extensionActions:
			menuExport.addSeparator()
			for action, mimetype in self.extensionActions:
				menuExport.addAction(action)
			menuExport.aboutToShow.connect(self.updateExtensionsVisibility)
		menuFile.addAction(self.actionPrint)
		menuFile.addAction(self.actionPrintPreview)
		menuFile.addSeparator()
		menuFile.addAction(self.actionQuit)
		menuEdit.addAction(self.actionUndo)
		menuEdit.addAction(self.actionRedo)
		menuEdit.addSeparator()
		menuEdit.addAction(self.actionCut)
		menuEdit.addAction(self.actionCopy)
		menuEdit.addAction(self.actionPaste)
		menuEdit.addSeparator()
		if enchant_available:
			menuSC = menuEdit.addMenu(self.tr('Spell check'))
			menuSC.addAction(self.actionEnableSC)
			menuSC.addAction(self.actionSetLocale)
		menuEdit.addAction(self.actionSearch)
		menuEdit.addAction(self.actionChangeEditorFont)
		menuEdit.addAction(self.actionChangePreviewFont)
		menuEdit.addSeparator()
		if len(availableMarkups) > 1:
			self.menuMode = menuEdit.addMenu(self.tr('Default markup'))
			for markupAction in markupActions:
				self.menuMode.addAction(markupAction)
		menuFormat = menuEdit.addMenu(self.tr('Formatting'))
		menuFormat.addAction(self.actionBold)
		menuFormat.addAction(self.actionItalic)
		menuFormat.addAction(self.actionUnderline)
		menuEdit.addAction(self.actionWebKit)
		menuEdit.addSeparator()
		menuEdit.addAction(self.actionViewHtml)
		menuEdit.addAction(self.actionPreview)
		menuEdit.addAction(self.actionTableMode)
		if ReTextFakeVimHandler:
			menuEdit.addAction(self.actionFakeVimMode)
		menuEdit.addSeparator()
		menuEdit.addAction(self.actionFullScreen)
		menuEdit.addAction(self.actionConfig)
		menuHelp.addAction(self.actionHelp)
		menuHelp.addSeparator()
		menuHelp.addAction(self.actionAbout)
		menuHelp.addAction(self.actionAboutQt)
		toolBar.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
		toolBar.addAction(self.actionNew)
		toolBar.addSeparator()
		toolBar.addAction(self.actionOpen)
		toolBar.addAction(self.actionSave)
		toolBar.addAction(self.actionPrint)
		toolBar.addSeparator()
		toolBar.addAction(self.actionPreview)
		toolBar.addAction(self.actionFullScreen)
		self.editBar.addAction(self.actionUndo)
		self.editBar.addAction(self.actionRedo)
		self.editBar.addSeparator()
		self.editBar.addAction(self.actionCut)
		self.editBar.addAction(self.actionCopy)
		self.editBar.addAction(self.actionPaste)
		self.editBar.addSeparator()
		self.editBar.addWidget(self.formattingBox)
		self.editBar.addWidget(self.symbolBox)
		self.searchEdit = QLineEdit(self.searchBar)
		self.searchEdit.setPlaceholderText(self.tr('Search'))
		self.searchEdit.returnPressed.connect(self.find)
		self.csBox = QCheckBox(self.tr('Case sensitively'), self.searchBar)
		self.searchBar.addWidget(self.searchEdit)
		self.searchBar.addSeparator()
		self.searchBar.addWidget(self.csBox)
		self.searchBar.addAction(self.actionFindPrev)
		self.searchBar.addAction(self.actionFind)
		self.searchBar.addAction(self.actionCloseSearch)
		self.searchBar.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
		self.searchBar.setVisible(False)
		self.autoSaveEnabled = globalSettings.autoSave
		if self.autoSaveEnabled:
			timer = QTimer(self)
			timer.start(60000)
			timer.timeout.connect(self.saveAll)
		self.ind = None
		if enchant_available:
			self.sl = globalSettings.spellCheckLocale
			if self.sl:
				try:
					enchant.Dict(self.sl)
				except Exception as e:
					print(e, file=sys.stderr)
					self.sl = None
			if globalSettings.spellCheck:
				self.actionEnableSC.setChecked(True)
		self.fileSystemWatcher = QFileSystemWatcher()
		self.fileSystemWatcher.fileChanged.connect(self.fileChanged)
示例#58
0
    def center(self):

        screen = QDesktopWidget().screenGeometry()
        size = self.geometry()
        self.move((screen.width()-size.width())/2,
            (screen.height()-size.height())/2)
 def CenterOnScreen(self):
     '''alinhando a o formulario no centro da tela'''
     resolucao = QDesktopWidget().screenGeometry()
     self.move((resolucao.width() / 2) - (self.frameSize().width() / 2),
               (resolucao.height() / 2) - (self.frameSize().height() / 2))
示例#60
0
    def createGrid(self):
        def btn_restart_game():
            if self.playing:
                self.packAndSend({
                    'to':self.opponent['client_id'],
                    'action':'restart',
                    'value': 'apply'
                })
            else:
                QMessageBox.information(self,'系统消息',"没有加入任何游戏")
                self.restartGame()
        def btn_leave_game():
            if self.playing:
                self.packAndSend({
                    'to':self.opponent['client_id'],
                    'action':'leave',
                    'value': ''
                })
                self.restartGame()
            else:
                QMessageBox.information(self,'系统消息',"没有加入任何游戏")
        #设置主窗口的大小与位置
        screen = QDesktopWidget().screenGeometry()
        self.setGeometry( (screen.width() - UI_WIDTH)/2 ,( screen.height() - UI_HEIGHT )/2,UI_WIDTH,UI_HEIGHT)
        self.setFixedSize(UI_WIDTH,UI_HEIGHT)
        #创建布局
        main = QWidget(self)
        main.setObjectName('main')
        self.setCentralWidget(main)
        self.othello = Othello()
        self.board = Board(main,self.othello)
        self.hall = Hall(self)

        #创建应该下子的图片标志,初始化为黑子
        pic = QLabel(self)
        pic.setGeometry(UI_WIDTH*0.212,UI_HEIGHT*0.12,50,50)
        pic.setObjectName('label_for_turn_image')

        #创建功能按钮
        buttons = QWidget(self)
        buttons.setGeometry(UI_WIDTH*0.77,UI_HEIGHT*0.4,UI_WIDTH*0.2,UI_HEIGHT*0.12)
        buttons.setObjectName('buttons')
        btn_restart = QPushButton('重新开始',self)
        btn_list = QPushButton('玩家列表',self)
        btn_leave = QPushButton('离开',self)
        btn_hall = QPushButton('大厅',self)
        grid = QGridLayout()
        grid.addWidget(btn_restart,0,0)
        grid.addWidget(btn_list,0,1)
        grid.addWidget(btn_leave,1,0)
        grid.addWidget(btn_hall,1,1)
        buttons.setLayout(grid)
        btn_restart.clicked.connect(btn_restart_game)
        btn_list.clicked.connect(lambda:self.packAndSend({'to':'admin','action':'list','value': '玩家列表'}))
        btn_hall.clicked.connect(lambda:self.packAndSend({'to':'admin','action':'games','value': '列出大厅'}))
        btn_leave.clicked.connect(btn_leave_game)
        #创建分数显示屏,包括黑棋得分,黑棋昵称,白棋得分,白棋昵称
        self.score_black = QLabel(self)
        self.score_black.setObjectName('score_black')
        self.score_black.setGeometry(UI_WIDTH*0.08,UI_HEIGHT*0.25,100,60)
        self.nickname_black = QLabel("<p style='text-align:center'>黑棋</p>",self)
        self.nickname_black.setObjectName('nickname_black')
        self.nickname_black.setGeometry(UI_WIDTH*0.03,UI_HEIGHT*0.36,120,60)

        self.score_white = QLabel(self)
        self.score_white.setObjectName('score_white')
        self.score_white.setGeometry(UI_WIDTH*0.08,UI_HEIGHT*0.57,100,60)
        self.nickname_white = QLabel("<p style='text-align:center'>白棋</p>",self)
        self.nickname_white.setObjectName('nickname_white')
        self.nickname_white.setGeometry(UI_WIDTH*0.03,UI_HEIGHT*0.68,120,60)
        self.move_record =  QTextEdit("当前下子情况",self)
        self.move_record.setReadOnly(True)
        #显示走棋的位置
        self.move_record =  QTextEdit("下子情况",self)
        self.move_record.setObjectName("move_record")
        self.move_record.setReadOnly(True)
        self.move_record.setGeometry(UI_WIDTH*0.765,UI_HEIGHT*0.24,UI_WIDTH*0.215,UI_HEIGHT*0.15)

        #创建输入框
        chat = QWidget(self)
        chat.setObjectName('chat')
        chat.setGeometry(UI_WIDTH*0.755,UI_HEIGHT*0.54,UI_WIDTH*0.235,UI_HEIGHT*0.45)
        grid = QGridLayout()
        chat.setLayout(grid)
        # 聊天窗口
        self.messages = QTextEdit("欢饮来到呆尐兔兔五子棋,撒花~~~",self)
        self.messages.setReadOnly(True)
        self.edit = QLineEdit(self)
        btn_send_msg = QPushButton("Enter/发送",self)
        btn_send_msg.clicked.connect(self.chat)
        grid.addWidget(self.messages,0,0,10,10)
        grid.addWidget(self.edit,10,0,2,8)
        grid.addWidget(btn_send_msg,10,8,2,2)