Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 30 additions & 3 deletions OpenTool.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@
import threading
import time
import systemhotkey
import os
import base64
from icon import MYICO,ADDICO
FONT_1 = ('微软雅黑',10,'normal')
FONT_2 = ('Arial',10,'normal')

Win_Hide = False



# 主窗体
class Application(tk.Frame):
def __init__(self,master = None): #顶层窗口master默认为空,应用中为root
Expand Down Expand Up @@ -117,17 +122,27 @@ def changeitem(self):
cw = Add_PopupDialog(self,'change',urlname)
self.wait_window(cw) # 這一句很重要!!!


def doevent(self):
#self.keywdbox.bind("<Return>",self.showlist) # 按回车键,显示搜索结果
self.keywdbox.bind("<KeyRelease>",self.showlist) # 按任意键,显示搜索结果 一定要用keyrelease 否则字符还没有输入到Enter就进入了事件处理程序
#self.keywdbox.bind("<BackSpace>",self.showlistAll)
#self.keywdbox.bind("<Return>", lambda e: print('enter'))
self.keywdbox.bind("<Delete>",self.showlistAll)
self.listbox.bind("<Delete>", self.Rest)
self.listbox.bind("<Escape>", self.Rest)
self.keywdbox.bind("<Escape>",self.showlistAll)
self.listbox.bind('<Double-Button-1>',self.openurl) # 双击打开地址
self.listbox.bind('<Return>',self.openurl) # 按Enter键打开地址
self.listbox.bind('<Left>', lambda e:self.keywdbox.focus_set()) # 返回搜索框
#self.listbox.bind('<Delete>', lambda e: self.keywdbox.focus_set()) # 返回搜索框
self.listbox.bind('<Right>', lambda e: self.keywdbox.focus_set()) # 返回搜索框
self.keywdbox.bind("<Down>",self.jump_to_result)

def Rest(self,event):
self.keywdbox.focus_set()
self.showlistAll(event)

def openurl(self, event):
self.listbox.focus_set()
if self.listbox.curselection() == tuple():
Expand All @@ -138,6 +153,7 @@ def openurl(self, event):

if url is not None and url != '':
webbrowser.open(url)
root.iconify() #打开地址自动最小化
else:
messagebox.showinfo('Error !', '打开地址失败!地址为空。')

Expand Down Expand Up @@ -208,6 +224,12 @@ def __init__(self,parent,add_or_change = 'new',aim_urlname = None):
self.geometry("%dx%d+%d+%d" %(ww,wh,x,y)) #设置窗口大小和布局位置
self.resizable(0,0) #设置 x,y方向都不可以缩放

tmp2 = open("tmp2.ico","wb")
tmp2.write(base64.b64decode(ADDICO))
tmp2.close()
self.iconbitmap("tmp2.ico")
#os.remove("tmp2.ico")

#self.iconbitmap('add_new.ico')
self.parent = parent #创建parent属性储存parent
frame = tk.Frame(self) #创建一个frame
Expand Down Expand Up @@ -295,26 +317,31 @@ def action(arg):
def hotkey():
global EXITFLG
while (EXITFLG == False):
time.sleep(0.5)
#print(EXITFLG)
if systemhotkey.RUN == True:
print(systemhotkey.RUN)
if(root.winfo_viewable()):
root.iconify()
else:
print(root.winfo_viewable())
#root.update()
root.update()
root.deiconify()
systemhotkey.RUN = False
print("hotkey run")
time.sleep(0.1)




if __name__ == '__main__':
root = tk.Tk()
root.title('我的快捷管理')
# root.iconbitmap('Myshortcut.ico')
tmp = open("tmp.ico","wb")
tmp.write(base64.b64decode(MYICO))
tmp.close()
root.iconbitmap("tmp.ico")
#os.remove("tmp.ico")
#root.iconbitmap('Myshortcut.ico')
root.resizable(0, 0) # 固定窗口大小
print("taskmain start")
print("init hotkey")
Expand Down
33 changes: 30 additions & 3 deletions OpenTool.pyw
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@ from pypinyin import Style
import threading
import time
import systemhotkey
import os
import base64
from icon import MYICO,ADDICO
FONT_1 = ('微软雅黑',10,'normal')
FONT_2 = ('Arial',10,'normal')

Win_Hide = False



