コード例 #1
0
	def __init__(self, presenter, parent, style=HORIZONTAL):
		self.presenter = presenter
		self.eventloop = presenter.eventloop
		self.style = style
		HPanel.__init__(self, parent)
		if not VFONT: load_font()
		size = config.ruler_size
		self.add((size, size))
		self.default_cursor = self.GetCursor()
		if self.style == HORIZONTAL:
			self.guide_cursor = self.presenter.app.cursors[modes.HGUIDE_MODE]
		else:
			self.guide_cursor = self.presenter.app.cursors[modes.VGUIDE_MODE]
		self.SetBackgroundColour(wx.WHITE)
		self.set_double_buffered()
		self.Bind(wx.EVT_PAINT, self._on_paint, self)
		self.Bind(wx.EVT_LEFT_DOWN, self.mouse_down)
		self.Bind(wx.EVT_LEFT_UP, self.mouse_up)
		self.Bind(wx.EVT_MOTION, self.mouse_move)
		self.Bind(wx.EVT_MOUSE_CAPTURE_LOST, self.capture_lost)
		self.eventloop.connect(self.eventloop.VIEW_CHANGED, self.repaint)
		events.connect(events.CONFIG_MODIFIED, self.check_config)
		if wal.is_msw(): self.SetDoubleBuffered(True)
		if is_mac():
			self.timer = wx.Timer(self)
			self.Bind(wx.EVT_TIMER, self._repaint_after)
			self.timer.Start(50)
コード例 #2
0
ファイル: ruler.py プロジェクト: Scrik/sk1-wx
	def __init__(self, presenter, parent, style=HORIZONTAL):
		self.presenter = presenter
		self.eventloop = presenter.eventloop
		self.style = style
		HPanel.__init__(self, parent)
		if not VFONT: load_font()
		size = config.ruler_size
		self.add((size, size))
		self.default_cursor = self.GetCursor()
		if self.style == HORIZONTAL:
			self.guide_cursor = self.presenter.app.cursors[modes.HGUIDE_MODE]
		else:
			self.guide_cursor = self.presenter.app.cursors[modes.VGUIDE_MODE]
		self.SetBackgroundColour(wx.WHITE)
		self.SetDoubleBuffered(True)
		self.Bind(wx.EVT_PAINT, self._on_paint, self)
		self.Bind(wx.EVT_LEFT_DOWN, self.mouse_down)
		self.Bind(wx.EVT_LEFT_UP, self.mouse_up)
		self.Bind(wx.EVT_MOTION, self.mouse_move)
		self.Bind(wx.EVT_MOUSE_CAPTURE_LOST, self.capture_lost)
		self.eventloop.connect(self.eventloop.VIEW_CHANGED, self.repaint)
		events.connect(events.CONFIG_MODIFIED, self.check_config)
		if is_mac():
			self.timer = wx.Timer(self)
			self.Bind(wx.EVT_TIMER, self._repaint_after)
			self.timer.Start(50)
コード例 #3
0
ファイル: filedlgs.py プロジェクト: sk1project/sk1-wx
def _get_open_filters(items=[]):
	wildcard = ''
	descr = uc2const.FORMAT_DESCRIPTION
	ext = uc2const.FORMAT_EXTENSION
	if not items:
		items = [] + data.LOADER_FORMATS
	wildcard += _('All supported formats') + '|'
	for item in items:
		for extension in ext[item]:
			wildcard += '*.' + extension + ';'
			wildcard += '*.' + extension.upper() + ';'
	if is_mac():return wildcard

	wildcard += '|'

	wildcard += _('All files (*.*)') + '|'
	wildcard += '*;*.*|'

	for item in items:
		wildcard += descr[item] + '|'
		for extension in ext[item]:
			wildcard += '*.' + extension + ';'
			wildcard += '*.' + extension.upper() + ';'
		if not item == items[-1]:
			wildcard += '|'

	return wildcard
