Пример #1
0
class MosaicWindow(QMainWindow):
    objectID = None

    def __init__(self, pmConfig: PMConfig, screenID: int = 0):
        """
                TODO: Implement parsing display configuration from config file
        """
        super(MosaicWindow, self).__init__()
        self.objectID = uuid4()
        self.pmConfig = pmConfig
        self.screenID = screenID
        self.selectedScreenGeometry = QDesktopWidget().screenGeometry(self.screenID)

        self.initUI()
        self.mosaicWindowWidget = MosaicWindowWidget(pmConfig,
                                                     QSize(self.selectedScreenGeometry.width(),
                                                           self.selectedScreenGeometry.height()))
        self.setCentralWidget(self.mosaicWindowWidget)
        self.show()

    def initUI(self):
        self.setGeometry(0, 0, self.selectedScreenGeometry.width(), self.selectedScreenGeometry.height())
        self.setWindowTitle(self.pmConfig.displays[self.screenID].screenDescription)
        self.setContentsMargins(1, 1, 1, 1)
        self.setAutoFillBackground(True)
        self.styleSheetAsText = """
                                QMainWindow {
                                    background-color:black;
                                }
                                """
        self.setStyleSheet(self.styleSheetAsText)
        self.showMaximized()
        self.setWindowFlags(Qt.FramelessWindowHint)
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.setWindowModality(Qt.WindowModality.WindowModal)
Пример #2
0
def window_position(window):
    screen = QDesktopWidget(window).availableGeometry()
    default_size = screen.width() * 0.75, screen.height() * 0.75
    default_pos = (screen.width() - default_size[0]) / 2, \
        (screen.height() - default_size[1]) / 2

    config = QSettings("justacid", "Segmate")
    config.beginGroup("MainWindow")
    size = config.value("size", QSize(*default_size))
    pos = config.value("position", QPoint(*default_pos))
    is_maximized = config.value("maximized", "false")
    is_maximized = True if "true" in is_maximized else False
    config.endGroup()

    return size, pos, is_maximized
Пример #3
0
    def __init__(self):
        super(QLiberationWindow, self).__init__()

        self.game: Optional[Game] = None
        self.game_model = GameModel()
        Dialog.set_game(self.game_model)
        self.ato_panel = QAirTaskingOrderPanel(self.game_model)
        self.info_panel = QInfoPanel(self.game)
        self.liberation_map = QLiberationMap(self.game_model)

        self.setGeometry(300, 100, 270, 100)
        self.setWindowTitle(f"DCS Liberation - v{VERSION}")
        self.setWindowIcon(QIcon("./resources/icon.png"))
        self.statusBar().showMessage('Ready')

        self.initUi()
        self.initActions()
        self.initMenuBar()
        self.initToolbar()
        self.connectSignals()

        screen = QDesktopWidget().screenGeometry()
        self.setGeometry(0, 0, screen.width(), screen.height())
        self.setWindowState(Qt.WindowMaximized)

        self.onGameGenerated(persistency.restore_game())
Пример #4
0
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)

        #window setup
        resolution = QDesktopWidget().screenGeometry()
        self.screen_w = resolution.width()
        self.screen_h = resolution.height()
        self.setGeometry(0, 0, 650, 550)
        self.setWindowTitle('MARS_v1_8')
        self.setWindowIcon(QIcon('icons/mouse.png'))
        self.queue = Queue()
        self.queue_list = []
        self.str_proc = ''
        self.fname = ''

        #center window
        qr = self.frameGeometry()
        cp = QDesktopWidget().availableGeometry().center()
        qr.moveCenter(cp)
        self.move(qr.topLeft())
        #adjust size
        self.resize(self.screen_w / 2, self.screen_h / 2)
        self.Menu()
        self.Layout()

        central_widget = QWidget()
        central_widget.setLayout(self.main_layout)
        self.setCentralWidget(central_widget)
    def center(self):
        '''centers the window on the screen'''

        screen = QDesktopWidget().screenGeometry()
        size = self.geometry()
        self.move((screen.width() - size.width()) / 2,
                  (screen.height() - size.height()) / 2)
Пример #6
0
    def __init__(self):
        super().__init__()
        self.setWindowFlags(Qt.WindowStaysOnTopHint)

        # self.setFocusPolicy(Qt.NoFocus)
        #self.setWindowFlag(Qt.WindowTransparentForInput, True)
        #self.setWindowFlag(Qt.WindowDoesNotAcceptFocus, True)
        #self.setAttribute(Qt.WA_ShowWithoutActivating, True)

        self.timer = QTimer(self)
        self.timer.timeout.connect(self.update_window)

        available_geometry = QDesktopWidget().availableGeometry()
        width = max(available_geometry.width() * .55, 900)
        height = max(available_geometry.height() * .55, 650)

        self.resize(width, height)
        self.load(QUrl("http://dotapicker.com/herocounter/"))
        self.setWindowTitle('AI Picker By Mohsen H')
        self.page().setBackgroundColor(QColor('black'))
        self.sharedobj = BrowserSharedObject()
        self.sharedobj.reset_clicked.connect(self.reset_clicked.emit)
        self.channel = QWebChannel()
        self.channel.registerObject('backend', self.sharedobj)
        self.page().setWebChannel(self.channel)
        self.loadFinished.connect(self.load_done)
