示例#1
0
	def OnGetItemText(self, item, column):
		# It seems that clicking on the dictionary list to dismiss the module 
		# popup will give error messages about ints being requireed when
		# looking things up in the cache. By looking up an attribute on self
		# that doesn't exist, we don't get these problems for some reason
		# Probably a wx problem, I'd guess.
		# To reproduce this problem easily, comment out the next two lines and
		# replace with import cPickle. Otherwise, you will need to scroll down 
		# to the 257th item (or even further down if you want) 
		has = hasattr(self, "broken")
		assert not has, "Don't set broken!"


		key = item, column
		if key in self.cache:
			return self.cache[key]
		
		# return text encoded as utf-8; wxPython 2.9.1.1 on Mac crashes if
		# non-ascii unicode text in there, but utf-8 works fine.
		data = self.get_data(item, column)
		if osutils.is_mac():
			data = data.encode("utf8")
		
		self.cache[key] = data
		return data
示例#2
0
    def __init__(self, parent, model):
        self.model = model
        super(FilterableTree, self).__init__(parent)

        self.bound = False

        self.tree = self.CreateTreeCtrl(
            self,
            style=wx.TR_HAS_BUTTONS | wx.TR_LINES_AT_ROOT | wx.TR_HIDE_ROOT)

        self.search = SearchCtrl(self)

        self.search.SetDescriptiveText(self.blank_text)
        self.search.ShowCancelButton(True)

        self.search.Bind(wx.EVT_KEY_DOWN, self.on_key_down)
        self.search.Bind(wx.EVT_TEXT,
                         lambda evt: self.filter(self.search.Value))
        self.search.Bind(wx.EVT_SEARCHCTRL_CANCEL_BTN, self.clear_filter)

        self.on_selection = ObserverList()

        sizer = wx.BoxSizer(wx.VERTICAL)

        if osutils.is_mac():
            sizer.Add(self.search, 0, wx.GROW | wx.ALL, 3)
            sizer.Add(self.tree, 1, wx.GROW | wx.TOP, 6)
        else:
            sizer.Add(self.search, 0, wx.GROW | wx.BOTTOM, 3)
            sizer.Add(self.tree, 1, wx.GROW)

        self.SetSizer(sizer)
        self.expansion_state = None
        self.bind_events()
示例#3
0
	def __init__(self, parent,
	style=wx.TE_CENTRE|wx.TE_PROCESS_ENTER|wx.NO_BORDER):
		super(TextPanel, self).__init__(parent, style=style)
		self.Bind(wx.EVT_KILL_FOCUS, self.end_parent_modal)
		self.TopLevelParent.Bind(wx.EVT_KILL_FOCUS, self.end_parent_modal)
		self.Bind(wx.EVT_CHAR, self.add_letter)
		if osutils.is_mac():
			# On Windows, this event binding seems unnecessary and caused issue 220
			# (repeated error message if you typed a wrong reference).
			# Since it was only added to fix Mac issues, it seems OK to make it Mac specific.
			self.Bind(wx.EVT_KEY_UP, self.add_letter)
		self.Bind(wx.EVT_TEXT_ENTER, self.on_enter)
		self.SetFont(wx.Font(30, wx.SWISS, wx.NORMAL, wx.FONTWEIGHT_BOLD, False))
		dc = wx.MemoryDC()
		bmp = wx.EmptyBitmap(1, 1)
		dc.SelectObject(bmp)
		dc.SetFont(self.Font)
		w, self.height = dc.GetTextExtent(string.letters)
		self.MinSize = 1, self.height
示例#4
0
def find_xulrunner_path():
    if osutils.is_mac():
        path = os.getcwd() + "/../MacOS/"
        if os.path.exists(path):
            return path
        else:
            return os.getcwd() + "/dist/BPBible.app/Contents/MacOS/"

    if osutils.is_gtk():
        xulrunner_path = (osutils.find_file_in_path("xulrunner")
                          or osutils.find_file_in_path("xulrunner-stub"))
        if xulrunner_path:
            return os.path.dirname(os.path.realpath(xulrunner_path))

    path = os.path.join(os.getcwd(), "xulrunner")
    if not os.path.isdir(path):
        # XXX: Perhaps we should make this error handling a little more friendly?
        sys.stderr.write("Unable to find XULRunner.\n")
        sys.exit(1)
    return path