コード例 #4
0
def _get_open_filters(items=[]):
    wildcard = ''
    descr = uc2const.FORMAT_DESCRIPTION
    ext = uc2const.FORMAT_EXTENSION
    if not items:
        items = [] + data.LOADER_FORMATS
    wildcard += _('All supported formats') + '|'
    for item in items:
        for extension in ext[item]:
            wildcard += '*.' + extension + ';'
            wildcard += '*.' + extension.upper() + ';'
    if is_mac(): return wildcard

    wildcard += '|'

    wildcard += _('All files (*.*)') + '|'
    wildcard += '*;*.*|'

    for item in items:
        wildcard += descr[item] + '|'
        for extension in ext[item]:
            wildcard += '*.' + extension + ';'
            wildcard += '*.' + extension.upper() + ';'
        if not item == items[-1]:
            wildcard += '|'

    return wildcard
コード例 #5
0
ファイル: filedlgs.py プロジェクト: sk1project/sk1-wx
def get_save_file_name(parent, app, path, msg='',
					file_types=[], path_only=False):
	ret = None
	if not msg: msg = _('Save document As...')
	if is_mac(): msg = ''

	if path == '~': path = os.path.expanduser(path)

	doc_folder = os.path.dirname(path)
	doc_name = os.path.basename(path)

	dlg = wx.FileDialog(
		parent, message=msg,
		defaultDir=doc_folder,
		defaultFile=doc_name,
		wildcard=_get_save_fiters(file_types),
		style=wx.FD_SAVE | wx.FD_CHANGE_DIR | wx.FD_OVERWRITE_PROMPT | wx.FD_PREVIEW
	)
	dlg.CenterOnParent()
	if dlg.ShowModal() == wx.ID_OK:
		if path_only:
			ret = path_system(dlg.GetPath())
			if not file_types:
				ext = uc2const.FORMAT_EXTENSION[data.SK2][0]
			else:
				index = dlg.GetFilterIndex()
				ext = uc2const.FORMAT_EXTENSION[file_types[index]][0]
			ret = os.path.splitext(ret)[0] + '.' + ext
		else:
			ret = (path_system(dlg.GetPath()), dlg.GetFilterIndex())
	dlg.Destroy()
	return ret
コード例 #6
0
ファイル: filedlgs.py プロジェクト: wenlibin02/sk1-wx
def get_save_file_name(parent, app, path, msg='',
					file_types=[], path_only=False):
	ret = None
	if not msg: msg = _('Save document As...')
	if is_mac(): msg = ''

	if path == '~': path = os.path.expanduser(path)

	doc_folder = os.path.dirname(path)
	doc_name = os.path.basename(path)

	dlg = wx.FileDialog(
		parent, message=msg,
		defaultDir=doc_folder,
		defaultFile=doc_name,
		wildcard=_get_save_fiters(file_types),
		style=wx.FD_SAVE | wx.FD_CHANGE_DIR | wx.FD_OVERWRITE_PROMPT | wx.FD_PREVIEW
	)
	dlg.CenterOnParent()
	if dlg.ShowModal() == wx.ID_OK:
		if path_only:
			ret = path_system(dlg.GetPath())
			if not file_types:
				ext = uc2const.FORMAT_EXTENSION[uc2const.SK2][0]
			else:
				index = dlg.GetFilterIndex()
				ext = uc2const.FORMAT_EXTENSION[file_types[index]][0]
			ret = os.path.splitext(ret)[0] + '.' + ext
		else:
			ret = (path_system(dlg.GetPath()), dlg.GetFilterIndex())
	dlg.Destroy()
	return ret
コード例 #7
0
	def set_enable(self, enabled):
		if not enabled == self.enabled:
			self.enabled = enabled
			for widget in self.widgets:
				widget.set_enable(self.enabled)
			if not self.toolbar is None and not const.is_mac():
				self.toolbar.EnableTool(self.action_id, self.enabled)
コード例 #8
0
	def update(self):
		for widget in self.widgets:
			if not is_wx2():
				if not widget in self.menuitem:
					widget.update()
			else:
				widget.update()
		if not self.toolbar is None and not const.is_mac():
			self.toolbar.EnableTool(self.action_id, self.enabled)
			self.toolbar.SetToolShortHelp(self.action_id, self.get_descr_text())