Пример #7
0
    def initUI(self):

        flo = QFormLayout()
        edit1 = QLineEdit()
        edit2 = QLineEdit()
        edit3 = QLineEdit()
        edit4 = QLineEdit()

        flo.addRow("Normal", edit1)
        flo.addRow("Noecho", edit2)
        flo.addRow("Password", edit3)
        flo.addRow("Passwoedecho", edit4)

        edit1.setPlaceholderText("Normal")
        edit2.setPlaceholderText("Noecho")
        edit3.setPlaceholderText("Password")
        edit4.setPlaceholderText("Passwoedecho")

        edit1.setEchoMode(QLineEdit.Normal)
        edit2.setEchoMode(QLineEdit.NoEcho)
        edit3.setEchoMode(QLineEdit.Password)
        edit4.setEchoMode(QLineEdit.PasswordEchoOnEdit)

        screen = QDesktopWidget().screenGeometry()
        size = self.geometry()
        self.move((screen.width() - size.width()) / 2,
                  (screen.height() - size.height()) / 2)
        self.setLayout(flo)
        self.show()
Пример #8
0
    def center(self):
        """Called to center the window on the screen on startup.
        """

        screen = QDesktopWidget().screenGeometry()
        size = self.geometry()
        self.move((screen.width() - size.width()) / 2,
                  (screen.height() - size.height()) / 2)
Пример #9
0
    def location_on_the_screen(self, Form):
        #ag = QDesktopWidget().availableGeometry()
        sg = QDesktopWidget().screenGeometry()

        widget = Form.geometry()
        x = (sg.width() - widget.width()) / 2
        y = (sg.height() - widget.height()) / 2
        Form.move(x, y)
Пример #10
0
 def center(self):
     """
     使窗口居中
     """
     screen_g = QDesktopWidget().screenGeometry()
     window_g = self.geometry()
     left = int((screen_g.width() - window_g.width()) / 2)
     up = int((screen_g.height() - window_g.height()) / 2)
     self.move(left, up)
Пример #11
0
    def center(self):
        #获取屏幕坐标系
        screen = QDesktopWidget().screenGeometry()
        #获取窗口坐标系
        size = self.geometry()

        newLeft = (screen.width() - size.width()) / 2
        newTop = (screen.height() - size.height()) / 2
        self.move(newLeft, newTop)
Пример #12
0
 def centerMainWindow(self):  #Ok
     """
     Use a classe QDesktopWidget para acessar informações sobre 
     sua tela e use-a para centralizar a janela do aplicativo.
     """
     desktop = QDesktopWidget().screenGeometry()
     screen_width = desktop.width()
     screen_height = desktop.height()
     self.move((screen_width - self.width()) / 2,
               (screen_height - self.height()) / 2)
    def center(self):
        """
        Centers the window on the screen

        """

        screen = QDesktopWidget().screenGeometry()
        size = self.geometry()
        self.move(int((screen.width() - size.width()) / 2),
                  int((screen.height() - size.height()) / 2))
    def __init__(self, parent):
        super(OptionsWindow, self).__init__(parent)

        # Window configurations
        self.setWindowTitle("Options")
        self.setGeometry(0, 0, OptionsWindow.WINDOW_WIDTH, OptionsWindow.WINDOW_HEIGHT)
        resolution = QDesktopWidget().screenGeometry()
        self.move((resolution.width() / 2) - (self.frameSize().width() / 2), (resolution.height() / 2) - (self.frameSize().height() / 2))

        # Create delay options
        self.delay_display = QLabel("Blink Controller Scroll Delay: " + str(TEXT_TIMER_DELAY/1000) + " s")
        self.delay_display.setAlignment(Qt.AlignVCenter | Qt.AlignLeft)
        self.delay_display.setStyleSheet("font: 10pt")
        self.button_slower = QPushButton("+")
        self.button_slower.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        self.button_slower.setFixedSize(36, 36)
        self.button_slower.setFont(QFont("Helvetica", TEXT_SIZE))
        self.button_slower.clicked.connect(self.button_slower_clicked)
        self.button_faster = QPushButton("-")
        self.button_faster.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        self.button_faster.setFixedSize(36, 36)
        self.button_faster.setFont(QFont("Helvetica", TEXT_SIZE))
        self.button_faster.clicked.connect(self.button_faster_clicked)

        # Create text size options
        self.text_size_display = QLabel("Blink Controller Text Size: " + str(OVERLAY_TEXT_SIZE) + " pt")
        self.text_size_display.setAlignment(Qt.AlignVCenter | Qt.AlignLeft)
        self.text_size_display.setStyleSheet("font: 10pt")
        self.button_larger = QPushButton("+")
        self.button_larger.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        self.button_larger.setFixedSize(36, 36)
        self.button_larger.setFont(QFont("Helvetica", TEXT_SIZE))
        self.button_larger.clicked.connect(self.button_larger_clicked)
        self.button_smaller = QPushButton("-")
        self.button_smaller.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        self.button_smaller.setFixedSize(36, 36)
        self.button_smaller.setFont(QFont("Helvetica", TEXT_SIZE))
        self.button_smaller.clicked.connect(self.button_smaller_clicked)

        # Create layouts to hold the labels
        self.delay_layout = QHBoxLayout()
        self.delay_layout.addWidget(self.button_slower)
        self.delay_layout.addWidget(self.button_faster)
        self.delay_layout.addWidget(self.delay_display)

        self.text_size_layout = QHBoxLayout()
        self.text_size_layout.addWidget(self.button_larger)
        self.text_size_layout.addWidget(self.button_smaller)
        self.text_size_layout.addWidget(self.text_size_display)

        self.v_layout = QVBoxLayout()
        self.v_layout.addLayout(self.delay_layout)
        self.v_layout.addLayout(self.text_size_layout)
        self.setLayout(self.v_layout)
        self.show()