示例#5
0
def find_xulrunner_path():
	if osutils.is_mac():
		path = os.getcwd() + "/../MacOS/"
		if os.path.exists(path):
			return path
		else:
			return os.getcwd() + "/dist/BPBible.app/Contents/MacOS/"

	if osutils.is_gtk():
		xulrunner_path = (osutils.find_file_in_path("xulrunner") or
			osutils.find_file_in_path("xulrunner-stub"))
		if xulrunner_path:
			return os.path.dirname(os.path.realpath(xulrunner_path))

	path = os.path.join(os.getcwd(), "xulrunner")
	if not os.path.isdir(path):
		# XXX: Perhaps we should make this error handling a little more friendly?
		sys.stderr.write("Unable to find XULRunner.\n")
		sys.exit(1)
	return path
示例#6
0
    def OnGetItemText(self, item, column):
        # It seems that clicking on the dictionary list to dismiss the module
        # popup will give error messages about ints being requireed when
        # looking things up in the cache. By looking up an attribute on self
        # that doesn't exist, we don't get these problems for some reason
        # Probably a wx problem, I'd guess.
        # To reproduce this problem easily, comment out the next two lines and
        # replace with import cPickle. Otherwise, you will need to scroll down
        # to the 257th item (or even further down if you want)
        has = hasattr(self, "broken")
        assert not has, "Don't set broken!"

        key = item, column
        if key in self.cache:
            return self.cache[key]

        # return text encoded as utf-8; wxPython 2.9.1.1 on Mac crashes if
        # non-ascii unicode text in there, but utf-8 works fine.
        data = self.get_data(item, column)
        if osutils.is_mac():
            data = data.encode("utf8")

        self.cache[key] = data
        return data
示例#7
0
        if not prevItem.IsOk() or prevItem == item:
            # there are no visible items before item
            return wx.TreeItemId()

    # from there we must be able to navigate until this item
    while (prevItem.IsOk()):
        nextItem = self.GetNextVisible(prevItem)
        if not nextItem.IsOk() or nextItem == item:
            break

        prevItem = nextItem

    return prevItem


if osutils.is_gtk() or osutils.is_mac():
    wx.TreeCtrl.GetPrevVisible = GetPrevVisible


class TreeItem(object):
    def __init__(self, text, data=None, filterable=True):
        self._children = []
        self._text = text
        self.data = data
        self.filterable = filterable

    @property
    def text(self):
        return self._text

    @property
示例#8
0

class DummyMainfrm(object):
    def hide_tooltips(*args, **kwargs):
        pass

    lost_focus = True
    from util.observerlist import ObserverList
    on_close = ObserverList()


mainfrm = DummyMainfrm()
app = None
icons = None

use_versetree = not osutils.is_mac()
use_one_toolbar = osutils.is_mac()


def get_colour_set(colour_set):
    def get_tooltip_colours(html_style=True):
        colours = [wx.SystemSettings.GetColour(x) for x in colour_set]
        if html_style:
            colours = [x.GetAsString(wx.C2S_HTML_SYNTAX) for x in colours]

        return colours

    return get_tooltip_colours


