本文整理汇总了Python中Plugins.get方法的典型用法代码示例。如果您正苦于以下问题:Python Plugins.get方法的具体用法?Python Plugins.get怎么用?Python Plugins.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Plugins
的用法示例。
在下文中一共展示了Plugins.get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: keyPressEvent
# 需要导入模块: import Plugins [as 别名]
# 或者: from Plugins import get [as 别名]
def keyPressEvent(self, e):
if e.key()==QtCore.Qt.Key_Backspace:
if self.parent.plugin==False:
self.parent.current_text=self.parent.current_text[:-1]
self.parent.allApps=Apps.info(str(self.parent.current_text))
self.parent.webview.page().mainFrame().evaluateJavaScript("setNewApps({})".format(self.parent.allApps))
self.parent.update()
elif e.key()==QtCore.Qt.Key_Return:
if len(self.parent.allApps)==1:
a=self.parent.allApps[0]
print("[Duck Launcher] Launching '{0}' with '{1}'".format(a["name"], a["exec"]) )
thread = Launch(parent=self.parent)
thread.app=a["exec"]
thread.start()
self.parent.close_it()
self.parent.current_text=''
self.parent.allApps=Apps.find_info('')
html= Plugins.get(str(self.parent.current_text),color=(self.parent.conf["r"],self.parent.conf["g"],self.parent.conf["b"]),font=self.parent.conf["font"])
if html!=None:
self.parent.webview.load(QtCore.QUrl(html))
self.parent.webview.show()
self.parent.plugin=True
self.parent.webview.page().mainFrame().setFocus()
self.parent.webview.setFocus()
self.update()
elif e.key()==16777216:
#ESC
self.parent.current_text=""
self.parent.allApps=Apps.info(str(self.parent.current_text))
self.parent.webview.page().mainFrame().evaluateJavaScript("setNewApps({})".format(self.parent.allApps))
self.parent.initApps()
elif e.text()!='':
self.parent.current_text+=e.text()
self.parent.allApps=Apps.info(str(self.parent.current_text))
self.parent.webview.page().mainFrame().evaluateJavaScript("setNewApps({})".format(self.parent.allApps))
self.parent.update()
else:
if e.key()==16777250:
if self.parent.current_state=="half_open":
self.parent.activity="apps"
self.parent.current_text=''
self.parent.allApps=Apps.info('')
self.parent.initApps()
self.parent.open_it()
elif self.parent.current_state=="open":
self.parent.close_it()
self.parent.update()
示例2: keyPressEvent
# 需要导入模块: import Plugins [as 别名]
# 或者: from Plugins import get [as 别名]
def keyPressEvent(self, e):
QtCore.QCoreApplication.sendEvent(self.parent, e)
if e.key()==QtCore.Qt.Key_Backspace:
self.parent.current_text=self.parent.current_text[:-1]
if self.plugin==False:
self.parent.allApps=Apps.info(str(self.parent.current_text))
self.parent.update()
elif e.key()==QtCore.Qt.Key_Return:
if len(self.parent.allApps)==1:
a=self.parent.allApps[0]
print("[Duck Launcher] Launching '{0}' with '{1}'".format(a["name"], a["exec"]) )
thread = Launch(parent=self.parent)
thread.app=a["exec"]
thread.start()
self.parent.close_it()
self.parent.current_text=''
self.parent.allApps=Apps.find_info('')
pl= Plugins.get(str(self.parent.current_text))
#html = pl.html(color=(self.parent.conf["r"],self.parent.conf["g"],self.parent.conf["b"]),font=self.parent.conf["font"])
if pl.isAlright():
self.parent.fg_color=pl.getColor("background")
self.parent.font_color=pl.getColor("foreground")
self.parent.pl_logo=pl.getLogo()
if self.parent.plugin==False:
self.parent.plugin=True
self.parent.open_pl_rect()
html = pl.html(color=(self.parent.conf["r"],self.parent.conf["g"],self.parent.conf["b"]),font=self.parent.conf["font"])
if html !=None:
self.parent.webview.setHtml(html)
else:print("ummm, error")
self.parent.setAttribute(QtCore.Qt.WA_X11NetWmWindowTypeDock,False)
self.update()
self.parent.update()
self.parent.webview.show()
self.parent.webview.page().mainFrame().setFocus()
self.parent.webview.setFocus()
self.parent.webview.update()
elif e.key()==16777216:
#ESC
if self.parent.plugin==False:
self.parent.current_text=""
self.parent.allApps=Apps.info('')
self.parent.app_page_state=0
if self.parent.plugin==True:
self.parent.close_it()
self.parent.update()
#QtGui.QApplication.processEvents()
elif e.text()!='':
self.parent.current_text+=e.text()
self.parent.app_page_state=0
self.parent.allApps=Apps.info(str(self.parent.current_text))
#self.parent.webview.page().mainFrame().evaluateJavaScript("setNewApps({})".format(self.parent.allApps))
self.parent.update()
else:
if e.key()==16777250:
if self.parent.current_state=="half_open":
self.parent.activity="apps"
self.parent.current_text=''
self.parent.allApps=Apps.info('')
self.parent.open_it()
elif self.parent.current_state=="open":
self.parent.webview.hide()
self.parent.close_pl_rect()
self.parent.fg_color=(int(self.parent.conf['r']),int(self.parent.conf['g']),int(self.parent.conf['b']))
self.parent.close_it()
self.parent.update()
示例3: mouseReleaseEvent
# 需要导入模块: import Plugins [as 别名]
# 或者: from Plugins import get [as 别名]
def mouseReleaseEvent(self,e):
x_m,y_m = e.x(),e.y()
self.drawAppRect=False
Window.activateFakewin(self.fakewin.winId())
#While moving
if self.current_state=="nothing":
if self.plugin==False:
self.webview.hide()
self.move=False
###sets position to right one
pos_list = [self.HALF_OPEN_POS, self.s_width/3]
closest = min(pos_list, key=lambda x: abs(x-self.pos_x))
if closest<self.pos_x:
while closest<self.pos_x:
self.pos_x-=5
self.setGeometry(0,self.top_pos,self.pos_x+7,self.s_height)
QtGui.QApplication.processEvents()
self.update()
self.pos_x=closest
QtGui.QApplication.processEvents()
self.update()
elif closest>self.pos_x:
while closest>self.pos_x:
self.pos_x+=5
self.setGeometry(0,self.top_pos,self.pos_x+7,self.s_height)
QtGui.QApplication.processEvents()
self.update()
self.pos_x=closest
QtGui.QApplication.processEvents()
self.update()
##set the current state
if self.pos_x==self.HALF_OPEN_POS:
self.pos_x-=3
self.dock_apps = Apps.find_info(self.conf['dock-apps'])
self.current_state="half_open"
elif self.pos_x==self.s_width/3:
self.pos_x-=3
self.current_state="open"
else: self.current_state="nothing"
if self.plugin==True and self.current_state=='open' and self.activity=='apps':
self.webview.show()
if self.plugin==False and self.current_state=='open' and self.activity=='apps':
self.current_text=""
self.initApps()
#Events
#
elif self.current_state=="open":
if self.pos_x-14<x_m<self.pos_x and self.move==False and e.button()==QtCore.Qt.LeftButton:
self.close_it()
if y_m>self.s_height-13:
print("[Duck Launcher] Saving configuration.")
Config.check_dict(self.conf)
QtGui.QApplication.processEvents()
print("[Duck Launcher] Quitting, Good Bye!")
QtGui.qApp.quit()
###app events
elif self.activity==False and self.plugin==True:
self.webview.show()
elif self.activity == "files":
pass
elif self.activity=="star":
blocks=pickle.loads(Config.get()["blocks"])
all_rows=0
apps_per_row = math.trunc(((self.s_width/3)-30)/int(self.conf["icon-size"]))
for i,b in enumerate(blocks):
all_stuff = Config.get_from_block(b)
if len(all_stuff)!=apps_per_row:
row_num = math.trunc(len(all_stuff)/apps_per_row)+1
else:
row_num = math.trunc(len(all_stuff)/apps_per_row)
h=int(self.conf["icon-size"])*all_rows+i*50
all_rows+=row_num
for j, thing in enumerate(all_stuff):
row_pos = math.trunc(j/apps_per_row)
x_pos = int(self.conf["icon-size"])*(j-(row_pos*apps_per_row))+40
y_pos = (row_pos*int(self.conf["icon-size"])+20)+h+30
if x_pos-10<x_m<x_pos-10+int(self.conf["icon-size"]) and y_pos<y_m<y_pos+int(self.conf["icon-size"]) and x_m<self.pos_x-self.SIZE-3:
if e.button()==QtCore.Qt.LeftButton:
if thing['type']=='app':
the_exec=""
for a in Apps.info(''):
if thing['value'] in a['name']:
the_exec=a['exec']
thread = Launch(parent=self)
thread.app=the_exec
thread.start()
print("[Duck Launcher] Launching '{0}' with '{1}'".format(thing["value"], the_exec) )
else:
import webbrowser
webbrowser.open(thing['value'])
elif self.current_state=="half_open":
##buttons
if self.pos_x-self.SIZE<x_m<self.pos_x and self.move==False and self.s_height/2-20<y_m<self.s_height/2+20:
self.activity="apps"
self.current_text=""
self.open_it()
self.initApps()
#.........这里部分代码省略.........
示例4: mouseReleaseEvent
# 需要导入模块: import Plugins [as 别名]
# 或者: from Plugins import get [as 别名]
def mouseReleaseEvent(self,e):
x_m,y_m = e.x(),e.y()
self.drawAppRect=False
Window.activateFakewin(self.fakewin.winId())
#While moving
''''
if self.current_state=="nothing":
if self.plugin==False:
self.webview.hide()
self.move=False
###sets position to right one
pos_list = [self.HALF_OPEN_POS, self.s_width/3]
closest = min(pos_list, key=lambda x: abs(x-self.pos_x))
if closest<self.pos_x:
while closest<self.pos_x:
self.pos_x-=5
self.setGeometry(0,self.top_pos,self.pos_x+9,self.s_height)
QtGui.QApplication.processEvents()
self.update()
self.pos_x=closest
QtGui.QApplication.processEvents()
self.update()
elif closest>self.pos_x:
while closest>self.pos_x:
self.pos_x+=5
self.setGeometry(0,self.top_pos,self.pos_x+9,self.s_height)
QtGui.QApplication.processEvents()
self.update()
self.pos_x=closest
QtGui.QApplication.processEvents()
self.update()
##set the current state
if self.pos_x==self.HALF_OPEN_POS:
self.pos_x-=3
#self.dock_apps = Apps.find_info(self.conf['dock-apps'])
self.current_state="half_open"
elif self.pos_x==self.s_width/3:
self.pos_x-=3
self.current_state="open"
else: self.current_state="nothing"
if self.plugin==True and self.current_state=='open' and self.activity=='apps':
self.webview.show()
if self.plugin==False and self.current_state=='open' and self.activity=='apps':
self.current_text=""
#self.initApps()
'''
#Events
#
if self.current_state=="open":
if self.pos_x-14<x_m<self.pos_x and self.move==False and e.button()==QtCore.Qt.LeftButton:
self.close_it()
if y_m>self.s_height-13:
print("[Duck Launcher] Saving configuration.")
c = Config.check_dict(self.conf)
QtGui.QApplication.processEvents()
print("[Duck Launcher] Quitting, Good Bye!")
QtGui.qApp.quit()
###app events
if self.activity == "apps" and self.plugin==False:
max_apps= math.trunc((len(self.allApps)-1)/self.apps_per_page)+1
minus = math.trunc(len(self.allApps)/self.apps_per_page)*15/2
##Change Page
for i in range(0,max_apps):
btn_size = 15
x_pos = self.s_width/6-btn_size+(btn_size*i)-minus
if x_pos<x_m<x_pos+btn_size and 12<y_m<btn_size+12:
self.app_page_state=i
self.update()
QtGui.QApplication.processEvents()
for i, app in enumerate(self.allApps):
app_page = math.trunc(i/self.apps_per_page)
if app_page==self.app_page_state:
row_pos = math.trunc(i/self.apps_per_row)
page_row_pos=row_pos-(self.apps_per_page/self.apps_per_row*app_page)
col_pos=(i-(row_pos*self.apps_per_row))
x_pos = self.ICON_SIZE*col_pos+30+col_pos*10
y_pos = page_row_pos*self.ICON_SIZE+45+page_row_pos*10
if x_pos<x_m<x_pos+int(self.conf["icon-size"]) and y_pos<y_m<y_pos+int(self.conf["icon-size"]):
if e.button()==QtCore.Qt.LeftButton:
print("[Duck Launcher] Launching '{0}' with '{1}'".format(app["name"],app["exec"]) )
thread = Widgets.Launch(parent=self)
thread.app=app["exec"]
thread.start()
self.close_it()
elif self.activity=="star":
blocks=pickle.loads(Config.get()["blocks"])
all_rows=0
apps_per_row = math.trunc(((self.s_width/3)-30)/int(self.conf["icon-size"]))
for i,b in enumerate(blocks):
all_stuff = Config.get_from_block(b)
if len(all_stuff)!=apps_per_row:
row_num = math.trunc(len(all_stuff)/apps_per_row)+1
else:
row_num = math.trunc(len(all_stuff)/apps_per_row)
h=int(self.conf["icon-size"])*all_rows+i*50
all_rows+=row_num
#.........这里部分代码省略.........