Пример #15
0
    def __init__(self, app, title):
        QMainWindow.__init__(self, parent=None)
        self.app = app
        self.setWindowTitle(title)
        self.setMinimumSize(500, 400)
        dw = QDesktopWidget()

        self.dockWidgets = []

        self.resize(dw.width() * 0.7, dw.height() * 0.3)

        # self.showFullScreen()
        self.gui_init()
Пример #16
0
    def __init__(self, device):
        QWidget.__init__(self)
        self.setWindowIcon(QIcon("icon/silabslogo.png"))

        self.device = device
        screen = QDesktopWidget()
        self.m_width = screen.width()
        self.m_height = screen.height()
        self.resize(self.m_width, self.m_height)
        self.showMaximized()

        self.setWindowTitle("Silabs")
        self.setObjectName("mainWindow")
        self.setStyleSheet("#mainWindow{background-color:rgb(54, 56, 60);}")

        self.layout = QtWidgets.QHBoxLayout()
        self.layout.setContentsMargins(self.m_width / 200, self.m_width / 200,
                                       self.m_width / 200, self.m_width / 20)
        self.layout.setSpacing(10)

        self.create_left_frame()
        self.create_right_frame()

        self.layout.setStretch(0, 3)
        self.layout.setStretch(1, 1)

        self.setLayout(self.layout)

        if self.device:
            logging.debug("device name:" + str(self.device))
            self.readThread = USBReadThread(self.device)
            self.readThread.updateWaveForm.connect(self.update_canvas)
            self.readThread.updateFrequency.connect(self.update_frequency)
            self.readThread.singleTrigger.connect(self.single_trigger_event)
            self.readThread.start()

            self.frequencyGet = Protocol.PREAMBLE.value \
                + Protocol.FREQUENCY_GET.value \
                + '\x00'  # '\xAA' + '\x41' + '\x00'
            self.setThread = USBWriteThread(self.device, self.frequencyGet)
            self.setThread.start()
    def __init__(self):
        super(QLiberationWindow, self).__init__()

        self.info_panel = None
        self.setGame(persistency.restore_game())

        self.setGeometry(300, 100, 270, 100)
        self.setWindowTitle("DCS Liberation - v" + CONST.VERSION_STRING)
        self.setWindowIcon(QIcon("./resources/icon.png"))
        self.statusBar().showMessage('Ready')

        self.initUi()
        self.initActions()
        self.initMenuBar()
        self.initToolbar()
        self.connectSignals()
        self.onGameGenerated(self.game)

        screen = QDesktopWidget().screenGeometry()
        self.setGeometry(0, 0, screen.width(), screen.height())
        self.setWindowState(Qt.WindowMaximized)
Пример #18
0
    def initUI(self):

        layout = QVBoxLayout()
        self.textedit = QTextEdit()

        self.button1 = QPushButton("显示文本")
        self.button2 = QPushButton("显示HTML")

        self.button1.clicked.connect(self.button1_clicked)
        self.button2.clicked.connect(self.button2_clicked)

        layout.addWidget(self.textedit)
        layout.addWidget(self.button1)
        layout.addWidget(self.button2)

        screen = QDesktopWidget().screenGeometry()
        size = self.geometry()
        self.move((screen.width() - size.width()) / 2,
                  (screen.height() - size.height()) / 2)
        self.setLayout(layout)
        self.show()
Пример #19
0
    def __init__(self, game: Optional[Game]) -> None:
        super(QLiberationWindow, self).__init__()

        self.game = game
        self.game_model = GameModel(game)
        Dialog.set_game(self.game_model)
        self.ato_panel = QAirTaskingOrderPanel(self.game_model)
        self.info_panel = QInfoPanel(self.game)
        self.liberation_map = QLiberationMap(self.game_model, self)

        self.setGeometry(300, 100, 270, 100)
        self.updateWindowTitle()
        self.setWindowIcon(QIcon("./resources/icon.png"))
        self.statusBar().showMessage("Ready")

        self.initUi()
        self.initActions()
        self.initToolbar()
        self.initMenuBar()
        self.connectSignals()

        screen = QDesktopWidget().screenGeometry()
        self.setGeometry(0, 0, screen.width(), screen.height())
        self.setWindowState(Qt.WindowMaximized)

        if self.game is None:
            last_save_file = liberation_install.get_last_save_file()
            if last_save_file:
                try:
                    logging.info("Loading last saved game : " +
                                 str(last_save_file))
                    game = persistency.load_game(last_save_file)
                    self.onGameGenerated(game)
                    self.updateWindowTitle(last_save_file if game else None)
                except:
                    logging.info("Error loading latest save game")
            else:
                logging.info("No existing save game")
        else:
            self.onGameGenerated(self.game)
Пример #20
0
 def center_window(self):
     screen = QDesktopWidget().screenGeometry()
     widget = self.geometry()
     Dx = screen.width() - widget.width()
     Dy = screen.height() - widget.height()
     self.move(Dx / 2, Dy / 2)
