python制作一个桌面小工具_自己做一个桌面小工具-程序员宅基地

技术标签: python  

python实现一个桌面小工具,制作一个桌面的便签提醒工具

参考代码:https://github.com/cosven/memo

参考链接:https://www.jb51.net/article/70821.htm

参考链接:https://blog.csdn.net/v1_vivian/article/details/78418660

核心代码

#!/usr/bin/env xdg-open
[Desktop Entry]
Type=Application
Name=Memo
Comment=Memo Launcher
Exec=/usr/bin/env python "/home/ysw/python/pyqt/memo/widget.py"
Icon=/home/ysw/python/pyqt/memo/img/icon.png
Terminal=false
StartupNotify=true

最近发现了一个非常有意思的python小应用,觉得很赞,所以将学习记录一下。

下载之后大概就是这些文件了,出来的效果也很赞。

 

小图标制作的也很精致,更加觉得非常有意思了,接下来,看一下源码。

 源码

环境是windows+py3

所以,这里我们需要建立一个py2.7的虚拟环境,因为我安装了anaconda,所以可以采用conda建立一个虚拟环境

conda create -n python2.7 python=2.7

激活python2.7的虚拟环境

activate python2.7

退出虚拟环境

deactivate

删除虚拟环境

conda remove -n python2.7 --all

根据这个步骤,我就新建了一个名叫python2.7的虚拟环境。

 

dataAccess.py 

# -*- coding:utf8 -*-
#! /usr/bin/python

'''
dictdata = {
        'id': '2012', 
        'datetime': '10',
        'memoList': [
            {
                'id': '1',
                'pid': '2012',
                'content': 'hello',
                'deadline': '2013',
                'finished': True,
                },
            ],
        'notfinish': [],
        }
'''
import os
import json

'''
assume that filename is date.json
memo id is date
the id of each content in memo is number
'''

def save(dictdata):
    '''
    1. judge if exists the file
        yes: write jsondata
        no: new the file and write jsondata
    '''
    filename = dictdata['id'] + '.json'
    f = open(filename, 'w')
    jsondata = json.dumps(dictdata)
    f.write(jsondata)
    f.close

def read(date):
    '''
    1. if exist today's file
        a. judge finish or not and directly load it
    2. not exist
        a. init the today's file
            1. to check log and get lastmemo file
    3. finally, return a unfinished content list
    '''
    contentlist = []

    filename = date + '.json'
    if os.path.exists(filename):
        f = open(filename, 'r')
        jsondata = json.load(f)
        f.close()
        memolist = jsondata['memolist']
        for each in memolist:
            if not each['finished']:
                contentlist.append(each)
    else:
        f = open('log.json', 'r')
        jsondata = json.load(f)
        f.close()
        lastmemo = jsondata['last']
        filename = lastmemo + '.json'
        f = open(filename, 'r')
        jsondata = json.load(f)
        f.close()
        memolist = jsondata['memolist']
        for each in memolist:
            if not each['finished']:
                contentlist.append(each)
    return contentlist

if __name__ == "__main__":
    data = {
        'id': '2012',
        'datetime': '10',
        'memolist': [
            {
                'id': '1',
                'pid': '2012',
                'content': 'hello',
                'deadline': '2013',
                'finished': False,
                },
            {
                'id': '2',
                'pid': '2012',
                'content': 'world',
                'deadline': '2013',
                'finished': False,
                },
            ],
        'notfinish': [],
        }
    save(data)
    r = read(data['id'])

exe.py

from distutils.core import setup
import py2exe
import sys
 
#this allows to run it with a simple double click.
sys.argv.append('py2exe')
 
py2exe_options = {
        "includes": ["sip"],
        "dll_excludes": ["MSVCP90.dll",],
        "compressed": 1,
        "optimize": 2,
        "ascii": 0,
        "bundle_files": 1,
        }
 
window = [{
	"script": "hotkey.pyw",
	'icon_resources': [(1, 'icon2.ico'),]
	}]

setup(
      name = 'PyQt Demo',
      version = '1.0',
      windows = ['hotkey.pyw',], 
      options = {'py2exe': py2exe_options}
      )

myLabel.py

# -*- coding:utf8 -*-

from PyQt4 import QtCore, QtGui
from PyQt4.QtCore import *
from PyQt4.QtGui import *