get_tooltip_colours = get_colour_set(
示例#9
0
			# same click, so repost this event to the window beneath us
			winUnder = wx.FindWindowAtPoint(event2.GetPosition())
			if ( winUnder ):
			    # translate the event coords to the ones of the window
			    # which is going to get the event
			    event2.m_x, event2.m_y = winUnder.ScreenToClient((event2.m_x, event2.m_y))
			                                                                
			    event2.SetEventObject(winUnder);
			    wx.PostEvent(winUnder, event2);
	
	def ProcessLeftDown(self, event):
		self.Dismiss()	
		return False


if osutils.is_mac():
	# mac doesn't implement these
	wx.PopupTransientWindow = PopupTransientWindow
	wx.PopupWindow = PopupWindow

	hasNativePopupWindows = False
else:
	hasNativePopupWindows = True

def add_close_window_esc_accelerator(frame, handler):

	def escape_handler(event):
		if event.KeyCode == wx.WXK_ESCAPE and not event.GetModifiers():
			handler()
		else:
			event.Skip()
示例#10
0
	def __init__(self, parent, size=wx.DefaultSize, title="", style=0):
		super(QuickSelector, self).__init__(parent, size=size, 
			style=style
                         | wx.FRAME_SHAPED
                         | wx.NO_BORDER
                         | wx.FRAME_NO_TASKBAR
		)
		
		if not self.SetTransparent(opacity * 255):
			dprint(WARNING, "Transparency not supported")
			set_theme("white")

		self.SetBackgroundColour(back_colour)
		self.SetForegroundColour(text_colour)
		
		
		self.p = wx.Panel(self)
		self.p.SetBackgroundColour(back_colour)
		self.p.SetForegroundColour(text_colour)
		text = wx.StaticText(self.p, label=title, #pos=(0, radius + 10), 
			style=wx.ALIGN_CENTRE)

		text.SetBackgroundColour(back_colour)
		text.SetForegroundColour(text_colour)

		hrule = Line(self.p)
		hrule.SetSize((-1, 1))
		self.panel = TextPanel(self.p)
		self.panel.SetBackgroundColour(back_colour)
		self.panel.SetForegroundColour(text_colour)
		
		sizer = wx.BoxSizer(wx.VERTICAL)
		

		sizer.Add(text, 0, wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT|wx.BOTTOM, 10)
		sizer.Add(hrule, 0, wx.GROW|wx.LEFT|wx.RIGHT|wx.BOTTOM, 10)
		sizer.Add(self.panel, 1, wx.GROW|wx.BOTTOM|wx.LEFT|wx.RIGHT, 20)
		self.p.Sizer = sizer

		s1 = wx.BoxSizer(wx.HORIZONTAL)
		s1.Add(self.p, 1, wx.GROW|wx.ALL, 1)
		
		self.panel.ForegroundColour = text_colour
		f = text.Font
		f.SetWeight(wx.FONTWEIGHT_BOLD)
		f.SetPointSize(12)
		text.Font = f
		self.SetSizerAndFit(s1)
#		self.Size = self.p.BestSize
		if osutils.is_mac():
			# on mac it seems to make our textbox to small so descending
			# letters are chopped off
			self.SetSize((350, self.BestSize[1]+7))
		else:
			self.SetSize((350, self.BestSize[1]))

#		self.SetSize(self.p.BestSize)

		if osutils.is_gtk():
			self.Bind(wx.EVT_WINDOW_CREATE, lambda evt:self.set_shape())
		else:
			self.set_shape()
		if not parent:
			self.CentreOnScreen()
		else:
			self.CentreOnParent()
示例#11
0
from util import osutils
from util.debug import dprint, MESSAGE

class DummyMainfrm(object):
	def hide_tooltips(*args, **kwargs):
		pass
	
	lost_focus = True
	from util.observerlist import ObserverList
	on_close = ObserverList()

mainfrm = DummyMainfrm()
app = None
icons = None

use_versetree = not osutils.is_mac()
use_one_toolbar = osutils.is_mac()
def get_colour_set(colour_set):
	def get_tooltip_colours(html_style=True):
		colours = [wx.SystemSettings.GetColour(x) for x in colour_set]
		if html_style:
			colours = [x.GetAsString(wx.C2S_HTML_SYNTAX) for x in colours]

		return colours
	
	return get_tooltip_colours

get_tooltip_colours = get_colour_set(
	(wx.SYS_COLOUR_INFOBK, wx.SYS_COLOUR_INFOTEXT)
)