Пример #21
0
    def __init__(self, parent=None):
        super().__init__(parent)  # 调用父类构造函数,创建窗体
        self.ui = Ui_MainWindow()  # 创建UI对象
        self.ui.setupUi(self)  # 构造UI界面
        self.setWindowTitle(bt)  # 设置窗体标题
        self.setWindowIcon(QIcon(tb))   # 设置窗体图标
        # self.setStyleSheet("MainWindow{border-image:url(./python.jpg);}")  #设置窗口背景图片
        self.tab = {}  # 空字典

        global L
        db = self.connect_db()
        # 获取游标
        self.cur = db.cursor(pymysql.cursors.DictCursor)  # 使用字典类型输出
        # 根据” ID 字段“排序,倒叙输出 人员信息 表中的数据。备注:asc是表示升序,desc表示降序。limit 1表示输出一条记录
        sql_renyuan = "select * FROM 人员信息 WHERE 工号 = %s order by ID desc limit 1"
        rows = self.cur.execute(sql_renyuan, L[len(L) - 1])
        rows = self.cur.fetchone()
        qiye = QLabel(bt)           # 设置窗体标题
        qiye.setMinimumWidth(150)
        gonghao = QLabel("工号:%s" % L[len(L) - 1])
        gonghao.setMinimumWidth(120)
        xingming = QLabel("姓名:%s" % rows['姓名'])
        xingming.setMinimumWidth(120)
        bumen = QLabel("部门:%s" % rows['部门'])
        bumen.setMinimumWidth(120)
        zhiwei = QLabel("职位:%s" % rows['职位'])
        zhiwei.setMinimumWidth(120)

        curDateTime = QDateTime.currentDateTime()   #提取系统当前日期时间
        week = datetime.now().isocalendar()[1]    #当前日期的三元组(年号,第几周,第几天)
        riqi0 = curDateTime.toString("yyyy年MM月dd日  dddd  " + '%s周'%week)     #日期与星期
        riqi = QLabel(riqi0)
        self.ui.statusBar.addPermanentWidget(riqi)      #addPermanentWidget为右侧,showMessage为左侧


        self.ui.statusBar.addWidget(qiye)  # 加到状态栏
        self.ui.statusBar.addWidget(gonghao)
        self.ui.statusBar.addWidget(xingming)
        self.ui.statusBar.addWidget(bumen)
        self.ui.statusBar.addWidget(zhiwei)
        cur = db.cursor(pymysql.cursors.DictCursor)

        # 1.控件的上面的小tab变成透明
        # 2.选项卡部件:窗格{ 边框:1px纯灰;顶部:-1px;背景:透明;}
        # 3.突出选中的部分(改变颜色)
        # 4.设置QTabBar删除按钮图标和位置
        # 4.设置QTabBar删除按钮图标(点击前)
        # 4.设置QTabBar删除按钮图标(点击时)
        str = "QTabBar::tab{background-color:rbg(255,255,255,0);}" + \
              "QTabWidget:pane{border: 0.5px solid grey; top: -1px;background: transparent;}" + \
              "QTabBar::tab:selected{color:blue;background-color:rbg(255,255,255);} " + \
              "QTabBar::close-button{image: url(ICO/240.png);subcontrol-postion:left}" + \
              "QTabBar::close-button:hover{image:url(ICO/301.png);subcontrol-postion:left}" + \
              "QTabBar::close-button:pressed{image:url(ICO/302.png);subcontrol-postion:left}"

        self.ui.ZhuCaiDan.setStyleSheet(str)

        # 使用父级构造一个空的日期编辑器。日期设置为date。
        sty = "QDateEdit :: QDateEdit(const QDate&date,QWidget * parent = nullptr)"
        self.ui.xmxx_Q_riqi.setStyleSheet(sty)

        self.ui.ZhuCaiDan.setCurrentIndex(0)  # 显示第一个选项卡
        self.ui.ZhuCaiDan.setTabsClosable(True)  # 所有选项加上关闭按钮
        self.ui.ZhuCaiDan.tabBar().setTabButton(0, QTabBar.RightSide, None)  # 第一项去掉关闭按钮
        # self.ui.ZhuCaiDan.tabBar().setTabButton(1, QTabBar.RightSide, None)
        # # 第二项去掉关闭按钮
        u = self.ui.ZhuCaiDan.count()  # 获取选项卡数量
        # 删除多余选项卡
        while u > 0:
            self.ui.ZhuCaiDan.removeTab(u)
            u = u - 1
        self.ui.ZhuCaiDan.tabCloseRequested.connect(
            self.close_tab)  # ZhuCaiDan(页)关闭函数取消

        # 窗体居中设置
        deskSize = QDesktopWidget().screenGeometry()       # 获取桌面窗体参数
        windowSize = self.geometry()    # 获取窗体本身参数
        self.move((deskSize.width() - windowSize.width()) / 2,
                  (deskSize.height() - windowSize.height()) / 2-30)  # 居中设置


        # self.LineEdit_Date()
        self.riqikuangxuanxiang(self.ui.ryxx_Q_riqi, self.ui.renyuanxinxi)  # 创建日历控件
        self.riqikuangxuanxiang(self.ui.ryxx_J_riqi, self.ui.renyuanxinxi)
