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


Python events.emit函数代码示例

本文整理汇总了Python中sk1.events.emit函数的典型用法代码示例。如果您正苦于以下问题:Python emit函数的具体用法?Python emit怎么用?Python emit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: save_as

	def save_as(self):
		doc_file = '' + self.current_doc.doc_file
		if not doc_file:
			doc_file = '' + self.current_doc.doc_name
		if not os.path.splitext(doc_file)[1] == "." + \
					uc2const.FORMAT_EXTENSION[uc2const.SK2][0]:
			doc_file = os.path.splitext(doc_file)[0] + "." + \
					uc2const.FORMAT_EXTENSION[uc2const.SK2][0]
		if not os.path.lexists(os.path.dirname(doc_file)):
			doc_file = os.path.join(config.save_dir,
								os.path.basename(doc_file))
		doc_file = dialogs.get_save_file_name(self.mw, self, doc_file)[0]
		if doc_file:
			old_file = self.current_doc.doc_file
			old_name = self.current_doc.doc_name
			self.current_doc.set_doc_file(doc_file)
			try:
				self.make_backup(doc_file)
				self.current_doc.save()
			except:
				self.current_doc.set_doc_file(old_file, old_name)
				first = _('Cannot save document')
				msg = ("%s '%s'.") % (first, self.current_doc.doc_name) + '\n'
				msg += _('Please check file name and write permissions')
				dialogs.error_dialog(self.mw, self.appdata.app_name, msg)
				self.print_stacktrace()
				return False
			config.save_dir = str(os.path.dirname(doc_file))
			self.history.add_entry(doc_file, appconst.SAVED)
			events.emit(events.DOC_SAVED, self.current_doc)
			events.emit(events.APP_STATUS, _('Document saved'))
			return True
		else:
			return False
开发者ID:Scrik,项目名称:sk1-wx,代码行数:34,代码来源:application.py

示例2: save

	def save(self, doc=''):
		if not doc:
			doc = self.current_doc
		if not doc.doc_file:
			return self.save_as()
		ext = os.path.splitext(self.current_doc.doc_file)[1]
		if not ext == "." + uc2const.FORMAT_EXTENSION[uc2const.SK2][0]:
			return self.save_as()
		if not os.path.lexists(os.path.dirname(self.current_doc.doc_file)):
			return self.save_as()

		try:
			self.make_backup(self.current_doc.doc_file)
			doc.save()
			self.history.add_entry(self.current_doc.doc_file, appconst.SAVED)
			events.emit(events.DOC_SAVED, doc)
		except:
			msg = _('Cannot save file')
			msg = "%s '%s'" % (msg, self.current_doc.doc_file) + '\n'
			msg += _('Please check file write permissions')
			dialogs.error_dialog(self.mw, self.appdata.app_name, msg)
			self.print_stacktrace()
			return False
		events.emit(events.APP_STATUS, _('Document saved'))
		return True
开发者ID:Scrik,项目名称:sk1-wx,代码行数:25,代码来源:application.py

示例3: set_selected_nodes

	def set_selected_nodes(self, points=[], add_flag=False):
		if points: self.new_node = None
		if not add_flag:
			for item in self.selected_nodes:
				item.selected = False
			self.selected_nodes = []
		for item in points:
			if item.is_start() and item.path.is_closed():
				continue
			if item.selected and item in self.selected_nodes:
				item.selected = False
				self.selected_nodes.remove(item)
			else:
				item.selected = True
				self.selected_nodes.append(item)
		if len(self.selected_nodes) == 1:
			self.create_control_points()
		else:
			self.clear_control_points()
		events.emit(events.SELECTION_CHANGED, self.presenter)
		msg = _('No selected nodes')
		if self.selected_nodes:
			msg = _('Selected %d node(s)') % len(self.selected_nodes)
		events.emit(events.APP_STATUS, msg)
		self.canvas.selection_redraw()
开发者ID:Scrik,项目名称:sk1-wx,代码行数:25,代码来源:editor_bezier.py

