Ejemplo n.º 1
0
def set_shortcut():
    startup_path = shell.SHGetPathFromIDList(
        shell.SHGetSpecialFolderLocation(0, shellcon.CSIDL_STARTUP))
    print startup_path
    shortcut = pythoncom.CoCreateInstance(shell.CLSID_ShellLink, None,
                                          pythoncom.CLSCTX_INPROC_SERVER,
                                          shell.IID_IShellLink)
    shortcut.SetPath(os.getcwd() + "\Companions.exe")
    shortcut.SetWorkingDirectory(os.getcwd())
    shortcut.SetIconLocation(os.getcwd() + "\data\UI\images\Icon.ico", 0)
    shortcut.QueryInterface(pythoncom.IID_IPersistFile).Save(
        startup_path + "\Companions.lnk", 0)
Ejemplo n.º 2
0
	def save_clicked(self):
		global changed,current_theme,setted_theme,startup_path
		if changed:
			setted_theme=current_theme
			setted_theme_file=open("data/settings/setted_theme.txt","w")
			setted_theme_file.write(setted_theme.encode("gbk"))
			setted_theme_file.close()
			transparency_file=open("data/settings/transparency.txt","w")
			transparency_file.write(str(self.slider.value()))
			transparency_file.close()
			if self.check.isChecked()==True:	
				set_shortcut()
			else:
				os.remove(shell.SHGetPathFromIDList(shell.SHGetSpecialFolderLocation(0,shellcon.CSIDL_STARTUP))+"/Companions.lnk")
			self.close()
Ejemplo n.º 3
0
from _is_ import _is_
from reminder import *
from count_down import *
from exact_time import *
from blur import *
from xiaohua import *
from neihan import *
from iciba import *

en_punctuation=['+','-','*','/','^','!','"','#','$','%','&','\'','(',')',',','.',';','<','=','>','?','@','[','\\',']','^','_','`','{','|','}','~']
cn_punctuation=['!','“','”','¥','&','‘','’','(',')',',','。',';','《','》','?','【','、','】','…','—','·']
operator=['+','-','*','/','^','!','加','减','乘','除','次方','平方','立方','根号','阶乘','次幂','的正弦','的余弦','的正切','的余切','的正割','的余割','sin','cos','tan','cot','sec','csc','ln']
number=['0','1','2','3','4','5','6','7','8','9']
Q=['吗','呢','么','啥','哪','谁','咋','如何','怎样','咋样','为何','有没有','喜欢不喜欢','行不行','是不是','能不能','会不会','好不好','','','']
schedule = sched.scheduler(time.time, time.sleep)
windows_path = shell.SHGetPathFromIDList(shell.SHGetSpecialFolderLocation(0,shellcon.CSIDL_WINDOWS))
programfiles_path = shell.SHGetPathFromIDList(shell.SHGetSpecialFolderLocation(0,shellcon.CSIDL_PROGRAM_FILES))
def baidu(key):
    feedback=None
    url="http://www.baidu.com/baidu?word="+key
    webbrowser.open_new_tab(url)
    feedback='正在为您搜索"'+key+'"'
    return feedback
def main(info):  
    feedback = None
    special_format=False
###########################################################################################
#calc
###########################################################################################
    op=False
    nu=False