Пример #22
0
    def __init__(self, game: Game | None, dev: bool) -> None:
        super().__init__()

        self._uncaught_exception_handler = UncaughtExceptionHandler(self)

        self.game = game
        self.sim_controller = SimController(self.game)
        self.sim_controller.sim_update.connect(EventStream.put_nowait)
        self.game_model = GameModel(game, self.sim_controller)
        GameContext.set_model(self.game_model)
        self.new_package_signal.connect(
            lambda target: Dialog.open_new_package_dialog(target, self))
        self.tgo_info_signal.connect(self.open_tgo_info_dialog)
        self.control_point_info_signal.connect(
            self.open_control_point_info_dialog)
        QtContext.set_callbacks(
            QtCallbacks(
                lambda target: self.new_package_signal.emit(target),
                lambda tgo: self.tgo_info_signal.emit(tgo),
                lambda cp: self.control_point_info_signal.emit(cp),
            ))
        Dialog.set_game(self.game_model)
        self.ato_panel = QAirTaskingOrderPanel(self.game_model)
        self.info_panel = QInfoPanel(self.game)
        self.liberation_map = QLiberationMap(self.game_model, dev, self)

        self.setGeometry(300, 100, 270, 100)
        self.updateWindowTitle()
        self.setWindowIcon(QIcon("./resources/icon.png"))
        self.statusBar().showMessage("Ready")

        self.initUi()
        self.initActions()
        self.initToolbar()
        self.initMenuBar()
        self.connectSignals()

        # Default to maximized on the main display if we don't have any persistent
        # configuration.
        screen = QDesktopWidget().screenGeometry()
        self.setGeometry(0, 0, screen.width(), screen.height())
        self.setWindowState(Qt.WindowMaximized)

        # But override it with the saved configuration if it exists.
        self._restore_window_geometry()

        if self.game is None:
            last_save_file = liberation_install.get_last_save_file()
            if last_save_file:
                try:
                    logging.info("Loading last saved game : " +
                                 str(last_save_file))
                    game = persistency.load_game(last_save_file)
                    self.onGameGenerated(game)
                    self.updateWindowTitle(last_save_file if game else None)
                except:
                    logging.info("Error loading latest save game")
            else:
                logging.info("No existing save game")
        else:
            self.onGameGenerated(self.game)
Пример #23
0
    def __init__(self):
        super().__init__()

        # 检查python版本是否满足要求
        minimum = '3.6.2'
        current = platform.python_version()
        current, minimum = (pkg.parse_version(x) for x in (current, minimum))
        if current < minimum:
            msg = msg_box.MsgWarning()
            msg.setText(f'当前Python版本({current})过低,请升级到{minimum}以上!')
            msg.exec()
            sys.exit()

        self.setWindowTitle(f'{APP_NAME} {APP_VERSION}')
        self.setWindowIcon(QIcon('img/yologo.png'))

        gb.init_logger()
        gb.clean_log()
        gb.init_config()

        self.camera = WidgetCamera()  # 摄像头
        self.info = WidgetInfo()  # 信息面板
        self.config = WidgetConfig()  # Yolo配置界面
        self.settings = SettingsDialog()

        self.signal_config_error.connect(self.slot_msg_dialog)

        # 模型加载线程
        self.load_model_thread = threading.Thread(target=self.load_yolo)
        self.load_model_thread.start()

        self.config.btn_settings.clicked.connect(self.settings.exec)
        self.settings.accepted.connect(self.reload)

        self.status_icon = QLabel()
        self.status_text = QLabel()
        self.update_status('Loading model...', False)
        hbox = QHBoxLayout()
        hbox.addWidget(self.status_icon)
        hbox.addWidget(self.status_text)

        self.btn_camera = QPushButton('Open/Close Camera')  # 开启或关闭摄像头
        self.btn_camera.setEnabled(False)
        self.btn_camera.clicked.connect(self.oc_camera)
        self.btn_camera.setFixedHeight(60)

        vbox1 = QVBoxLayout()
        vbox1.setContentsMargins(0, 0, 0, 0)
        vbox1.addWidget(self.info)
        vbox1.addWidget(self.config)
        vbox1.addStretch()
        vbox1.addLayout(hbox)
        vbox1.addWidget(self.btn_camera)

        right_widget = QWidget()
        right_widget.setMaximumWidth(400)
        right_widget.setLayout(vbox1)

        hbox = QHBoxLayout()
        hbox.addWidget(self.camera, 3)
        hbox.addWidget(right_widget, 1)

        vbox = QVBoxLayout()
        vbox.addLayout(hbox)

        self.central_widget = QWidget()
        self.central_widget.setLayout(vbox)

        self.setCentralWidget(self.central_widget)

        # ---------- 自适应不同大小的屏幕  ---------- #
        screen = QDesktopWidget().screenGeometry(self)
        available = QDesktopWidget().availableGeometry(self)
        title_height = self.style().pixelMetric(QStyle.PM_TitleBarHeight)
        if screen.width() < 1280 or screen.height() < 768:
            self.setWindowState(Qt.WindowMaximized)  # 窗口最大化显示
            self.setFixedSize(
                available.width(),
                available.height() - title_height)  # 固定窗口大小
        else:
            self.setMinimumSize(QSize(1100, 700))  # 最小宽高
        self.show()  # 显示窗口
Пример #24
0
 def move_to_center(self):
     screen = QDesktopWidget().screenGeometry()
     size = self.geometry()
     self.move((screen.width() - size.width()) / 2,
               (screen.height() - size.height()) / 2)
Пример #25
0
 def centerApplication(self):
     resolution = QDesktopWidget().screenGeometry()
     w = ((resolution.width() / 2) - (self.frameSize().width() / 2))
     h = ((resolution.height() / 2) - (self.frameSize().height() / 2))
     self.move(w, h)
