當前位置: 首頁>>代碼示例>>Python>>正文


Python Files.getFileIcon方法代碼示例

本文整理匯總了Python中Files.getFileIcon方法的典型用法代碼示例。如果您正苦於以下問題:Python Files.getFileIcon方法的具體用法?Python Files.getFileIcon怎麽用?Python Files.getFileIcon使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Files的用法示例。


在下文中一共展示了Files.getFileIcon方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: paintEvent

# 需要導入模塊: import Files [as 別名]
# 或者: from Files import getFileIcon [as 別名]

#.........這裏部分代碼省略.........
				if self.current_text=='':
					qp.drawText(t_rect, QtCore.Qt.AlignCenter, "Type to search..")
				else:
					qp.drawText(t_rect, QtCore.Qt.AlignCenter, "Searching: "+self.current_text)
				max_apps=  math.trunc(len(Apps.info(self.current_text))/self.apps_per_page)+1
				for i in range(0, max_apps):
						btn_size = 20
						x_pos = self.s_width/6-btn_size+(btn_size*i)
						rect = QtCore.QRectF(x_pos,2,btn_size,btn_size)
						qp.drawRect(rect)
						qp.drawText(rect,QtCore.Qt.AlignCenter,str(i+1))
				###app_buttons
				for i, app in enumerate(Apps.info(self.current_text)):
						app_page = math.trunc(i/self.apps_per_page)
						if app_page==self.app_page_state:
							qp.setBrush(QtGui.QColor(self.R,self.G,self.B))
							row_pos = math.trunc(i/self.apps_per_row)
							x_pos = self.ICON_SIZE*(i-(row_pos*self.apps_per_row))+30
							y_pos = row_pos*self.ICON_SIZE+30-(app_page*(self.ICON_SIZE*self.apps_per_col))
							try:		
								da_icon=Apps.ico_from_name(app["icon"])
								if da_icon!=None:
									da_icon.paint(qp,x_pos+10,y_pos+10,self.ICON_SIZE-30,self.ICON_SIZE-30)
									r1 =QtCore.QRect(x_pos+10,y_pos+10,self.ICON_SIZE-30,self.ICON_SIZE-30)
							except KeyError:
								i = QtGui.QImage('images/apps.png')
								rect= QtCore.QRectF(x_pos+10,y_pos+10,self.ICON_SIZE-30,self.ICON_SIZE-30)
								qp.drawImage(rect,i)
							qp.setPen(QtGui.QColor(250,250,250))
							text_rect = QtCore.QRectF(x_pos-5,y_pos+self.ICON_SIZE-20,self.ICON_SIZE,30)
							qp.setFont(QtGui.QFont('Hermeneus One',8))
							qp.drawText(text_rect,QtCore.Qt.AlignCenter,self.tr(app["name"]).replace(u"Â", ""))
				
			###	
			if self.activity=="files":
				#Buttons
				b1_rect=QtCore.QRectF(10,10,30,30)
				qp.drawRect(b1_rect)#temporarily
				ico = QtGui.QIcon("/usr/share/duck-launcher/icons/back.svg")
				max_files=  math.trunc(len(self.Files.all())/self.apps_per_page)+1
				for i in range(0, max_files):
						btn_size = 20
						x_pos = self.s_width/6-btn_size+(btn_size*i)
						rect = QtCore.QRectF(x_pos,2,btn_size,btn_size)
						qp.drawRect(rect)
						qp.drawText(rect,QtCore.Qt.AlignCenter,str(i+1))
				###app_buttons
				for i, f in enumerate(self.Files.all()):
						app_page = math.trunc(i/self.apps_per_page)
						if app_page==self.files_page_state:
							qp.setBrush(QtGui.QColor(self.R,self.G,self.B))
							row_pos = math.trunc(i/self.apps_per_row)
							x_pos = self.ICON_SIZE*(i-(row_pos*self.apps_per_row))+30
							y_pos = row_pos*self.ICON_SIZE+30-(app_page*(self.ICON_SIZE*self.apps_per_col))
							print Files.getFileIcon(f["whole_path"])
							try:	
								if f["type"]=="directory":
									da_icon=QtGui.QIcon("/usr/share/duck-launcher/icons/folder.svg")
									da_icon.paint(qp,x_pos+10,y_pos+10,self.ICON_SIZE-30,self.ICON_SIZE-30)	
								if f["type"]=="file":
									da_icon=QtGui.QIcon("/usr/share/duck-launcher/icons/file.svg")
									da_icon.paint(qp,x_pos+10,y_pos+10,self.ICON_SIZE-30,self.ICON_SIZE-30)	
							except KeyError:
								i = QtGui.QImage('images/apps.png')
								rect= QtCore.QRectF(x_pos+10,y_pos+10,self.ICON_SIZE-30,self.ICON_SIZE-30)
								qp.drawImage(rect,i)
							qp.setPen(QtGui.QColor(250,250,250))
							text_rect = QtCore.QRectF(x_pos-5,y_pos+self.ICON_SIZE-20,self.ICON_SIZE,30)
							qp.setFont(QtGui.QFont('Hermeneus One',8))
							qp.drawText(text_rect,QtCore.Qt.AlignCenter,f["name"].replace(u"Â", ""))
			if self.activity=="star":
				qp.setPen(QtGui.QPen(QtGui.QColor(250,250,250), 3, QtCore.Qt.SolidLine))
				all_rows=0
				for i,b in enumerate(self.conf['blocks']):
					all_stuff = Config.get_from_block(b)
					row_num = math.trunc(len(all_stuff)/self.apps_per_row)+1
					h=self.ICON_SIZE*all_rows+20
					all_rows+=row_num
					qp.setFont(QtGui.QFont('Hermeneus One',16))
					qp.drawText(QtCore.QRectF(20, h+10,self.s_width/3,200),b['name'])
					qp.setFont(QtGui.QFont('Hermeneus One',10))
					for j, thing in enumerate(all_stuff):
						#same thing as for the apps
						row_pos = math.trunc(j/self.apps_per_row)
						x_pos = self.ICON_SIZE*(j-(row_pos*self.apps_per_row))+40
						y_pos = (row_pos*self.ICON_SIZE+20)+h
						if thing['type']=='app':
							icon = Apps.ico_from_app(thing['value'])
							to_write=thing['value']
						elif thing['type']=='directory':
							icon = QtGui.QIcon('/usr/share/duck-launcher/icons/folder.svg')
							splitted = thing['value'].split('/')
							to_write =  splitted[-1]
						elif thing['type']=='file':
							icon = QtGui.QIcon('/usr/share/duck-launcher/icons/file.svg')
							splitted = thing['value'].split('/')
							to_write =  splitted[-1]
						icon.paint(qp, x_pos+15,y_pos+15, self.ICON_SIZE-50,self.ICON_SIZE-50)
						rect = QtCore.QRectF(x_pos+10, y_pos+self.ICON_SIZE-30, self.ICON_SIZE, 30)
						txt = qp.drawText(rect, to_write)