示例4: export_as

	def export_as(self):
		doc_file = '' + self.current_doc.doc_file
		if not doc_file:
			doc_file = '' + self.current_doc.doc_name
		if os.path.splitext(doc_file)[1] == "." + \
					uc2const.FORMAT_EXTENSION[uc2const.SK2][0]:
			doc_file = os.path.splitext(doc_file)[0] + "." + \
					uc2const.FORMAT_EXTENSION[uc2const.PNG][0]
		doc_file = os.path.join(config.export_dir,
								os.path.basename(doc_file))
		doc_file = dialogs.get_save_file_name(self.mw, self, doc_file,
							_('Export document As...'),
							file_types=data.SAVER_FORMATS[1:])[0]
		if doc_file:
			try:
				self.make_backup(doc_file, True)
				self.current_doc.export_as(doc_file)
			except:
				first = _('Cannot save document')
				msg = ("%s '%s'.") % (first, self.current_doc.doc_name) + '\n'
				msg += _('Please check file name and write permissions')
				dialogs.error_dialog(self.mw, self.appdata.app_name, msg)
				self.print_stacktrace()
				return
			config.export_dir = str(os.path.dirname(doc_file))
			events.emit(events.APP_STATUS, _('Document is successfully exported'))
开发者ID:Scrik,项目名称:sk1-wx,代码行数:26,代码来源:application.py

示例5: __setattr__

	def __setattr__(self, attr, value):
		if attr in ['filename', 'app']:
			self.__dict__[attr] = value
			return
		if not hasattr(self, attr) or getattr(self, attr) != value:
			self.__dict__[attr] = value
			events.emit(events.CONFIG_MODIFIED, attr, value)
开发者ID:sk1project,项目名称:sk1-wx,代码行数:7,代码来源:app_conf.py

示例6: open

	def open(self, doc_file='', silent=False):
		if not doc_file:
			doc_file = dialogs.get_open_file_name(self.mw, self, config.open_dir)
		if os.path.lexists(doc_file) and os.path.isfile(doc_file):
			try:
				doc = PD_Presenter(self, doc_file, silent)

			except RuntimeError:
				msg = _('Cannot open file:')
				msg = "%s\n'%s'" % (msg, doc_file) + '\n'
				msg += _('The file contains newer SK2 format.\n')
				msg += _('Try updating sK1 application from http://www.sk1project.net')
				dialogs.error_dialog(self.mw, self.appdata.app_name, msg)
				self.print_stacktrace()
				return
			except:
				msg = _('Cannot open file:')
				msg = "%s\n'%s'" % (msg, doc_file) + '\n'
				msg += _('The file may be corrupted or not supported format')
				dialogs.error_dialog(self.mw, self.appdata.app_name, msg)
				self.print_stacktrace()
				return
			self.docs.append(doc)
			config.open_dir = str(os.path.dirname(doc_file))
			self.history.add_entry(doc_file)
			self.set_current_doc(doc)
			events.emit(events.APP_STATUS, _('Document opened'))
开发者ID:sk1project,项目名称:sk1-wx,代码行数:27,代码来源:application.py

示例7: save_as

	def save_as(self):
		doc_file = '' + self.current_doc.doc_file
		if not doc_file:
			doc_file = '' + self.current_doc.doc_name
		if not os.path.splitext(doc_file)[1] == "." + \
					uc2const.FORMAT_EXTENSION[uc2const.PDXF][0]:
			doc_file = os.path.splitext(doc_file)[0] + "." + \
					uc2const.FORMAT_EXTENSION[uc2const.PDXF][0]
		if not os.path.lexists(os.path.dirname(doc_file)):
			doc_file = os.path.join(config.save_dir,
								os.path.basename(doc_file))
		doc_file = get_save_file_name(self.mw, self, doc_file)
		if doc_file:
			old_file = self.current_doc.doc_file
			old_name = self.current_doc.doc_name
			self.current_doc.set_doc_file(doc_file)
			try:
				self.current_doc.save()
			except IOError:
				self.current_doc.set_doc_file(old_file, old_name)
				details = sys.exc_info()[1].__str__() + sys.exc_info()[2].__str__()
				first = _('Cannot save document')
				sec = _('Please check file name and write permissions')
				msg = ("%s '%s'.") % (first, self.current_doc.doc_name)

				wal.error_dialog(self.mw, self.appdata.app_name, msg, sec, details)

				return False
			config.save_dir = os.path.dirname(doc_file)
			events.emit(events.APP_STATUS, _('Document saved'))
			return True
		else:
			return False
开发者ID:tisn05,项目名称:sk1,代码行数:33,代码来源:application.py