# 主窗体
class Application(tk.Frame):
def __init__(self,master = None): #顶层窗口master默认为空,应用中为root
Expand Down Expand Up @@ -117,17 +122,27 @@ class Application(tk.Frame):
cw = Add_PopupDialog(self,'change',urlname)
self.wait_window(cw) # 這一句很重要!!!


def doevent(self):
#self.keywdbox.bind("<Return>",self.showlist) # 按回车键,显示搜索结果
self.keywdbox.bind("<KeyRelease>",self.showlist) # 按任意键,显示搜索结果 一定要用keyrelease 否则字符还没有输入到Enter就进入了事件处理程序
#self.keywdbox.bind("<BackSpace>",self.showlistAll)
#self.keywdbox.bind("<Return>", lambda e: print('enter'))
self.keywdbox.bind("<Delete>",self.showlistAll)
self.listbox.bind("<Delete>", self.Rest)
self.listbox.bind("<Escape>", self.Rest)
self.keywdbox.bind("<Escape>",self.showlistAll)
self.listbox.bind('<Double-Button-1>',self.openurl) # 双击打开地址
self.listbox.bind('<Return>',self.openurl) # 按Enter键打开地址
self.listbox.bind('<Left>', lambda e:self.keywdbox.focus_set()) # 返回搜索框
#self.listbox.bind('<Delete>', lambda e: self.keywdbox.focus_set()) # 返回搜索框
self.listbox.bind('<Right>', lambda e: self.keywdbox.focus_set()) # 返回搜索框
self.keywdbox.bind("<Down>",self.jump_to_result)

def Rest(self,event):
self.keywdbox.focus_set()
self.showlistAll(event)

def openurl(self, event):
self.listbox.focus_set()
if self.listbox.curselection() == tuple():
Expand All @@ -138,6 +153,7 @@ class Application(tk.Frame):

if url is not None and url != '':
webbrowser.open(url)
root.iconify() #打开地址自动最小化
else:
messagebox.showinfo('Error !', '打开地址失败!地址为空。')

Expand Down Expand Up @@ -208,6 +224,12 @@ class Add_PopupDialog(tk.Toplevel):
self.geometry("%dx%d+%d+%d" %(ww,wh,x,y)) #设置窗口大小和布局位置
self.resizable(0,0) #设置 x,y方向都不可以缩放

tmp2 = open("tmp2.ico","wb")
tmp2.write(base64.b64decode(ADDICO))
tmp2.close()
self.iconbitmap("tmp2.ico")
#os.remove("tmp2.ico")

#self.iconbitmap('add_new.ico')
self.parent = parent #创建parent属性储存parent
frame = tk.Frame(self) #创建一个frame
Expand Down Expand Up @@ -295,26 +317,31 @@ EXITFLG = False
def hotkey():
global EXITFLG
while (EXITFLG == False):
time.sleep(0.5)
#print(EXITFLG)
if systemhotkey.RUN == True:
print(systemhotkey.RUN)
if(root.winfo_viewable()):
root.iconify()
else:
print(root.winfo_viewable())
#root.update()
root.update()
root.deiconify()
systemhotkey.RUN = False
print("hotkey run")
time.sleep(0.1)




if __name__ == '__main__':
root = tk.Tk()
root.title('我的快捷管理')
# root.iconbitmap('Myshortcut.ico')
tmp = open("tmp.ico","wb")
tmp.write(base64.b64decode(MYICO))
tmp.close()
root.iconbitmap("tmp.ico")
#os.remove("tmp.ico")
#root.iconbitmap('Myshortcut.ico')
root.resizable(0, 0) # 固定窗口大小
print("taskmain start")
print("init hotkey")
Expand Down
2 changes: 2 additions & 0 deletions icon.py

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions im2py.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import base64
open_icon = open("Myshortcut.ico","rb")
b64str = base64.b64encode(open_icon.read())
open_icon.close()
write_data = "MYICO = '%s'\n" % b64str.decode()
f = open("icon.py","w+")
f.write(write_data)

open_icon = open("add_new.ico","rb")
b64str = base64.b64encode(open_icon.read())
open_icon.close()
write_data = "ADDICO = '%s'" % b64str.decode()

f.write(write_data)



f.close()
Binary file added tmp.ico
Binary file not shown.
Binary file added tmp2.ico
Binary file not shown.