def __init__(self, parent):
        tk.Frame.__init__(self, parent)
        self.parent = parent
        monitor_info = GetMonitorInfo(MonitorFromPoint((0, 0)))
        work_area = monitor_info.get("Work")
        self.width = root.winfo_screenwidth()
        self.height = root.winfo_screenheight()
        self.parent.geometry("%dx%d+0+0" % (self.width / 2, self.height - 95))
        #Frame
        self.frameThumb = tk.Frame(parent,
                                   height=int(2 * self.height / 3),
                                   width=int(self.width / 2))
        self.frameInteractiveView = tk.Frame(parent,
                                             height=int(self.height / 3),
                                             width=int(self.width / 2))
        self.frameThumb.pack(fill=tk.BOTH, expand=True)
        self.frameInteractiveView.pack(fill=tk.BOTH, expand=True)

        #menu bar
        self.menu = MenuBar(self)
        self.parent.config(menu=self.menu.menuBar)

        #interactive view
        self.interactiveView = InteractiveView(self, self.frameInteractiveView)
        self.interactiveView.canvas.grid(row=0, column=0, sticky="nsew")
        self.frameInteractiveView.grid_rowconfigure(0, weight=1)
        self.frameInteractiveView.grid_columnconfigure(0, weight=1)

        #thumb
        self.thumb = Thumb(self.frameThumb, self.interactiveView)
        self.thumb.thumb.pack(fill=tk.BOTH, expand=True)

        #init blender
        self.initBlender()