示例8: mouse_move

	def mouse_move(self, event):
		if self.start:
			self.end = self.snap.snap_point(event.get_point())[2]
			self._update_style()
			style = deepcopy(self.new_style)
			self.api.set_temp_style(self.target, style)
			events.emit(events.APP_STATUS, self.msg)
开发者ID:sk1project,项目名称:sk1-wx,代码行数:7,代码来源:grad_ctrl.py

示例9: update_points

	def update_points(self):
		self.corner_points = []
		self.midpoints = []
		coef1 = self.target.coef1
		coef2 = self.target.coef2
		angle1 = self.target.angle1
		angle2 = self.target.angle2
		corners_num = self.target.corners_num
		center = [0.5, 0.5]
		corner_angle = 2.0 * math.pi / float(corners_num)
		corners_start = [0.5, 0.5 + 0.5 * coef1]
		midpoint_start = [0.5, 0.5 + 0.5 * coef2 * math.cos(corner_angle / 2.0)]

		corner_angle_shift = angle1
		midpoint_angle_shift = corner_angle / 2.0 + angle2

		for i in range(0, corners_num):
			angle = float(i) * corner_angle + corner_angle_shift
			point = libgeom.rotate_point(center, corners_start, angle)
			self.corner_points.append(CornerPoint(self.canvas,
												self.target, point, i))

			angle = float(i) * corner_angle + midpoint_angle_shift
			point = libgeom.rotate_point(center, midpoint_start, angle)
			self.midpoints.append(CornerPoint(self.canvas,
												self.target, point, i))
		msg = _('Polygon in editing')
		events.emit(events.APP_STATUS, msg)
开发者ID:Scrik,项目名称:sk1-wx,代码行数:28,代码来源:editor_polygon.py

示例10: mouse_move

 def mouse_move(self, event):
     x, y = self.win_to_doc_coords(list(event.GetPositionTuple()))
     unit = self.presenter.model.doc_units
     tr_unit = uc2const.unit_short_names[unit]
     msg = "  %i x %i" % (x * point_dict[unit], y * point_dict[unit])
     events.emit(events.MOUSE_STATUS, "%s %s" % (msg, tr_unit))
     self.controller.mouse_move(CanvasEvent(event))
开发者ID:sk1project,项目名称:sk1-wx,代码行数:7,代码来源:canvas.py

示例11: goto_page

	def goto_page(self, index):
		pages = self.get_pages()
		current_index = pages.index(self.active_page)
		if index >= 0 and index <> current_index:
			self.api.set_active_page(index)
			self.eventloop.emit(self.eventloop.PAGE_CHANGED)
			events.emit(events.PAGE_CHANGED, self)
开发者ID:Scrik,项目名称:sk1-wx,代码行数:7,代码来源:presenter.py

示例12: config_changed

	def config_changed(self, attr, value):
		if attr[0:4] == 'cms_':
			self.update()
			self.update_mngrs()
			events.emit(events.CMS_CHANGED)
			for item in self.app.docs:
				item.model.clear_color_cache()
			self.app.current_doc.canvas.force_redraw()
开发者ID:sk1project,项目名称:sk1-wx,代码行数:8,代码来源:app_cms.py

示例13: close

	def close(self):
		if not self.docarea is None:
			self.app.mw.remove_tab(self.docarea)
		for obj in self.traced_objects: obj.close()
		fields = self.__dict__
		items = fields.keys()
		for item in items: fields[item] = None
		events.emit(events.DOC_CLOSED, self)
开发者ID:sk1project,项目名称:sk1-gtk2,代码行数:8,代码来源:presenter.py

示例14: start_

	def start_(self):
		self.snap = self.presenter.snap
		self.target = self.selection.objs[0]
		self.selection.clear()
		self.canvas.selection_redraw()
		self.orig_style = self.target.style
		self.new_style = deepcopy(self.orig_style)
		events.emit(events.APP_STATUS, self.msg)
开发者ID:sk1project,项目名称:sk1-wx,代码行数:8,代码来源:grad_ctrl.py

示例15: start_

	def start_(self):
		self.snap = self.presenter.snap
		self.target = self.selection.objs[0]
		self.selected_obj = None
		self.update_points()
		self.api.set_mode()
		self.selection.clear()
		msg = _('Ellipse in editing')
		events.emit(events.APP_STATUS, msg)
开发者ID:Scrik,项目名称:sk1-wx,代码行数:9,代码来源:editor_ellipse.py


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