コード例 #9
0
def get_dir_path(parent, app, path='~', msg=''):
    ret = ''
    if not msg: msg = _('Select directory')
    if is_mac(): msg = ''

    if path == '~': path = os.path.expanduser(path)

    dlg = wx.DirDialog(parent,
                       message=msg,
                       defaultPath=path,
                       style=wx.DD_DEFAULT_STYLE | wx.DD_DIR_MUST_EXIST)
    dlg.CenterOnParent()
    if dlg.ShowModal() == wx.ID_OK:
        ret = path_system(dlg.GetPath())
    dlg.Destroy()
    return ret
コード例 #10
0
ファイル: filedlgs.py プロジェクト: sk1project/sk1-wx
def get_dir_path(parent, app, path='~', msg=''):
	ret = ''
	if not msg: msg = _('Select directory')
	if is_mac(): msg = ''

	if path == '~': path = os.path.expanduser(path)

	dlg = wx.DirDialog(
		parent, message=msg,
		defaultPath=path,
		style=wx.DD_DEFAULT_STYLE | wx.DD_DIR_MUST_EXIST
	)
	dlg.CenterOnParent()
	if dlg.ShowModal() == wx.ID_OK:
		ret = path_system(dlg.GetPath())
	dlg.Destroy()
	return ret
コード例 #11
0
def get_open_file_name(parent, app, start_dir, msg='', file_types=[]):
    ret = ''
    if not msg: msg = _('Open document')
    if is_mac(): msg = ''

    if start_dir == '~': start_dir = os.path.expanduser(start_dir)

    dlg = wx.FileDialog(parent,
                        message=msg,
                        defaultDir=start_dir,
                        defaultFile="",
                        wildcard=_get_open_filters(file_types),
                        style=wx.OPEN | wx.CHANGE_DIR | wx.FILE_MUST_EXIST)
    dlg.CenterOnParent()
    if dlg.ShowModal() == wx.ID_OK:
        ret = path_system(dlg.GetPath())
    dlg.Destroy()
    return ret
コード例 #12
0
ファイル: filedlgs.py プロジェクト: sk1project/sk1-wx
def get_open_file_name(parent, app, start_dir, msg='', file_types=[]):
	ret = ''
	if not msg: msg = _('Open document')
	if is_mac(): msg = ''

	if start_dir == '~': start_dir = os.path.expanduser(start_dir)

	dlg = wx.FileDialog(
		parent, message=msg,
		defaultDir=start_dir,
		defaultFile="",
		wildcard=_get_open_filters(file_types),
		style=wx.FD_OPEN | wx.FD_CHANGE_DIR | wx.FD_FILE_MUST_EXIST | wx.FD_PREVIEW
		)
	dlg.CenterOnParent()
	if dlg.ShowModal() == wx.ID_OK:
		ret = path_system(dlg.GetPath())
	dlg.Destroy()
	return ret
コード例 #13
0
def get_save_file_name(parent, app, path, msg='', file_types=[]):
    ret = ('', 0)
    if not msg: msg = _('Save document As...')
    if is_mac(): msg = ''

    if path == '~': path = os.path.expanduser(path)

    doc_folder = os.path.dirname(path)
    doc_name = os.path.basename(path)

    dlg = wx.FileDialog(parent,
                        message=msg,
                        defaultDir=doc_folder,
                        defaultFile=doc_name,
                        wildcard=_get_save_fiters(file_types),
                        style=wx.SAVE | wx.CHANGE_DIR | wx.FD_OVERWRITE_PROMPT)
    dlg.CenterOnParent()
    if dlg.ShowModal() == wx.ID_OK:
        ret = (path_system(dlg.GetPath()), dlg.GetFilterIndex())
    dlg.Destroy()
    return ret
コード例 #14
0
# 	along with this program.  If not, see <http://www.gnu.org/licenses/>.

import wx
import wal

from wal import const

from artids import ART_IDS
from labels import LABELS

ACC_KEYS = {}

from acc_keys import GENERIC_KEYS
ACC_KEYS.update(GENERIC_KEYS)

if const.is_mac():
	pass
elif const.is_msw():
	MSW_KEYS = {
			wx.ID_EXIT:(wx.ACCEL_ALT, wx.WXK_F4),
			}
	ACC_KEYS.update(MSW_KEYS)
else:
	pass

def get_acc_by_id(action_id):
	if ACC_KEYS.has_key(action_id):
		return ACC_KEYS[action_id] + (action_id,)
	return None

def get_accentry_by_id(action_id):