class FocusEdit(QWidget):
    def __init__(self, parent=None):
        super(FocusEdit, self).__init__(parent)
        self.initObjects()
        self.setObjects()
        self.setStyle()
        self.setMySizePolicy()
        self.connect(self.timeEdit, SIGNAL("dateTimeChanged(QDateTime)"),
                self.setDateTime)

    def initObjects(self):
        self.textEdit = QTextEdit()
        self.timeEdit = QDateTimeEdit()
        self.layout = QHBoxLayout()

    def setObjects(self):
        self.layout.addWidget(self.textEdit)
        self.layout.addWidget(self.timeEdit)
        self.setLayout(self.layout)

    def setMySizePolicy(self):
        self.layout.setContentsMargins(0,0,0,0)
        self.layout.setSpacing(0)
        self.timeEdit.setMinimumHeight(40)
        self.textEdit.setMinimumHeight(40)
        self.textEdit.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.timeEdit.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)

    def setStyle(self):
        edit = '''
            QTextEdit{
                border-top-left-radius: 4px;
                border-bottom-left-radius: 4px;
                background-c
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/yql_617540298/article/details/109299100

智能推荐

Word插件开发

创建一个新的 Office 插件项目:在 Visual Studio 中,选择"文件" -> “新建项目”,然后在模板中选择"Office/SharePoint",选择适当的 Office 插件项目模板,如 Word 插件、Excel 插件或 PowerPoint 插件。设计用户界面:在解决方案资源管理器中,打开你的插件项目,并在其中打开相应的 Office 文件(如 Word 文件、Excel 文件或 PowerPoint 文件)。你可以在 Office 应用中测试插件的功能,并在开发过程中进行调试。

便携式iv检测仪解析

在应用场景方面,便携式IV功率测试仪广泛应用于光伏电站的日常运维、光伏组件生产过程中的质量控制以及光伏项目的前期评估等环节。在光伏电站运维中,定期对光伏组件进行IV测试,可以及时发现性能下降或损坏的组件,为电站的运维提供有力支持。首先,从工作原理来看,光伏电站便携式IV功率测试仪通过模拟太阳光照射光伏组件,并测量组件在不同电压下的电流输出,从而绘制出IV曲线。此外,测试仪还可以计算光伏组件的功率输出、转换效率等参数,为用户提供全面的性能评估。

postgresql 索引之 hash_load_categories_hash postgres-程序员宅基地

文章浏览阅读3.6k次。os: ubuntu 16.04postgresql: 9.6.8ip 规划192.168.56.102 node2 postgresqlhelp create indexpostgres=# \h create indexCommand: CREATE INDEXDescription: define a new indexSyntax:CREATE [ UNIQUE ..._load_categories_hash postgres

face++实现人脸识别及人脸相似度对比_face++人脸识别 html5-程序员宅基地

文章浏览阅读4.8k次。使用face++,先获取key和secret下方是人脸识别,还添加了画出人脸轮廓的正方形下方是人脸识别,还添加了画出人脸轮廓的正方形 import requests#网络访问控件 from json import JSONDecoder#互联网数据交换标准格式 import cv2 as cv#图像处理控件 http_url ="https://a..._face++人脸识别 html5

desencrypt java md5_Java实现DES加密与解密,md5加密以及Java实现MD5加密解密类-程序员宅基地

文章浏览阅读322次。很多时候要对秘要进行持久化加密,此时的加密采用md5。采用对称加密的时候就采用DES方法了import java.io.IOException;import java.security.MessageDigest;import java.security.SecureRandom;import javax.crypto.Cipher;import javax.crypto.SecretKey;im..._java desencrypt.encrypt(pass)

BZOJ 2818 欧拉函数,线性筛_线性筛预处理质数表, 并求出欧拉函数, 预处理前缀和即可 bzoj2818boj-程序员宅基地

文章浏览阅读145次。题目链接:https://www.acwing.com/problem/content/description/222/给定整数N,求1<=x,y<=N且GCD(x,y)为素数的数对(x,y)有多少对。GCD(x,y)即求x,y的最大公约数。输入格式输入一个整数N输出格式输出一个整数,表示满足条件的数对数量。数据范围1≤N≤10^7输入样例:4..._线性筛预处理质数表, 并求出欧拉函数, 预处理前缀和即可 bzoj2818boj

随便推点

UVA 12534 - Binary Matrix 2 (网络流‘最小费用最大流’ZKW)_uva12534-程序员宅基地

文章浏览阅读687次。题目:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=93745#problem/A题意:给出r*c的01矩阵,可以翻转格子使得0表成1,1变成0,求出最小的步数使得每一行中1的个数相等,每一列中1的个数相等。思路:网络流。容量可以保证每一行和每一列的1的个数相等,费用可以算出最小步数。行向列建边,如果该格子是_uva12534

免费SSL证书_csdn alphassl免费申请-程序员宅基地

文章浏览阅读504次。1、Let's Encrypt 90天,支持泛域名2、Buypass:https://www.buypass.com/ssl/resources/go-ssl-technical-specification6个月,单域名3、AlwaysOnSLL:https://alwaysonssl.com/ 1年,单域名 可参考蜗牛(wn789)4、TrustAsia5、Alpha..._csdn alphassl免费申请

测试算法的性能(以选择排序为例)_算法性能测试-程序员宅基地

文章浏览阅读1.6k次。测试算法的性能 很多时候我们需要对算法的性能进行测试,最简单的方式是看算法在特定的数据集上的执行时间,简单的测试算法性能的函数实现见testSort()。【思想】:用clock_t计算某排序算法所需的时间,(endTime - startTime)/ CLOCKS_PER_SEC来表示执行了多少秒。【关于宏CLOCKS_PER_SEC】:以下摘自百度百科,“CLOCKS_PE_算法性能测试

Lane Detection_lanedetectionlite-程序员宅基地

文章浏览阅读1.2k次。fromhttps://towardsdatascience.com/finding-lane-lines-simple-pipeline-for-lane-detection-d02b62e7572bIdentifying lanes of the road is very common task that human driver performs. This is important ..._lanedetectionlite

【数据结构】静态表查找之顺序查找、二分查找、分块查找_读取表元是什么意思-程序员宅基地

文章浏览阅读4.1k次,点赞8次,收藏23次。​通过一定的方法找出与给定关键字相同的数据元素的过程叫做查找。也就是根据给定的某个值,在查找表中确定一个关键字等于给定值的记录或数据元素。_读取表元是什么意思

如何设置交易滑点?精确到tick 测算期货冲击成本(附源码)_滑点设置多少合适-程序员宅基地

文章浏览阅读8.3k次,点赞4次,收藏18次。我们在非撮合回测模式下,因为无法获知交易价格当时的真实盘口价差、挂单数量,常主观设定一个滑点均值,比如针对螺纹钢等合约,设置 1 跳,针对某些交易不活跃的品种,设置 2 跳。但是这种近乎拍脑袋的方法并不精确。我们今天尝试通过简单的辅助工具,实现尽可能接近准确的 tick 级别滑点设置,代码已写好,不用编程也可获得结果。_滑点设置多少合适

推荐文章

热门文章

相关标签