def screen_size():
    if OS.WINDOWS:
        import ctypes
        from win32api import GetMonitorInfo, MonitorFromPoint

        ctypes.windll.shcore.SetProcessDpiAwareness(2)

        monitor_info = GetMonitorInfo(MonitorFromPoint((0, 0)))
        monitor_area = monitor_info.get("Monitor")
        work_area = monitor_info.get("Work")

        def dimension(i: int):
            monitor_dimension = monitor_area[i]
            work_dimension = work_area[i]

            return (work_dimension if monitor_dimension == work_dimension else
                    work_dimension - monitor_dimension // 20)

        return Size(dimension(2), dimension(3))

    try:
        from screeninfo import get_monitors

        screen = get_monitors()[0]
        return Size(screen.width, screen.height)

    except IndexError:
        raise NoScreen('No screen for displaying images found.')
def get_orientation():
	# user32 = ctypes.windll.user32
	# width = user32.GetSystemMetrics(0)
	# height = user32.GetSystemMetrics(1)
	monitor_info = GetMonitorInfo(MonitorFromPoint((0,0)))
	_, _, width, height = monitor_info.get("Monitor")
	print(width, height)
	if(width > height): orientation = 'landscape'
	else:  orientation = 'portrait'
	return orientation
def main():
    # get screen size info
    for monitor in EnumDisplayMonitors():
        info = GetMonitorInfo(monitor[0])
        if info['Flags'] == 1:
            break

    root = tk.Tk()
    gui = SauceFinder(root, info['Work'][2:])
    root.mainloop()
Exemple #5
0
def _get_location_in_pixel(driver, element, tab_bar_height, scaling):
    """
    Get location of element that is shown in browser

    :param driver: WebDriver in selenium.webdriver.remote.webdriver
    :param element: webelement in selenium.webdriver.remote.webelement
    :return: dict
    """
    x_location_inside_of_browser = element.location["x"]
    y_location_inside_of_browser = element.location["y"]
    scroll_size = _get_scroll_size(scaling)
    vertical_scroll_size = 0
    horizontal_scroll_size = 0
    if _is_vertical_scroll_on_screen(driver):
        vertical_scroll_size = scroll_size
    if _is_horizontal_scroll_on_screen(driver):
        horizontal_scroll_size = scroll_size

    browser_width_in_pixels = driver.get_window_size()['width'] * scaling / 100
    browser_height_in_pixels = driver.get_window_size(
    )['height'] * scaling / 100
    x_location_in_pixels = (
        x_location_inside_of_browser + element.size["width"] / 2) * (
            browser_width_in_pixels - vertical_scroll_size) / (int(
                driver.find_element_by_tag_name("html").get_attribute(
                    "clientWidth"))) + driver.get_window_position()['x']
    monitor_info = GetMonitorInfo(MonitorFromPoint((0, 0)))
    monitor_area = monitor_info.get("Monitor")
    work_area = monitor_info.get("Work")
    task_bar = monitor_area[3] - work_area[3]
    hidden_pixels = driver.execute_script("return window.pageYOffset")
    y_location_in_pixels = (
        y_location_inside_of_browser + element.size["height"] / 2 -
        hidden_pixels) * (
            browser_height_in_pixels - tab_bar_height -
            horizontal_scroll_size) / int(
                driver.find_element_by_tag_name("html").get_attribute(
                    "clientHeight")) + driver.get_window_position()['y']

    return {'x': x_location_in_pixels, 'y': y_location_in_pixels}
    def run(self):
        print('-- thread started: ScalingClass(QThread).run(self)')

        # Store Work Area Geometry For Comparison
        monitor_info = GetMonitorInfo(MonitorFromPoint((0, 0)))
        work_area = monitor_info.get("Work")
        scr_geo0 = work_area[3]

        while True:
            try:
                time.sleep(0.1)

                # Get Work Area Geometry Each Loop
                monitor_info = GetMonitorInfo(MonitorFromPoint((0, 0)))
                work_area = monitor_info.get("Work")
                scr_geo1 = work_area[3]

                # Compare Current Work Area Geometry To Stored Work Area Geometry
                if scr_geo0 != scr_geo1:

                    # I Use This To Compliment AA_EnableHighDpiScaling, I Find Moving the Window Helps Update Re-Scaling
                    print(
                        '-- ScalingClass(QThread).run(self) ~ refreshing geometry'
                    )
                    self.setGeometry(self.pos().x(),
                                     self.pos().y(), self.width, self.height)

                    # Store Current Work Area Geometry Again Since It Has Changed
                    scr_geo0 = scr_geo1
            except Exception as e:
                print(e)
Exemple #7
0
class Screen:
    screenInfo: dict[str, tuple[int]]
    screenInfo = GetMonitorInfo(MonitorFromPoint((0, 0)))
    monW: int = screenInfo.get('Monitor')[2]
    monH: int = screenInfo.get('Monitor')[3]
    taskbarH: int = monH - screenInfo.get('Work')[3]
    appW: int
    appH: int
    X: int
    Y: int

    def __init__(self):
        self.appW: int = (BTN_SIZE * 3 + LBL_W * 2)
        self.appH: int = max(BTN_SIZE, ((BTN_SIZE + self.taskbarH) // 2))
        self.X: int = round(self.monW - OFFSET_X - self.appW)
        self.Y: int = round(self.monH - OFFSET_Y - self.appH)
    def ui_graph(self):
        ################################################################################################################
        #                                       Build UI
        # Initialize UI
        global root
        root = Tk()
        root.title('Graph Complexity - Visualiser and Calculator')
        root.state("zoomed")  # to make it full screen

        # Obtain screen size
        monitor_info = GetMonitorInfo(MonitorFromPoint((0, 0)))
        work_area = monitor_info.get("Work")
        width = root.winfo_screenwidth()

        # Returns height of window minus task bar and title bar
        height = work_area[3]-50

        # Base values to ensure relative positioning within interface
        graph_frame_width = width / 2
        side_frame_width = width / 4

        # Create the main container (Super container)
        desc_frame = Frame(root, width=side_frame_width, height=height)
        graph_frame = Frame(root, width=graph_frame_width, height=height)
        complex_frame = Frame(root, bg='white', width=side_frame_width, height=height)

        # Arrange frames
        desc_frame.grid(row=0, column=0)
        graph_frame.grid(row=0, column=1)
        complex_frame.grid(row=0, column=2)

        # Build canvas - used to display directed graph
        graph_canvas = Canvas(graph_frame, bg='white', width=width / 2, height=height)
        graph_canvas.pack()
        graph_canvas.pack(fill=BOTH, expand=1)

        # Create the main menu object
        main_menu = Menu(root)
        open_menu = Menu(main_menu, tearoff=0)

        # Add the pull down menu to the menu bar
        main_menu.add_cascade(label="Graph", menu=open_menu)
        # Lambda functions stops recursive exe of methods
        open_menu.add_command(label="Open", command=lambda:DiGraphUI.open_graph(self))
        # Display the menu bar
        root.config(menu=main_menu)

        ################################################################################################################
        #                                       DiGraph UI
        # Sizes relative to the display resolution used to ensure UI deign works across multiple display resolutions
        padded_frame_width = graph_frame_width - (graph_frame_width / 8)
        padded_height = height - (height / 25)

        # Counter for measuring size of NetworkX graph/pydot layoutPyDot produced directional node graph
        max_width = 0
        max_height = 0
        # Calculate Pydot graph layout of graph
        pydot_layout = (nx.nx_pydot.pydot_layout(self, prog='dot'))
        # Calculate dimensions of DiGraph, to build/size TkInter interface
        # No library function for it, so must extract values manually
        for node in pydot_layout:
            x = pydot_layout[node][0]
            if x > max_width:
                max_width = x
            y = pydot_layout[node][1]
            if y > max_height:
                max_height = y

        # Extract nodes from NetworkX graph/pydot layout, then insert as labels/widgets in TkInter interface
        frame_graph_layout = {}
        for node in pydot_layout:
            # Extract x and y location, then set relative location in TkInter interface
            x = pydot_layout[node][0]
            x_relative = x * (padded_frame_width / max_width)
            y = pydot_layout[node][1]
            y_relative = (y * (padded_height / max_height)) - (max_height / 200)
            y_relative = padded_height - y_relative
            # Set visuals/aesthetics
            widget = Label(graph_canvas, text=node, fg='white', bg='red')
            widget.place(x=x_relative, y=y_relative)
            frame_graph_layout[node] = x_relative, y_relative
            # Add tool tip to label/node
            ToolTipGen(widget, str(self.nodes[node]['Activity']))

        # Extract choice variables (yes/no edges) from NetworkX graph
        edge_labels = nx.get_edge_attributes(self, 'choice')
        for node, yesNo in edge_labels.items():
            # Extract x and y location, then set relative location in TkInter interface
            start_label_node = node[0]
            end_label_node = node[1]
            start_label_node_x = frame_graph_layout[start_label_node][0]
            start_label_node_y = frame_graph_layout[start_label_node][1]
            end_label_node_x = frame_graph_layout[end_label_node][0]
            end_label_node_y = frame_graph_layout[end_label_node][1]
            avg_label_node_x = (start_label_node_x+end_label_node_x)/2
            avg_label_node_y = (start_label_node_y+end_label_node_y)/2
            # Set visuals/aesthetics
            edge_label = Label(graph_canvas, text=yesNo, fg='black', bg='white')
            edge_label.place(x=avg_label_node_x, y=avg_label_node_y)

        # Insert edges as arrows
        edge_list = list(self.edges)
        # Iterate through edge list
        for edge in edge_list:
            start_node = edge[0]
            end_node = edge[1]
            # Set edge nodes coordinates
            start_node_x = frame_graph_layout[start_node][0]
            start_node_y = frame_graph_layout[start_node][1]
            end_node_x = frame_graph_layout[end_node][0]
            end_node_y = frame_graph_layout[end_node][1]
            # Draw edge/arrow
            graph_canvas.create_line(start_node_x, start_node_y, end_node_x, end_node_y, arrow=LAST)

        ################################################################################################################
        #                                       Complexity UI
        # Add graph name to complexity UI space
        graph_name = Label(complex_frame, text=str(self), font=("TkDefaultFont", 25), bg='white')
        graph_name.place(x=side_frame_width / 2, y=(height / 16), anchor="center")

        # Add complexity header/title
        complexity_header = Label(complex_frame, text="Complexity measures", font=("TkDefaultFont", 25), bg='white')
        complexity_header.place(x=side_frame_width / 2, y=2*(height / 16), anchor="center")

        # Add cyclomatic number + UI for it
        cyclomatic_number_val = DiGraphUI.cyclomatic_number(self)
        cyclomatic_label = Label(complex_frame, text=("Cyclomatic complexity \n" + str(cyclomatic_number_val)),
                                 bg='white', font=("TkDefaultFont", 20))
        cyclomatic_label.place(x=side_frame_width / 2, y=3*(height/8), anchor="center")
        ToolTipGen(cyclomatic_label, 'A measure of connectedness of the graph.')

        # Add restrictiveness estimator number + UI for it
        restrictiveness_val = DiGraphUI.restrictiveness(self)
        restrictiveness_label = Label(complex_frame, text=("Restrictiveness estimator\n" + str(restrictiveness_val)),
                                      bg='white', font=("TkDefaultFont", 20))
        restrictiveness_label.place(x=side_frame_width / 2, y=5 * (height / 8), anchor="center")
        ToolTipGen(restrictiveness_label, 'A measure of complexity, in regards to the arrangement of the processes.\n'
                                          '0 - All processes are in parallel\n'
                                          '1 - All processes are in series')

        # Add number of trees+ UI for it
        number_of_trees_val = DiGraphUI.number_of_trees(self)
        number_of_trees_label = Label(complex_frame, text=("Number of trees\n" + str(number_of_trees_val)),
                                     bg='white', font=("TkDefaultFont", 20))
        number_of_trees_label.place(x=side_frame_width / 2, y=7 * (height / 8), anchor="center")
        ToolTipGen(number_of_trees_label, 'The number of distinct trees in the graph.\n'
                                          'A tree being any two reachable nodes, connected by a path.')

        ################################################################################################################
        #                                       Activity list UI
        # Extract list of activities from NetworkX graph object
        list_box = Listbox(root)
        activity_list = self.nodes
        # Iterate/extract activities, insert into UI box
        for activity in activity_list:
            list_box.insert(activity, str(activity) + " - " + self.nodes[activity]['Activity'])
        list_box.grid(row=0, column=0, sticky="nsew")
        # Declare as lambda to stop unintended execution
        root.protocol('WM_DELETE_WINDOW', lambda: sys.exit())
        root.mainloop()
Exemple #9
0
import time

import cv2 as cv2
import numpy as np
import platform
import subprocess
from utils import load_images, image_processing

if platform.system() == 'Windows':
    from win32api import GetMonitorInfo, MonitorFromPoint
    screen_width = GetMonitorInfo(MonitorFromPoint((0, 0))).get("Work")[2]
    screen_height = GetMonitorInfo(MonitorFromPoint(
        (0, 0))).get("Work")[3] - 32  # subtracting title bar height
else:
    output = subprocess.Popen('xrandr | grep "\*" | cut -d" " -f4',
                              shell=True,
                              stdout=subprocess.PIPE).communicate()[0]
    resolution = output.split()[0].split(b'x')
    screen_width = int(resolution[0])
    screen_height = int(resolution[1]) - 200


def display_img(img, width=0, title=None, wait=True):
    if title is None:
        title = str(time.time())
    if width != 0:
        img = image_processing.resize_img_width(img, width)

    img = correct_if_oversized(img)

    cv2.imshow(title, img)
Exemple #10
0
import pygame
import time
import random
from win32api import GetMonitorInfo, MonitorFromPoint

pygame.init()

monitor_info = GetMonitorInfo(MonitorFromPoint((0, 0)))
monitor_area = monitor_info.get("Monitor")

white = (255, 255, 255)
yellow = (255, 255, 102)
black = (0, 0, 0)
red = (213, 50, 80)
green = (12, 105, 47)
blue = (0, 183, 234)
dark_blue = (9, 9, 128)

dis_width = monitor_area[2]
dis_height = monitor_area[3]

dis = pygame.display.set_mode((dis_width, dis_height), pygame.FULLSCREEN)
pygame.display.set_caption('Snake Game')

clock = pygame.time.Clock()

snake_block = 10
snake_speed = 10

font_style = pygame.font.SysFont("algerian", 35)
score_font = pygame.font.SysFont("arial black", 25, bold=True)
 def get_work_area_geometry():
     monitor_info = GetMonitorInfo(MonitorFromPoint((0, 0)))
     work_area = monitor_info.get("Work")
     return work_area[0], work_area[1], work_area[2], work_area[3]
Exemple #12
0
def initializeWindowSize():
	global WIDTH_WINDOW, HEIGHT_WINDOW

	list_area = GetMonitorInfo(MonitorFromPoint((0,0))).get("Work")
	WIDTH_WINDOW = list_area[2]
	HEIGHT_WINDOW = list_area[3]
Exemple #13
0
    def setupUi(self, WinControl):
        gui_serial.read_serial_data(self)
        # 获取屏幕分辨率
        user32 = ctypes.windll.user32
        screensizex = user32.GetSystemMetrics(0)
        screensizey = user32.GetSystemMetrics(1)

        monitor_info = GetMonitorInfo(MonitorFromPoint((0, 0)))
        work_area = monitor_info.get("Work")

        # 计算实际窗口分辨率
        self.widget_height = work_area[3] - work_area[3] / 10
        self.widget_width = work_area[2] - work_area[2] / 10
        print(self.widget_height, self.widget_width)

        # 设置窗口尺寸和标题
        # 隐藏标题栏,重写标题栏
        WinControl.resize(self.widget_width, self.widget_height)
        WinControl.setWindowFlags(QtCore.Qt.FramelessWindowHint
                                  | QtCore.Qt.WindowMinimizeButtonHint)
        icon = QIcon()
        icon.addPixmap(QPixmap("res/0key1.png"), QIcon.Normal, QIcon.Off)
        WinControl.setWindowIcon(icon)

        lblfill = QLabel(WinControl)
        lblfill.setAlignment(QtCore.Qt.AlignCenter)
        lblfill.setGeometry(0, 0, self.widget_width, self.widget_height)
        lblfill.setStyleSheet("background-color:rgb(22,109,167);")

        # 添加logo
        pix = QPixmap('res/0key.png')
        lblLogo = QLabel(WinControl)
        lblLogo.setPixmap(pix)
        lblLogo.setScaledContents(True)
        lblLogo.setGeometry(0, 0, self.widget_width / 20,
                            self.widget_height / 30)
        lblLogo.setStyleSheet("background-color:rgb(22,109,167)")
        # 添加logo

        # 添加一个titel
        lblTitel = QLabel('乐开自动化测试 V0.1', WinControl)
        lblTitel.setFont(QFont('微软雅黑', 8))
        lblTitel.setGeometry(lblLogo.x() + lblLogo.width(), 0,
                             self.widget_width, self.widget_height / 30)
        lblTitel.setStyleSheet(
            "background-color:rgb(22,109,167);color:rgb(255,255,255)")
        # 添加一个titel

        # 添加最大化最小化按钮
        self.exitActClose = QAction(QIcon('res/关闭.png'), '关闭', WinControl)
        self.exitActMin = QAction(QIcon('res/最小化.png'), '最小化', WinControl)
        self.exitActClose.triggered.connect(self.close)
        self.exitActMin.triggered.connect(self.showMinimized)

        self.winwidget = QtWidgets.QWidget(WinControl)
        self.winwidget.setGeometry(
            QtCore.QRect(self.widget_width - 80, 0,
                         self.widget_width - self.widget_height / 30 + 1,
                         self.widget_height / 30))
        self.winwidget.setStyleSheet("background-color:rgb(22,109,167)")
        self.winwidget.setObjectName("boolwidget")

        winbar = QToolBar(self.winwidget)
        winbar.setIconSize(
            QtCore.QSize(self.widget_height / 42, self.widget_height / 42))
        winbar.addAction(self.exitActMin)
        winbar.addAction(self.exitActClose)  # 关联到“文件”->"退出应用"
        # 添加最大化最小化按钮

        # 加入工具栏和工具按钮
        self.exitActStart = QAction(QIcon('res/开始.png'), '开始',
                                    WinControl)  # 创建串口开始图标
        self.exitActStop = QAction(QIcon('res/结束.png'), '结束',
                                   WinControl)  # 创建串口结束图标
        self.exitActSet = QAction(QIcon('res/设置.png'), '设置',
                                  WinControl)  # 创建串口结束图标
        self.exitActLink = QAction(QIcon('res/连接.png'), '连接',
                                   WinControl)  # 创建串口结束图标
        self.exitActBreak = QAction(QIcon('res/断开连接.png'), '断开连接',
                                    WinControl)  # 创建串口结束图标
        self.exitActStop.triggered.connect(self.test_pcb_stop_fun)
        self.exitActStart.triggered.connect(self.test_pcb_start_fun)
        self.exitActSet.triggered.connect(self.menu_set_fun)
        self.exitActLink.triggered.connect(self.menu_start_stop_fun)
        self.exitActBreak.triggered.connect(self.menu_start_stop_fun)

        self.exitActLink.setEnabled(True)  # 初始状态开始按键可用,停止按键不可用
        self.exitActBreak.setEnabled(False)

        self.boolwidget = QtWidgets.QWidget(WinControl)
        self.boolwidget.setGeometry(
            QtCore.QRect(0, self.widget_height / 30, self.widget_width,
                         self.widget_height / 10))
        self.boolwidget.setStyleSheet("background-color:rgb(22,109,167)")
        self.boolwidget.setObjectName("boolwidget")

        toolbar = QToolBar(self.boolwidget)
        toolbar.setIconSize(
            QtCore.QSize(self.widget_height / 12, self.widget_height / 12))
        toolbar.addAction(self.exitActStart)  # 关联到“文件”->"退出应用"
        toolbar.addAction(self.exitActStop)
        toolbar.addAction(self.exitActSet)
        toolbar.addAction(self.exitActLink)  # 关联到“文件”->"退出应用"
        toolbar.addAction(self.exitActBreak)

        self.tab_accout = QtWidgets.QWidget(WinControl)
        self.tab_accout.setGeometry(
            QtCore.QRect(
                0,
                self.boolwidget.y() + self.boolwidget.height(),
                self.widget_width / 3, self.widget_height -
                (self.boolwidget.y() + self.boolwidget.height())))
        self.tab_accout.setObjectName("tab_accout")
        self.gridLayout_accout = QtWidgets.QGridLayout(self.tab_accout)
        self.gridLayout_accout.setObjectName("gridLayout_accout")
        self.groupBox_accout = QtWidgets.QGroupBox(self.tab_accout)
        self.groupBox_accout.setTitle("")
        self.groupBox_accout.setObjectName("groupBox_accout")
        self.formLayout_accout = QtWidgets.QFormLayout(self.groupBox_accout)
        self.formLayout_accout.setObjectName("formLayout_accout")
        self.gridLayout_accout.addWidget(self.groupBox_accout, 0, 0, 1, 1)

        for i in range(0, 18):
            global_list.GLOBAL_LABLE_ARRAY[i] = creat_lable(
                self, "recv" + str(i) + ":", i * 2, self.groupBox_accout,
                self.formLayout_accout)
            global_list.GLOBAL_LABLE_ARRAY[i].setText("recv" + str(i) + ":")
        for i in range(0, 18):
            global_list.GLOBAL_LABLE_ARRAY[i] = creat_lable(
                self, "send" + str(i) + ":", i * 2 + 1, self.groupBox_accout,
                self.formLayout_accout)
            global_list.GLOBAL_LABLE_ARRAY[i].setText("send" + str(i) + ":")

        for i in range(0, 36):
            global_list.GLOBAL_TEXT_ARRAY[i] = creat_edit(
                self, "recv" + str(i) + ":", i, self.groupBox_accout,
                self.formLayout_accout)
            label_palette = QPalette()
            label_palette.setColor(QPalette.Base, QtCore.Qt.lightGray)
            global_list.GLOBAL_TEXT_ARRAY[i].setPalette(label_palette)

        self.tab_accout2 = QtWidgets.QWidget(WinControl)
        self.tab_accout2.setGeometry(
            QtCore.QRect(
                self.widget_width / 3,
                self.boolwidget.y() + self.boolwidget.height(),
                self.widget_width / 3, self.widget_height -
                (self.boolwidget.y() + self.boolwidget.height())))
        self.tab_accout2.setObjectName("tab_accout2")
        self.gridLayout_accout2 = QtWidgets.QGridLayout(self.tab_accout2)
        self.gridLayout_accout2.setObjectName("gridLayout_accout2")
        self.groupBox_accout2 = QtWidgets.QGroupBox(self.tab_accout2)
        self.groupBox_accout2.setTitle("")
        self.groupBox_accout2.setObjectName("groupBox_accout2")
        self.formLayout_accout2 = QtWidgets.QFormLayout(self.groupBox_accout2)
        self.formLayout_accout2.setObjectName("formLayout_accout2")
        self.gridLayout_accout2.addWidget(self.groupBox_accout2, 0, 0, 1, 1)

        for i in range(0, 18):
            global_list.GLOBAL_LABLE_ARRAY[i + 18] = creat_lable(
                self, "recv" + str(i + 18) + ":", i * 2, self.groupBox_accout2,
                self.formLayout_accout2)
            global_list.GLOBAL_LABLE_ARRAY[i + 18].setText("recv" +
                                                           str(i + 18) + ":")
        for i in range(0, 18):
            global_list.GLOBAL_LABLE_ARRAY[i + 18] = creat_lable(
                self, "send" + str(i + 18) + ":", i * 2 + 1,
                self.groupBox_accout2, self.formLayout_accout2)
            global_list.GLOBAL_LABLE_ARRAY[i + 18].setText("send" +
                                                           str(i + 18) + ":")

        for i in range(0, 36):
            global_list.GLOBAL_TEXT_ARRAY[i + 36] = creat_edit(
                self, "recv" + str(i) + ":", i, self.groupBox_accout2,
                self.formLayout_accout2)
            label_palette = QPalette()
            label_palette.setColor(QPalette.Base, QtCore.Qt.lightGray)
            global_list.GLOBAL_TEXT_ARRAY[i + 36].setPalette(label_palette)

        gui_serial.read_list_data(self)

        # 添加一个log打印窗口和清空按键
        global_list.textLog = QTextEdit(WinControl)
        global_list.textLog.setGeometry(
            (self.widget_width * 2) / 3,
            self.boolwidget.y() + self.boolwidget.height(),
            self.widget_width / 3, self.widget_height -
            (self.boolwidget.y() + self.boolwidget.height() + 60))
        global_list.textLog.setStyleSheet(
            "border:2px solid rgb(22,109,167);background-color:rgb(0,0,0);color:rgb(255,255,255)"
        )
        global_list.textLog.setReadOnly(True)
        global_list.textLog.moveCursor(QTextCursor.End)
        global_list.textLog.setAutoFillBackground(True)
        global_list.textLog.document().setMaximumBlockCount(5000)

        clearButton = QtWidgets.QPushButton(WinControl)
        clearButton.setIcon(QIcon("res/清空.png"))
        clearButton.setIconSize(QtCore.QSize(530 / 5, 270 / 5))
        clearButton.setGeometry(
            self.widget_width - 530 / 5,
            global_list.textLog.y() + global_list.textLog.height(), 530 / 5,
            270 / 5)
        clearButton.setObjectName("clearButton")
        clearButton.clicked.connect(self.clearButton_click)

        self.retranslateUi(WinControl)
        QtCore.QMetaObject.connectSlotsByName(WinControl)
Exemple #14
0
    def __get_system_info(self):

        if self.statuses[1] is True:

            win = GetObject("winmgmts:root\\cimv2")

            os_info = win.ExecQuery("Select * from Win32_OperatingSystem")[0]
            cpu_info = win.ExecQuery("Select * from Win32_Processor")[0].Name
            gpu_info = win.ExecQuery("Select * from Win32_VideoController")[0].Name
            monitors_info = ", ".join(f"{monitor['Device'][4:]} {monitor['Monitor'][2]}x{monitor['Monitor'][3]}" for monitor in [GetMonitorInfo(monitor[0]) for monitor in EnumDisplayMonitors()])

            try:
                net_info = urlopen(Request(method="GET", url=self.config.IPUrl)).read().decode("utf-8")
            except:
                net_info = "Error"

            info = (
                f"User: {self.config.User}\n",
                f"IP: {net_info}\n",
                f"OS Name: {os_info.Name.split('|')[0]}\n",
                f"OS Version: {os_info.Version} {os_info.BuildNumber}\n",
                f"Monitors: {monitors_info}\n"
                f"CPU: {cpu_info}\n",
                f"GPU: {gpu_info}\n",
                f"RAM: {round(float(os_info.TotalVisibleMemorySize) / 1048576)} GB\n",
            )

            with open(rf"{self.storage_path}\{self.folder}\Configuration.txt", "a", encoding="utf-8") as system:

                for item in info:
                    system.write(item)

            system.close()
 def getWorking_area(self):
     monitor_info = GetMonitorInfo(MonitorFromPoint((0, 0)))
     return monitor_info.get("Work")
Exemple #16
0
# Make window allways on top and make it black and transparent
form.protocol("WM_DELETE_WINDOW", disable_event)
form.wm_attributes("-topmost", 1)
form.wm_attributes("-alpha", 0.7)
form['bg'] = 'black'

# Get os screen width and height
screen_width = form.winfo_screenwidth()
screen_height = form.winfo_screenheight()

# Set app windows screen width and height
window_height = 50
window_width = screen_width

# Get taskbar y coordinate
monitor_info = GetMonitorInfo(MonitorFromPoint((0,0)))
work_area = monitor_info.get("Work")
taskBar_y_coordinate = work_area[3]

# Set app x and y coordinates
x_coordinate = 0
y_coordinate = taskBar_y_coordinate - window_height

# Place the app window on right above the taskbar and make it unresizable and borderless
form.geometry("{}x{}+{}+{}".format(window_width, window_height, x_coordinate, y_coordinate))
form.resizable(False, False)
form.overrideredirect(True)

canvas = Canvas(form, width=window_width - 4, height=window_height - 2, background='black', highlightthickness=0)
canvas.pack()
def get_resolution():
	monitor_info = GetMonitorInfo(MonitorFromPoint((0,0)))
	_, taskbar_height, width, height = monitor_info.get("Work")
	print(width, height, taskbar_height)
	return width, height, taskbar_height