摘要:
以下是关于Tkinter中获取和设置组件属性的一份简明指南: 获取组件属性 常规方法: 几乎所有的Tkinter组件都支持.cget()方法来获取属性值,以及可以直接通过键值对的方式读取属性。 # 假设 widget 是已创建的任意Tkinter组件实例 # 使用 .cget() 方法获取属性值 v 阅读全文
摘要:
import os # 获取当前工作目录 current_dir = os.getcwd() print(f"当前工作目录: {current_dir}") # 更改当前工作目录到指定路径 new_dir = "/path/to/your/directory" os.chdir(new_dir) # 阅读全文
摘要:
import os file_path = "C:\\path\\to\\your\\file_or_directory" os.startfile(file_path) 阅读全文
该文被密码保护。 阅读全文
摘要:
def singleton(cls): threadNames = [] # 线程名称列表 instances = {} # 实例字典 def get_instance(threadName, *args, **kwargs): """ 获取单例实例,通过线程名创建单例,保障每个线程里面的实例保持一 阅读全文
摘要:
# Python 3.5 之后可用,之前需要pip安装 from typing import TypedDict # 每个字段必须 class Person(TypedDict): name: str age: int qq: str p1_dict: Person = { "name": "大佬" 阅读全文
摘要:
import threading import time def singleton(cls): instances = {} def get_instance(*args, **kwargs): # 判断实例是否已经存在 if cls not in instances: # 如果不存在,创建新的实 阅读全文
摘要:
# 定义接口类 from abc import ABC, abstractmethod class Animal(ABC): @abstractmethod def speak(self): pass # 定义实现类 class Dog(Animal): def speak(self): retur 阅读全文
摘要:
1. Ctrl + 左键 :追溯源代码Ctrl + Alt + ←:后退 (可回到 追溯源代码 前)Ctrl + Alt + →:前进Ctrl + B:生命或用例 2.Ctrl + Alt + L:格式化代码 阅读全文
摘要:
import time def run_time(func): "计算运行时长装饰器" def wrapper(*args,**kwargs): # 包装函数 start = time.time() # 在调用装饰函数前干点事情 res = func(*args,**kwargs) end = ti 阅读全文
摘要:
python tkinter事件循环中一直检测初始化加载文件有没有加载成功 import tkinter as tk def check_file_loaded(): # 检查文件是否加载成功的逻辑 if file_loaded: # 文件加载成功,执行相应操作 print("文件加载成功") el 阅读全文
摘要:
import cv2 import threading import tkinter as tk from PIL import Image, ImageTk class CameraThread(threading.Thread): def __init__(self, camera_index, 阅读全文
摘要:
# pip install wmi import wmi def get_camera_name(): camera_names = [] wmi_obj = wmi.WMI() cameras = wmi_obj.Win32_PnPEntity() for camera in cameras: i 阅读全文
摘要:
如果一个线程修改属性,而另一个线程读取相同的属性,那么在多线程环境中,为了确保数据的一致性,通常也需要使用锁来同步访问。 即使一个线程只读取属性而不修改它,也不能保证在读取的同时,另一个线程进行修改操作。如果没有适当的同步机制,可能会导致读取到不一致或不完整的数据。 以下是一个示例代码,演示了在一个 阅读全文
摘要:
turtle.forward(distance) 向当前画笔方向移动 distance 像素长度 turtle.backward(distance) 向当前画笔相反方向移动 distance 像素长度 turtle.right(degree) 顶时针移动 degree°角度 turtle.left( 阅读全文
摘要:
#!/usr/bin/python # -*- coding:utf-8 -*- import logging import time import os class Log(object): ''' 封装后的logging ''' def __init__(self, logger=None, l 阅读全文
摘要:
import win32gui import win32ui import win32con import numpy as np import cv2 import base64 # 通过句柄截取窗口内容 def capture_window_by_handle(handle): left, to 阅读全文
摘要:
''' pip install numpy pip install opencv-python ''' from io import BytesIO import cv2 import numpy as np def pic_compress(pic_path, out_path, target_s 阅读全文
摘要:
import ctypes # 定义Windows API函数 import time user32 = ctypes.WinDLL("user32") user32.ShowWindow.argtypes = [ctypes.c_void_p, ctypes.c_int] user32.ShowW 阅读全文
摘要:
1. https://alpha.bito.co/bitoai/需要输入邮箱获取验证码 2.https://chat-shared2.zhile.io/shared.html 输入个密码用来隔离,账号共享多 阅读全文
该文被密码保护。 阅读全文
摘要:
import time import win32gui import win32api # 获取当前鼠标【x y】坐标 time.sleep(2) print("2秒内移动鼠标到对应窗口") point = win32api.GetCursorPos() print(point) # 通过坐标获取坐 阅读全文
摘要:
from pynput import keyboard from multiprocessing import Process import multiprocessing, psutil def run(index): # index = 1 while True: index += 1 prin 阅读全文
摘要:
# 将该脚本和pyd放同一目录 import os #导入模块 filename = os.getcwd() #文件地址 list_path = os.listdir(filename) #读取文件夹里面的名字 for index in list_path: #list_path返回的是一个列表 通 阅读全文
摘要:
from pynput import keyboard # 监听键盘按下 def listenKey(): with keyboard.Listener(on_press=on_press, on_release=None) as (listener): listener.join() # 监听回调 阅读全文
摘要:
在 Tkinter 中隐藏和取消隐藏窗口 – Python 先决条件: Tkinter Python为开发 GUI(图形用户界面)提供了多种选择。在所有 GUI 方法中,Tkinter 是最常用的方法。它是Python附带的 Tk GUI 工具包的标准Python接口。 Python with Tk 阅读全文
摘要:
1、pynput 控制移动版本 import random import time import pynput ctr = pynput.mouse.Controller() window_size = (1366, 768) step = 20 target = (1366, 768) end = 阅读全文
摘要:
一、题目描述 在一个迷宫游戏里,有一些小怪物要去攻击主角,现在希望给这些小怪物加上聪明的AI,让他们可以自动绕过迷宫中的障碍物,寻找到主角所在。二、解题思路迷宫游戏里的场景通常都是由小方格组成。假设我们有一个7*5大小的迷宫,图中红色格子是终点,绿色格子是起点,蓝色格子是一堵墙。 AI角色从起点开始 阅读全文