開發者ID:xcool,項目名稱:launcher,代碼行數:104,代碼來源:Main.py

示例2: paintEvent

# 需要導入模塊: import Files [as 別名]
# 或者: from Files import getFileIcon [as 別名]

#.........這裏部分代碼省略.........
								else:
									i = QtGui.QIcon('/usr/share/duck-launcher/icons/apps.svg')
									i.paint(qp,x_pos+20,y_pos+20,self.ICON_SIZE-40,self.ICON_SIZE-40)
									
							except KeyError:
								i = QtGui.QIcon('/usr/share/duck-launcher/icons/apps.svg')
								i.paint(qp,x_pos+20,y_pos+20,self.ICON_SIZE-40,self.ICON_SIZE-40)
							qp.setPen(QtGui.QColor(250,250,250))
							text_rect = QtCore.QRectF(x_pos+5,y_pos+self.ICON_SIZE-10,self.ICON_SIZE-10,60)
							#qp.drawRect(text_rect)
							qp.setFont(QtGui.QFont(self.conf["font"],8))
							qp.drawText(text_rect,QtCore.Qt.TextWordWrap |QtCore.Qt.AlignHCenter,self.tr(app["name"]).replace(u"Â", ""))
				
			###
			if self.activity=="files":
				#Buttons
				b1_rect=QtCore.QRectF(10,10,30,30)
				ico = QtGui.QIcon("/usr/share/duck-launcher/icons/home.svg")
				ico.paint(qp,self.s_width/3-40-self.SIZE,10,25,25)
				ico2 = QtGui.QIcon("/usr/share/duck-launcher/icons/back.svg")
				ico2.paint(qp,self.s_width/3-80-self.SIZE,10,25,25)
				max_files=  math.trunc(len(self.Files.all())/self.apps_per_page)+1
				for i in range(0, max_files):
						btn_size = 20
						x_pos = self.s_width/6-btn_size+(btn_size*i)
						rect = QtCore.QRectF(x_pos,2,btn_size,btn_size)
						if self.files_page_state==i:
							qp.setBrush(QtGui.QColor(self.R,self.G,self.B))
						else:
							qp.setBrush(QtGui.QColor(100,100,100,100))
						qp.setPen(QtGui.QPen(QtGui.QColor(self.R,self.G,self.B,100), 2, QtCore.Qt.SolidLine))
						qp.drawRect(rect)
						qp.setPen(QtGui.QPen(QtGui.QColor(250,250,250), 2, QtCore.Qt.SolidLine))
						qp.setFont(QtGui.QFont(self.conf["font"],10))
						qp.drawText(rect,QtCore.Qt.TextWordWrap |QtCore.Qt.AlignHCenter,str(i+1))
				#Text
				t_rect=QtCore.QRectF(10,10,self.s_width/8,30)
				qp.drawText(t_rect,QtCore.Qt.AlignRight,self.Files.directory.replace(u"Â", ""))
				###app_buttons
				for i, f in enumerate(self.Files.all()):
						app_page = math.trunc(i/self.apps_per_page)
						if app_page==self.files_page_state:
							qp.setBrush(QtGui.QColor(self.R,self.G,self.B))
							row_pos = math.trunc(i/self.apps_per_row)
							x_pos = self.ICON_SIZE*(i-(row_pos*self.apps_per_row))+30
							y_pos = row_pos*self.ICON_SIZE+30-(app_page*(self.ICON_SIZE*self.apps_per_col))
							try:
								if f["type"]=="directory":
									da_icon=QtGui.QIcon("/usr/share/duck-launcher/icons/folder.svg")
									da_icon.paint(qp,x_pos+20,y_pos+20,self.ICON_SIZE-40,self.ICON_SIZE-40)
								if f["type"]=="file":
									da_icon=Files.getFileIcon(f["whole_path"])
									da_icon.paint(qp,x_pos+20,y_pos+20,self.ICON_SIZE-40,self.ICON_SIZE-40)
							except KeyError:
								i = QtGui.QImage('images/apps.png')
								rect= QtCore.QRectF(x_pos+20,y_pos+20,self.ICON_SIZE-40,self.ICON_SIZE-40)
								qp.drawImage(rect,i)
							qp.setPen(QtGui.QColor(250,250,250))
							text_rect = QtCore.QRectF(x_pos-5,y_pos+self.ICON_SIZE-20,self.ICON_SIZE,30)
							qp.setFont(QtGui.QFont(self.conf["font"],8))
							qp.drawText(text_rect,QtCore.Qt.AlignCenter,f["name"].replace(u"Â", ""))
			if self.activity=="star":
				qp.setPen(QtGui.QPen(QtGui.QColor(250,250,250), 3, QtCore.Qt.SolidLine))
				all_rows=0
				for i,b in enumerate(self.conf['blocks']):
					all_stuff = Config.get_from_block(b)
					if len(all_stuff)!=self.apps_per_row:
						row_num = math.trunc(len(all_stuff)/self.apps_per_row)+1
					else:
						row_num = math.trunc(len(all_stuff)/self.apps_per_row)
					h=self.ICON_SIZE*all_rows+i*50
					all_rows+=row_num
					qp.setFont(QtGui.QFont(self.conf["font"],8))
					for j, thing in enumerate(all_stuff):
						#same thing as for the apps
						row_pos = math.trunc(j/self.apps_per_row)
						x_pos = self.ICON_SIZE*(j-(row_pos*self.apps_per_row))+40
						y_pos = (row_pos*self.ICON_SIZE+20)+h+30
						if thing['type']=='app':
							icon = Apps.ico_from_app(thing['value'])
							to_write=thing['value']
						elif thing['type']=='directory':
							icon = QtGui.QIcon('/usr/share/duck-launcher/icons/folder.svg')
							splitted = thing['value'].split('/')
							to_write =  splitted[-1]
						elif thing['type']=='file':
							icon = QtGui.QIcon('/usr/share/duck-launcher/icons/file.svg')
							splitted = thing['value'].split('/')
							to_write =  splitted[-1]
						if icon!=None:
							icon.paint(qp, x_pos+15,y_pos+15, self.ICON_SIZE-50,self.ICON_SIZE-50)
							rect = QtCore.QRectF(x_pos-10, y_pos+self.ICON_SIZE-30, self.ICON_SIZE, 30)
							txt = qp.drawText(rect,QtCore.Qt.TextWordWrap |QtCore.Qt.AlignHCenter,to_write)
					#Title
					qp.setPen(QtGui.QColor(0,0,0,0))
					qp.setBrush(QtGui.QColor(self.R,self.G,self.B))
					qp.drawRect(18, h+40,self.s_width/6,2)
					qp.setPen(QtGui.QColor(250,250,250))
					qp.setFont(QtGui.QFont(self.conf["font"],16))
					qp.drawText(QtCore.QRectF(20, h+10,self.s_width/3,200),b['name'])
開發者ID:archlinux2002,項目名稱:launcher,代碼行數:104,代碼來源:Main.py


注:本文中的Files.getFileIcon方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。