Пример #26
0
class Simulator(QMainWindow):
    def __init__(self):
        super().__init__(None, Qt.WindowStaysOnTopHint)
        
        self.stdout = StreamOutput()
        self.stderr = StreamError()
        self.exec = StreamInput()
        
        self.frame = QFrame()
        self.setCentralWidget(self.frame)
        self.screen = QDesktopWidget().screenGeometry()
        self.setGeometry(self.screen)
        self.grid = QGridLayout()
        self.frame.setLayout(self.grid)
        self.map = SimulatedFieldMap()
        
        # -- setting splitters
        splitter_bottom = QSplitter(Qt.Horizontal)  # STDIN, STDOUT
        splitter_main = QSplitter(Qt.Vertical)  # Map ((STDIN,STDOUT), STDERR)
        # --------------
        
        # -- top --
        frame = QFrame()
        grid = QGridLayout()
        frame.setLayout(grid)
        splitter_main.addWidget(frame)
        grid.addWidget(self.map, 0, 0, 10, 1)
        
        slider_zoom = QSlider(Qt.Horizontal)
        slider_zoom.setMinimum(100)
        slider_zoom.setMaximum(1000)
        grid.addWidget(slider_zoom, 1, 1)
        
        sp = QSizePolicy()
        sp.setVerticalPolicy(QSizePolicy.Maximum)
        
        label = QLabel("Zoom")
        label.setSizePolicy(sp)
        grid.addWidget(label, 0, 1)
        
        zoom_label = QLabel("1")
        zoom_label.setSizePolicy(sp)
        
        slider_zoom.valueChanged.connect(lambda n: zoom_label.setText(str(n / 100)))
        
        grid.addWidget(zoom_label, 2, 1, Qt.AlignHCenter)
        
        splitter_main.addWidget(frame)
        # ------
        
        # -- bottom left --
        box = QVBoxLayout()
        frame = QFrame()
        frame.setLayout(box)
        box.addWidget(QLabel('Exec'))
        box.addWidget(self.exec)
        splitter_bottom.addWidget(frame)
        # -------
        
        # -- bottom middle --
        box = QVBoxLayout()
        frame = QFrame()
        frame.setLayout(box)
        splitter_bottom.addWidget(frame)
        box.addWidget(QLabel('Output'))
        box.addWidget(self.stdout)
        # -------
        
        # -- bottom right --
        box = QVBoxLayout()
        frame = QFrame()
        frame.setLayout(box)
        splitter_bottom.addWidget(frame)
        box.addWidget(QLabel('Error'))
        box.addWidget(self.stderr)
        # -------
        splitter_main.addWidget(splitter_bottom)
        
        self.grid.addWidget(splitter_main, 0, 0)
        splitter_main.setSizes((self.screen.height() * 0.6, self.screen.height() * 0.4))
        splitter_bottom.setSizes((self.map.width / 2, self.map.width / 2, self.stderr.sizeHint().width()))
Пример #27
0
    def __init__(self):
        QWidget.__init__(self)

        self.theme = 2

        screen = QDesktopWidget()
        logging.info("screen size:" + str(screen.width()) + "," +
                     str(screen.height()))

        self.m_width = screen.height() / 2
        self.m_height = screen.height() / 2
        self.resize(self.m_width, self.m_height)
        # self.setFixedSize(self.m_width, self.m_height)
        size = self.geometry()
        self.move((screen.width() - size.width()) / 2,
                  (screen.height() - size.height()) / 2)

        # delete title box
        self.setWindowFlags(Qt.FramelessWindowHint)
        # self.setAttribute(Qt.WA_TranslucentBackground)

        logging.info("login widget size:" + str(self.size()))
        self.bitmap = QBitmap(self.size())
        painter = QPainter(self.bitmap)

        painter.fillRect(self.rect(), Qt.white)

        painter.setBrush(QColor(0, 0, 0))
        painter.setRenderHint(QPainter.Antialiasing, True)
        painter.drawRoundedRect(self.rect(), 10, 10)
        self.setMask(self.bitmap)

        self.layout = QVBoxLayout(self)
        self.layout.setContentsMargins(0, 0, 0, self.m_height / 15)
        self.layout.setSpacing(self.m_height / 15)
        self.topframe = QFrame(self)
        self.topframe.setObjectName("topframe")
        if self.theme == 1:
            self.topframe.setStyleSheet(
                "#topframe{background-color:qlineargradient("
                "spread:pad,"
                "x1:0,y1:0,x2:1,y2:1,"
                "stop:0 #5efce8,"
                "stop:1 #736efe);}")
        elif self.theme == 2:
            self.topframe.setStyleSheet(
                "#topframe{background-color:qlineargradient("
                "spread:pad,"
                "x1:0,y1:0,x2:1,y2:0,"
                "stop:0 #3a6186,"
                "stop:1 #89253e);}")
        elif self.theme == 3:
            self.topframe.setStyleSheet(
                "#topframe{background-color:qlineargradient("
                "spread:pad,"
                "x1:0,y1:0,x2:0,y2:1,"
                "stop:0 #19547b,"
                "stop:1 #ffd89b);}")
        else:
            self.topframe.setStyleSheet(
                "#topframe{background-color:qlineargradient("
                "spread:pad,"
                "x1:0,y1:0,x2:1,y2:1,"
                "stop:0 #ff8177,"
                "stop:1 #b12a5b);}")
        self.layout.addWidget(self.topframe)

        # setup checkbox
        self.combobox = QComboBox(self)
        self.combobox.setObjectName("combobox")
        self.combobox.setFixedSize(self.m_width / 1.5, self.m_height / 10)
        self.combobox.setStyleSheet(
            "QComboBox{border: 2px solid gray;"
            "border-radius:5px;"
            "background-color:rgb(255, 255, 255);"
            "color:rgb(0, 0, 0);"
            "padding: 1px 20px;}"
            "QComboBox:drop-down{subcontrol-origin: padding;"
            "subcontrol-position: top right;"
            "width: 50px;border-left-style:solid;"
            "border-top-right-radius: 3px;"
            "border-bottom-right-radius: 3px;"
            "border-left: 2px solid gray;"
            "background-color: rgba(100, 25, 100, 0);}"
            "QComboBox:down-arrow{border-image:url(icon/arrow-1.png);}"
            "QComboBox:item:selected{background: rgb(232, 241, 250);color: rgb(2, 65, 132);}"
            "QStyledItemDelegate{border: 100px solid rgb(161,161,161);}")

        # self.combobox.move(200, 200)
        self.layout.addWidget(self.combobox, 0, Qt.AlignHCenter)

        # setup login button
        self.loginbtn = QPushButton("ENTER", self)
        self.loginbtn.setObjectName("loginbtn")
        self.loginbtn.setFixedSize(self.m_width / 1.5, self.m_height / 10)
        self.loginbtn.setContentsMargins(200, 20, 20, 20)
        self.loginbtn.clicked.connect(self.login_event)
        self.loginbtn.setStyleSheet(
            "QPushButton{border-radius:%dpx;"
            "background-color:#89253e;"
            "color:rgb(0, 0, 0);}"
            "QPushButton:hover{color:rgb(0, 255, 0);}" % (self.m_height / 20))
        self.layout.addWidget(self.loginbtn, 0, Qt.AlignHCenter)

        # setup exit button
        self.exitbtn = QPushButton(self)
        # self.exitbtn.setText("Close")
        self.exitbtn.setToolTip("Close the widget")
        self.exitbtn.setFixedSize(40, 40)
        self.exitbtn.setIcon(QIcon("icon/close.png"))
        self.exitbtn.setIconSize(QSize(40, 40))
        self.exitbtn.clicked.connect(self.exit_event)
        logging.info("topframesize:" + str(self.topframe.size()))
        self.exitbtn.move(self.width() - 40, 0)
        # self.exitbtn.setGeometry(self.topframe.width()-40, 0, 100, 40)
        self.exitbtn.setStyleSheet("background-color: #600")
        self.exitbtn.setStyleSheet("background-color: transparent")
        self.exitbtn.isEnabled()

        self.logoImage = QPixmap("icon/silabslogo.png")
        self.logo = self.logoImage.scaled(self.m_width / 5, self.m_height / 5,
                                          Qt.KeepAspectRatio,
                                          Qt.SmoothTransformation)

        self.logoLable = QLabel(self)
        self.logoLable.setObjectName("logoLable")
        self.logoLable.setAlignment(Qt.AlignCenter)
        self.logoLable.setPixmap(self.logo)
        self.logoLable.setFixedSize(self.m_width / 4, self.m_height / 4)
        # self.logo.setScaledContents(True)
        self.logoLable.setStyleSheet("#logoLable{border: 2px solid gray;"
                                     "border-radius:75px;"
                                     "background-color:rgb(100, 100, 100);"
                                     "color:rgb(0, 0, 0);}")
        self.logoLable.move(self.m_width / 2 - self.m_width / 8,
                            self.m_height / 6)

        self.m_drag = False
        self.m_DragPosition = 0
        self.MainWindow = 0