Ejemplo n.º 4
0
	def __init__(self,parent=None):
		global changed,auto_start,ui_path,setted_theme,current_theme,themes_list,next,previous,theme_id,startup_path
		changed=next=previous=False
		theme_id=0
		startup_path = shell.SHGetPathFromIDList(shell.SHGetSpecialFolderLocation(0,shellcon.CSIDL_STARTUP))
		if os.path.isfile(startup_path+"/Companions.lnk"):
			auto_start=True
		else:
			auto_start=False
		super(Setting_UI,self).__init__(parent)
		setting_close_qss_file=open("data/UI/style_sheets/btn_close.txt","r")
		setting_close_qss=setting_close_qss_file.read()
		setting_close_qss_file.close()
		setting_previous_qss_file=open("data/UI/style_sheets/btn_previous.txt","r")
		setting_previous_qss=setting_previous_qss_file.read()
		setting_previous_qss_file.close()
		setting_next_qss_file=open("data/UI/style_sheets/btn_next.txt","r")
		setting_next_qss=setting_next_qss_file.read()
		setting_next_qss_file.close()
		setting_default_qss_file=open("data/UI/style_sheets/btn_default.txt","r")
		setting_default_qss=setting_default_qss_file.read()
		setting_default_qss_file.close()
		setting_save_qss_file=open("data/UI/style_sheets/btn_save.txt","r")
		setting_save_qss=setting_save_qss_file.read()
		setting_save_qss_file.close()
		setting_cancel_qss_file=open("data/UI/style_sheets/btn_bcancel.txt","r")
		setting_cancel_qss=setting_cancel_qss_file.read()
		setting_cancel_qss_file.close()
		setting_browser_qss_file=open("data/UI/style_sheets/QTextBrowser.txt","r")
		setting_browser_qss=setting_browser_qss_file.read()
		setting_browser_qss_file.close()
		setting_check_qss_file=open("data/UI/style_sheets/QCheckBox.txt","r")
		setting_check_qss=setting_check_qss_file.read()
		setting_check_qss_file.close()
		setting_slider_qss_file=open("data/UI/style_sheets/QSlider.txt","r")
		setting_slider_qss=setting_slider_qss_file.read()
		setting_slider_qss_file.close()
		themes_list=[]
		themes_list1=os.listdir('data/themes')
		for i in range(len(themes_list1)-1,-1,-1):
			themes_list.append(themes_list1[i].decode('gbk'))
		self.theme_pic=QLabel()
		self.btn_close=QPushButton()
		self.btn_previous=QPushButton()
		self.btn_next=QPushButton()
		self.btn_default=QPushButton()
		self.btn_save=QPushButton()
		self.btn_cancel=QPushButton()
		self.btn_close.setCursor(QCursor(Qt.PointingHandCursor))
		self.btn_previous.setCursor(QCursor(Qt.PointingHandCursor))
		self.btn_next.setCursor(QCursor(Qt.PointingHandCursor))
		self.btn_default.setCursor(QCursor(Qt.PointingHandCursor))
		self.btn_save.setCursor(QCursor(Qt.PointingHandCursor))
		self.btn_cancel.setCursor(QCursor(Qt.PointingHandCursor))
		self.browser0=QTextBrowser()
		self.browser1=QTextBrowser()
		self.browser2=QTextBrowser()
		self.browser3=QTextBrowser()
		self.browser4=QTextBrowser()
		self.check=QCheckBox(u'开机自动运行',self)
		self.check.setCursor(QCursor(Qt.PointingHandCursor))
		self.check.move(110,100)
		self.slider=QSlider(Qt.Horizontal)
		self.slider.setCursor(QCursor(Qt.PointingHandCursor))
		self.slider.setMinimum(40)
		self.slider.setMaximum(400)
		self.slider.setValue(trans)
		self.btn_close.setStyleSheet(setting_close_qss)
		self.btn_previous.setStyleSheet(setting_previous_qss)
		self.btn_next.setStyleSheet(setting_next_qss)
		self.btn_default.setStyleSheet(setting_default_qss)
		self.btn_save.setStyleSheet(setting_save_qss)
		self.btn_cancel.setStyleSheet(setting_cancel_qss)
		self.browser0.setStyleSheet(setting_browser_qss)
		self.browser1.setStyleSheet(setting_browser_qss)
		self.browser2.setStyleSheet(setting_browser_qss)
		self.browser3.setStyleSheet(setting_browser_qss)
		self.browser4.setStyleSheet(setting_browser_qss)
		self.check.setStyleSheet(setting_check_qss)
		self.slider.setStyleSheet(setting_slider_qss)
		self.theme_pic.setParent(self)
		self.btn_close.setParent(self)
		self.btn_previous.setParent(self)
		self.btn_next.setParent(self)
		self.btn_default.setParent(self)
		self.btn_save.setParent(self)
		self.btn_cancel.setParent(self)
		self.browser0.setParent(self)
		self.browser1.setParent(self)
		self.browser2.setParent(self)
		self.browser3.setParent(self)
		self.browser4.setParent(self)
		self.slider.setParent(self)
		self.theme_pic.setGeometry(136,200,128,128)
		self.btn_close.setGeometry(380,10,9,9)
		self.btn_previous.setGeometry(100,260,11,18)
		self.btn_next.setGeometry(289,260,11,18)
		self.btn_default.setGeometry(30,497,70,26)
		self.btn_save.setGeometry(180,495,80,30)
		self.btn_cancel.setGeometry(290,495,80,30)
		self.browser0.setGeometry(6,2,50,28)
		self.browser1.setGeometry(30,50,50,35)
		self.browser2.setGeometry(30,150,50,35)
		self.browser3.setGeometry(30,380,70,35)
		self.browser4.setGeometry(100,330,200,35)
		self.slider.setGeometry(100,420,200,35)
		self.browser0.append(u'<p style="font-family:Microsoft Yahei;font:15px;color:#4f5359">设置</p>')
		self.browser1.append(u'<p style="font-family:Microsoft Yahei;font:18px;color:#4f5359">启动</p>')
		self.browser2.append(u'<p style="font-family:Microsoft Yahei;font:18px;color:#4f5359">主题</p>')
		self.browser3.append(u'<p style="font-family:Microsoft Yahei;font:18px;color:#4f5359">透明度</p>')
		self.btn_previous.setEnabled(previous)
		self.btn_next.setEnabled(next)
		self.btn_save.setEnabled(changed)
		for i in range(0,len(themes_list)):
			if current_theme==themes_list[i]:
				if i==0:
					if len(themes_list)>1:
						previous=False
						next=True
						self.btn_previous.setEnabled(previous)
						self.btn_next.setEnabled(next)
					else:
						previous=False
						next=False
				elif i==len(themes_list)-1:
					if len(themes_list)>1:
						previous=True
						next=False
						self.btn_previous.setEnabled(previous)
						self.btn_next.setEnabled(next)
					else:
						previous=False
						next=False
						self.btn_previous.setEnabled(previous)
						self.btn_next.setEnabled(next)
				else:
					previous=True
					next=True
					self.btn_previous.setEnabled(previous)
					self.btn_next.setEnabled(next)
				theme_id=i
				break
		if len(current_theme)>10:
			theme_name=current_theme[:10]+'...'
		else:
			theme_name=current_theme
		self.browser4.append(u'<div align=center><p style="font-family:Microsoft Yahei;font:15px">%s</p></div>'%theme_name)
		self.theme_pic.setPixmap(QPixmap(ui_path+"cover.png"))
		self.check.setChecked(auto_start)
		self.btn_close.clicked.connect(self.close_clicked)
		self.btn_next.clicked.connect(self.next_clicked)
		self.btn_previous.clicked.connect(self.previous_clicked)
		self.btn_default.clicked.connect(self.default_clicked)
		self.btn_save.clicked.connect(self.save_clicked)
		self.btn_cancel.clicked.connect(self.close_clicked)
		self.slider.valueChanged.connect(self.update_transparency)
		self.check.clicked.connect(self.check_change)
		if self.check.isChecked() != auto_start or current_theme != setted_theme or trans != transparency:
			changed=True
			self.btn_save.setEnabled(changed)
		else:
			changed=False
			self.btn_save.setEnabled(changed)
		self.setWindowTitle(u"设置 - Companions")
		self.icon = QIcon(ui_path+"cover.png")
		self.setWindowIcon(self.icon)
		self.setAttribute(Qt.WA_TranslucentBackground)
		self.dragPosition=None
		self.setWindowFlags(Qt.FramelessWindowHint|Qt.SubWindow)
		self.resize(400,550)
		screen = QDesktopWidget().screenGeometry()
		size = self.geometry()
		self.move((screen.width()-size.width())/2, (screen.height()-size.height())/2)
Ejemplo n.º 5
0
#!/usr/bin/env python
#-*- encoding: gbk -*-
import string,os,thread,math
from shell import shell
from shell import shellcon
windows_path = shell.SHGetPathFromIDList(shell.SHGetSpecialFolderLocation(0,shellcon.CSIDL_WINDOWS))
operator=['+','-','*','/','^','!','加','减','乘','除','次方','平方','立方','根号','阶乘','次幂','的正弦','的余弦','的正切','的余切','sin','cos','tan','cot','ln']
number=['0','1','2','3','4','5','6','7','8','9']
##def translator(frm='',to='',delete='',keep=None):
##    if len(to)==1:
##        to=to*len(frm)
##    trans=string.maketrans(frm,to)
##    if keep is not None:
##        allchars=string.maketrans('','')
##        delete=allchars.translate(allchars,keep.trancelate(allchars,delete))
##    def translate(s):
##        return s.translate(trans,delete)
##    return translate
def calc(a):
    feedback=None
    digits=['0','1','2','3','4','5','6','7','8','9','.']
    n_op=0
    NaN=False
    num1_id=None
    num2_id=None
    op_id=None
    end_id=None
    num1=None
    num2=None
    b=None
    length=len(a)