当前位置: 首页>>代码示例>>Python>>正文


Python Label.focus_set方法代码示例

本文整理汇总了Python中tkinter.Label.focus_set方法的典型用法代码示例。如果您正苦于以下问题:Python Label.focus_set方法的具体用法?Python Label.focus_set怎么用?Python Label.focus_set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tkinter.Label的用法示例。


在下文中一共展示了Label.focus_set方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from tkinter import Label [as 别名]
# 或者: from tkinter.Label import focus_set [as 别名]
class Photo:

	def __init__(self, **kwargs):
		self.repr = kwargs['repr']
		self.path = kwargs['path']

	def config(self, **kwargs):
		if 'path' in kwargs:
			self.path = kwargs['path']
			self.picture = Image.open(self.path)
			self.picture = self.picture.resize((200, 200), Image.ANTIALIAS)
			self.image = ImageTk.PhotoImage(self.picture)
			self.label.config(image=self.image)

	def place(self, **kwargs):
		self.parent = kwargs['parent']
		self.row = kwargs['row']
		self.column = kwargs['column']

		self.picture = Image.open(self.path)
		self.image = ImageTk.PhotoImage(self.picture)

		self.label = Label(self.parent, image=self.image, bd=1)
		self.label.grid(row=self.row, column=self.column)
		self.label.bind('<Button-1>', lambda e: self.label.focus_set())

	def getData(self):
		return self.path

	def setData(self, data):
		#le sigh
		if data == '' or 'N/A': return
		self.config(path=data)

	def hide(self):
		self.label.grid_forget()
开发者ID:wasifzaman,项目名称:ryb_tms,代码行数:38,代码来源:photoWidget2.py

示例2: Photo

# 需要导入模块: from tkinter import Label [as 别名]
# 或者: from tkinter.Label import focus_set [as 别名]
class Photo(Widget):

	def __init__(self, **kwargs):

		try:
			self.repr = kwargs['repr']
			self.path = kwargs['path']
		except:
			print("widget could not be loaded")

		#self.script_dir = os.path.dirname(os.path.abspath(__file__))
		self.width = 200
		self.height = 200


	def config(self, **kwargs):

		try:
			self.path = kwargs['path']
			self.picture = Image.open(self.path)
			if 'resize_portr' in kwargs:
				self.picture = self.picture.resize((200, 200), Image.ANTIALIAS)
			self.image = ImageTk.PhotoImage(self.picture)
			self.label.config(image=self.image)
		except:
			pass
			#print("the widget could not be configured")

		try:
			self.bgc = kwargs['bg']
			self.label.config(bg=self.bgc)
		except:
			pass
			#print("the widget background color could not be changed")


	def trytoplace(self, **kwargs):
		self.parent = kwargs['parent']
		self.row = kwargs['row']
		self.column = kwargs['column']


	def place(self, **kwargs):

		try:
			self.trytoplace(**kwargs)
		except:
			print("widget could not be placed")

		self.picture = Image.open(self.path)
		self.image = ImageTk.PhotoImage(self.picture)

		self.label = Label(self.parent, image=self.image, bd=1)#, bg='black')
		self.label.grid(row=self.row, column=self.column, pady=5)
		self.label.bind('<Button-1>', lambda e: self.label.focus_set())


	def getData(self):
		return self.path


	def setData(self, data):
		#le sigh
		if data == '' or 'N/A': return
		self.config(path=data, resize_portr=True)


	def hide(self):
		self.label.grid_forget()
开发者ID:drinkingTea,项目名称:ryb_sms,代码行数:71,代码来源:photoWidget2.py


注:本文中的tkinter.Label.focus_set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。