Пример #28
0
from PySide2.QtGui import QPixmap
from functools import partial


def _exit_on_esc(e):
    if e.key() == Qt.Key_Escape:
        QApplication.instance().quit()


if __name__ == '__main__':
    app = QApplication([])

    window = QWidget()
    wg = QGridLayout()
    rect = QDesktopWidget().screenGeometry()
    window.setFixedSize(rect.width(), rect.height())
    window.showFullScreen()
    window.keyPressEvent = _exit_on_esc
    grid = QGridLayout()
    surv = QWidget()
    surv.setFixedSize(rect.width() // 2, rect.height() // 4)
    wg.addWidget(surv)
    # grid.setVerticalSpacing(0)
    # grid.setContentsMargins(0, 0, 0, 0)

    dv5_1 = QPixmap('dv5_1.png')

    grid.addWidget(QLabel('Reserved'), 0, 0)
    header = [
        "1\nCompletely\ninappropriate", "2", "3", "4", "5", "6",
        "7\nCompletely\nappropriate"
Пример #29
0
    def init(self):
        self.setWindowFlags(
            Qt.FramelessWindowHint |
            Qt.WindowCloseButtonHint)

        # default setting

        self.screen_num = 0  # default setting is main screen
        self.line = 0
        #######

        try:
            read_file = open("record.json", "r")
            dic_data = json.load(read_file)
            read_file.close()
            self.speed = dic_data['speed']
            self.scale = dic_data['scale']
            if self.scale == 20:
                self.checkBox_1.setCheckState(Qt.Checked)
            elif self.scale == 25:
                self.checkBox_2.setCheckState(Qt.Checked)
            elif self.scale == 30:
                self.checkBox_3.setCheckState(Qt.Checked)
            else:
                self.checkBox_2.setCheckState(Qt.Checked)

            self.transparent_slider.setValue(dic_data['transparent'])
            if dic_data['bold']:
                self.isBold.setChecked(Qt.Checked)

        except:
            self.checkBox_2.setCheckState(Qt.Checked)  # for scale middle (中)
            self.speed = 50  # between 50 ~ 120
            self.scale = 25  # 20 25 30
            self.transparent_slider.setValue(100)

        self.Speed_Slider.setValue(self.speed)

        self.is_save = True

        self.Qrcode_msg = MyPopup()
        self.Qrcode_msg.hide()

        self.serverThread = serverThread(self.window())
        self.serverThread.start()
        self.public_url = ngrok.connect(8888)
        self.Qrcode_msg.setLink(self.public_url)

        self.textEdit.setReadOnly(True)
        self.textEdit.insertHtml(
            "<p style='color:red;'>--------------------------Connected!--------------------------</p>")
        self.textEdit.append('')

        self.Msg_queue = queue.Queue()

        self.desktopWidget = QDesktopWidget(QApplication.desktop)
        self.screenRect = self.desktopWidget.screenGeometry(self.screen_num)

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

        self.detect_screen()

        self.btn_detect_sreen.clicked.connect(self.detect_screen)
        # when the server gets the msg from the client, then pop up the danmaku
        # sig is the global signal
        # signal.sig.connect(self.popupMsg)
        signal.sig.connect(self.add_to_queue)
        self.onBindingUI()
Пример #30
0
class MainWindow(QMainWindow):
    def __init__(self, title="", icon="", object_name="MainWindow"):
        """
        Template for main window that sets window size and placement, creates menu and status bars, and handles menu
        signals.
    
        :param title: str; Name to be displayed at the top of the window
        :param icon: str; file path to icon image file
        :param object_name: str; Name of main window object
        """

        super().__init__()
        self.setObjectName(object_name)
        self.screen = QDesktopWidget().availableGeometry()
        self.setup_template(title)
        if icon:
            self.setWindowIcon(QIcon(icon))
        self.menu_list = self.menu()
        self.menu_bar = QMenuBar(self)
        self.menu_heads = {}
        self.menu_items = {}
        self.setup_menu(object_name)
        self.menu_signals()
        self.status_bar = QStatusBar(self)
        self.setStatusBar(self.status_bar)

    def menu(self):
        """
        Re-implement this function to define the window menu

        Lists all of the menu operations available in formats:
        {"Menu head": ["Menu item"]}
        {"Menu head 1": ["Menu item under 1"], "Menu head 2": ["Menu item under 2"]}
        {"Menu head": ["Menu item 1", "Menu item 2"]}
        {"Menu head": [["Menu item 1, ["Menu subitem 1", "Menu subitem 2"]], "Menu item 2"]}
        Notice that if subitems are desired, the format is to replace "Menu item" with ["Menu item", [subitems]]
        For a line between menu items, specify five dashes, e.g. {"Menu head": ["Menu item 1", "-----", "Menu item 2"]}
        """

        menu = {
            "File": ["Close"],
            "Example": [
                "Item", ["Item with subitems", ["Subitem 1", "Subitem 2"]],
                "-----", "Another item"
            ]
        }
        return menu

    def menu_operations(self, head, item, subitem=None):
        """
        Re-implement this function to define what happens when each menu item is selected.
        
        :param head: str, menu head name as defined in self.menu()
        :param item: str, menu item name as defined in self.menu()
        :param head: str, menu subitem name, if applicable, as defined in self.menu()
        """

        if head == "File":
            if item == "Close":
                self.close()

    def setup_template(self, title):
        """Sets up window size and title"""

        self.resize(self.screen.width() - 150,
                    self.screen.height() -
                    150)  # Sets window size 150 px from screen edge
        self.centre_on_screen()
        self.setWindowTitle(title)

    def centre_on_screen(self):
        """Centers the screen on the desktop"""

        centre = self.screen.center()
        x, y = centre.x() - self.size().width() / 2, centre.y(
        ) - self.size().height() / 2
        x = 0 if x < 0 else x
        y = 0 if y < 0 else y
        self.move(x, y)

    def menu_signals(self):
        """Interprets the selection of a menu item or subitem and sends the appropriate signal via menu_connections"""

        for head, option in self.menu_items.items():
            for item, widget in option.items():
                if type(
                        widget
                ) == list:  # Open a side menu for any menu item with a list of subitems
                    for subitem, subwidget in widget[1].items():
                        subwidget.triggered.connect(
                            self.menu_connections(head, item, subitem))
                else:
                    widget.triggered.connect(self.menu_connections(head, item))

    def menu_connections(self, head, item, subitem=None):
        """Redirects menu signals to the menu_operations function in the main window class. Leave this."""
        return lambda: self.menu_operations(head, item, subitem)

    def setup_menu(self, object_name):
        """Builds a dictionary of menu item instances based on the menu items specified in menu method"""

        for head, items in self.menu_list.items():
            self.menu_heads[head] = QMenu(self.menu_bar)
            self.menu_bar.addAction(self.menu_heads[head].menuAction())
            self.menu_items[head] = {}
            for item in items:
                if type(item) == str:
                    if item == "-----":
                        self.menu_heads[head].addSeparator()
                    else:
                        self.menu_items[head][item] = QAction(self)
                        self.menu_heads[head].addAction(
                            self.menu_items[head][item])
                elif type(item) == list:
                    root = item[0]
                    self.menu_items[head][root] = []
                    self.menu_items[head][root].append(
                        QMenu(self.menu_heads[head]))
                    self.menu_heads[head].addAction(
                        self.menu_items[head][root][0].menuAction())
                    self.menu_items[head][root].append({})
                    for subitem in item[1]:
                        self.menu_items[head][root][1][subitem] = QAction(self)
                        self.menu_items[head][root][0].addAction(
                            self.menu_items[head][root][1][subitem])

        self.setMenuBar(self.menu_bar)

        _translate = QCoreApplication.translate
        for menu_head, widget in self.menu_heads.items():
            widget.setTitle(_translate(object_name, menu_head))
        for menu_head, menu_item in self.menu_items.items():
            for item, widget in menu_item.items():
                if type(widget) == list:
                    widget[0].setTitle(_translate(object_name, item))
                    for subitem, subwidget in widget[1].items():
                        subwidget.setText(_translate(object_name, subitem))
                else:
                    if item != '-----':
                        widget.setText(_translate(object_name, item))